Chinaunix首页 | 论坛 | 博客
  • 博客访问: 139106
  • 博文数量: 53
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 224
  • 用 户 组: 普通用户
  • 注册时间: 2015-06-28 01:08
文章分类
文章存档

2020年(1)

2019年(1)

2017年(1)

2016年(18)

2015年(32)

我的朋友

分类: LINUX

2015-11-09 11:54:33

一、Emacs 安装

1.        软件下载:   latest 版本下载。

 

功能和热键的学习:

·  

·   《学习 GNU Emacs 》《 GNU Emacs Lisp 编程入门》

·  

2.        软件上传:本人采用虚拟机安装的 linux 系统,主机是 Windows XP ,而由 XP linux 上传文件采用的工具是: FileZilla ;大家可以在网上下载,实在下载不了,请给本人发 email

3.        将下载的 emacs 上传到 Linux 系统的一个文件夹下,进行解压:

#tar –zxvf emacs-23.1.tar.gz  

4.        解压完成之后,在解压到文件夹里有一个 install 的文本文件,详细写明安装方法:

./configure   // 执行完后,会显示 Create 。。。。。。

// 根据 configure.ac makefile.in 来生成 makefile

 

Make                  // 按照 makefile 中的要求,进行编译,

// 生成的可执行文件什么的都在当前的 src 目录下

 

Make install   // 按照 makefile 中的要求,将可执行文件、 manpage 文件、

//info 文件等从 src 目录向指定目录中 copy
//
就是从当前目录向目标目录 install

Make clean // 清除多余的安装临时文件

 

上面四部一定都执行完(本人新手,第一次时 make 执行了很长时间,以为安装完成, emacs 程序只能运行 src/emacs 来执行)。

5. 重点:
      
记住个别编辑工作中常用 Hotkey
      
知道 .emacs 文件和 设置的作用和用法。
      
知道 LISP 语言。 ( 但是不一定要掌握这种语言,抄抄网络上大侠的就行,同时也希望更              多的人加入到 Lisp 行列中 )

 

简单说明:

·   .emacs 文件 : Emacs 启动时,自动读取用户自定义配置的默认的配置文件
( 手动创建该文件,自定义配置都写在该文件中,其形式为 LISP 语言,将其放在 "/home/yourname/" 路径下 )

·   shell 命令启动 Emacs 时,如果用 'emacs -q' 命令,则不加载任何额外的自定义设置启动 Emacs.

:由 '.emacs' 文件中编写的相应的自定义配置,调用的关联 **.el 文件的存放路径。
*.el 文件是为了更方便使用 emacs ,安装其他辅助软件时对 emacs 的配置文件,将其放入到 emacs 文件中,如 .emacsLoadpath 文件夹中。这个 的文件夹,可以手动创建 ( 推荐) ,也可以用 Emacs 软件的默认路径 (/usr/local/share/emacs/site-lisp/)

·   下记的 .emacsLoadpath 就是手动创建的,前面的“ . ”是指隐藏文件。

