FlyZhy.Org logo Projects - Configuring Emacs

What
TODO
Before
HowTo
~/.emacs
~/Emacs/Configurations/common.el
~/Emacs/Configurations/tweak.el
~/Emacs/Configurations/modes.el
~/Emacs/Configurations/macros.el
After

What's Emacs? What can it do? How to use it as freely as you can? Here gives the detail appearance with source codes and screenshots which will take you in the relaxed world of versatile Emacs.

What

                       E. M. A. C. S.
                Emacs Makes A Computer Slow
               Escape Meta Alt Control Shift
               Emacs Makers Are Crazy Sickos
              Emacs Makes All Computing Simple
            Emacs Makefiles Annihilate C-Shells
            Emacs Manuals Always Cause Senility
            Emacs May Allow Customized Screwups
           Emacs Manuals Are Cryptic and Surreal
          Eventually Munches All Computer Storage
          Eight Megabytes And Constantly Swapping
          Elsewhere Maybe All Commands are Simple
          Excellent Manuals Are Clearly Suppressed
         Emacs May Alienate Clients and Supporters
         Except by Middle Aged Computer Scientists
         Extended Macros Are Considered Superfluous
        Every Mode Accelerates Creation of Software
       Each Manual's Audience is Completely Stupefied
  Exceptionally Mediocre Algorithm for Computer Scientists
Easily Maintained with the Assistance of Chemical Solutions
Eradication of Memory Accomplished with Complete Simplicity

top

TODO

"Emacs was originally a text editor, but it became a way of life and a religion."

Read What can Emacs do (in Chinese) for more information.

top

Before

HowTo

The configuration structure for my Emacs is:

$HOME/
  |©¤©¤ .emacs
  |©¤©¤ Emacs
         |©¤©¤ Configurations
         |          |©¤©¤ common.el
         |          |©¤©¤ tweak.el
         |          |©¤©¤ modes.el
         |          |©¤©¤ macros.el
         |©¤©¤ Extensions
         |          |©¤©¤ session.el
         |          |©¤©¤ ibuffer.el
         |          |©¤©¤ browse-kill-ring.el
         |          |©¤©¤ ido.el
         |          |©¤©¤ swbuff.el
         |          |©¤©¤ tabbar.el
         |          |©¤©¤ table.el
         |          |©¤©¤ setnu.el
         |          |©¤©¤ hide-region.el
         |          |©¤©¤ hide-lines.el
         |          |©¤©¤ folding.el
         |          |©¤©¤ color-theme.el
         |          |©¤©¤ ctypes.el
         |          |©¤©¤ matlab.el
         |          |©¤©¤ php-mode.el
         |          |©¤©¤ gnuplot.el
         |          |©¤©¤ gnuplot-gui.el
         |          |©¤©¤ keisen-mouse.el
         |          |©¤©¤ keisen-mule.el
         |          |©¤©¤ mpg123.el
         |          |©¤©¤ lrc.el
         |          |©¤©¤ wcy-escreen.el
         |          |©¤©¤ htmlize.el
         |          |©¤©¤ thumbs.el
         |          |©¤©¤ rect-mark.el
         |          |©¤©¤ dictionary-init.elc
         |          |©¤©¤ dictionary.elc
         |          |©¤©¤ connection.elc
         |          |©¤©¤ link.elc
         |          |©¤©¤ muse-zhy-en.el
         |          |©¤©¤ EmacsMuse/
         |                   |©¤©¤ ...
         |©¤©¤ Source
         |      |©¤©¤ ...
         |©¤©¤ Docs
                |©¤©¤ ...

~/.emacs

(setq load-path
      (cons "~/Emacs/Extensions" load-path))
