Emacs = Emacs Makes A Computer Slower
NTEmacs
from SFConfigure interface
Fonts
the font I am using now is
-outline-Bitstream Vera Sans Mono-normal-r-normal-normal-*-*-96-96-c-*-iso8859-1"it can be downloaded from http://www.gnome.org/fonts/, it works under Windows.
The default font in emacs 20
(set-default-font "-Misc-Fixed-Medium-R-Normal--15-140-75-75-C-90-ISO8859-1")to see the default font in your emacs, look at (frame-parameters) in Lisp-interaction mode
explanation for X Windows fonts naming:
-a-b-c-d-e--f-g-h-i-j-k-l- the letter stand for a = foundry b = font family c = weight d = slant e = set width f = pixels g = points in tenths of a point h = horiz resolution in dpi i = vertical resolution in dpi j = spacing k = average width in tenths of a pixel l = character set
Some of my settings:
(column-number-mode t)
(tool-bar-mode nil)
(menu-bar-mode nil)
(transient-mark-mode t)
(setq scroll-step 1
scroll-margin 3
scroll-conservatively 10000)
(setq frame-title-format "%b - EMACS")
(show-paren-mode t)
(setq show-paren-style 'parentheses)
;; display time
(setq display-time-day-and-date t)
(setq display-time-24hr-format t)
(display-time)
(setq require-final-newline t)
(mouse-wheel-mode t)
(xterm-mouse-mode t)
(auto-image-file-mode t)
(global-set-key `[27 right] `forward-word)
(global-set-key `[27 left] `backward-word)
(global-set-key `[27 up] `backward-paragraph)
(global-set-key `[27 down] `forward-paragraph)
;; TeX
(setq tex-dvi-view-command "xdvi")
;; spell-check
(add-hook `tex-mode-hook `flyspell-mode)
For reference, see Emacs FAQ about fonts (contains information on non-Latin language display)
Programming in Emacs
Compile and debug: type this and it will prompt you for the actual command, "make -k" is defaultM-x compilea writeup about programming using Emacs
use mouse in console mode
when working in console mode, mouse can be emulated in Emacs.M-x xterm-mouse-modeor load it automatically
(xterm-mouse-mode t)
shortcut keys I cannot remember
- move by words
- M-f/M-b
- move to begin/end of sentence
- M-a/M-e
- move to begin/end of file
- M-< /M->
- execute Lisp in interaction mode
- C-j
spell check
(ispell-minor-mode t)or
(flyspell-mode t)in flyspell mode, M-$ will check the spelling of the word at point and M-TAB will complete the word
case
M-l Convert following word to lower case (downcase-word). M-u Convert following word to upper case (upcase-word). M-c Capitalize the following word (capitalize-word). C-x C-l Convert region to lower case (downcase-region). C-x C-u Convert region to upper case (upcase-region).
key bindings
note that the key sequences are quite different from terminal ('-nw') mode and X modeuse "C-h l" will print out the list of previous 100 key strokes
use "C-h c" "C-h k" will query the function according to the key stroke
C-x ESC ESC will show the previous command
a good reference http://tiny-tools.sourceforge.net/emacs-keys.html
moving around
(global-set-key `[27 right] `forward-word) (global-set-key `[27 left] `backward-word) (global-set-key `[27 up] `backward-paragraph) (global-set-key `[27 down] `forward-paragraph)
using Gnus
a quick startuse smtpmail module
http://josefsson.org/smtpmail.htmlnote that it required GNUTLS or starttls program to be present on your machine
pop3.el needs to be replaced by the one supports SSL: http://cvs.m17n.org/viewcvs/*checkout*/root/gnus/lisp/pop3.el?rev=1.6.30.21.4.25
DOS/Unix EOL and Choosing Encoding
according to emacs manual:
To visit a file and specify whether it uses DOS-style or Unix-style end-of-line, specify a coding system (see section Q.9 Specifying a Coding System). For example, C-x RET c unix RET C-x C-f foobar.txt visits the file `foobar.txt' without converting the EOLs; if some line ends with a carriage-return linefeed pair, Emacs will display `^M' at the end of that line. Similarly, you can direct Emacs to save a buffer in a specified EOL format with the C-x RET f command. For example, to save a buffer with Unix EOL format, type C-x RET f unix RET C-x C-s. If you visit a file with DOS EOL conversion, then save it with Unix EOL format, that effectively converts the file to Unix EOL style, like dos2unix.
Encoding can be chosen in similar way, e.g.
C-x RET c utf-8-unix RET C-x C-f test.txt
regexp
As in GNU Emacs Manual:
http://www.gnu.org/software/emacs/manual/emacs.html#Regexps
for example: to replace "@test" with "@test = parsel($ltest)" you can put "@\(\w+\)" as search pattern, and use "@\1 = parsel($l\1)"
emacs-xft
http://www.emacswiki.org/cgi-bin/wiki/XftGnuEmacs
this version has support for the xft anti-aliasing fonts (and UNICODE).
if you compiled emacs on Debian or Ubuntu Linux, you might get this when you try to run emacs in terminal mode (-nw):
emacs: Cannot open termcap database file
the fix is to install "libncurses5-dev" package. This will install "termcap.h" at /usr/include. Emacs needs to be compiled again after this.
swbuffer.el
allow you to switch to next/prev buffers easily
some other modes useful for switching buffers are buffer-menu, electric-buffer-list, etc.
JDEE
an Java IDE for emacs http://jdee.sunsite.dk/
match new line
http://www.cs.umd.edu/~jspacco/emacs.html
type "C-q C-j", also works in replace.
javascript mode
http://edward.oconnor.cx/2005/09/editing-javascript-in-emacs
Print with syntax highlighting
http://osdir.com/ml/user-groups.linux.chlug/2003-05/msg00091.html
check perl syntax within emacs
http://www.perlmonks.org/?node_id=398159
note cperl mode has the function called "cperl-check-syntax" already, but GNU Emacs needs mode-compile.el, link can be found at
http://www.emacswiki.org/emacs/ModeCompile
Ediff mode
http://www.delorie.com/gnu/docs/emacs/ediff.html
work with git
http://xtalk.msk.su/~ott/en/writings/emacs-vcs/EmacsGit.html
http://parijatmishra.wordpress.com/2008/09/06/up-and-running-with-emacs-and-git/
edit and run SQL from Emacs
http://www.ibm.com/developerworks/db2/library/techarticle/0206mathew/0206mathew.html
uniq for a buffer
http://www.emacswiki.org/emacs/EmacsNiftyTricks
Automatically save and load buffers between sessions
works for GNU Emacs 21.3
(desktop-load-default) (desktop-read)