例:
;load-path
(add-to-list 'load-path "/home/yourname/.emacsLoadpath")

 

 

下面安装的所有软件的功能都是使我们在 Linux 系统下的开发工作更舒服,使emacs 工具用起来更得心应手,每装一个软件都要在.emacs 内容中记入相应的配置内容。

 

二、 Gtags 安装与设置

1 软件下载

2.  Gtags 安装:同样将下载的安装文件上传到一个自己喜欢的目录下后,解压,在解压后的文件夹中有一个 ANSTALL 文本文件,上面有安装方法。

       How to install  

       $./configure

       $make

       $make install

3.         设置 .emaca

上面的 emacs 安装完成后,默认的安装路径 /use/local/emacs 下了。

以后创建文本的时候,默认的路径都在~ / 下(也就是 /home/yourname/ 下)。

个人建议,在应用 emacs 软件之前,一定要进行关于 emaca 的功能和热键的学习

$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$

***********************************************************


功能和热键的学习:

·    

·   《学习 GNU Emacs 》《 GNU Emacs Lisp 编程入门》网上有中文扫描版和英文版的下载,忘了在哪里下的了,搜搜吧。
扫描版不清晰,例代码根本看不清,建议购入原书。

·    

4.    gtags 配置:

下载安装gtags 后,会有名为gtags.el 的文件,注意看安装时make installlist, 即可找到gtags.el 的安装位置( 默认目录是:/usr/local/share/gtags/)
gtags.el 的路径设置为Emacs gtags.el直接复制.emacsLoadpath文件夹中,注意,调试.emacs文件时,最好一点点往里加代码,不然出错了也不知道错误在哪里。
例: `$HOME/.emacs' 文件中加入下记代码例。

 

 

 

(setq load-path (cons "/home/owner/global" load-path)); gtags.el load-path

(autoload 'gtags-mode "gtags" "" t);gtags-mode is true

从此启动Emacs 后,及在loadgtags.el 文件,并将gtags-mode 设置为真( 等同于每次启动后,都在Emacs 中的M-x ,手动键入gtags-mode)

 

个人的 .emacs 文件中的内容为:

个人 .emacs 文件中的内容:

;##global(GNU GLOBAL source code tag system);;;;;;;;;;;;;;;;;;;;;
;to use global from Emacs, you need to load the `gtags.el' and execute gtags-mode function in it.
;you need to add it to load-path. for `gtags.el'file.
;(add-to-list 'load-path "");
已经在之前的代码中 load 完了
(autoload 'gtags-mode "gtags" "" t);;start Emacs and execute gtags-mode function. 
(setq c-mode-hook
      '(lambda ()
     (gtags-mode 1)));get into gtags-mode whenever you get into c-mode
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

 

详细用法:
直接参考 gtags 的英文的 Tutorial( 指导 )
有很多章节可以跳过,因为那是 global 在别的编辑软件中的应用方法的说明。 ( 例如 shell,vi )
章节还是要必看的。

 


gtags:GNU GLOBAL source code tag system (Ver:5.7.7)
HP:
看看Tutorial(指导)中的Overview就知道,通过gtags能够建立软件工程项目。
这就说明,Emacs+gtags的组合,就可以是能够创建工程项目的编辑软件了。
(基本等于sourceinsight,如果在加上cedet和ecb就更完美了)

还有很多人不用gtags而用的是cscope,我个人没用过cscope,大家可尝试使用。

支持的基本环境

  • Shell command line
  • Bash shell
  • Vi editor (Nvi, Elvis, vim)
  • Less viewer
  • Emacs editor (Emacs, Mule, Xemacs)
  • Web browser
  • Doxygen documentation system

基本用法:
1.下载安装gtags 后,在源文件的目录中,键入"gtags -v"命令,就会生成相应文件。
[xx@localhost sys]$ gtags -v

例:source code(/usr/src/sys)       123MB
GPATH 1MB `GPATH' path name database
GTAGS 26MB `GTAGS' definition database
GRTAGS 22MB `GRTAGS' reference database
GSYMS 23MB `GSYMS' symbol database
-------------------------------------
total of tag files 72MB
gtags 的其他options的含义,请参考man手册。

(辅助:http://blog.chinaunix.net/u3/98822 /showart_2129660.html)

2.当源程序的源文件的内容变化了(导致行号变化),或追加删除了源文件等等。只要有改变,就要更新gtags生成的那4个文件。

例:source code(/usr/src/sys)
[xx@localhost sys]$ gtags -vi

or
[xx@localhost sys]$ global -u (推荐)

详细用法:
直接参考gtags的英文的Tutorial(指导)。
有很多章节可以跳过,因为那是global在别的编辑软件中的应用方法的说明。(例如shell,vi等)
章节还是要必看的。

看了gtags的英文的Tutorial(指导)后,发现htags 也蛮有用的。





3.CEDET:Collection of Emacs DevelopmentEnvironment Tools Ver: 1.0pre6

安装:

没有 CEDET 的话,后续的 ecb 不能安装使用。
这个组件,安装简单,使用便利。(望大家阅读文档,了解他的各种功能)
我个人常用的两个功能是, speedbar smart code completion( 自动补全 )

个人 .emacs 文件中的内容:

;##cedet(Collection of Emacs Development Environment Tools);;;;;;
(load-file "/home/yourname/.emacsLoadpath/cedet/common/cedet.el")
;
读取子目录中的特别的 .el 文件
(global-ede-mode 1); Enable the Project management system
(semantic-load-enable-code-helpers); Enable prototype help and smart completion
(global-srecode-minor-mode 1); Enable template insertion menu
(global-set-key [(f4)] 'speedbar-get-focus);speedbar
快捷键 [F4]
(define-key c-mode-base-map [(control tab)] 'semantic-ia-complete-symbol-menu);
自动补全 Ctrl+tab
;(control tab)(meta ?/)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

配置完之后,按下 F4 ,就可以显示 speedbar 菜单了,有了点 Sourceinsight 的风格了。并且有了自动补全的功能,按下 control tab 或者 meta / ?就可以自动补全了。

 

4.ECB:Emacs Code Browser Ver:ecb-2.40

安装:

其中 Requirements 内容中的 1 2 还是必要的, 3 4 对于我来说用不上 ( 我的环境非 XEmacs ,目标代码也不是 Java)
辅助:

  http://blog.csdn.net/intrepyd/archive/2009/07/09/4333893.aspx

·   其中在上记 " 辅助 " blog 中设置 [ 鼠标支持 ] 的时候, fedora 使用 ' 鼠标滚轮下按 ' 的方式选择和设置。

·   关闭 ecb " 每日提醒 " info upgrandoption 界面,请参考下记 .emacs 文件中的代码。

个人 .emacs 文件中的内容:

;##ecb(Emacs Code Browser);;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(add-to-list 'load-path "/home/lb/.emacsLoadpath/ecb")
(load-file "/home/lb/.emacsLoadpath/ecb/ecb.el")
(require 'ecb)
(require 'ecb-autoloads)
;(setq ecb-auto-activate t);
自动启动 ecb
(setq ecb-auto-activate t;
自动启动 ecb
ecb-tip-of-the-day nil;
不显示每日提醒
inhibit-startup-message t;
不知道什么意思 , 望各位指导
ecb-auto-compatibility-check nil;
ecb-version-check nil)
;
(global-set-key [f8] 'ecb-activate) ;; 定义 F8 键为激活 ecb
(global-set-key [f7] 'ecb-deactivate) ;;
定义 F7 为停止 ecb
;;;;
各窗口间切换
(global-set-key [M-left] 'windmove-left)
(global-set-key [M-right] 'windmove-right)
(global-set-key [M-up] 'windmove-up)
(global-set-key [M-down] 'windmove-down)
;;;;
使某一 ecb 窗口最大化
(define-key global-map "\C-c1" 'ecb-maximize-window-directories)
(define-key global-map "\C-c2" 'ecb-maximize-window-sources)
(define-key global-map "\C-c3" 'ecb-maximize-window-methods)
(define-key global-map "\C-c4" 'ecb-maximize-window-history)
;;;;
恢复原始窗口布局
(define-key global-map "\C-c`" 'ecb-restore-default-window-sizes)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

到此为止,已经基本跟 sourceinsight 的环境一样了,呵呵,感觉这个界面很熟悉吧?

大家赶紧试一试吧!

 

;;########################

;多语言乱码对应

;;########################


;;unicad多语言对应,避免打开文件乱码
;[]
(require 'unicad)

(custom-set-faces
  ;; custom-set-faces was added by Custom.
  ;; If you edit it by hand, you could mess it up, so be careful.
  ;; Your init file should contain only one such instance.
  ;; If there is more than one, they won't work right.
 '(default ((t (:inherit nil :stipple nil :background "grey30" :foreground "gainsboro" :inverse-video nil :box nil :strike-through nil :overline nil :underline nil :slant normal :weight normal :height 93 :width normal :foundry "unknown" :family "DejaVu Sans Mono")))))











 

以下为个人 .emacs 文件内容,没怎么整理,仅供参考:

$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$

***********************************************************

C-x C-f 创建文件: Find file:~/.emacs

进入之后,个人文本中输入了一下内容:

//                                                       .emacs 内容

 

;load-path

  (add-to-list 'load-path' "/home/zhonghua/.emacsLoadpath")

  (custom-set-variables

  ;; custom-set-variables was added by Custom.

  ;; If you edit it by hand, you could mess it up, so be careful.

  ;; Your init file should contain only one such instance.

  ;; If there is more than one, they won't work right.

    '(column-number-mode t)

  '(display-time-mode t)

  '(ecb-options-version "2.40")

  '(inhibit-startup-screen t)

  '(show-paren-mode t))

  (setq visible-bell t); 关闭出错时的蜂鸣提示声

  (mouse-avoidance-mode'animate); 当鼠标箭头与光标相近时,使鼠标箭头自动移开

  ;(blink-cursor-mode nil); 光标不闪烁

  (setq-default cursor-type 'bar); 光标显示为一竖线

  ;(tool-bar-mode -1);; 不显示 emcas 的工具栏

  ;(menu-bar-mode -1);; 不显示 emcas 的菜单栏 , ctrl+ 鼠标右键仍能调出该菜单

  (setq x-select-enable-clipboard t);; 支持 emacs 和外部程序之间进行粘贴

  (fset 'yes-or-no-p 'y-or-n-p); 'y/n' 字样代替原默认的 'yes/no' 字样

  ;(setq frame-title-format "%b@emacs"); 在最上方的标题栏显示当前 buffer 的名字

(setq frame-title-format "%f@emacs"); 在最上方的标题栏显示当前 buffer 的名字

  (setq make-backup-files nil); 关闭自动备份功能

  (setq auto-save-mode nil); 关闭自动保存模式

  (setq auto-save-default nil); 不生成名为 #filename# 的临时文件

  (setq require-final-newline t);; 自动的在当前的 buffer 文件的最后加一个空行

  (global-set-key "\r" 'align-newline-and-indent);; 自动缩进 变为

  ;;;;;;;;;;;;;;;;; 启动时最大化 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

  ;(require 'maxframe)

  ;(add-hook 'window-setup-hook 'maximize-frame t)

  ; 下载 maxframe.el 并放置在

  ;http://emacsblog.org/2007/02/22/maximize-on-startup-part-2/

  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

  ;;;;;;;;;;;;;;;;web 方式显示行号 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;

  ;(set-scroll-bar-mode 'right); 滚动条在右侧

  (set-scroll-bar-mode nil)   ; 不显示滚动条 , even in x-window system (recommended)

  (require 'wb-line-number)

  (wb-line-number-toggle)

  ; 下载 wb-line-number.el 并放置在

  ;

  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;cc-mode;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(add-to-list 'load-path "/home/zhonghua/.emacsLoadpath/cc-mode-5.31.3")

(require 'cc-mode)

(c-set-offset 'inline-open 0)

(c-set-offset 'substatement-open 0)

;

  ;

  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

 

;##global(GNU GLOBAL source code tag system);;;;;;;;;;;;;;;;;;;;;

;to use global from Emacs, you need to load the `gtags.el' and execute gtags-mode function in it.

;you need to add it to load-path. for `gtags.el'file.

;(add-to-list 'load-path ""); 已经在之前的代码中 load 完了

(autoload 'gtags-mode "gtags" "" t);;start Emacs and execute gtags-mode function.

(setq c-mode-hook

'(lambda ()

(gtags-mode 1)));get into gtags-mode whenever you get into c-mode

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(set-face-background 'default "gainsboro"); 背景设定

; 颜色参考 value X 界面菜单栏中 [edit]->[text properties]->[Display colors]

;##cedet(Collection of Emacs Development Environment Tools);;;;;;

(load-file "/home/zhonghua/.emacsLoadpath/cedet-1.0pre6/common/cedet.el")

(global-ede-mode 1); Enable the Project management system

(semantic-load-enable-code-helpers); Enable prototype help and smart completion

(global-srecode-minor-mode 1); Enable template insertion menu

(global-set-key [(f4)] 'speedbar-get-focus);speedbar 快捷键 [F4]

(define-key c-mode-base-map [(control tab)] 'semantic-ia-complete-symbol-menu); 自动补齐 Ctrl+tab

;(control tab)(meta ?/)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;##ecb(Emacs Code Browser);;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(add-to-list 'load-path"/home/zhonghua/.emacsLoadpath/ecb-2.40")

(load-file "/home/zhonghua/.emacsLoadpath/ecb-2.40/ecb.el")

(require 'ecb)

(require 'ecb-autoloads)

(setq ecb-auto-activate t; 自动启动 ecb

ecb-tip-of-the-day nil; 不显示每日提醒

inhibit-startup-message t; 不知道什么意思 , 望各位指导

ecb-auto-compatibility-check nil;

ecb-version-check nil);

(global-set-key [f8] 'ecb-activate) ;; 定义 F8 键为激活 ecb

(global-set-key [f7] 'ecb-deactivate) ;; 定义 F7 为停止 ecb

;;;; 各窗口间切换

(global-set-key [M-left] 'windmove-left)

(global-set-key [M-right] 'windmove-right)

(global-set-key [M-up] 'windmove-up)

(global-set-key [M-down] 'windmove-down)

;;;; 使某一 ecb 窗口最大化

(define-key global-map "\C-c1" 'ecb-maximize-window-directories)

(define-key global-map "\C-c2" 'ecb-maximize-window-sources)

(define-key global-map "\C-c3" 'ecb-maximize-window-methods)

(define-key global-map "\C-c4" 'ecb-maximize-window-history)

;;;; 恢复原始窗口布局

(define-key global-map "\C-c`" 'ecb-restore-default-window-sizes)

 

 ;###tabbar####
(require 'tabbar)
(tabbar-mode t)
(global-set-key (kbd "") 'tabbar-backward-group)
(global-set-key (kbd "") 'tabbar-forward-group)
(global-set-key (kbd "") 'tabbar-backward)
(global-set-key (kbd "") 'tabbar-forward)
;  使用[Win徽标键 + 方向键],切换tabbarbuffer
;" "
;" Debian also includes tabbar.el in the emacs-goodies-el package. "
;  For非Debian用户" http://blogimg.chinaunix.net/blog/upfile2/100123133751.zip "
;;所有的tab 都在一个组中
;(setq tabbar-buffer-groups-function
;          (lambda ()
;            (list "All"))) ;; code by Peter Barabas
;###tabbar^^^^





 

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

//                                                       .emacs 内容

 

 

 

 



阅读(3233) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~