The very unofficial .emacs home SteveDodd.emacs
emacs
Sections
home
what is this all about ?
customization basics
special topics
local dotfiles
dotfiles on the web
new and updated pages
useful sites and pages
search locally
EMacro
OS/2 Emacs
Latest Additions
local files:
John J. Glynn
David Jolley

linked files:


articles:


links:
The Emacs wiki
ODP search for Emacs


dmoz.org
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; 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-file-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" "Run VM major mode on a buffer" t)
(autoload 'vm-mail "vm" "Send a mail message using VM." t)
(autoload 'vm-submit-bug-report "vm" "Send a bug report about VM." t)


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; BIG BROTHER DATABASE
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; Doesn't work with my current version of Emacs...
;;
;;(autoload 'bbdb         "bbdb-com" "Insidious Big Brother Database" t)
;;(autoload 'bbdb-name    "bbdb-com" "Insidious Big Brother Database" t)
;;(autoload 'bbdb-company "bbdb-com" "Insidious Big Brother Database" t)
;;(autoload 'bbdb-net     "bbdb-com" "Insidious Big Brother Database" t)
;;(autoload 'bbdb-notes   "bbdb-com" "Insidious Big Brother Database" t)
;;(autoload 'bbdb-insinuate-vm       "bbdb-vm"    "Hook BBDB into VM")
;;(autoload 'bbdb-insinuate-rmail    "bbdb-rmail" "Hook BBDB into RMAIL")
;;(autoload 'bbdb-insinuate-gnus     "bbdb-gnus"  "Hook BBDB into GNUS")
;;(autoload 'bbdb-insinuate-sendmail "bbdb"       "Hook BBDB into sendmail")
;;(setq rmail-mode-hook 'bbdb-insinuate-rmail)
;;(setq gnus-startup-hook 'bbdb-insinuate-gnus)
;;(setq mail-setup-hook 'bbdb-insinuate-sendmail)
;;(setq bbdb/mail-auto-create-p 'bbdb-ignore-some-messages-hook)
;;(setq bbdb-ignore-some-messages-alist 
;;      '(("From" . "qt\\|sdodd\\|mailer.daemon")
;;      ("Sender" . "troll.no\\|qt")))


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; MOUSE SIMPLE SET UP
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;; Paste at point NOT at cursor
(setq mouse-yank-at-point 't)

;; Scroll Bar gets dragged by mouse butn 1
(global-set-key [vertical-scroll-bar down-mouse-1] 'scroll-bar-drag)

;;
;; Rebind mouse-2 events to mouse-1 in various places:
;; Completion list
(add-hook 'completion-list-mode-hook
  '(lambda() (define-key completion-list-mode-map [down-mouse-1] 
               'mouse-choose-completion)))
;; TexInfo
(add-hook 'Info-mode-hook
  '(lambda() (define-key Info-mode-map [down-mouse-1] 
               'Info-mouse-follow-nearest-node)))
;; Buffer Menu
(add-hook 'buffer-menu-mode-hook
  '(lambda() (define-key Buffer-menu-mode-map [down-mouse-1] 
               'Buffer-menu-mouse-select)))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; INTELLIMOUSE SETUP
;; . Wheel forward/backwards scrolls by 10 lines
;; . Shift + wheel forward/backwards scrolls by 1 line
;;   (change mwheel-scroll-amount to change these defaults).
;; . Bind control + wheel scroll to undo
;; . Set wheel action focus to follow mouse pointer NOT cursor. (Change 
;;   mwheel-follow-mouse to "nil" to get wheel to only act on the window
;;   containing the text cursor.
;;
;; * Please see the copyright notice below for original copyright stuff.
;;   I have made a few small changes to the code, such as the undo binding to
;;   the wheel, contact me at sdodd@udnergrad.math.uwaterloo.ca for the
;;   original code, or the maintainer below.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; mwheel.el --- Mouse support for MS intelli-mouse type mice
;; Copyright (C) 1998, Free Software Foundation, Inc.
;; Maintainer: William M. Perry <wmperry@cs.indiana.edu>
;; Keywords: mouse
;; This file is part of XEmacs.
;; XEmacs 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, or (at your option)
;; any later version.
;; XEmacs 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 XEmacs; see the file COPYING.  If not, write to the 
;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
;; Boston, MA 02111-1307, USA.
;; Synched up with: Not synched.
;; Commentary:
;; Code:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(require 'custom)
(require 'cl)
(defconst mwheel-running-xemacs (string-match "XEmacs" (emacs-version)))
(defcustom mwheel-scroll-amount '(10 . 1)
  "Amount to scroll windows by when spinning the mouse wheel.
This is actually a cons cell, where the first item is the amount to scroll
on a normal wheel event, and the second is the amount to scroll when the
wheel is moved with the shift key depressed.
This should be the number of lines to scroll, or `nil' for near
full screen.
A near full screen is `next-screen-context-lines' less than a full screen."
  :group 'mouse
  :type '(cons
          (choice :tag "Normal"
                  (const :tag "Full screen" :value nil)
                  (integer :tag "Specific # of lines"))
          (choice :tag "Shifted"
                  (const :tag "Full screen" :value nil)
                  (integer :tag "Specific # of lines"))))

;; Change to nil to only scroll the window the cursor is in (not the pointer)
(defcustom mwheel-follow-mouse 1
  "Whether the mouse wheel should scroll the window that the mouse is over.
This can be slightly disconcerting, but some people may prefer it."
  :group 'mouse
  :type 'boolean)

(if (not (fboundp 'event-button))
    (defun mwheel-event-button (event)
      (let ((x (symbol-name (event-basic-type event))))
        (if (not (string-match "^mouse-\\([0-9]+\\)" x))
            (error "Not a button event: %S" event))
        (string-to-int (substring x (match-beginning 1) (match-end 1)))))
  (fset 'mwheel-event-button 'event-button))

(if (not (fboundp 'event-window))
    (defun mwheel-event-window (event)
      (posn-window (event-start event)))
  (fset 'mwheel-event-window 'event-window))

(defun mwheel-scroll (event)
  (interactive "e")
  (let ((curwin (if mwheel-follow-mouse
                    (prog1
                        (selected-window)
                      (select-window (mwheel-event-window event)))))
        (amt (if (memq 'shift (event-modifiers event))
                 (cdr mwheel-scroll-amount)
               (car mwheel-scroll-amount))))
    (case (mwheel-event-button event)
      (4 (scroll-down amt))
      (5 (scroll-up amt))
      (otherwise (error "Bad binding in mwheel-scroll")))
    (if curwin (select-window curwin))))

(defun mwheel-undo (event)
  (interactive "e")
  (let ((curwin (if mwheel-follow-mouse
                    (prog1
                        (selected-window)
                      (select-window (mwheel-event-window event)))))
        )
    (case (mwheel-event-button event)
      (4 (undo))
      (5 (undo))
      (otherwise (error "Bad binding in mwheel-scroll")))
    (if curwin (select-window curwin))))

(define-key global-map 
  (if mwheel-running-xemacs 'button4 [mouse-4]) 'mwheel-scroll)
(define-key global-map 
  (if mwheel-running-xemacs 'button5 [mouse-5])  'mwheel-scroll)
(define-key global-map 
  (if mwheel-running-xemacs [(shift button4)] [S-mouse-4]) 'mwheel-scroll)
(define-key global-map 
  (if mwheel-running-xemacs [(shift button5)] [S-mouse-5]) 'mwheel-scroll)
(define-key global-map 
  (if mwheel-running-xemacs [(control button4)] [C-mouse-4]) 'mwheel-undo)
(define-key global-map 
  (if mwheel-running-xemacs [(control button5)] [C-mouse-5]) 'mwheel-undo)
(provide 'mwheel)


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; NEW FANGLED STYLE CUT 'N PASTE FUNCTIONS
;; (and other nice keyboard fixes)
;;
;; Defining the Region:
;;
;; . Shift + Cursor movement allows you to define a region
;; . Cursor movement (without Shift) clears the mark (unhighlights the region)
;; . Mouse down 1 + drag allows you to define the region (as in standard emacs)
;; . Mouse down 1 (dbl click) selects the current word (as in standard emacs)
;; * Mouse down 1 (trpl click) doesn't work well with this simplistic package.
;;   The problem is that it will copy the dbl click result into the temp
;;   variable which stores the old x selection; thus if you then insert into
;;   the region (i.e. with Shift+Insert, or mouse2) you would just replace the
;;   whole line with the word you dbl clicked on...
;;   You can still use this function, you just can't use it to define a region
;;   to insert over.
;; . Mouse 3 sets the mark as usual
;; 
;;  
;; Once the region is defined:
;;
;; . If you defined the region with the mouse, then the old x selection is
;;   kept in a temp variable; if you hit mouse down 2, then the temp variable
;;   will replace the region you defined.
;;   So, you can select one word with the mouse, then select another word,
;;   press butn 2 and the first word will replace the second!
;; . Delete deletes the region
;; . Shift + Delete kills the region
;; . Ctrl + Delete copies the region into the kill ring
;; . Shift + Insert deletes the region, then yanks the old x selection (if
;;   there was one), or yanks the top off of the kill ring.
;; . Typing any other key (i.e. a self-insert-command key) will delete the 
;;   region, then insert themselves, thus in effect replacing the region with
;;   the char you typed.
;; 
;; General Cursor Movement Changes:
;;
;; . Home = beginning of line
;; . Ctrl + Home = beginning of buffer
;; . End, Ctrl + End are similar
;; . Pageup/Pagedown are slightly changed: in default emacs if you try to page
;;   at either end of the buffer you will get an End of buffer message; this
;;   is changed so that the point is actually moved to the beginning/end of 
;;   the buffer.
;; . All of the above understand the "Shift +" idea to extend the mark,
;;   i.e. Ctrl + Shift + End sets the mark at the end of the buffer.
;;
;; Steve Dodd
;; March 1998
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;
;; Use this as a shell around self-insert-command; this function checks if a
;; region is currently defined -- if it is, the region is replaced with the
;; key you pressed to invoke the function.
;; 

(defun s-self-insert-command ()
  (interactive)
  (if mark-active (kill-region (point) (mark)) ())
  (self-insert-command 1))

;;
;; Simple cursor movement functions
;;

(defun s-shift-forward-char ()
  (interactive)
  (if (not mark-active) (set-mark-command nil) ())
  (forward-char))
(defun s-forward-char ()
  (interactive)
  (if mark-active (set-mark nil) ())
  (forward-char))

(defun s-shift-backward-char ()
  (interactive)
  (if (not mark-active) (set-mark-command nil) ())
  (backward-char))
(defun s-backward-char ()
  (interactive)
  (if mark-active (set-mark nil) ())
  (backward-char))

(defun s-shift-previous-line1 ()
  (interactive)
  (if (not mark-active) (set-mark-command nil) ())
  (previous-line 1))
(defun s-previous-line1 ()
  (interactive)
  (if mark-active (set-mark nil) ())
  (previous-line 1))

(defun s-shift-next-line1 ()
  (interactive)
  (if (not mark-active) (set-mark-command nil) ())
  (next-line 1))
(defun s-next-line1 ()
  (interactive)
  (if mark-active (set-mark nil) ())
  (next-line 1))

;;
;; End, and Home functions
;;

(defun s-shift-end-of-line ()
  (interactive)
  (if (not mark-active) (set-mark-command nil) ())
  (end-of-line))
(defun s-shift-ctrl-end-of-buffer ()
  (interactive)
  (if (not mark-active) (set-mark-command nil) (message "hi"))
  (goto-char (point-max)))
(defun s-end-of-line ()
  (interactive)
  (if mark-active (set-mark nil) ())
  (end-of-line))

(defun s-shift-beginning-of-line ()
  (interactive)
  (if (not mark-active) (set-mark-command nil) ())
  (beginning-of-line))
(defun s-shift-ctrl-beginning-of-buffer ()
  (interactive)
  (if (not mark-active) (set-mark-command nil) ())
  (goto-char (point-min)))
(defun s-beginning-of-line ()
  (interactive)
  (if mark-active (set-mark nil) ())
  (beginning-of-line))

;;
;; Pageup/Pagedown functions
;;

(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-and-exit)
(global-set-key "\C-xb" 's-switch-to-buffer)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; END OF BUFFER SWITCHING FIX
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


All content copyright by the contributors. Website maintained with Emacs , wsmake and html-helper-mode
Emacs community logo by Daniel Lundin Last updated on Sat Jan 22 14:49:24 2005 by Ingo Koch