BBS水木清华站∶精华区

发信人: yanglc (魂归燕园), 信区: Linux        
标  题: Steve's .emacs                         pure  
发信站: BBS 水木清华站 (Sat May 13 20:02:21 2000) 
 
发信人: pure (青衣~ Shadow in silence), 信区: FreeBSD        
标  题: Steve's .emacs 
发信站: BBS 水木清华站 (Sat Apr 17 15:55:44 1999) 
 
Steve's .emacs 
January 27th 1999, 01:49:00 PM 
Included in this .emacs are a couple of useful functions apart from simple  
key rebindings:  
 
1. Support for wheel mice (mouse buttons 4 & 5 under X),  
to scroll windows, do really fast undo/redo, etc...  
 
2. Buffer switch fix. The default completion list includes the name of the  
buffer you're in. This is very annoying if you're editing prog.c, and prog.h  
since you have to type either c, or h to switch between these files. This fix 
removes the current buffer name from the completion list.  
 
3. Microsoft style highlighting. Hold down shift and move the cursor  
around to define a region. Defining a region then pasting text (via emacs  
kill ring, or X cut buffer) will replace the region, among other functions.  
Each of these is documented in the file itself. 
 
 
 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 
;; Emacs customizations 
;; 
;; To use this: 
;;  - byte compile this file into .emacs-source.elc 
;;    i.e. go into the Emacs-Lisp menu and select "Byte Compile This File" 
;;  - in your .emacs file put the line 
;;      (load-file "~/.emacs-source.elc") 
;;    to load the byte compiled version of this.  This reduces Emacs' start 
;;    up time. 
;; 
;; Steve Dodd 
;; March 1998 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 
 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 
;; ASSORTED GLOBAL KEY BINDINGS 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 
 