(mapc 'load (directory-files "~/Emacs/Configurations" t "\.el$"))
;;;----------------------automatic customize----------------------------
(custom-set-variables
 '(scheme-program-name "scheme -large -band 6001.com"))
  ;;; custom-set-variables was added by Custom --

top

setq

The easiest customizations are accomplished by changing the value of a variable in Emacs. The list code to do this looks like this:

(setq variable-name new-value)

Where variable-name is the name of the variable and new-value is the value you'd like to give the variable. (In Lisp-speak, you're binding a variable to a value.) The setq function in lisp is analogous to the assignment operators (usually = ) in other programming languages.

Emacs Beginner's HOWTO ©¤©¤ up

load-path

If you load many extensions, as I do, then instead of specifying the exact location of the extension file, as shown above, you can specify that directory as part of Emacs load-path. Then, when Emacs loads a file, it will search that directory as well as its default list of directories. (The default list is specified in paths.h when Emacs is built.)

Programming in Emacs Lisp ©¤©¤ up

cons

cons - Constructing a list. For example, cons can be used to make a four element list from the three element list, (fir oak maple):

(cons 'pine '(fir oak maple))

After evaluating this list, you will see

(pine fir oak maple)

appear in the echo area. cons causes the creation of a new list in which the element is followed by the elements of the original list.

Programming in Emacs Lisp ©¤©¤ up

mapc

A mapping function applies a given function to each element of a list or other collection. Take mapcar for example,

mapcar function sequence

which applies function to each element of sequence in turn, and returns a list of the results. The argument sequence can be any kind of sequence except a char-table; that is, a list, a vector, a bool-vector, or a string. The result is always a list. The length of the result is the same as the length of sequence. While

mapc function sequence

mapc is like mapcar except that function is used for side-effects only--the values it returns are ignored, not collected into a list. mapc always returns sequence.

GNU Emacs Lisp Reference Manual ©¤©¤ up

load

You can use a load command to evaluate a complete file and thereby install all the functions and variables in the file into Emacs. For example:

(load "~/emacs/slowsplit")

This evaluates, i.e. loads, the slowsplit.el file or if it exists, the faster, byte compiled slowsplit.elc file from the emacs sub-directory of your home directory.

Programming in Emacs Lisp ©¤©¤ up

directory-files

syntax:

directory-files directory &optional full-name match-regexp nosort

This function returns a list of the names of the files in the directory directory. By default, the list is in alphabetical order.

If full-name is non-nil, the function returns the files' absolute file names. Otherwise, it returns the names relative to the specified directory.

If match-regexp is non-nil, this function returns only those file names that contain a match for that regular expression--the other file names are excluded from the list.

If nosort is non-nil, directory-files does not sort the list, so you get the file names in no particular order. Use this if you want the utmost possible speed and don't care what order the files are processed in. If the order of processing is visible to the user, then the user will probably be happier if you do sort the names.

An error is signaled if directory is not the name of a directory that can be read.

GNU Emacs Lisp Reference Manual ©¤©¤ up

;

A ";" is used to comment a line in Emacs Lisp.

up

custom-set-variables

Todays Emacs has a built in customization feature called customization buffers. Customization buffers allow you to set package settings in a user friendly environment with information about the settings you are able to change.

Especially for people new to Emacs this is a very convenient way to customize Emacs. All packages of the standard distribution of Emacs and most of the additional packages have support for the customization buffers build in, even if not all of their customization might be done this way.

Customize handles the information which is set through the use of the buffers with the help of a set of special lists which begin with custom-set (custom-set-variables and custom-set-faces).

(custom-set-variables
 '(kill-ring-max 70)
 '(user-full-name "Ingo Koch"))
(custom-set-faces
 '(font-lock-comment-face ((((class color)) (:foreground "red"))))
 '(font-lock-string-face ((((class color)) (:foreground "green4"))))
 '(font-lock-keyword-face ((((class color)) (:foreground "blue"))))
 '(font-lock-type-face ((((class color)) (:foreground "blue"))))
 '(font-lock-variable-name-face ((((class color)) (:foreground "brown"))))
 '(font-lock-function-name-face ((((class color)) (:foreground "blue")))))

These lists are placed in your .emacs by default and are read on startup to apply the appropriate changes to the packages.

The very unofficial dotemacs home ©¤©¤ up

dotemacs

You may ask for the question that why my dotemacs is so simple. It is simple, but what did it do?

setq set the variable load-path to be the original load-path add to the new path ~/Emacs/Configurations. Then mapc applies the load function to every .el file in the directory ~/Emacs/Configurations while load will evaluate the specified .el file and thereby install all the functions and variables in the file into Emacs. After skipping some comment lines with ";" at the beginning, the custom-set-variables will customize some variables.

I put my own customized settings into the .el files in ~/Emacs/Configurations directory which will be installed while Emacs startup, and put all the other Elisp packages that I may load in the .el files of ~/Emacs/Configurations directory into the ~/Emacs/Extensions directory. However, I may also use the ~/Emacs/Source directory to store the source code of the Elisp packages I used and ~/Emacs/Docs directory to store some documents for these packages.

(setq load-path
      (cons "~/Emacs/Extensions" load-path))
(mapc 'load (directory-files "~/Emacs/Configurations" t "\.el$"))
;;;----------------------automatic customize----------------------------
(custom-set-variables
 '(scheme-program-name "scheme -large -band 6001.com"))
  ;;; custom-set-variables was added by Custom --

up

~/Emacs/Configurations/common.el

;;; -*- mode: emacs-lisp; mode:font-lock; coding: gb2312 -*-
;;; common.el
;;  ~/Emacs/Configurations/common.el
;;  made by Haiyong Zheng AT http://www.flyzhy.org
;
;;  Set up the Emacs own function ;;
;
;;; inhibit the startup message
(setq inhibit-startup-message t)
;
;;; set up Chinese environment
(set-language-environment 'Chinese-GB)
(set-keyboard-coding-system 'cn-gb)
(set-clipboard-coding-system 'cn-gb)
(set-terminal-coding-system 'cn-gb)
(set-buffer-file-coding-system 'cn-gb)
(set-selection-coding-system 'ctext)
(modify-coding-system-alist 'process "*" 'cn-gb)
(setq default-process-coding-system
      '(cn-gb . cn-gb))
(setq-default pathname-coding-system 'cn-gb)
;
;;; set up sentence-end to recognize Chinese punctuationg
;;  so that you have no need to insert two spaces after Chinese period
(setq sentence-end "\\([¡££¡£¿]\\|¡­¡­\\|[.?!][]\"')}]*\\($\\|[ \t]\\)\\)[ \t\n]*")
(setq sentence-end-double-space nil)
;
;;; display the buffer name on the titlebar
(setq frame-title-format "emacs@%b")
;
;;; set up text-mode to be the default major mode
;;  but not the ugly fundamental-mode
(setq default-major-mode 'text-mode)
;
;;; syntax highlight
(global-font-lock-mode t)
;
;;; no visual feedback on selection
(setq-default transient-mark-mode nil)
;
;;; no end a file with newline
(setq require-final-newline nil)
;; Stop at the end of the file, not just add lines
(setq next-line-add-newlines nil)
;
;;; enable wheelmouse support by default
;(cond (window-system (mwheel-install)))
;
;;; set up the parentheses matching
(show-paren-mode t)
(setq show-paren-style 'parentheses)
;
;;; display the chosen area
(transient-mark-mode t)
;
;;; display the column number
(setq column-number-mode t)
;
;;; set fill-column to be 60
(setq default-fill-column 60)
;
;;; display images automatically
(auto-image-file-mode t)
;
;;; set kill-ring-max to be 200 to avoid delete something important
(setq kill-ring-max 200)
;
;;; display the compressed file automatically
(auto-compression-mode t)
;
;;; substitute the yes/no to y/n
(fset 'yes-or-no-p 'y-or-n-p)
;
;;; inhibit beep
(set-default 'visible-bell t)
;
;;; inhibit blink in console
(setq ring-bell-function (lambda () t))
;
;;; set default saved variables number to be 5000
(set-default 'max-specpdl-size 5000)
;
;;; set the syntax highlight mode to be executed in necessary situation
;;  in order to speed up the file scrolling
(set-default 'lazy-lock-defer-on-scrolling 't)
;
;;; set up the display format of time
(setq display-time-day-and-date t)
(setq display-time-format "%m/%d %H:%M")
(setq display-time-24hr-format t)
(display-time)
;
;;; set up the time stamp of the last modified files
(add-hook 'write-file-hooks 'time-stamp)
(setq time-stamp-format "%:u %02m/%02d/%04y %02H:%02M:%02S (%s)")
;
;;; set up the convert between CJK and UTF
(when (boundp 'utf-translate-cjk)
  (setq utf-translate-cjk t)
  (custom-set-variables
   '(utf-translate-cjk t)))
(if (fboundp 'utf-translate-cjk-mode)
    (utf-translate-cjk-mode 1))
(put 'narrow-to-page 'disabled nil)
;
;;; set up toolbar and menubar
;;  toolbar
(setq tool-bar-mode t);
;;  no menubar
(setq menu-bar-mode nil);
;
;;; use clipboard
(setq x-select-enable-clipboard t)
;
;;; let dired can copy and delete directories recursively
(setq dired-recursive-copies 'top)
(setq dired-recursive-deletes 'top)
;
;;; hippie-expand
;;  M-/
(global-set-key [(meta ?/)] 'hippie-expand)
(setq hippie-expand-try-functions-list
      '(try-expand-dabbrev
        try-expand-dabbrev-visible
        try-expand-dabbrev-all-buffers
        try-expand-dabbrev-from-kill
        try-complete-file-name-partially
        try-complete-file-name
        try-expand-all-abbrevs
        try-expand-list
        try-expand-line
        try-complete-lisp-symbol-partially
        try-complete-lisp-symbol))
;
;;; ask for y or n before killing emacs
;(setq confirm-kill-emacs 'yes-or-no-p)
(setq confirm-kill-emacs 'y-or-n-p)

top

~/Emacs/Configurations/tweak.el

;;; tweak.el
;;  ~/Emacs/Configurations/tweak.el
;;  made by Haiyong Zheng AT http://www.flyzhy.org
;
;;  Funny but useful things ;;
;
;;; use minibuffer recursively
(setq enable-recursive-minibuffers t)
;
;;; move away mouse pointer automatically when it closes to cursor
(mouse-avoidance-mode 'animate)
;
;;; open these default nil stuffs
(put 'set-goal-column 'disabled nil)
(put 'narrow-to-region 'disabled nil)
(put 'upcase-region 'disabled nil)
(put 'downcase-region 'disabled nil)
(put 'LaTeX-hide-environment 'disabled nil)
;
;;; a shortcut to set up auto-mode-alist to avoid to write many add-to-list
(mapcar
 (function (lambda (setting)
             (setq auto-mode-alist
                   (cons setting auto-mode-alist))))
 '(("\\.xml$".  sgml-mode)
   ("\\\.bash" . sh-mode)
   ("\\.rdf$".  sgml-mode)
   ("\\.session" . emacs-lisp-mode)
   ("\\.l$" . c-mode)
   ("\\.css$" . css-mode)
   ("\\.cfm$" . html-mode)
   ("gnus" . emacs-lisp-mode)
   ("\\.idl$" . idl-mode)))
;
;;; set up useful personal information
(setq user-full-name "Haiyong Zheng")
(setq user-mail-address "zhenghaiyong@gmail.com")
;
;;; ASCII table
(autoload 'ascii-table "ascii-table" "ASCII TABLE" t)
;
;;; Matching parenthesis
(global-set-key "%" 'match-paren)
(defun match-paren (arg)
  "Go to the matching paren if on a paren; otherwise insert %."
  (interactive "p")
  (cond ((looking-at "\\s\(") (forward-list 1) (backward-char 1))
        ((looking-at "\\s\)") (forward-char 1) (backward-list 1))
        (t (self-insert-command (or arg 1)))))
;;; Temporary Mark
;;  C-. to set a mark and C-, to swith each other
(global-set-key [(control ?\.)] 'ska-point-to-register)
(global-set-key [(control ?\,)] 'ska-jump-to-register)
(defun ska-point-to-register()
  "Store cursorposition _fast_ in a register.
Use ska-jump-to-register to jump back to the stored
position."
  (interactive)
  (setq zmacs-region-stays t)
  (point-to-register 8))
(defun ska-jump-to-register()
  "Switches between current cursorposition and position
that was stored with ska-point-to-register."
  (interactive)
  (setq zmacs-region-stays t)
  (let ((tmp (point-marker)))
        (jump-to-register 8)
        (set-register 8 tmp)))
;
;;; go-to-char
;;  C-c a x to jump to next char x
(defun wy-go-to-char (n char)
  "Move forward to Nth occurence of CHAR.
Typing `wy-go-to-char-key' again will move forwad to the next Nth
occurence of CHAR."
  (interactive "p\ncGo to char: ")
  (search-forward (string char) nil nil n)
  (while (char-equal (read-char)
                     char)
    (search-forward (string char) nil nil n))
  (setq unread-command-events (list last-input-event)))
(define-key global-map (kbd "C-c a") 'wy-go-to-char)
;
;;; mmm-mode
(autoload 'mmm-mode "mmm-mode" "Multiple Major Modes" t)
(autoload 'mmm-parse-buffer "mmm-mode" "Automatic MMM-ification" t)
;
;;; substitute aspell for ispell
(setq ispell-program-name "aspell")
(add-hook 'message-mode-hook (lambda () (flyspell-mode 1)))

top

~/Emacs/Configurations/modes.el

;;; Other useful modes
;;  ~/Emacs/Configurations/modes.el
;;  made by Haiyong Zheng AT http://www.flyzhy.org
;

top

session.el and desktop.el(c)

code:

;;; Save session and desktop
;;  ~/Emacs/Extensions/session.el
;   /usr/share/emacs/21.4/lisp/desktop.el(c)
(add-to-list 'load-path "~/.emacs.d")
(require 'session)
(add-hook 'after-init-hook 'session-initialize)
(load "desktop")
(desktop-load-default)
(desktop-read);

up

ibuffer.el

code:

;;; ibuffer.el
;;  ~/Emacs/Extensions/ibuffer.el
;;  C-x C-b
(require 'ibuffer)
(global-set-key (kbd "C-x C-b") 'ibuffer)

up

browse-kill-ring.el

code:

;;; browse-kill-ring.el
;;  ~/Emacs/Extensions/browse-kill-ring.el
;;  C-c k
(require 'browse-kill-ring)
(global-set-key [(control c)(k)] 'browse-kill-ring)
(browse-kill-ring-default-keybindings)

up

ido.el

code:

;;; ido.el
;;  ~/Emacs/Extensions/ido.el
(require 'ido)
(ido-mode t)
(add-hook 'ido-define-mode-map-hook 'ido-my-keys)
(defun ido-my-keys ()
  "Set up the keymap for `ido'."
  ;; common keys
  (define-key ido-mode-map "\C-e" 'ido-edit-input)
  (define-key ido-mode-map "\t" 'ido-complete) ;; complete partial
  (define-key ido-mode-map "\C-j" 'ido-select-text)
  (define-key ido-mode-map "\C-m" 'ido-exit-minibuffer)
  (define-key ido-mode-map "?" 'ido-completion-help) ;; list completions
  (define-key ido-mode-map [(control ? )] 'ido-restrict-to-matches)
  (define-key ido-mode-map [(control ?@)] 'ido-restrict-to-matches)
  ;; cycle through matches
  (define-key ido-mode-map "\C-r" 'ido-prev-match)
  (define-key ido-mode-map "\C-s" 'ido-next-match)
  (define-key ido-mode-map [right] 'ido-next-match)
  (define-key ido-mode-map [left] 'ido-prev-match)
  ;; toggles
  (define-key ido-mode-map "\C-t" 'ido-toggle-regexp) ;; same as in isearch
  (define-key ido-mode-map "\C-p" 'ido-toggle-prefix)
  (define-key ido-mode-map "\C-c" 'ido-toggle-case)
  (define-key ido-mode-map "\C-a" 'ido-toggle-ignore)
  ;; keys used in file and dir environment
  (when (memq ido-cur-item '(file dir))
    (define-key ido-mode-map "\C-b" 'ido-enter-switch-buffer)
    (define-key ido-mode-map "\C-d" 'ido-enter-dired)
    (define-key ido-mode-map "\C-f" 'ido-fallback-command)
    ;; cycle among directories
    ;; use [left] and [right] for matching files
    (define-key ido-mode-map [down] 'ido-next-match-dir)
    (define-key ido-mode-map [up]   'ido-prev-match-dir)
    ;; backspace functions
    (define-key ido-mode-map [backspace] 'ido-delete-backward-updir)
    (define-key ido-mode-map "\d"        'ido-delete-backward-updir)
    (define-key ido-mode-map [(meta backspace)] 'ido-delete-backward-word-updir)
    (define-key ido-mode-map [(control backspace)] 'ido-up-directory)
    ;; I can't understand this
    (define-key ido-mode-map [(meta ?d)] 'ido-wide-find-dir)
    (define-key ido-mode-map [(meta ?f)] 'ido-wide-find-file)
    (define-key ido-mode-map [(meta ?k)] 'ido-forget-work-directory)
    (define-key ido-mode-map [(meta ?m)] 'ido-make-directory)
    (define-key ido-mode-map [(meta down)] 'ido-next-work-directory)
    (define-key ido-mode-map [(meta up)] 'ido-prev-work-directory)
    (define-key ido-mode-map [(meta left)] 'ido-prev-work-file)
    (define-key ido-mode-map [(meta right)] 'ido-next-work-file)
    ;; search in the directories
    ;; use C-_ to undo this
    (define-key ido-mode-map [(meta ?s)] 'ido-merge-work-directories)
    (define-key ido-mode-map [(control ?\_)] 'ido-undo-merge-work-directory)
    )
  (when (eq ido-cur-item 'file)
    (define-key ido-mode-map "\C-k" 'ido-delete-file-at-head)
    (define-key ido-mode-map "\C-l" 'ido-toggle-literal)
    (define-key ido-mode-map "\C-o" 'ido-copy-current-word)
    (define-key ido-mode-map "\C-v" 'ido-toggle-vc)
    (define-key ido-mode-map "\C-w" 'ido-copy-current-file-name)
    )
  (when (eq ido-cur-item 'buffer)
    (define-key ido-mode-map "\C-b" 'ido-fallback-command)
    (define-key ido-mode-map "\C-f" 'ido-enter-find-file)
    (define-key ido-mode-map "\C-k" 'ido-kill-buffer-at-head)
    ))
(ido-mode t)
;;}}}

up

swbuff.el

code:

;;; swbuff.el
;;  ~/Emacs/Extensions/swbuff.el
(require 'swbuff)
(global-set-key (kbd "") 'swbuff-switch-to-previous-buffer)
(global-set-key (kbd "") 'swbuff-switch-to-next-buffer)
(setq swbuff-exclude-buffer-regexps
     '("^ " "\\*.*\\*"))
;
(setq swbuff-status-window-layout 'scroll)
(setq swbuff-clear-delay 1)
(setq swbuff-separator "|")
(setq swbuff-window-min-text-height 1)

up

tabbar.el

code:

;;; tabbar.el
;;  ~/Emacs/Extensions/tabbar.el
;;  Win+Arrow Key
(require 'tabbar)
(tabbar-mode)
(define-prefix-command 'lwindow-map)
;(global-set-key (kbd "") 'lwindow-map)
(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)
;(autoload 'tabbar-mode "tabbar" "tabbar mode." t)

up

table.el

code:

;;; table.el
;;  ~/Emacs/Extensions/table.el
(autoload 'table-insert "table" "WYGIWYS table editor")

up

recentf.el(c)

code:

;;; recentf.el
;;  /usr/share/emacs/21.4/lisp/recentf.el(c)
(require 'recentf)
(recentf-mode 1)
;;  C-x C-r
(defun recentf-open-files-compl ()
  (interactive)
  (let* ((all-files recentf-list)
         (tocpl (mapcar (function
                         (lambda (x) (cons (file-name-nondirectory x) x))) all-files))
         (prompt (append '("File name: ") tocpl))
         (fname (completing-read (car prompt) (cdr prompt) nil nil)))
    (find-file (cdr (assoc-ignore-representation fname tocpl)))))
(global-set-key [(control x)(control r)] 'recentf-open-files-compl)

up

setnu.el

code:

;;; setnu.el
;;  ~/Emacs/Extensions/setnu.el
;;  M-x setnu-mode
(require 'setnu)
;(add-hook 'text-mode-hook 'turn-on-setnu-mode)

up

hide-region.el

code:

;;; hide region
;;  ~/Emacs/Extensions/hide-region.el
(require 'hide-region)
(global-set-key (kbd "C-c r") 'hide-region-hide)
(global-set-key (kbd "C-c R") 'hide-region-unhide)

up

hide-lines.el

code:

;;; hide lines
;;  ~/Emacs/Extensions/hide-lines.el
(require 'hide-lines)
(global-set-key (kbd "C-c l") 'hide-lines)
(global-set-key (kbd "C-c L") 'show-all-invisible)

up

folding.el

code:

;;; folding.el
;;  ~/Emacs/Extensions/folding.el
(load-library  "folding")
(declare (special fold-fold-on-startup
                  fold-keys-already-setup
                  ))
(setq fold-fold-on-startup t)
(folding-mode-add-find-file-hook)
(setq fold-keys-already-setup nil)
(add-hook 'folding-mode-hook
          (function (lambda()
                      (unless fold-keys-already-setup
                        (setq fold-keys-already-setup t)
                        (define-prefix-command 'ctl-f-folding-mode-prefix)
                        (define-key 'ctl-f-folding-mode-prefix "f" 'fold-fold-region)
                        (define-key  'ctl-f-folding-mode-prefix "e" 'fold-enter)
                        (define-key 'ctl-f-folding-mode-prefix "x" 'fold-exit)
                        (define-key  'ctl-f-folding-mode-prefix "b" 'fold-whole-buffer)
                        (define-key 'ctl-f-folding-mode-prefix "o" 'fold-open-buffer)
                        (define-key 'ctl-f-folding-mode-prefix "h" 'fold-hide)
                        (define-key 'ctl-f-folding-mode-prefix "s" 'fold-show)
                        (define-key 'ctl-f-folding-mode-prefix "t" 'fold-top-level)
                        (define-key 'ctl-f-folding-mode-prefix "f" 'fold-fold-region)
                        )
                      (local-set-key "\C-f" 'ctl-f-folding-mode-prefix))))
(fold-add-to-marks-list 'sgml-mode
                        "<!-- {"
                        "<!-- } -->" " --> ")
(fold-add-to-marks-list 'c-mode "/* <" "/* > */" "*/")
(fold-add-to-marks-list 'c++-mode
                        "//<" "//>" "")
(fold-add-to-marks-list 'LaTeX-mode "%%% {{{" "%%% }}}" " ")
(fold-add-to-marks-list 'latex2e-mode "%%% {{{" "%%% }}}" " ")
(fold-add-to-marks-list 'latex-mode "%%%% {{{" "%%%% }}}" " ")
(fold-add-to-marks-list 'BibTeX-mode "%%% {{{" "%%% }}}" " ")
(fold-add-to-marks-list 'lisp-mode ";;; {" ";;; }" "")
(fold-add-to-marks-list 'lex-mode" /* {{{ " " /* }}} */ " "*/")
(fold-add-to-marks-list 'html-mode "<!-- { " "<!-- } -->" "-->")
(fold-add-to-marks-list 'shell-script-mode "# {{{" "# }}}" nil)
(fold-add-to-marks-list 'sh-mode "# {{{ " "# }}}" nil)

up

color-theme.el

code:

;;; color-theme
;;  ~/Emacs/Extensions/color-theme.el
;(add-to-list 'load-path "~/Emacs/FlyZhyEmacs")
(require 'color-theme)
;(color-theme-dark-blue)

up

ctypes.el

code:

;;; ctypes.el
;;  ~/Emacs/Extensions/ctypes.el
;;  for typedef highlight in C
(require 'ctypes)
(ctypes-auto-parse-mode 1)

up

muse-mode

code:

Look through WebsiteSettings page for the details if you are interested in Muse-Mode and the generations of this web.

;;; muse-mode
;;  ~/Emacs/Extensions/EmacsMuse/
;(load-file "~/Emacs/Extensions/muse-zhy.el")
(load-file "~/Emacs/Extensions/muse-zhy-en.el")

up

matlab.el

code:

;;; matlab-mode
;;  ~/Emacs/Extensions/matlab.el
;;  M-x matlab-shell
(autoload 'matlab-mode "matlab" "Enter Matlab mode." t)
(setq auto-mode-alist (cons '("\\.m$" . matlab-mode) auto-mode-alist))
(defun my-matlab-mode-hook ()
  (setq matlab-indent-function t) ; if you want function bodies indented
  (setq fill-column 76) ; where auto-fill should wrap
  (matlab-mode-hilit)
  (turn-on-auto-fill))
(setq matlab-mode-hook 'my-matlab-mode-hook)
(autoload 'matlab-shell "matlab" "Interactive Matlab mode." t)
(defun my-matlab-shell-mode-hook ()
  '())
(setq matlab-mode-hook 'my-matlab-mode-hook)
;; Matlab 6 now defaults to a GUI, but matlab-mode still expects CLI.
(setq matlab-shell-command-switches '("-nodesktop")) ; try also -nojvm

up

php-mode.el

code:

;;; php-mode
;;  ~/Emacs/Extensions/php-mode.el
(require 'php-mode)
(setq auto-mode-alist
  (append '(("\\.php$" . php-mode)
            ("\\.php3$" . php-mode))
              auto-mode-alist))

up

gnuplot.elc and gnuplot-gui.elc

code:

;;; gnuplot-mode
;;  ~/Emacs/Extensions/gnuplot.elc
;;  ~/Emacs/Extensions/gnuplot-gui.elc
(autoload 'gnuplot-mode "gnuplot"
  "gnuplot major mode" t)
(autoload 'gnuplot-make-buffer "gnuplot"
  "open a buffer in gnuplot mode" t)
(setq auto-mode-alist
      (append '(("\\.gp$" . gnuplot-mode))
              auto-mode-alist))
(global-set-key [(f9)] 'gnuplot-make-buffer)

up

keisen-mouse.el and keisen-mule.el

code:

;;; keisen-mode
;;  ~/Emacs/Extensions/keisen-mouse.el
;;  ~/Emacs/Extensions/keisen-mule.el
(if window-system
    (autoload 'keisen-mode "keisen-mouse" "MULE table" t)
  (autoload 'keisen-mode "keisen-mule" "MULE table" t))

up

mpg123.el and lrc.el

code:

;;; mpg123 lrc
;;  ~/Emacs/Extensions/mpg123.el
;;  ~/Emacs/Extensions/lrc.el
;;  M-x mpg123
;(setq lrc-lyric-dir "/path/to/lrc") to ~/.emacs
(setq lrc-lyric-dir "~/Music/lrc")
(require 'mpg123)

up

wcy-escreen.el

code:

;;; wcy-escreen
;;  ~/Emacs/Extensions/wcy-escreen.el
(require 'wcy-escreen)
(wcy-escreen-install)

up

htmlize.el

code:

;;; htmlize.el
;;  ~/Emacs/Extensions/htmlize.el
(require 'htmlize)

up

thumbs.el

code:

;;; thumbs.el
;;  ~/Emacs/Extensions/thumbs.el
(require 'thumbs)

up

rect-mark.el

code:

;;; rect-mark.el
;;  ~/Emacs/Extensions/rect-mark.el
(require 'rect-mark)

up

dictionary

code:

;;; dictionary
;;; http://www.myrkr.in-berlin.de/dictionary/index.html
;;  ~/Emacs/Extensions/dictionary-init.el
;;  ~/Emacs/Extensions/dictionary.elc
;;  ~/Emacs/Extensions/connection.elc
;;  ~/Emacs/Extensions/link.elc
;;; C-c d ---> look up the current word
;;; C-c m ---> look for a matching word in the dictionary
(add-to-list 'load-path "~/Emacs/FlyZhyEmacs")
(autoload 'dictionary-search "dictionary"
  "Ask for a word and search it in all dictionaries" t)
(autoload 'dictionary-match-words "dictionary"
  "Ask for a word and search all matching words in the dictionaries" t)
(autoload 'dictionary-lookup-definition "dictionary"
  "Unconditionally lookup the word at point." t)
(autoload 'dictionary "dictionary"
  "Create a new dictionary buffer" t)
;;autosearch had been canceled
(autoload 'dictionary-mouse-popup-matching-words "dictionary"
  "Display entries matching the word at the cursor"t )
(autoload 'dictionary-popup-matching-words "dictionary"
  "Display entries matching the word at the point" t)
(autoload 'dictionary-tooltip-mode "dictionary"
  "Display tooltips for the current word" t)
(autoload 'global-dictionary-tooltip-mode "dictionary"
  "Enable/disable dictionary-tooltip-mode for all buffers" t)
;(global-set-key [mouse-3] 'dictionary-mouse-popup-matching-words)
(global-set-key [(control c)(d)] 'dictionary-lookup-definition)
(global-set-key [(control c)(s)] 'dictionary-search)
(global-set-key [(control c)(m)] 'dictionary-match-words)
;; choose a dictionary server
(setq dictionary-server "localhost")
;; for dictionary tooltip mode
;; choose the dictionary: "wn" for WordNet
;; "web1913" for Webster's Revised Unabridged Dictionary(1913)
;; so on
(setq dictionary-tooltip-dictionary "oxford-gb")
(setq dictionary-tooltip-dictionary "wn")
(global-dictionary-tooltip-mode t)
(dictionary-tooltip-mode t)
;;dictionary mode settings end here

up

Other installed packages

code:

;;; AUCTeX -> http://www.gnu.org/software/auctex/
;;; preview-latex -> http://sourceforge.net/project/showfiles.php?group_id=35101&release_id=134739
;;; dictionary -> http://www.myrkr.in-berlin.de/dictionary/index.html
;;; Emacs Muse -> http://www.mwolson.org/projects/EmacsMuse.html
;;; gnuplot-mode
;;; session
;;; aspell

up

~/Emacs/Configurations/macros.el

This file is existed to save the macros I used. About how to use and save macros in Emacs please see the Macros (Hour 13) in Sams teach yourself Emacs in 24 hours.

;;; macros.el
;;  ~/Emacs/Configurations/macros.el
;;  Some macros I saved and used

top

After

After looking through my Emacs configuration, you must want to know what they are and how to use them. Actually you can get the help file of every Elisp file except my own Elisp files in ~/Emacs/Configurations directory from internet. Besides, you should learn to use Emacs first, or else you will be completely defeated by Emacs. Read the following resources in order until you know what I exactly said before.