Some useful Emacs modes
PSVN Very useful mode for handling svn directory trees. (load-file "~hallon/elisp/stuff.el")
Use M-x svn-status to see the status of the current directory. Press C-h m to see available functions. The diff mode (activated by =) has the useful key C-c C-a that can be used to revert a single diff chunk.
Flymake
Do syntax checking while coding. Included in recent Emacsen, enable with M-x flymake-mode. Suggested key bindings to jump to next error and to display error message:
(global-set-key [?\C-<] 'flymake-goto-next-error)(global-set-key [?\C->] 'flymake-display-err-menu-for-current-line)
To start automatically when C/C++ mode is activated:
(add-hook 'c-mode-common-hook 'flymake-mode)
If you program python and want to run some useful tools (like pep8 and pyflakes) add this to your .emacs
(when (load "flymake" t) (defun flymake-pycheck-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 "pycheck.py" (list local-file)))) (add-to-list 'flymake-allowed-file-name-masks '("\\.py\\'" flymake-pycheck-init)))(add-hook 'find-file-hook 'flymake-find-file-hook)and then create an executable python (pycheck.py) script in your path like this#!/usr/bin/pythonimport subprocessimport syssubprocess.call(['pep8', '-r', sys.argv[1]])subprocess.call(['pyflakes', sys.argv[1]])You need to have pep8 and pyflakes installed otherwise it wont work...Ido Fast buffer and file switching. Add (ido-mode t) to .emacs.
Calc Very powerful calculator.
(load-file "~hallon/elisp/stuff.el")
Start with M-x calc.
A more simple but easier calculator is also available with M-x calculator.
Findotherfile Find matching file (eg file.cpp and file.h). Suggested key binding:
(global-set-key "\C-xf" 'ff-find-other-file)
Rectangle Delete and insert rectangles of text. Use C-x r prefix. Most useful C-x r k to kill rectangle and C-x r t to insert string.
Auto-completion If you feel that the standard dynamic abbreviation expand is not good enough you could try the auto-complete extension. Besides being a bit more clever than dabbrev-expand it also features a nice and useful pop-up menu. Together with clang it can perform semantic completions instead of simple syntax analysis. See this page for more information. Cppcheck
If you want static code analysis in your emacs install cppcheck (fedora package) and add the following to your .emacs:
(defun cpp-check () (interactive) "Run cpp-check on current file the buffer is visiting." (shell-command (concat "/usr/bin/cppcheck --quiet --template '{file}:{line}: {severity}: {message}' " (buffer-file-name)) "*compilation*") (pop-to-buffer "*compilation*") (compilation-mode))Start with M-x cpp-check or bind a key.
Macros
Much useful for repetitive tasks.
Start defining a macro with C-x ( , then do things you want your macro to do. Stop defining with C-x ) . Execute your macro with C-x e and keep pressing e to repeat macro.
General stuff
Make use of the help key ( C-h or F1):
- You can always use C-h after a key prefix to see which buttons are available, for example C-x r C-h will list all functions in rectangle module. C-h C-h will list all help functions.
- C-h m will display help for all modes active in the current buffer.
- C-h k will show what function is bound to a specific key.
- M-x customize browse the available customization groups
- M-x customize-group browse a specific group, tab completion works as usual.
本文介绍了一系列提升Emacs使用效率的方法,包括SVN版本控制、语法检查、快速文件切换、计算器使用、矩形操作等功能,并提供了实用的宏定义及自定义快捷键建议。
2172

被折叠的 条评论
为什么被折叠?



