emacs tip: speedbar, iswitch-mode, which-function-mode
글쓴이: cinsk / 작성시간: 금, 2003/10/24 - 10:16오전
Emacs를 잘 쓰시던 분들도 이 세가지 모드를 잘 모르시는 경우가 많은데, 참고가 될까 해서 올립니다. 사용법은 일단 써 보시면 압니다. ^^;
iswitch-mode는 C-x b로 버퍼 전환할 때 편리하며 (버퍼 전환시 향상된 command-completion을 제공함, 기본 completion보다 편함), which-function-mode는 현재 커서가 위치한 곳의 함수 이름을 mini buffer에 보여주며, speedbar는 편리한 navigation을 제공합니다. 각각
M-x iswitch-mode ; (iswitch-mode) M-x which-function-mode ; (which-function-mode) M-x speedbar ; (speedbar)
이며, 주석 처리한 부분은 .emacs에 넣을 때 쓸 수 있습니다. 제 경우는 speedbar를 빼고 나머지 두개는 .emacs에 넣어서 항상 자동으로 실행되게 하고, speedbar는 필요할 때만 씁니다.

Forums:


Re: emacs tip: speedbar, iswitch-mode, which-function-mode
speedbar 의 경우는 상당히 괜찮은 기능인것 같습니다.. ;;
M-x iswitch-mode 는 없는것 같은데요..
M-x iswitchb-mode 가 있군요.. 아마 오타이거나.. 아님 버전이 올라 가면서 다른이름으로 변경된듯 하네요..
emacs .. 처음에는 저도 무지 배워 보고 싶었는데.. Lisp 도 한번 배워 보고 싶었는데.. 이맥스의 그 광범위함에 무너지더군요.. 대신 지금은 vim 을 만족할만한 수준으로 사용하고 있습니다..
실례가 안된다면.. cinsk님의 .emacs 파일을 좀 보고 싶군요.. ;; 처음 이맥스를 접하는 사람에게는 그게 더 좋은 팁이 될것 같다는... 생각이 듭니다..
.
남에게 보여줄 정도로 정리가 된게 아니라서.. ^^[code:1]
남에게 보여줄 정도로 정리가 된게 아니라서.. ^^
;;;; ;;;; Seong-Kook Shin's .emacs initialization file. ;;;; ;;; Set up the keyboard so the delete key on both the regular keyboard ;;; and the keypad delete the character under the cursor and to the right ;;; under X, instead of the default, backspace behavior. ;;; (global-set-key [delete] 'delete-char) ;;; (global-set-key [kp-delete] 'delete-char) ;;; ;;; This sets up the coding mode for linux kernel sources. ;;; (obtained from Documentation/CodingStyle in Linux kernel tree) ;;; (defun linux-c-mode () "C mode with adjusted defaults for use with the Linux kernel." (interactive) (c-mode) (c-set-style "K&R") (setq c-basic-offset 8)) (setq auto-mode-alist (cons '("/linux.*/.*\\.[ch]$" . linux-c-mode) auto-mode-alist)) ;;; ;;; for emacs-20.4, korean ;;; ;;; set input method toggle key to 'Shift-Space' (global-set-key [?\S- ] 'toggle-input-method) (defvar default-korean-keyboard "3") ;;; From Mr. Shin's FAQ ;;; and jay's setup <http://pllab.kaist.ac.kr/~jay> ;;; General korean langauge environment setting (require 'cl) (when enable-multibyte-characters (set-language-environment "Korean") (setq-default file-name-coding-system 'euc-kr) ;; comment out if you use 3 bulsik (setq default-korean-keyboard "3") (setq input-method-verbose-flag nil input-method-highlight-flag nil) ;;;; give highest priority to euc-kr (prefer-coding-system 'iso-2022-7bit) (set-default-coding-systems 'euc-kr) (when window-system (global-set-key "\C-\\" 'undefined)) (add-hook 'quail-inactivate-hook 'delete-quail-completions) (defun delete-quail-completions () (when (get-buffer "*Quail Completions*") (kill-buffer "*Quail Completions*"))) (set-selection-coding-system 'euc-kr) (unless window-system (menu-bar-mode -1) (set-keyboard-coding-system 'nil) (set-terminal-coding-system 'euc-kr)) ;; Hangul Mail setting (setq-default sendmail-coding-system 'euc-kr) ;; For use of `emacs -nw' in Korean terminal emulator (if (and (null window-system) (null noninteractive)) (progn (set-keyboard-coding-system 'euc-kr) (set-terminal-coding-system 'euc-kr))) ;; hangul printing for ps-mule.el (setq-default ps-multibyte-buffer 'non-latin-printer) ;; turn off C-h during input (eval-after-load "quail" '(progn (define-key quail-translation-keymap "\C-h" 'quail-delete-last-char) (define-key quail-translation-keymap "\C-?" 'quail-translation-help)))) ;;; for wheel mouse ;;; ;;; http://www.inria.fr/koala/colas/mouse-wheel-scroll/#gnuemacs ;;; (defun up-slightly () (interactive) (scroll-up 5)) (defun down-slightly () (interactive) (scroll-down 5)) (global-set-key [mouse-4] 'down-slightly) (global-set-key [mouse-5] 'up-slightly) (defun up-one () (interactive) (scroll-up 1)) (defun down-one () (interactive) (scroll-down 1)) (global-set-key [S-mouse-4] 'down-one) (global-set-key [S-mouse-5] 'up-one) (defun up-a-lot () (interactive) (scroll-up)) (defun down-a-lot () (interactive) (scroll-down)) ;(global-set-key [C-mouse-4] 'down-a-lot) ;(global-set-key [C-mouse-5] 'up-a-lot) ;;; ;;; If you want to scroll by half a page instead of only 5 lines as above, ;;; John Rowe sent this GNU Emacs code: ;;; ;;;(defun scroll-up-half () ;;; "Scroll up half a page." ;;; (interactive) ;;; (scroll-up (/ (window-height) 2))) ;;; ;;;(defun scroll-down-half () ;;; "Scroll down half a page." ;;; (interactive) ;;; (scroll-down (/ (window-height) 2))) ;;; ;;;(global-set-key [(mouse-5)] 'scroll-up-half) ;;;(global-set-key [(mouse-4)] 'scroll-down-half) (global-font-lock-mode t) ;;; ;;; If you are intended BS (backspace) key to work ;;; correctly on some terminals, uncomment one of below s-exp. ;;; -- cinsk ;;;(global-set-key [C-?] 'backward-delete-char) ;;;(global-set-key [C-h] 'backward-delete-char); ;;; ;;; Emacs Lisp escape sequence in a string: ;;; <TAB> - `\t' <RET> - `\r' <ESC> - `\e' <DEL> - `\d' ;;; ;;; To use function keys, mouse button, or non-ASCII character such ;;; as `C-=' or `H-a', use a vector(`[..]') to specify the key sequence. ;;; ;;; - If a vector element is a character, use the Lisp character constant, ;;; `?'. e.g. `?\C-=' ;;; - For example, below two statements are the same: ;;; (global-set-key "\C-x\e\e" 'repeat-complex-command) ;;; (global-set-key [?\C-x ?\e ?\e] 'repeat-complex-command) ;;; ;;; Lisp Symbols for the function keys: ;;; `left', `up', `right', `down' ;;; Cursor arrow keys. ;;; ;;; `begin', `end', `home', `next', `prior' ;;; Other cursor repositioning keys. ;;; ;;; `select', `print', `execute', `backtab' ;;; `insert', `undo', `redo', `clearline' ;;; `insertline', `deleteline', `insertchar', `deletechar' ;;; Miscellaneous function keys. ;;; ;;; `f1', `f2', ... `f35' ;;; Numbered function keys (across the top of the keyboard). ;;; ;;; `kp-add', `kp-subtract', `kp-multiply', `kp-divide' ;;; `kp-backtab', `kp-space', `kp-tab', `kp-enter' ;;; `kp-separator', `kp-decimal', `kp-equal' ;;; Keypad keys (to the right of the regular keyboard), with names or ;;; punctuation. ;;; ;;; `kp-0', `kp-1', ... `kp-9' ;;; Keypad keys with digits. ;;; ;;; `kp-f1', `kp-f2', `kp-f3', `kp-f4' ;;; Keypad PF keys. ;;; ;(defun cmd-compile () (interactive) (compile)) ;(global-set-key [C-,] 'cmd-compile) (global-set-key "\C-cc" 'compile) ; M-x compile ;(global-set-key "\C-cs" 'shell) ; M-x shell (global-set-key "\C-cd" 'shell) ; M-x shell (global-set-key [C-tab] 'other-window) ; C-x o (global-set-key [24 C-tab] 'other-frame) ; C-x C-tab is now the ; same as `C-x 5 o' (global-set-key [?\C-.] 'find-tag-other-window) ; C-x o (global-set-key "\C-cl" 'goto-line) ;;; C-x C-v is binded find-alternate-file by default. (global-set-key "\C-x\C-v" 'view-file) ;;;(defun my-c-mode-hook () ;;; (local-set-key "\C-cc" 'compile) ;;; (local-set-key "\C-cs" 'shell)) ;;; ;;;(add-hook 'c-mode-hook 'my-c-mode-hook) (define-abbrev-table 'c-mode-abbrev-table ;; I don't know why `@' for abbreviation doesn't work. ;; So I choose `$' for that. '(("$niy" "/* TODO: Not Implemented Yet. */" nil 0) ("$gpl" "/* * <one line to give the program's name and a brief idea of what it does.> * Copyright (C) <year> <name of author> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */" nil 0) ("$lgpl" "/* <one line to give the library's name and a brief idea of what it does.> * Copyright (C) <year> <name of author> * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the Free * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */" nil 0) ("$igpl" "static const char *gpl_notices[] = { \"PROGRAM-NAME version XXX, Copyright (C) YEAR AUTHOR-NAME\", \"PROGRAM-NAME comes with ABSOLUTELY NO WARRANTY; for details type `show w'.\", \"This is free software, and you are welcome to redistribute it\", \"under certain conditions; type `show c' for details.\", };" nil 0))) (define-abbrev-table 'c++-mode-abbrev-table ;; I don't know why `@' for abbreviation doesn't work. ;; So I choose `$' for that. '(("$niy" "// TODO: Not Implemented Yet." nil 0) ("@niy" "// TODO: Not Implemented Yet." nil 0) ("$cxxchk" "#ifndef __cplusplus #error This is a C++ header file #endif" nil 0) ("$gpl" "/* * <one line to give the program's name and a brief idea of what it does.> * Copyright (C) <year> <name of author> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */" nil 0) ("$lgpl" "/* <one line to give the library's name and a brief idea of what it does.> * Copyright (C) <year> <name of author> * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the Free * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */" nil 0) ("$igpl" "static const char *gpl_notices[] = { \"PROGRAM-NAME version XXX, Copyright (C) YEAR AUTHOR-NAME\", \"PROGRAM-NAME comes with ABSOLUTELY NO WARRANTY; for details type `show w'.\", \"This is free software, and you are welcome to redistribute it\", \"under certain conditions; type `show c' for details.\", };" nil 0))) (add-hook 'c-mode-hook (function (lambda nil (abbrev-mode 1)))) (add-hook 'c++-mode-hook (function (lambda nil (abbrev-mode 1)))) ;;; imenu mode ;;;(add-hook 'c-mode-hook (function (lambda nil (imenu-add-to-menubar)))) ;;;(add-hook 'c++-mode-hook (function (lambda nil (imenu-add-to-menubar)))) ;;; which-function mode ;;;(add-hook 'c-mode-hook (function (lambda nil (which-function-mode)))) ;;;(add-hook 'c++-mode-hook (function (lambda nil (which-function-mode)))) (which-function-mode) ; display function name in mode line (iswitchb-mode) ; smart buffer switching mode (tool-bar-mode -1) ;;(when window-system ;; (setq special-display-buffer-names ;; '("*Completions*" "*grep*" "*Buffer List*"))) ;;; ;;; Indentation can insert tabs if this is non-nil. ;;; (setq-default indent-tabs-mode nil) ;;; ;;; Colors ;;; ;;;(set-background-color "rgb:0000/1500/8000") ;;;(set-foreground-color "white") ;;;(set-cursor-color "") ;;;(set-mouse-color "") ;;;(set-face-foreground 'highlight "white") ;;;(set-face-background 'highlight "slate blue") ;;;(set-face-background 'region "slate blue") ;;;(set-face-background 'secondary-selection "turquoise") ;;; ;;; emacs server ;;; ;;;(load "/usr/share/emacs/21.2/lisp/gnuserv") (server-start) ;;;(load "gnuserv") ;;;(gnuserv-start) ;;; ;;; I prefer case-sensitive search & replace ;;; (setq-default case-fold-search nil) (setq-default tags-case-fold-search nil) (fset 'find-next-tag "\C-u\256") ; macro for C-u M-. (fset 'find-prev-tag "\C-u-\256") ; macro for C-u - M-. (global-set-key "\M-]" 'find-next-tag) (global-set-key "\M-[" 'find-prev-tag) (global-set-key [up] '(lambda () (interactive) (scroll-down 1))) (global-set-key [down] '(lambda () (interactive) (scroll-up 1))) ;;; ;;; psgml mode setup ;;; (autoload 'sgml-mode "psgml" "Major mode to edit SGML files." t) (autoload 'xml-mode "psgml" "Major mode to edit XML files." t) ;;; ;;; cscope binding ;;; ;;; You need to install cscope(1) and xcscope.el to use below bindings ;;; Read xcscope.el packaged in cscope source tarball. It can be obtained ;;; from http://cscope.sourceforge.net/ ;;; (require 'xcscope) (define-key global-map [(control f3)] 'cscope-set-initial-directory) (define-key global-map [(control f4)] 'cscope-unset-initial-directory) (define-key global-map [(control f5)] 'cscope-find-this-symbol) (define-key global-map [(control f6)] 'cscope-find-global-definition) (define-key global-map [(control f7)] 'cscope-find-global-definition-no-prompting) (define-key global-map [(control f8)] 'cscope-pop-mark) (define-key global-map [(control f9)] 'cscope-next-symbol) (define-key global-map [(control f10)] 'cscope-next-file) (define-key global-map [(control f11)] 'cscope-prev-symbol) (define-key global-map [(control f12)] 'cscope-prev-file) (define-key global-map [(meta f9)] 'cscope-display-buffer) (define-key global-map [(meta f10)] 'cscope-display-buffer-toggle) ;;; ;;; custom procedure ;;; (when window-system (setq same-window-buffer-names (append '("*compilation*" "*Process List*") same-window-buffer-names)) (setq special-display-regexps '(("\\*Buffer List\\*" (font . "fixed") (left . 0) ; in pixels (top . -30) (auto-raise . t) (width . 70) (height . 10) ; in characters (vertical-scroll-bars . nil) (tool-bar-lines . nil) (menu-bar-lines . nil)) (("\\*Completions\\*" (font . "fixed") (left . 0) ; in pixels (top . -30) (auto-raise . f) (width . 70) (height . 10) ; in characters (vertical-scroll-bars . nil) (tool-bar-lines . nil) (menu-bar-lines . nil)) ("\\*cscope\\*" (font . "fixed") (left . 0) (top . 0) (auto-raise . t) (width . 80) (height . 20) (vertical-scroll-bars . nil) (tool-bar-lines . nil) (menu-bar-lines . nil)) ("\\*.*\\*" (tool-bar-lines . nil) (menu-bar-lines . nil)) )))) ;;; To save & load Emacs session, following lines should be the last line ;;; in this file. ;;; ;;; The first time you save the state of the Emacs session, you must do it ;;; manually, with the command `M-x desktop-save'. Once you have done that, ;;; exiting Emacs will save the state again--not only the present Emacs ;;; session, but also subsequent sessions. You can also save the state at ;;; any time, without exiting Emacs, by typing `M-x desktop-save' again. ;;; ;;; In order for Emacs to recover the state from a previous session, you ;;; must start it with the same current directory as you used when you ;;; started the previous session. This is because `desktop-read' looks in ;;; the current directory for the file to read. This means that you can have ;;; separate saved sessions in different directories; the directory in which ;;; you start Emacs will control which saved session to use. ;(desktop-load-default) ;(desktop-read) (load "~/.emacs.d/theme")아 그리고 $HOME/.emacs.d/theme.el은 다음과 같습니다:
;;; ;;; Emacs Random Theme Selector ;;; ;;; ;;; If it seems not working, uncomment any setting relative frame parameters ;;; (e.g. emacs*Background, emacs*Foreground, and so on) in your X resource ;;; file (possibly $HOME/.Xdefaults or $HOME/.Xdefaults-$HOSTNAME) ;;; (defvar random-theme-alist '(((foreground-color . "black") (background-color . "khaki") (background-mode . "light")) ((foreground-color . "powder blue") (background-color . "dark slate blue") (background-mode . "dark")) ((foreground-color . "light steel blue") (background-color . "medium blue") (background-mode . "dark")) ((foreground-color . "saddle brown") (background-color . "light goldenrod") (background-mode . "light")) ((foreground-color . "pink") (background-color . "dark violet") (background-mode . "dark")) ((foreground-color . "black") (background-color . "cornflower blue") (background-mode . "light")) ((foreground-color . "black") (background-color . "medium aquamarine") (background-mode . "light")) ((foreground-color . "black") (background-color . "light salmon") (background-mode . "light")) ((foreground-color . "black") (background-color . "medium purple") (background-mode . "light")) ((foreground-color . "black") (background-color . "cornsilk3") (background-mode . "light")) ) "list of theme. Each element of the list is a set of frame parameters") (defun update-alist-elem (lst-sym elem) (if (assoc (car elem) (symbol-value lst-sym)) (set lst-sym (assq-delete-all (car elem) (symbol-value lst-sym)))) (add-to-list lst-sym elem)) (defun update-alist (lst-sym newlst) (dolist (elem newlst) (update-alist-elem lst-sym elem)) (symbol-value lst-sym)) (defun apply-random-theme () (update-alist 'default-frame-alist (nth (random (length random-theme-alist)) random-theme-alist))) (add-hook 'before-make-frame-hook (function apply-random-theme)) ;; ;; uncomment below sentences to apply random theme to the initial X ;; window frame. ;; ;; Bug: I don't know why, but if you uncomment below sentences, the ;; global-font-lock-mode might not work correctly. ;; ;;(random t) ;;(update-alist 'initial-frame-alist (nth (random (length random-theme-alist)) ;; random-theme-alist)) ;;C FAQ: http://www.eskimo.com/~scs/C-faq/top.html
Korean Ver: http://cinsk.github.io/cfaqs/
댓글 달기