;;; Other useful modes ;; ~/Emacs/Configurations/modes.el ;; made by Haiyong Zheng AT http://www.flyzhy.org ; ;;; 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); ; ;;; ibuffer.el ;; ~/Emacs/Extensions/ibuffer.el ;; C-x C-b (require 'ibuffer) (global-set-key (kbd "C-x C-b") 'ibuffer) ; ;;; 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) ; ;;; 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) ;;}}} ; ;;; 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) ; ;;; 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) ; ;;; table.el ;; ~/Emacs/Extensions/table.el (autoload 'table-insert "table" "WYGIWYS table editor") ; ;;; recentf.el ;; ~/Emacs/Extensions/recentf.el (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) ; ;;; setnu.el ;; ~/Emacs/Extensions/setnu.el ;; M-x setnu-mode (require 'setnu) ;(add-hook 'text-mode-hook 'turn-on-setnu-mode) ; ;;; 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) ; ;;; 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) ; ;;; 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) ; ;;; color-theme ;; ~/Emacs/Extensions/color-theme.el ;(add-to-list 'load-path "~/Emacs/FlyZhyEmacs") (require 'color-theme) ;(color-theme-dark-blue) ; ;;; ctypes.el ;; ~/Emacs/Extensions/ctypes.el ;; for typedef highlight in C (require 'ctypes) (ctypes-auto-parse-mode 1) ; ;;; muse-mode ;; ~/Emacs/Extensions/EmacsMuse/ ;(load-file "~/Emacs/Extensions/muse-zhy.el") (load-file "~/Emacs/Extensions/muse-zhy-en.el") ; ;;; 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 ; ;;; php-mode ;; ~/Emacs/Extensions/php-mode.el (require 'php-mode) (setq auto-mode-alist (append '(("\\.php$" . php-mode) ("\\.php3$" . php-mode)) auto-mode-alist)) ; ;;; 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) ; ;;; 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)) ; ;;; 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) ; ;;; wcy-escreen ;; ~/Emacs/Extensions/wcy-escreen.el (require 'wcy-escreen) (wcy-escreen-install) ; ;;; htmlize.el ;; ~/Emacs/Extensions/htmlize.el (require 'htmlize) ; ;;; thumbs.el ;; ~/Emacs/Extensions/thumbs.el (require 'thumbs) ; ;;; rect-mark.el ;; ~/Emacs/Extensions/rect-mark.el ;(require 'rect-mark) ; ;;; dictionary ;;; http://www.myrkr.in-berlin.de/dictionary/index.html ;; ~/Emacs/Extensions/dictionary-init.el ;; ~/Emacs/Extensions/dictionary.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 ; ;;; Other installed packages ;;; 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 ; ;;;