;; Make control+pageup/down scroll the other buffer 
(global-set-key [C-next] 'scroll-other-window) 
(global-set-key [C-prior] 'scroll-other-window-down) 
 
;; Rebind C-z to start a shell (use .emacs_shellname for the shells rc file) 
(global-set-key "\C-z" 'shell) 
 
;; This binds word completions to Shift-Tab, and Ctrl+Space 
(global-set-key [S-iso-lefttab] 'dabbrev-completion) 
(global-unset-key [?\C-\040]) 
(global-set-key [?\C-\040] 'dabbrev-completion) 
 
;; Set up some f-key shortcuts 
(global-set-key [f1]    'help) 
(global-set-key [S-f1]  'man) 
(global-set-key [f2]    'save-buffer) 
(global-set-key [f3]    'find-file) 
(global-set-key [f4]    'kill-buffer) 
 
(global-set-key [f5]    'compile) 
(global-set-key [f6]    'first-error) 
(global-set-key [f7]    'previous-error) 
(global-set-key [f8]    'next-error) 
 
(global-set-key [f9]    'new-frame) 
(global-set-key [S-f9]  'delete-frame) 
(global-set-key [f10]   'split-window-vertically) 
(global-set-key [S-f10] 'delete-other-windows) 
(global-set-key [f11]   'undo) 
(global-set-key [f12]   'other-window) 
(global-set-key [S-f12] 'delete-window) 
 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 
;; GENERAL STUFF 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 
 
;; Set email address 
(setq user-mail-address "sdodd@undergrad.math.uwaterloo.ca"); 
;;(setq sendmail-program "/usr/sbin/sendmail -i -t -fsdodd@undergrad.uwaterloo 
.ca") 
(setq sendmail-program "/usr/sbin/sendmail") 
 
;; Set extensions 
(setq tex-dvi-view-command "xdvi") 
(setq compile-command "make") 
 
;; Show mark'ed text 
(setq transient-mark-mode '1) 
 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 
;; DIRED MODE 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 
(add-hook 'dired-mode-hook 
          '(lambda() 
             (define-key dired-mode-map [delete] 'dired-flag-file-deletion) 
             (define-key dired-mode-map [return] 'dired-find-file-other-window 

             (define-key dired-mode-map [C-down-mouse-1] 'dired-mouse-find-fil 
e-other-window))) 
 
 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 
;; GNUS 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 
(setq gnus-select-method '(nnspool "")) 
(setq nnspool-inews-switches '("-h")) 
 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 
;; VM 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 
(setq load-path (append load-path '("/usr/share/emacs/site-lisp/vm"))) 
 
(autoload 'vm "vm" "Start VM on your primary inbox." t) 
(autoload 'vm-other-frame "vm" "Like `vm' but starts in another frame." t) 
(autoload 'vm-visit-folder "vm" "Start VM on an arbitrary folder." t) 
(autoload 'vm-visit-virtual-folder "vm" "Visit a VM virtual folder." t) 
(autoload 'vm-mode "vm" "Ru;; 
 
(defun s-shift-scroll-up () 
  (interactive) 
  (if (not mark-active) (set-mark-command nil) ()) 
  (if (condition-case nil 
      (scroll-up) 
      (error 't)) (goto-char (point-max)) ())) 
(defun s-scroll-up () 
  (interactive) 
  (if mark-active (set-mark nil) ()) 
  (if (condition-case nil 
      (scroll-up) 
      (error 't)) (goto-char (point-max)) ())) 
 
(defun s-shift-scroll-down () 
  (interactive) 
  (if (not mark-active) (set-mark-command nil) ()) 
  (if (condition-case nil 
      (scroll-down) 
      (error 't)) (goto-char (point-min)) ())) 
(defun s-scroll-down () 
  (interactive) 
  (if mark-active (set-mark nil) ()) 
  (if (condition-case nil 
      (scroll-down) 
      (error 't)) (goto-char (point-min)) ())) 
 
;; 
;; Cut and paste functions 
;; 
 
(defun s-shift-delete () 
  (interactive) 
  (if mark-active (kill-region (point) (mark)) (kill-line)) 
  (setq s-prev-selection nil)) 
(defun s-ctrl-delete () 
  (interactive) 
  (if mark-active (copy-region-as-kill (point) (mark)) ()) 
  (setq s-prev-selection nil)) 
(defun s-delete () 
  (interactive) 
  (if mark-active (progn 
                    (delete-region (point) (mark)) 
                     (if s-prev-selection 
                         (x-set-selection 'PRIMARY s-prev-selection) ()) 
                     (setq s-prev-selection nil)) 
    (delete-char 1))) 
 
(defun s-mouse-drag-region (event) 
  (interactive "e") 
  (condition-case nil 
          (setq s-prev-selection (x-get-selection)) 
        (error 't)) 
  (mouse-drag-region event)) 
 
(defun s-mouse-yank-at-click () 
  (interactive) 
  (if mark-active (progn (delete-region (point) (mark)) 
                         (if s-prev-selection 
                             (x-set-selection 'PRIMARY s-prev-selection) ())) 
    ()) 
  (mouse-yank-at-click nil nil)) 
 
; This is where we store the old X cutbuffer contents in case the user doesn't 
; want the highlighted region on the cutbuffer. 
(setq s-prev-selection nil) 
 
;; 
;; MS Style Keybindings 
;; 
 
(substitute-key-definition 'self-insert-command 's-self-insert-command 
                           global-map) 
(substitute-key-definition 'mouse-yank-at-click 's-mouse-yank-at-click 
                           global-map) 
(define-key global-map [S-right] 's-shift-forward-char) 
(define-key global-map [right] 's-forward-char) 
(define-key global-map [S-left] 's-shift-backward-char) 
(define-key global-map [up] 's-backward-char) 
(define-key global-map [S-up] 's-shift-previous-line1) 
(define-key global-map [up] 's-previous-line1) 
(define-key global-map [S-down] 's-shift-next-line1) 
(define-key global-map [down] 's-next-line1) 
(define-key global-map [end] 's-end-of-line) 
(define-key global-map [S-end] 's-shift-end-of-line) 
(define-key global-map [C-end] 'end-of-buffer) 
(define-key global-map [C-S-end] 's-shift-ctrl-end-of-buffer) 
(define-key global-map [home] 's-beginning-of-line) 
(define-key global-map [S-home] 's-shift-beginning-of-line) 
(define-key global-map [C-home] 'beginning-of-buffer) 
(define-key global-map [C-S-home] 's-shift-ctrl-beginning-of-buffer) 
(define-key global-map [next] 's-scroll-up) 
(define-key global-map [S-next] 's-shift-scroll-up) 
(define-key global-map [prior] 's-scroll-down) 
(define-key global-map [S-prior] 's-shift-scroll-down) 
(define-key global-map [down-mouse-1] 's-mouse-drag-region) 
(define-key global-map [S-delete] 's-shift-delete) 
(define-key global-map [C-S-delete] 's-shift-delete) 
(define-key global-map [delete] 's-delete) 
(define-key global-map [C-delete] 's-ctrl-delete) 
(define-key global-map [S-insert] 's-mouse-yank-at-click) 
 
 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 
;; End of Cut 'n Paste Functions 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 
 
 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 
;; BUFFER SWITCHING FIX 
;; 
;; This changes the behaviour of the switch-to-buffer completion functions so 
;; that the current buffer is NOT in the completion list. 
;; 
;; i.e. say you're working in "temp.c", and you want to visit "temp.h"; so you 
;; type "C-xb", then "t<TAB>" which then presents you with a completion list  
of 
;; temp.c and temp.h, so you then must type "h<RET>".  This is annoying since 
;; why would you want to switch back to the buffer you're in?!? 
;; Using this fix would remove "temp.c" from the completion lits so that when 
;; you had typed "t<TAB>" the name would be completed as "temp.h" as desired. 
;; 
;; Steve Dodd 
;; March 1998 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 
 
(defun s-minibuffer-complete () 
  "A shell around minibuffer-complete which removes the name of the current  
buffer from the buffer completion list.  The default behaviour doesn't make  
sense since there is no reason to ask to switch to the buffer you are already  
in!" 
  (interactive) 
  (if s-remove-first-completion 
      (progn (setq s-remove-first-completion nil) 
             (if (consp minibuffer-completion-table) 
                 (setq  minibuffer-completion-table 
                        (cdr minibuffer-completion-table)) ())) 
    ()) 
  (minibuffer-complete)) 
 
(defun s-minibuffer-complete-word () 
  "A shell around minibuffer-complete-word which removes the name of the  
current buffer from the buffer completion list.  The default behaviour  
doesn't make sense since there is no reason to ask to switch to the buffer  
you are already in!" 
  (interactive) 
  (if s-remove-first-completion 
      (progn (setq s-remove-first-completion nil) 
             (if (consp minibuffer-completion-table) 
                 (setq  minibuffer-completion-table 
                        (cdr minibuffer-completion-table)) ())) 
    ()) 
  (minibuffer-complete-word) 

 
(defun s-minibuffer-complete-and-exit () 
  "A shell around minibuffer-complete-and-exit which removes the name of the  
current buffer from the buffer completion list.  The default behaviour  
doesn't make sense since there is no reason to ask to switch to the buffer  
you are already in!" 
  (interactive) 
  (if s-remove-first-completion 
      (progn (setq s-remove-first-completion nil) 
             (if (consp minibuffer-completion-table) 
                 (setq  minibuffer-completion-table 
                        (cdr minibuffer-completion-table)) ())) 
    ()) 
  (minibuffer-complete-and-exit)) 
 
 
(defun s-switch-to-buffer () 
  "A shell around switch-to-buffer which removes the name of the current  
buffer from the buffer completion list.  The default behaviour doesn't make  
sense since there is no reason to ask to switch to the buffer you are already  
in!" 
  (interactive) 
  (setq s-remove-first-completion 't) 
  (switch-to-buffer (read-buffer "Switch to buffer: " (other-buffer)))) 
 
(setq s-remove-first-completion 'nil) 
 
(define-key minibuffer-local-completion-map "\040" 's-minibuffer-word) 
(define-key minibuffer-local-completion-map "\t" 's-minibuffer-complete) 
(define-key minibuffer-local-must-match-map [return] 's-minibuffer-complete-an 
d-exit) 
(global-set-key "\C-xb" 's-switch-to-buffer) 
 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 
;; END OF BUFFER SWITCHING FIX 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 
 
 
-- 
看着她笑,他忽然觉得她好寂寞好寂寞。 
她静静的看了他半天,才柔柔慢慢的:「 你好像已经找到了。」 
 
※ 来源:·BBS 水木清华站 bbs.net.tsinghua.edu.cn·[FROM: 210.78.132.48] 

BBS水木清华站∶精华区