sudo yum install erlang emacs
首先要安装erlang,其次要安装emacs。
我们以emacs作为erlang代码的编辑器。其可以提供很好的语法高亮,智能缩进,智能填充等功能。
首先在home目录下配置.emacs文件(如果没有需要创建),使其支持erlang mode
假设您的erlang的安装目录为/usr/lib/erlang,注意配置中涉及的目录,需要与您的安装环境相匹配。
;; setup erlang mode ;; add the location of the elisp files to the load-path (setq load-path (cons "/usr/lib/erlang/lib/tools-2.6.6.5/emacs" load-path)) ;; set the location of the man page hierarchy (setq erlang-root-dir "/usr/lib/erlang") ;; add the home of the erlang binaries to the exec-path (setq exec-path (cons "/usr/lib/erlang/bin" exec-path)) ;; load and eval the erlang-start package to set up ;; everything else (require 'erlang-start)
这样您的emacs已经支持erlang mode了。
随后您启动emacs,输入M-x erlang-mode 切换到erlang模式。
------------------------------------------------------------------------------------------------------------------
使用emacs 需要根据自己的需求加载相应的el文件,例如加载行号的话需要网上下载 linum.el 放到"usr/share/emacs/site-lisp/"下面,然后在/root目录下创建一个 .emacs 的文件 在文件里面写下相应的代码进行设置.
文件里面的代码如下:(例子)
;; author: chinazhangjie ;; e-mail: chinajiezhang@gmail.com ;; 指针颜色设置为白色 (set-cursor-color "white") ;; 鼠标颜色设置为白色 (set-mouse-color "white") ;; 从color-theme中获取 ;; 网上下载color-theme.el,放到加载路径(/usr/share/emacs/site-lisp )下 ;; M-x color-theme-select,鼠标左键选中,回车查看效果 ;; d查看信息,将出现如下信息: ;; color-theme-matrix is an interactive Lisp function in `color-theme.el'. ;; (color-theme-matrix) ;; Color theme by walterh@rocketmail.com, created 2003-10-16. ;; 选择(color-theme-blue-mood)即可 (require 'color-theme) (setq color-theme-is-global t) (color-theme-vim-colors) ;; 一打开就起用 text 模式。 (setq default-major-mode 'text-mode) ;; 语法高亮 (global-font-lock-mode t) ;; 以 y/n代表 yes/no (fset 'yes-or-no-p 'y-or-n-p) ;; 显示括号匹配 (show-paren-mode t) (setq show-paren-style 'parentheses) ;; 显示时间,格式如下 (display-time-mode 1) (setq display-time-24hr-format t) (setq display-time-day-and-date t) (transient-mark-mode t) ;; 支持emacs和外部程序的粘贴 (setq x-select-enable-clipboard t) ;; 在标题栏提示你目前在什么位置 (setq frame-title-format "zhj@%b") ;; 默认显示 80列就换行 (setq default-fill-column 80) ;; 去掉工具栏 (tool-bar-mode nil) ;;去掉菜单栏 ;;(menu-bar-mode nil) ;; 去掉滚动栏 (scroll-bar-mode nil) ;; 设置字体 ;; 方法为: emacs->options->Set Default Font->"M-x describe-font"查看当前使用的字体名称、字体大小 (set-default-font "-bitstream-Courier 10 Pitch-normal-normal-normal-*-17-*-*-*-m-0-iso10646-1") ;; 显示列号 (setq column-number-mode t) (setq line-number-mode t) ;; 设置缩进 (setq indent-tabs-mode nil) (setq default-tab-width 4) (setq tab-width 4) (setq tab-stop-list ()) (loop for x downfrom 40 to 1 do (setq tab-stop-list (cons (* x 4) tab-stop-list))) (defconst my-c-style '((c-tab-always-indent . t) (c-comment-only-line-offset . 4) (c-hanging-braces-alist . ((substatement-open after) (brace-list-open))) (c-hanging-colons-alist . ((member-init-intro before) (inher-intro) (case-label after) (label after) (access-label after))) (c-cleanup-list . (scope-operator empty-defun-braces defun-close-semi)) (c-offsets-alist . ((arglist-close . c-lineup-arglist) (substatement-open . 0) (case-label . 4) (block-open . 0) (knr-argdecl-intro . -))) (c-echo-syntactic-information-p . t) ) "My C Programming Style") ;; offset customizations not in my-c-style (setq c-offsets-alist '((member-init-intro . ++))) ;; Customizations for all modes in CC Mode. (defun my-c-mode-common-hook () ;; add my personal style and set it for the current buffer (c-add-style "PERSONAL" my-c-style t) ;; other customizations (setq tab-width 4 ;; this will make sure spaces are used instead of tabs indent-tabs-mode nil) ;; we like auto-newline and hungry-delete (c-toggle-auto-hungry-state 1) ;; key bindings for all supported languages. We can put these in ;; c-mode-base-map because c-mode-map, c++-mode-map, objc-mode-map, ;; java-mode-map, idl-mode-map, and pike-mode-map inherit from it. (define-key c-mode-base-map "C-m" 'c-context-line-break) ) (add-hook 'c-mode-common-hook 'my-c-mode-common-hook) ;; 回车缩进 (global-set-key "C-m" 'newline-and-indent) (global-set-key (kbd "C-<return>") 'newline) ;; 实现全屏效果,快捷键为f11 (global-set-key [f11] 'my-fullscreen) (defun my-fullscreen () (interactive) (x-send-client-message nil 0 nil "_NET_WM_STATE" 32 '(2 "_NET_WM_STATE_FULLSCREEN" 0)) ) ;; 最大化 (defun my-maximized () (interactive) (x-send-client-message nil 0 nil "_NET_WM_STATE" 32 '(2 "_NET_WM_STATE_MAXIMIZED_HORZ" 0)) (x-send-client-message nil 0 nil "_NET_WM_STATE" 32 '(2 "_NET_WM_STATE_MAXIMIZED_VERT" 0)) ) ;; 启动emacs时窗口最大化 (my-maximized) ;; 启动窗口大小 (setq default-frame-alist '((height . 35) (width . 125) (menu-bar-lines . 20) (tool-bar-lines . 0)))
加载usr/share/emacs/site-lisp/下的文件的时候要require 然后再进行相应的设置。
本文来自 :网络整理 + ~~~