我们这些程序员,我觉得都应该记住,马士兵说过的一句话:学东西,先要让它跑起来,再去研究它的工作原理!
所以,我也是这样做的!
emacs,要是先弄懂那一堆的乱七八糟的配置,再干活的话,学习曲线会很慢且很容易打击人的!弄懂一些基本的命了就行了,比如:c-x-f c-x-c c-x-s 等等
嗯!我呢,是google老师的好学生,自己想要的,就找他了!
以下是我的整理资料 + 感想:
步骤:
1.自己的ubuntu 安装好了erlang: ubuntu11.10 安装erlang
2.安装emacs。
- 第一种:
- sudo apt-get install emacs23
- 第二种:
- 软件中心安装
3. 配置 .emacs 文件:
- (setq default-directory "~/dika/erlang/")可以改成你喜欢的工作目录
- (global-set-key (kbd "C-SPC") 'nil)
- ;; share clipboard with outside programs
- (setq x-select-enable-clipboard t)
- (desktop-save-mode 1)
- (tool-bar-mode nil)
- ;;(menu-bar-mode nil)
- (scroll-bar-mode nil)
- (setq make-backup-files nil)
- ;; 设置另外一些颜色:语法高亮显示的背景和主题,区域选择的背景和主题,二次选择的背景和选择
- (set-face-foreground 'highlight "white")
- (set-face-background 'highlight "blue")
- (set-face-foreground 'region "cyan")
- (set-face-background 'region "blue")
- (set-face-foreground 'secondary-selection "skyblue")
- (set-face-background 'secondary-selection "darkblue")
- (set-foreground-color "grey")
- (set-background-color "black")
- (set-cursor-color "gold1")
- (set-mouse-color "gold1")
- ;;(set-scroll-bar-mode nil)
- ;设定光标为短线
- (setq-default cursor-type 'bar)
- ;设置标题
- (setq frame-title-format
- '(" mayi - Emacs - [ " (buffer-file-name "%f \]"
- (dired-directory dired-directory "%b \]"))))
- ;设置启动大小
- (set-frame-height (selected-frame) 65)
- (set-frame-width (selected-frame) 170)
- (setq inhibit-startup-message t);关闭起动时LOGO
- (setq visible-bell t);关闭出错时的提示声
- (setq default-major-mode 'erlang-mode);一打开就起用 text 模式
- (global-font-lock-mode t);语法高亮
- (auto-p_w_picpath-file-mode t);打开图片显示功能
- (fset 'yes-or-no-p 'y-or-n-p);以 y/n代表 yes/no
- (column-number-mode t);显示列号
- (show-paren-mode t);显示括号匹配
- (setq mouse-yank-at-point t);支持中键粘贴
- (transient-mark-mode t);允许临时设置标记
- (setq x-select-enable-clipboard t);支持emacs和外部程序的粘贴
- (setq auto-save-default nil);关闭备份文件#xxx#
- ;;-----kill ring 长度
- (setq kill-ring-max 200)
- (require 'linum)
- (global-linum-mode 1)
- ;;--------------------------快捷键定义------------------------
- (global-set-key [(f12)] 'loop-alpha) ;;玻璃
- ;;F1列模式
- (global-set-key [f1] 'cua-mode)
- ;;恢复,常用键
- (global-set-key [f2] 'undo)
- ;;F4,kill键,习惯设置,关闭当前buffer
- (global-set-key [f4] 'kill-this-buffer)
- ;;定义查找快捷键
- (global-set-key [f5] 'replace-regexp) ;;支持正则表达式
- (global-set-key [f6] 'replace-string)
- (global-set-key [f8] 'erlang-mode)
- (global-set-key [f7] 'ecb-activate) ;;定义F7键为激活ecb
- (global-set-key [C-f7] 'ecb-deactivate)
- (global-set-key [f11] 'delete-other-windows) ;;设置F11为删除其它窗口
- (global-set-key (kbd "C-c z") (quote shell))
- ;;-------------------------------全选---------------------
- (defun select-all ()
- "Select the whole buffer."
- (interactive)
- (goto-char (point-min))
- ;; Mark current position and push it into the mark ring.
- (push-mark-command nil nil)
- (goto-char (point-max))
- (message "ok."))
- (provide 'select-all)
- (autoload 'select-all "select-all"
- "Select the whole buffer." t nil)
- ;; user defined keys
- (global-set-key "\C-x\C-a" 'select-all)
- ;;-------------------glass style------------------
- (setq alpha-list '((85 55) (100 100)))
- (defun loop-alpha ()
- (interactive)
- (let ((h (car alpha-list)))
- ((lambda (a ab)
- (set-frame-parameter (selected-frame) 'alpha (list a ab))
- (add-to-list 'default-frame-alist (cons 'alpha (list a ab)))
- ) (car h) (car (cdr h)))
- (setq alpha-list (cdr (append alpha-list (list h))))
- ))
- ;;--------------------------erlang----------------------------------------------------------------------------------------------------------
- ;改成自己的erlang安装目录,不过erlang编译安装的默认目录就是这个
- (setq load-path (cons "/usr/local/lib/erlang/lib/tools-2.6.7/emacs" load-path))
- (setq erlang-root-dir "/usr/local/lib/erlang")
- (setq exec-path (cons "/usr/local/lib/erlang/bin" exec-path))
- (setq erlang-man-root-dir "/usr/local/lib/erlang/man")
- ;以上四句都要改了
- (require 'erlang-start)
- (add-to-list 'auto-mode-alist '("\\.erl?$" . erlang-mode))
- (add-to-list 'auto-mode-alist '("\\.hrl?$" . erlang-mode))
- (add-to-list 'load-path "~/.emacs.d/erlware-mode")
- ;;----------------------distel-------------------
- (let ((distel-dir "~/.emacs.d/distel/elisp"))
- (unless (member distel-dir load-path)
- ;; Add distel-dir to the end of load-path
- (setq load-path (append load-path (list distel-dir)))))
- (require 'distel)
- (distel-setup)
- ;; Some Erlang customizations
- (add-hook 'erlang-mode-hook
- (lambda ()
- ;; when starting an Erlang shell in Emacs, default in the node name
- (setq inferior-erlang-machine-options '("-sname" "emacs"))
- ;; add Erlang functions to an imenu menu
- (imenu-add-to-menubar "imenu")))
- ;; prevent annoying hang-on-compile
- (defvar inferior-erlang-prompt-timeout t)
- ;; tell distel to default to that node
- (setq erl-nodename-cache
- (make-symbol
- (concat
- "emacs@"
- ;; Mac OS X uses "name.local" instead of "name", this should work
- ;; pretty much anywhere without having to muck with NetInfo
- ;; ... but I only tested it on Mac OS X.
- (car (split-string (shell-command-to-string "hostname"))))))
- ;; A number of the erlang-extended-mode key bindings are useful in the shell too
- (defconst distel-shell-keys
- '(("\C-\M-i" erl-complete)
- ("\M-?" erl-complete)
- ("\M-." erl-find-source-under-point)
- ("\M-," erl-find-source-unwind)
- ("\M-*" erl-find-source-unwind)
- )
- "Additional keys to bind when in Erlang shell.")
- (add-hook 'erlang-shell-mode-hook
- (lambda ()
- ;; add some Distel bindings to the Erlang shell
- (dolist (spec distel-shell-keys)
- (define-key erlang-shell-mode-map (car spec) (cadr spec)))))
- ;;------------------------esense--------------------
- (setq load-path (cons "~/.emacs.d/esense-1.12" load-path))
- (require 'esense-start)
- (setq esense-indexer-program "~/.emacs.d/esense-1.12/esense.sh")
- ;;-------------------flymake-------------------
- ;
- ;(defun flymake-erlang-init ()
- ; (let* ((temp-file (flymake-init-create-temp-buffer-copy
- ; 'flymake-create-temp-inplace))
- ; (local-file (file-relative-name
- ; temp-file
- ; (file-name-directory buffer-file-name))))
- ; (list "/usr/local/bin/emakefly" (list local-file))))
- ;
- ;(add-to-list 'flymake-allowed-file-name-masks '("\\.erl\\'" flymake-erlang-init))
- ;(add-hook 'find-file-hook 'flymake-find-file-hook)
- ;(require 'erlang-flymake)
- -------------------mayi-flymake----------------
- ;使用erlang自带的语法检查,上面那个是dp自己搞的,不知从哪里来的!
- ;;仅在存盘时进行检查
- (erlang-flymake-only-on-save)
- ;;键盘映射
- (defvar flymake-mode-map (make-sparse-keymap))
- (define-key flymake-mode-map (kbd "<f3>") 'flymake-goto-next-error)
- (define-key flymake-mode-map (kbd "C-c <f3>") 'flymake-goto-prev-error)
- (define-key flymake-mode-map (kbd "<f4>") 'flymake-display-err-menu-for-current-line)
- (or (assoc 'flymake-mode minor-mode-map-alist)
- (setq minor-mode-map-alist
- (cons (cons 'flymake-mode flymake-mode-map)
- minor-mode-map-alist)))
- ;;----------------ecb--------------
- ;; cedet
- (load-file "~/.emacs.d/cedet-1.0/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
- (add-to-list 'load-path "~/.emacs.d/ecb-2.40")
- (require 'ecb)
- ;;(require 'ecb-autoloads)
- ;;(setq ecb-auto-activate t)
- (setq ecb-tip-of-the-day nil)
- ;; tabbar
- (add-to-list 'load-path "~/.emacs.d/tabbar")
- (require 'tabbar)
- (tabbar-mode t)
- (global-set-key [(meta j)] 'tabbar-backward)
- (global-set-key [(meta k)] 'tabbar-forward)
- ;;--------------------- tabbar----------
- (set-face-attribute 'tabbar-default-face nil
- :family "DejaVu Sans Mono"
- :background "gray80"
- :foreground "gray30"
- :height 1.0
- )
- (set-face-attribute 'tabbar-button-face nil
- :inherit 'tabbar-default
- :box '(:line-width 1 :color "yellow70")
- )
- (set-face-attribute 'tabbar-selected-face nil
- :inherit 'tabbar-default
- :foreground "DarkGreen"
- :background "LightGoldenrod"
- :box '(:line-width 2 :color "Darkgoldenrod")
- :overline "black"
- :underline "black"
- :weight 'bold
- )
- (set-face-attribute 'tabbar-unselected-face nil
- :inherit 'tabbar-default
- :box '(:line-width 2 :color "#00B2BF")
- )
- (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.
- '(ecb-options-version "2.40")
- '(ecb-primary-secondary-mouse-buttons (quote mouse-1--C-mouse-1)))
- (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.
- )
- ;;wrangler
- ;; --------- wrangler -----------------------
- (add-to-list 'load-path "/usr/local/share/wrangler/elisp")
- (require 'wrangler)
- ;;---------------------YASnippet--------------------
- (add-to-list 'load-path
- "~/.emacs.d")
- (require 'yasnippet-bundle)
- ;;----------------------auto-complete-------------
- ;;(add-to-list 'ac-dictionary-directories "~/.emacs.d/ac-dict")
- ;;(require 'auto-complete-config)
- ;;(ac-config-default)
- (add-to-list 'load-path "~/.emacs.d/")
- (require 'auto-complete-config)
- (add-to-list 'ac-dictionary-directories "~/.emacs.d//ac-dict")
- (ac-config-default)
PS:记得要改一些东西的哦! 我有在上面标示了 ,在下载文件里没改!
文件下载:
下载后,解压,要是看不到文件,就Ctrl + h 显示隐藏文件,然后全部复制到用户(~/)目录下,覆盖原本的文件即可!
打开emacs,一般都OK了 ,不行再找我吧
贴一下源吧:dp0304 ----->×××星 ,(*^__^*) 嘻嘻……
这个也不错:
ubuntu 11.10 使用 emacs-23.4 开发 erlang 整理之 使用自带erlang-flymake.el
适合我这种新手练手用!
2012-06-11-00时21分41秒