changeset 105994:009383a57ce8

* x-dnd.el (x-dnd-maybe-call-test-function): * window.el (split-window-vertically): * whitespace.el (whitespace-help-on): * vc-rcs.el (vc-rcs-consult-headers): * userlock.el (ask-user-about-lock-help) (ask-user-about-supersession-help): * type-break.el (type-break-force-mode-line-update): * time-stamp.el (time-stamp-conv-warn): * terminal.el (te-set-output-log, te-more-break, te-filter) (te-sentinel,terminal-emulator): * term.el (make-term, term-exec, term-sentinel, term-read-input-ring) (term-write-input-ring, term-check-source, term-start-output-log): (term-display-buffer-line, term-dynamic-list-completions): (term-ansi-make-term, serial-term): * subr.el (selective-display): * strokes.el (strokes-xpm-to-compressed-string, strokes-decode-buffer) (strokes-encode-buffer, strokes-xpm-for-compressed-string): * speedbar.el (speedbar-buffers-tail-notes, speedbar-buffers-item-info) (speedbar-reconfigure-keymaps, speedbar-add-localized-speedbar-support) (speedbar-remove-localized-speedbar-support) (speedbar-set-mode-line-format, speedbar-create-tag-hierarchy) (speedbar-update-special-contents, speedbar-buffer-buttons-engine) (speedbar-buffers-line-directory): * simple.el (shell-command-on-region, append-to-buffer) (prepend-to-buffer): * shadowfile.el (shadow-save-todo-file): * scroll-bar.el (scroll-bar-set-window-start, scroll-bar-drag-1) (scroll-bar-maybe-set-window-start): * sb-image.el (speedbar-image-dump): * saveplace.el (save-place-alist-to-file, save-places-to-alist) (load-save-place-alist-from-file): * ps-samp.el (ps-print-message-from-summary): * ps-print.el (ps-flush-output, ps-insert-file, ps-get-boundingbox) (ps-background-image, ps-begin-job, ps-do-despool): * ps-bdf.el (bdf-find-file, bdf-read-font-info): * printing.el (pr-interface, pr-ps-file-print, pr-find-buffer-visiting) (pr-ps-message-from-summary, pr-lpr-message-from-summary): (pr-call-process, pr-file-list, pr-interface-save): * novice.el (disabled-command-function) (enable-command, disable-command): * mouse.el (mouse-buffer-menu-alist): * mouse-copy.el (mouse-kill-preserving-secondary): * macros.el (kbd-macro-query): * ledit.el (ledit-go-to-lisp, ledit-go-to-liszt): * informat.el (batch-info-validate): * ido.el (ido-copy-current-word, ido-initiate-auto-merge): * hippie-exp.el (try-expand-dabbrev-visible): * help-mode.el (help-make-xrefs): * help-fns.el (describe-variable): * generic-x.el (bat-generic-mode-run-as-comint): * finder.el (finder-mouse-select): * find-dired.el (find-dired-sentinel): * filesets.el (filesets-file-close): * files.el (list-directory): * faces.el (list-faces-display, describe-face): * facemenu.el (list-colors-display): * ezimage.el (ezimage-image-association-dump, ezimage-image-dump): * epg.el (epg--process-filter, epg-cancel): * epa.el (epa--marked-keys, epa--select-keys, epa-display-info) (epa--read-signature-type): * emerge.el (emerge-copy-as-kill-A, emerge-copy-as-kill-B) (emerge-file-names): * ehelp.el (electric-helpify): * ediff.el (ediff-regions-wordwise, ediff-regions-linewise): * ediff-vers.el (rcs-ediff-view-revision): * ediff-util.el (ediff-setup): * ediff-mult.el (ediff-append-custom-diff): * ediff-diff.el (ediff-exec-process, ediff-process-sentinel) (ediff-wordify): * echistory.el (Electric-command-history-redo-expression): * dos-w32.el (find-file-not-found-set-buffer-file-coding-system): * disp-table.el (describe-display-table): * dired.el (dired-find-buffer-nocreate): * dired-aux.el (dired-rename-subdir, dired-dwim-target-directory): * dabbrev.el (dabbrev--same-major-mode-p): * chistory.el (list-command-history): * apropos.el (apropos-documentation): * allout.el (allout-obtain-passphrase): (allout-copy-exposed-to-buffer): (allout-verify-passphrase): Use with-current-buffer.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Fri, 13 Nov 2009 22:19:45 +0000
parents 505670342624
children d90116e2656a
files lisp/ChangeLog lisp/allout.el lisp/apropos.el lisp/chistory.el lisp/dabbrev.el lisp/dired-aux.el lisp/dired.el lisp/disp-table.el lisp/dos-w32.el lisp/echistory.el lisp/ediff-diff.el lisp/ediff-mult.el lisp/ediff-util.el lisp/ediff-vers.el lisp/ediff.el lisp/ehelp.el lisp/emerge.el lisp/epa.el lisp/epg.el lisp/ezimage.el lisp/facemenu.el lisp/faces.el lisp/files.el lisp/filesets.el lisp/find-dired.el lisp/finder.el lisp/generic-x.el lisp/help-fns.el lisp/help-mode.el lisp/hippie-exp.el lisp/ido.el lisp/informat.el lisp/ledit.el lisp/macros.el lisp/menu-bar.el lisp/mouse-copy.el lisp/mouse.el lisp/novice.el lisp/printing.el lisp/ps-bdf.el lisp/ps-print.el lisp/ps-samp.el lisp/saveplace.el lisp/sb-image.el lisp/scroll-bar.el lisp/shadowfile.el lisp/simple.el lisp/speedbar.el lisp/strokes.el lisp/term.el lisp/terminal.el lisp/time-stamp.el lisp/type-break.el lisp/userlock.el lisp/vc-rcs.el lisp/whitespace.el lisp/window.el lisp/x-dnd.el
diffstat 58 files changed, 348 insertions(+), 401 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/ChangeLog	Fri Nov 13 17:03:30 2009 +0000
+++ b/lisp/ChangeLog	Fri Nov 13 22:19:45 2009 +0000
@@ -1,12 +1,94 @@
+2009-11-13  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* x-dnd.el (x-dnd-maybe-call-test-function):
+	* window.el (split-window-vertically):
+	* whitespace.el (whitespace-help-on):
+	* vc-rcs.el (vc-rcs-consult-headers):
+	* userlock.el (ask-user-about-lock-help)
+	(ask-user-about-supersession-help):
+	* type-break.el (type-break-force-mode-line-update):
+	* time-stamp.el (time-stamp-conv-warn):
+	* terminal.el (te-set-output-log, te-more-break, te-filter)
+	(te-sentinel,terminal-emulator):
+	* term.el (make-term, term-exec, term-sentinel, term-read-input-ring)
+	(term-write-input-ring, term-check-source, term-start-output-log):
+	(term-display-buffer-line, term-dynamic-list-completions):
+	(term-ansi-make-term, serial-term):
+	* subr.el (selective-display):
+	* strokes.el (strokes-xpm-to-compressed-string, strokes-decode-buffer)
+	(strokes-encode-buffer, strokes-xpm-for-compressed-string):
+	* speedbar.el (speedbar-buffers-tail-notes, speedbar-buffers-item-info)
+	(speedbar-reconfigure-keymaps, speedbar-add-localized-speedbar-support)
+	(speedbar-remove-localized-speedbar-support)
+	(speedbar-set-mode-line-format, speedbar-create-tag-hierarchy)
+	(speedbar-update-special-contents, speedbar-buffer-buttons-engine)
+	(speedbar-buffers-line-directory):
+	* simple.el (shell-command-on-region, append-to-buffer)
+	(prepend-to-buffer):
+	* shadowfile.el (shadow-save-todo-file):
+	* scroll-bar.el (scroll-bar-set-window-start, scroll-bar-drag-1)
+	(scroll-bar-maybe-set-window-start):
+	* sb-image.el (speedbar-image-dump):
+	* saveplace.el (save-place-alist-to-file, save-places-to-alist)
+	(load-save-place-alist-from-file):
+	* ps-samp.el (ps-print-message-from-summary):
+	* ps-print.el (ps-flush-output, ps-insert-file, ps-get-boundingbox)
+	(ps-background-image, ps-begin-job, ps-do-despool):
+	* ps-bdf.el (bdf-find-file, bdf-read-font-info):
+	* printing.el (pr-interface, pr-ps-file-print, pr-find-buffer-visiting)
+	(pr-ps-message-from-summary, pr-lpr-message-from-summary):
+	(pr-call-process, pr-file-list, pr-interface-save):
+	* novice.el (disabled-command-function)
+	(enable-command, disable-command):
+	* mouse.el (mouse-buffer-menu-alist):
+	* mouse-copy.el (mouse-kill-preserving-secondary):
+	* macros.el (kbd-macro-query):
+	* ledit.el (ledit-go-to-lisp, ledit-go-to-liszt):
+	* informat.el (batch-info-validate):
+	* ido.el (ido-copy-current-word, ido-initiate-auto-merge):
+	* hippie-exp.el (try-expand-dabbrev-visible):
+	* help-mode.el (help-make-xrefs):
+	* help-fns.el (describe-variable):
+	* generic-x.el (bat-generic-mode-run-as-comint):
+	* finder.el (finder-mouse-select):
+	* find-dired.el (find-dired-sentinel):
+	* filesets.el (filesets-file-close):
+	* files.el (list-directory):
+	* faces.el (list-faces-display, describe-face):
+	* facemenu.el (list-colors-display):
+	* ezimage.el (ezimage-image-association-dump, ezimage-image-dump):
+	* epg.el (epg--process-filter, epg-cancel):
+	* epa.el (epa--marked-keys, epa--select-keys, epa-display-info)
+	(epa--read-signature-type):
+	* emerge.el (emerge-copy-as-kill-A, emerge-copy-as-kill-B)
+	(emerge-file-names):
+	* ehelp.el (electric-helpify):
+	* ediff.el (ediff-regions-wordwise, ediff-regions-linewise):
+	* ediff-vers.el (rcs-ediff-view-revision):
+	* ediff-util.el (ediff-setup):
+	* ediff-mult.el (ediff-append-custom-diff):
+	* ediff-diff.el (ediff-exec-process, ediff-process-sentinel)
+	(ediff-wordify):
+	* echistory.el (Electric-command-history-redo-expression):
+	* dos-w32.el (find-file-not-found-set-buffer-file-coding-system):
+	* disp-table.el (describe-display-table):
+	* dired.el (dired-find-buffer-nocreate):
+	* dired-aux.el (dired-rename-subdir, dired-dwim-target-directory):
+	* dabbrev.el (dabbrev--same-major-mode-p):
+	* chistory.el (list-command-history):
+	* apropos.el (apropos-documentation):
+	* allout.el (allout-obtain-passphrase):
+	(allout-copy-exposed-to-buffer):
+	(allout-verify-passphrase): Use with-current-buffer.
+
 2009-11-13  Glenn Morris  <rgm@gnu.org>
 
 	* Makefile.in (ELCFILES): Regenerate.
 
 2009-11-13  Michael Albinus  <michael.albinus@gmx.de>
 
-	* net/dbus.el (dbus-registered-objects-table): Renamed from
-	`dbus-registered-functions-table', because it contains also
-	properties.
+	* net/dbus.el (dbus-registered-objects-table): Rename from
+	`dbus-registered-functions-table', because it contains also properties.
 	(dbus-unregister-object): Unregister also properties.
 	(dbus-get-property, dbus-set-property, dbus-get-all-properties):
 	Use a timeout of 500 msec, in order to not block.
@@ -448,8 +530,8 @@
 	* custom.el (custom-declare-group): Purecopy standard-value.
 	(custom-declare-group): Purecopy custom-prefix.
 
-	* international/mule.el (load-with-code-conversion): Call
-	do-after-load-evaluation unconditionally.
+	* international/mule.el (load-with-code-conversion):
+	Call do-after-load-evaluation unconditionally.
 
 	* emacs-lisp/bytecomp.el (byte-compile-output-file-form): Handle defvaralias.
 
--- a/lisp/allout.el	Fri Nov 13 17:03:30 2009 +0000
+++ b/lisp/allout.el	Fri Nov 13 22:19:45 2009 +0000
@@ -5605,7 +5605,7 @@
 				   (goto-char beg)
 				   (allout-topic-flat-index))
 			   '(1))))
-    (save-excursion (set-buffer tobuf)(erase-buffer))
+    (with-current-buffer tobuf (erase-buffer))
     (allout-process-exposed 'allout-insert-listified
 			     beg
 			     end
@@ -6283,8 +6283,7 @@
 
     ;; Symmetric hereon:
 
-    (save-excursion
-      (set-buffer allout-buffer)
+    (with-current-buffer allout-buffer
       (let* ((hint (if (and (not (string= allout-passphrase-hint-string ""))
                             (or (equal allout-passphrase-hint-handling 'always)
                                 (and (equal allout-passphrase-hint-handling
@@ -6481,8 +6480,7 @@
   "True if passphrase successfully decrypts verifier, nil otherwise.
 
 \"Otherwise\" includes absence of passphrase verifier."
-  (save-excursion
-    (set-buffer allout-buffer)
+  (with-current-buffer allout-buffer
     (and (boundp 'allout-passphrase-verifier-string)
          allout-passphrase-verifier-string
          (allout-encrypt-string (allout-get-encryption-passphrase-verifier)
--- a/lisp/apropos.el	Fri Nov 13 17:03:30 2009 +0000
+++ b/lisp/apropos.el	Fri Nov 13 22:19:45 2009 +0000
@@ -736,8 +736,7 @@
 	(apropos-sort-by-scores apropos-documentation-sort-by-scores)
 	f v sf sv)
     (unwind-protect
-	(save-excursion
-	  (set-buffer standard-input)
+	(with-current-buffer standard-input
 	  (apropos-documentation-check-doc-file)
 	  (if do-all
 	      (mapatoms
--- a/lisp/chistory.el	Fri Nov 13 17:03:30 2009 +0000
+++ b/lisp/chistory.el	Fri Nov 13 22:19:45 2009 +0000
@@ -116,8 +116,7 @@
 	  (prin1 (car history))
 	  (terpri))
 	(setq history (cdr history))))
-    (save-excursion
-      (set-buffer "*Command History*")
+    (with-current-buffer "*Command History*"
       (goto-char (point-min))
       (if (eobp)
 	  (error "No command history")
--- a/lisp/dabbrev.el	Fri Nov 13 17:03:30 2009 +0000
+++ b/lisp/dabbrev.el	Fri Nov 13 22:19:45 2009 +0000
@@ -62,8 +62,7 @@
 ;; the article for expansion):
 ;; (set (make-local-variable 'dabbrev-friend-buffer-function)
 ;;      (lambda (buffer)
-;;         (save-excursion
-;;           (set-buffer buffer)
+;;         (with-current-buffer buffer
 ;;           (memq major-mode '(news-reply-mode gnus-article-mode)))))
 
 
@@ -594,8 +593,7 @@
 ;;; Checks if OTHER-BUFFER has the same major mode as current buffer.
 (defun dabbrev--same-major-mode-p (other-buffer)
   (eq major-mode
-      (save-excursion
-	(set-buffer other-buffer)
+      (with-current-buffer other-buffer
 	major-mode)))
 
 ;;; Back over all abbrev type characters and then moves forward over
--- a/lisp/dired-aux.el	Fri Nov 13 17:03:30 2009 +0000
+++ b/lisp/dired-aux.el	Fri Nov 13 22:19:45 2009 +0000
@@ -1251,8 +1251,7 @@
   (let ((expanded-from-dir (expand-file-name from-dir))
 	(blist (buffer-list)))
     (while blist
-      (save-excursion
-	(set-buffer (car blist))
+      (with-current-buffer (car blist)
 	(if (and buffer-file-name
 		 (dired-in-this-tree buffer-file-name expanded-from-dir))
 	    (let ((modflag (buffer-modified-p))
@@ -1530,8 +1529,7 @@
     ;; non-dired buffer may want to profit from this function, e.g. vm-uudecode
     (if dired-dwim-target
 	(let* ((other-buf (window-buffer (next-window)))
-	       (other-dir (save-excursion
-			    (set-buffer other-buf)
+	       (other-dir (with-current-buffer other-buf
 			    (and (eq major-mode 'dired-mode)
 				 (dired-current-directory)))))
 	  (or other-dir this-dir))
--- a/lisp/dired.el	Fri Nov 13 17:03:30 2009 +0000
+++ b/lisp/dired.el	Fri Nov 13 22:19:45 2009 +0000
@@ -819,8 +819,7 @@
     (while blist
       (if (null (buffer-name (cdr (car blist))))
 	  (setq blist (cdr blist))
-	(save-excursion
-	  (set-buffer (cdr (car blist)))
+	(with-current-buffer (cdr (car blist))
 	  (if (and (eq major-mode mode)
 		   dired-directory  ;; nil during find-alternate-file
 		   (equal dirname
--- a/lisp/disp-table.el	Fri Nov 13 17:03:30 2009 +0000
+++ b/lisp/disp-table.el	Fri Nov 13 22:19:45 2009 +0000
@@ -87,8 +87,7 @@
     (princ "\nVertical window border glyph: ")
     (prin1 (display-table-slot dt 'vertical-border))
     (princ "\nCharacter display glyph sequences:\n")
-    (save-excursion
-      (set-buffer standard-output)
+    (with-current-buffer standard-output
       (let ((vector (make-vector 256 nil))
 	    (i 0))
 	(while (< i 256)
--- a/lisp/dos-w32.el	Fri Nov 13 17:03:30 2009 +0000
+++ b/lisp/dos-w32.el	Fri Nov 13 22:19:45 2009 +0000
@@ -197,8 +197,7 @@
     (find-file filename)))
 
 (defun find-file-not-found-set-buffer-file-coding-system ()
-  (save-excursion
-    (set-buffer (current-buffer))
+  (with-current-buffer (current-buffer)
     (let ((coding buffer-file-coding-system))
       ;; buffer-file-coding-system is already set by
       ;; find-operation-coding-system, which was called from
--- a/lisp/echistory.el	Fri Nov 13 17:03:30 2009 +0000
+++ b/lisp/echistory.el	Fri Nov 13 22:19:45 2009 +0000
@@ -34,8 +34,7 @@
 With prefix arg NOCONFIRM, execute current line as-is without editing."
   (interactive "P")
   (let (todo)
-    (save-excursion
-      (set-buffer "*Command History*")
+    (with-current-buffer "*Command History*"
       (beginning-of-line)
       (setq todo (read (current-buffer)))
       (if (boundp 'electric-history-in-progress)
--- a/lisp/ediff-diff.el	Fri Nov 13 17:03:30 2009 +0000
+++ b/lisp/ediff-diff.el	Fri Nov 13 22:19:45 2009 +0000
@@ -1225,8 +1225,7 @@
     (unwind-protect
 	(let ((directory default-directory)
 	      proc)
-	  (save-excursion
-	    (set-buffer buffer)
+	  (with-current-buffer buffer
 	    (erase-buffer)
 	    (setq default-directory directory)
 	    (if (or (memq system-type '(emx ms-dos windows-nt windows-95))
@@ -1283,8 +1282,7 @@
   (if (and (memq (process-status process) '(exit signal))
            (buffer-name (process-buffer process)))
       (progn
-        (save-excursion
-          (set-buffer (process-buffer process))
+        (with-current-buffer (process-buffer process)
           (setq mode-line-process nil))
         (delete-process process))))
 
@@ -1354,8 +1352,7 @@
 	       ediff-forward-word-function)
 	   ediff-forward-word-function))
 	inbuf-syntax-tbl sv-point diff-string)
-    (save-excursion
-     (set-buffer in-buffer)
+    (with-current-buffer in-buffer
      (setq inbuf-syntax-tbl
 	   (if control-buf
 	       (ediff-with-current-buffer control-buf
--- a/lisp/ediff-mult.el	Fri Nov 13 17:03:30 2009 +0000
+++ b/lisp/ediff-mult.el	Fri Nov 13 22:19:45 2009 +0000
@@ -1639,8 +1639,7 @@
     (cond ((ediff-buffer-live-p custom-diff-buf)
 	   ;; for live session buffers we do them first because the user may
 	   ;; have changed them with respect to the underlying files
-	   (save-excursion
-	     (set-buffer meta-diff-buff)
+	   (with-current-buffer meta-diff-buff
 	     (goto-char (point-max))
 	     (insert-buffer-substring custom-diff-buf)
 	     (insert "\n")))
@@ -1649,8 +1648,8 @@
 			   ediff-merge-directories
 			   ediff-merge-directories-with-ancestor))
 	   ;; get diffs by calling shell command on ediff-custom-diff-program
-	   (save-excursion
-	     (set-buffer (setq tmp-buf (get-buffer-create ediff-tmp-buffer)))
+	   (with-current-buffer
+               (setq tmp-buf (get-buffer-create ediff-tmp-buffer))
 	     (erase-buffer)
 	     (shell-command
 	      (format
@@ -1662,8 +1661,7 @@
 	       )
 	      t)
 	     )
-	   (save-excursion
-	     (set-buffer meta-diff-buff)
+	   (with-current-buffer meta-diff-buff
 	     (goto-char (point-max))
 	     (insert-buffer-substring tmp-buf)
 	     (insert "\n")))
--- a/lisp/ediff-util.el	Fri Nov 13 17:03:30 2009 +0000
+++ b/lisp/ediff-util.el	Fri Nov 13 22:19:45 2009 +0000
@@ -343,8 +343,7 @@
 	    (setq buffer-C
 		  (get-buffer-create
 		   (ediff-unique-buffer-name "*ediff-merge" "*")))
-	    (save-excursion
-	      (set-buffer buffer-C)
+	    (with-current-buffer buffer-C
 	      (insert-buffer-substring buf)
 	      (goto-char (point-min))
 	      (funcall (ediff-with-current-buffer buf major-mode))
--- a/lisp/ediff-vers.el	Fri Nov 13 17:03:30 2009 +0000
+++ b/lisp/ediff-vers.el	Fri Nov 13 22:19:45 2009 +0000
@@ -123,8 +123,7 @@
 	(fundamental-mode))
       (let ((output-buffer (ediff-rcs-get-output-buffer filename buff)))
 	(delete-windows-on output-buffer)
-	(save-excursion
-	  (set-buffer output-buffer)
+	(with-current-buffer output-buffer
 	  (apply 'call-process "co" nil t nil
 		 ;; -q: quiet (no diagnostics)
 		 (append switches rcs-default-co-switches
--- a/lisp/ediff.el	Fri Nov 13 17:03:30 2009 +0000
+++ b/lisp/ediff.el	Fri Nov 13 22:19:45 2009 +0000
@@ -977,8 +977,7 @@
 	(buffer-B
          (ediff-clone-buffer-for-region-comparison buffer-B "-Region.B-"))
         reg-A-beg reg-A-end reg-B-beg reg-B-end)
-    (save-excursion
-      (set-buffer buffer-A)
+    (with-current-buffer buffer-A
       (setq reg-A-beg (region-beginning)
 	    reg-A-end (region-end))
       (set-buffer buffer-B)
@@ -1018,8 +1017,7 @@
 	(buffer-B
          (ediff-clone-buffer-for-region-comparison buffer-B "-Region.B-"))
         reg-A-beg reg-A-end reg-B-beg reg-B-end)
-    (save-excursion
-      (set-buffer buffer-A)
+    (with-current-buffer buffer-A
       (setq reg-A-beg (region-beginning)
 	    reg-A-end (region-end))
       ;; enlarge the region to hold full lines
--- a/lisp/ehelp.el	Fri Nov 13 17:03:30 2009 +0000
+++ b/lisp/ehelp.el	Fri Nov 13 22:19:45 2009 +0000
@@ -321,8 +321,7 @@
 		  ;;>>      suspend updating of the tick in order to allow
 		  ;;>>      things like momentary-string-display)
 		  (and b
-		       (save-excursion
-			 (set-buffer b)
+		       (with-current-buffer b
 			 (set-buffer-modified-p t)))
 		  (fset 'help-print-return-message 'ignore)
 		  (call-interactively fun)
@@ -333,8 +332,7 @@
 			   (not (buffer-modified-p b)))))
 	      (fset 'help-print-return-message p)
 	      (and b (buffer-name b)
-		   (save-excursion
-		     (set-buffer b)
+		   (with-current-buffer b
 		     (set-buffer-modified-p m))))))
 	(with-electric-help 'ignore name t))))
 
--- a/lisp/emerge.el	Fri Nov 13 17:03:30 2009 +0000
+++ b/lisp/emerge.el	Fri Nov 13 22:19:45 2009 +0000
@@ -2060,8 +2060,7 @@
 	 (A-end (1- (aref diff-vector 1)))
 	 ;; so further kills don't append
 	 this-command)
-    (save-excursion
-      (set-buffer emerge-A-buffer)
+    (with-current-buffer emerge-A-buffer
       (copy-region-as-kill A-begin A-end))))
 
 (defun emerge-copy-as-kill-B ()
@@ -2074,8 +2073,7 @@
 	 (B-end (1- (aref diff-vector 3)))
 	 ;; so further kills don't append
 	 this-command)
-    (save-excursion
-      (set-buffer emerge-B-buffer)
+    (with-current-buffer emerge-B-buffer
       (copy-region-as-kill B-begin B-end))))
 
 (defun emerge-insert-A (arg)
@@ -2170,8 +2168,7 @@
 				       (princ (buffer-name))))
 				   (princ "\n")))
       (princ emerge-output-description)
-      (save-excursion
-	(set-buffer standard-output)
+      (with-current-buffer standard-output
 	(help-mode)))))
 
 (defun emerge-join-differences (arg)
@@ -3020,8 +3017,7 @@
 ;;			       minor-mode indicator))
 ;;		(princ (documentation minor-mode)))))
 ;;	(setq minor-modes (cdr minor-modes))))
-;;    (save-excursion
-;;      (set-buffer standard-output)
+;;    (with-current-buffer standard-output
 ;;      (help-mode))
 ;;    (help-print-return-message)))
 
--- a/lisp/epa.el	Fri Nov 13 17:03:30 2009 +0000
+++ b/lisp/epa.el	Fri Nov 13 22:19:45 2009 +0000
@@ -463,8 +463,7 @@
   (apply #'epa--list-keys epa-list-keys-arguments))
 
 (defun epa--marked-keys ()
-  (or (save-excursion
-	(set-buffer epa-keys-buffer)
+  (or (with-current-buffer epa-keys-buffer
 	(goto-char (point-min))
 	(let (keys key)
 	  (while (re-search-forward "^\\*" nil t)
@@ -479,11 +478,10 @@
 	      (list key))))))
 
 (defun epa--select-keys (prompt keys)
-  (save-excursion
-    (unless (and epa-keys-buffer
-		 (buffer-live-p epa-keys-buffer))
-      (setq epa-keys-buffer (generate-new-buffer "*Keys*")))
-    (set-buffer epa-keys-buffer)
+  (unless (and epa-keys-buffer
+               (buffer-live-p epa-keys-buffer))
+    (setq epa-keys-buffer (generate-new-buffer "*Keys*")))
+  (with-current-buffer epa-keys-buffer
     (epa-key-list-mode)
     (let ((inhibit-read-only t)
 	  buffer-read-only)
@@ -615,8 +613,7 @@
 	  (setq epa-info-buffer (generate-new-buffer "*Info*")))
 	(if (get-buffer-window epa-info-buffer)
 	    (delete-window (get-buffer-window epa-info-buffer)))
-	(save-excursion
-	  (set-buffer epa-info-buffer)
+	(with-current-buffer epa-info-buffer
 	  (let ((inhibit-read-only t)
 		buffer-read-only)
 	    (erase-buffer)
@@ -716,8 +713,7 @@
 	     (setq type 'detached))
 	    ((eq c ??)
 	     (with-output-to-temp-buffer "*Help*"
-	       (save-excursion
-		 (set-buffer standard-output)
+	       (with-current-buffer standard-output
 		 (insert "\
 n - Create a normal signature
 c - Create a cleartext signature
--- a/lisp/epg.el	Fri Nov 13 17:03:30 2009 +0000
+++ b/lisp/epg.el	Fri Nov 13 22:19:45 2009 +0000
@@ -1143,8 +1143,7 @@
 	(goto-char (point-max))
 	(insert input)))
   (if (buffer-live-p (process-buffer process))
-      (save-excursion
-	(set-buffer (process-buffer process))
+      (with-current-buffer (process-buffer process)
 	(goto-char (point-max))
 	(insert input)
 	(unless epg-process-filter-running
@@ -1927,8 +1926,7 @@
 
 (defun epg-cancel (context)
   (if (buffer-live-p (process-buffer (epg-context-process context)))
-      (save-excursion
-	(set-buffer (process-buffer (epg-context-process context)))
+      (with-current-buffer (process-buffer (epg-context-process context))
 	(epg-context-set-result-for
 	 epg-context 'error
 	 (cons '(quit)
--- a/lisp/ezimage.el	Fri Nov 13 17:03:30 2009 +0000
+++ b/lisp/ezimage.el	Fri Nov 13 22:19:45 2009 +0000
@@ -300,8 +300,7 @@
 See `ezimage-expand-image-button-alist' for details."
   (interactive)
   (with-output-to-temp-buffer "*Ezimage Images*"
-    (save-excursion
-      (set-buffer "*Ezimage Images*")
+    (with-current-buffer "*Ezimage Images*"
       (goto-char (point-max))
       (insert "Ezimage image cache.\n\n")
       (let ((start (point)) (end nil))
@@ -324,8 +323,7 @@
 See `ezimage-expand-image-button-alist' for details."
   (interactive)
   (with-output-to-temp-buffer "*Ezimage Images*"
-    (save-excursion
-      (set-buffer "*Ezimage Images*")
+    (with-current-buffer "*Ezimage Images*"
       (goto-char (point-max))
       (insert "Ezimage image cache.\n\n")
       (let ((start (point)) (end nil))
--- a/lisp/facemenu.el	Fri Nov 13 17:03:30 2009 +0000
+++ b/lisp/facemenu.el	Fri Nov 13 22:19:45 2009 +0000
@@ -494,8 +494,7 @@
 	(if lc
 	    (setcdr lc nil)))))
   (with-help-window (or buffer-name "*Colors*")
-    (save-excursion
-      (set-buffer standard-output)
+    (with-current-buffer standard-output
       (setq truncate-lines t)
       (if temp-buffer-show-function
 	  (list-colors-print list)
--- a/lisp/faces.el	Fri Nov 13 17:03:30 2009 +0000
+++ b/lisp/faces.el	Fri Nov 13 22:19:45 2009 +0000
@@ -1273,8 +1273,7 @@
     (setq max-length (1+ max-length)
 	  line-format (format "%%-%ds" max-length))
     (with-help-window "*Faces*"
-      (save-excursion
-	(set-buffer standard-output)
+      (with-current-buffer standard-output
 	(setq truncate-lines t)
 	(insert
 	 (substitute-command-keys
@@ -1362,8 +1361,7 @@
     (if (not (listp face))
 	(setq face (list face)))
     (with-help-window (help-buffer)
-      (save-excursion
-	(set-buffer standard-output)
+      (with-current-buffer standard-output
 	(dolist (f face)
 	  (if (stringp f) (setq f (intern f)))
 	  ;; We may get called for anonymous faces (i.e., faces
--- a/lisp/files.el	Fri Nov 13 17:03:30 2009 +0000
+++ b/lisp/files.el	Fri Nov 13 22:19:45 2009 +0000
@@ -5411,8 +5411,7 @@
       (princ "Directory ")
       (princ dirname)
       (terpri)
-      (save-excursion
-	(set-buffer "*Directory*")
+      (with-current-buffer "*Directory*"
 	(let ((wildcard (not (file-directory-p dirname))))
 	  (insert-directory dirname switches wildcard (not wildcard)))))
     ;; Finishing with-output-to-temp-buffer seems to clobber default-directory.
--- a/lisp/filesets.el	Fri Nov 13 17:03:30 2009 +0000
+++ b/lisp/filesets.el	Fri Nov 13 22:19:45 2009 +0000
@@ -1552,8 +1552,7 @@
 if `buffer-modified-p' returns nil.
 
 SAVE-FUNCTION takes no argument, but works on the current buffer."
-  (save-excursion
-    (set-buffer buffer)
+  (with-current-buffer buffer
     (if (buffer-modified-p)
 	(funcall save-function))
     (if (not (buffer-modified-p))
--- a/lisp/find-dired.el	Fri Nov 13 17:03:30 2009 +0000
+++ b/lisp/find-dired.el	Fri Nov 13 22:19:45 2009 +0000
@@ -291,8 +291,7 @@
   (let ((buf (process-buffer proc))
 	(inhibit-read-only t))
     (if (buffer-name buf)
-	(save-excursion
-	  (set-buffer buf)
+	(with-current-buffer buf
 	  (let ((buffer-read-only nil))
 	    (save-excursion
 	      (goto-char (point-max))
--- a/lisp/finder.el	Fri Nov 13 17:03:30 2009 +0000
+++ b/lisp/finder.el	Fri Nov 13 22:19:45 2009 +0000
@@ -332,8 +332,7 @@
 (defun finder-mouse-select (event)
   "Select item in a finder buffer with the mouse."
   (interactive "e")
-  (save-excursion
-    (set-buffer (window-buffer (posn-window (event-start event))))
+  (with-current-buffer (window-buffer (posn-window (event-start event)))
     (goto-char (posn-point (event-start event)))
     (finder-select)))
 
--- a/lisp/generic-x.el	Fri Nov 13 17:03:30 2009 +0000
+++ b/lisp/generic-x.el	Fri Nov 13 22:19:45 2009 +0000
@@ -546,9 +546,7 @@
   (require 'comint)
   (let* ((file (buffer-file-name))
 	 (buf-name (concat "*" file "*")))
-    (save-excursion
-      (set-buffer
-       (get-buffer-create buf-name))
+    (with-current-buffer (get-buffer-create buf-name)
       (erase-buffer)
       (comint-mode)
       (comint-exec
--- a/lisp/help-fns.el	Fri Nov 13 17:03:30 2009 +0000
+++ b/lisp/help-fns.el	Fri Nov 13 22:19:45 2009 +0000
@@ -789,8 +789,7 @@
 		  (terpri)
 		  (princ output))))
 
-	    (save-excursion
-	      (set-buffer standard-output)
+	    (with-current-buffer standard-output
 	      ;; Return the text we displayed.
 	      (buffer-string))))))))
 
--- a/lisp/help-mode.el	Fri Nov 13 17:03:30 2009 +0000
+++ b/lisp/help-mode.el	Fri Nov 13 22:19:45 2009 +0000
@@ -413,8 +413,7 @@
 help buffers.  Variable `help-back-label' specifies the text for
 that."
   (interactive "b")
-  (save-excursion
-    (set-buffer (or buffer (current-buffer)))
+  (with-current-buffer (or buffer (current-buffer))
     (goto-char (point-min))
     ;; Skip the header-type info, though it might be useful to parse
     ;; it at some stage (e.g. "function in `library'").
--- a/lisp/hippie-exp.el	Fri Nov 13 17:03:30 2009 +0000
+++ b/lisp/hippie-exp.el	Fri Nov 13 22:19:45 2009 +0000
@@ -1000,8 +1000,7 @@
     (while (and (not (equal he-search-string ""))
 		(marker-position he-search-loc)
 		(not expansion))
-      (save-excursion
-	(set-buffer (marker-buffer he-search-loc))
+      (with-current-buffer (marker-buffer he-search-loc)
 	(goto-char he-search-loc)
 	(setq expansion (he-dabbrev-search he-search-string ()
 					   (window-end he-search-window)))
--- a/lisp/ido.el	Fri Nov 13 17:03:30 2009 +0000
+++ b/lisp/ido.el	Fri Nov 13 22:19:45 2009 +0000
@@ -2975,8 +2975,7 @@
 (defun ido-copy-current-word (all)
   "Insert current word (file or directory name) from current buffer."
   (interactive "P")
-  (let ((word (save-excursion
-		(set-buffer ido-entry-buffer)
+  (let ((word (with-current-buffer ido-entry-buffer
 		(let ((p (point)) start-line end-line start-name name)
 		  (if (and mark-active (/= p (mark)))
 		      (setq start-name (mark))
@@ -4184,8 +4183,7 @@
 	    ido-text-init contents
 	    ido-rotate-temp t
 	    ido-exit 'refresh)
-      (save-excursion
-	(set-buffer buffer)
+      (with-current-buffer buffer
 	(ido-tidy))
       (throw 'ido contents))))
 
--- a/lisp/informat.el	Fri Nov 13 17:03:30 2009 +0000
+++ b/lisp/informat.el	Fri Nov 13 22:19:45 2009 +0000
@@ -497,8 +497,7 @@
 		      nil ;(message "Checking validity of info file %s... OK" file)
 		    (message "----------------------------------------------------------------------")
 		    (message ">> PROBLEMS IN INFO FILE %s" file)
-		    (save-excursion
-		      (set-buffer loss-name)
+		    (with-current-buffer loss-name
 		      (princ (buffer-substring-no-properties
 			      (point-min) (point-max))))
 		    (message "----------------------------------------------------------------------")
--- a/lisp/ledit.el	Fri Nov 13 17:03:30 2009 +0000
+++ b/lisp/ledit.el	Fri Nov 13 22:19:45 2009 +0000
@@ -94,11 +94,10 @@
   (if ledit-save-files
       (save-some-buffers))
   (if (get-buffer ledit-buffer)
-      (save-excursion
-       (set-buffer ledit-buffer)
-       (goto-char (point-min))
-       (write-region (point-min) (point-max) ledit-zap-file)
-       (erase-buffer)))
+      (with-current-buffer ledit-buffer
+        (goto-char (point-min))
+        (write-region (point-min) (point-max) ledit-zap-file)
+        (erase-buffer)))
   (suspend-emacs ledit-go-to-lisp-string)
   (load ledit-read-file t t))
 
@@ -108,12 +107,11 @@
   (if ledit-save-files
       (save-some-buffers))
   (if (get-buffer ledit-buffer)
-      (save-excursion
-       (set-buffer ledit-buffer)
-       (goto-char (point-min))
-       (insert "(declare (macros t))\n")
-       (write-region (point-min) (point-max) ledit-compile-file)
-       (erase-buffer)))
+      (with-current-buffer ledit-buffer
+        (goto-char (point-min))
+        (insert "(declare (macros t))\n")
+        (write-region (point-min) (point-max) ledit-compile-file)
+        (erase-buffer)))
   (suspend-emacs ledit-go-to-liszt-string)
   (load ledit-read-file t t))
 
--- a/lisp/macros.el	Fri Nov 13 17:03:30 2009 +0000
+++ b/lisp/macros.el	Fri Nov 13 22:19:45 2009 +0000
@@ -209,8 +209,7 @@
 \\[exit]	Stop the macro entirely right now.
 \\[recenter]	Redisplay the screen, then ask again.
 \\[edit]	Enter recursive edit; ask again when you exit from that."))
-		     (save-excursion
-		       (set-buffer standard-output)
+		     (with-current-buffer standard-output
 		       (help-mode)))))))))))
 
 ;;;###autoload
--- a/lisp/menu-bar.el	Fri Nov 13 17:03:30 2009 +0000
+++ b/lisp/menu-bar.el	Fri Nov 13 22:19:45 2009 +0000
@@ -1857,8 +1857,7 @@
 ;;nil means the buffer shouldn't be listed.  You can redefine this."
 ;;  (if (string-match "\\` " (buffer-name buffer))
 ;;      nil
-;;    (save-excursion
-;;     (set-buffer buffer)
+;;    (with-current-buffer buffer
 ;;     (let ((size (buffer-size)))
 ;;       (format "%s%s %-19s %6s %-15s %s"
 ;;	       (if (buffer-modified-p) "*" " ")
--- a/lisp/mouse-copy.el	Fri Nov 13 17:03:30 2009 +0000
+++ b/lisp/mouse-copy.el	Fri Nov 13 22:19:45 2009 +0000
@@ -200,8 +200,7 @@
 		(window-buffer (posn-window (event-start click)))
 	      (current-buffer)))
 	(error "Select or click on the buffer where the secondary selection is")))
-  (save-excursion
-    (set-buffer (overlay-buffer mouse-secondary-overlay))
+  (with-current-buffer (overlay-buffer mouse-secondary-overlay)
     (kill-region (overlay-start mouse-secondary-overlay)
 		 (overlay-end mouse-secondary-overlay)))
   ;; (delete-overlay mouse-secondary-overlay)
--- a/lisp/mouse.el	Fri Nov 13 17:03:30 2009 +0000
+++ b/lisp/mouse.el	Fri Nov 13 22:19:45 2009 +0000
@@ -1975,12 +1975,10 @@
 		     (format "%%-%ds  %%s%%s  %%s" maxlen)
 		     (buffer-name elt)
 		     (if (buffer-modified-p elt) "*" " ")
-		     (save-excursion
-		       (set-buffer elt)
+		     (with-current-buffer elt
 		       (if buffer-read-only "%" " "))
 		     (or (buffer-file-name elt)
-			 (save-excursion
-			   (set-buffer elt)
+			 (with-current-buffer elt
 			   (if list-buffers-directory
 			       (expand-file-name
 				list-buffers-directory)))
--- a/lisp/novice.el	Fri Nov 13 17:03:30 2009 +0000
+++ b/lisp/novice.el	Fri Nov 13 22:19:45 2009 +0000
@@ -85,8 +85,7 @@
 n   to cancel--don't try the command, and it remains disabled.
 SPC to try the command just this once, but leave it disabled.
 !   to try it, and enable all disabled commands for this session only.")
-       (save-excursion
-	 (set-buffer standard-output)
+       (with-current-buffer standard-output
 	 (help-mode)))
      (fit-window-to-buffer (get-buffer-window "*Disabled Command*"))
      (message "Type y, n, ! or SPC (the space bar): ")
@@ -135,9 +134,8 @@
 	       (eq system-type 'windows-nt)
 	       (file-exists-p "~/_emacs"))
 	  (setq init-file "~/_emacs")))
-    (save-excursion
-      (set-buffer (find-file-noselect
-		   (substitute-in-file-name init-file)))
+    (with-current-buffer (find-file-noselect
+                          (substitute-in-file-name init-file))
       (goto-char (point-min))
       (if (search-forward (concat "(put '" (symbol-name command) " ") nil t)
 	  (delete-region
@@ -175,9 +173,8 @@
 	       (eq system-type 'windows-nt)
 	       (file-exists-p "~/_emacs"))
 	  (setq init-file "~/_emacs")))
-    (save-excursion
-      (set-buffer (find-file-noselect
-		   (substitute-in-file-name init-file)))
+    (with-current-buffer (find-file-noselect
+                          (substitute-in-file-name init-file))
       (goto-char (point-min))
       (if (search-forward (concat "(put '" (symbol-name command) " ") nil t)
 	  (delete-region
--- a/lisp/printing.el	Fri Nov 13 17:03:30 2009 +0000
+++ b/lisp/printing.el	Fri Nov 13 22:19:45 2009 +0000
@@ -3953,8 +3953,7 @@
 
 For more information, type \\[pr-interface-help]."
   (interactive)
-  (save-excursion
-    (set-buffer (or buffer (current-buffer)))
+  (with-current-buffer (or buffer (current-buffer))
     (pr-create-interface)))
 
 
@@ -4457,8 +4456,7 @@
 	 (if (string= pr-ps-command "")
 	     ;; default action
 	     (let ((ps-spool-buffer (get-buffer-create ps-spool-buffer-name)))
-	       (save-excursion
-		 (set-buffer ps-spool-buffer)
+	       (with-current-buffer ps-spool-buffer
 		 (erase-buffer)
 		 (insert-file-contents-literally file))
 	       (pr-despool-print))
@@ -5028,8 +5026,7 @@
 		      (symbol-value summary-buffer))
 		 (symbol-value summary-default))))
     (and (get-buffer buf)
-	 (save-excursion
-	   (set-buffer buf)
+	 (with-current-buffer buf
 	   (pr-mode-print n-up filename header-list)))))
 
 
@@ -5039,8 +5036,7 @@
 		      (symbol-value summary-buffer))
 		 (symbol-value summary-default))))
     (and (get-buffer buf)
-	 (save-excursion
-	   (set-buffer buf)
+	 (with-current-buffer buf
 	   (pr-mode-lpr header-list)))))
 
 
@@ -5633,8 +5629,7 @@
 	status)
     (setq args (pr-remove-nil-from-list args))
     ;; *Printing Command Output* == show command & args
-    (save-excursion
-      (set-buffer buffer)
+    (with-current-buffer buffer
       (goto-char (point-max))
       (insert (format "%s %S\n" cmd args)))
     ;; *Printing Command Output* == show any return message from command
@@ -5645,8 +5640,7 @@
 	     ((quit error)
 	      (error-message-string data)))))
     ;; *Printing Command Output* == show exit status
-    (save-excursion
-      (set-buffer buffer)
+    (with-current-buffer buffer
       (goto-char (point-max))
       (insert (format "Exit status: %s\n\n" status)))
     ;; message if error status
@@ -5839,8 +5833,7 @@
 	  (blist (buffer-list))
 	  found)
       (while (and (not found) blist)
-	(save-excursion
-	  (set-buffer (car blist))
+	(with-current-buffer (car blist)
 	  (and (eq major-mode 'dired-mode)
 	       (save-excursion
 		 (goto-char (point-min))
@@ -5864,9 +5857,8 @@
 			 pop-up-frames)
 		     (and (or buffer
 			      (file-readable-p file))
-			  (save-excursion
-			    (set-buffer (or buffer
-					    (find-file-noselect file)))
+			  (with-current-buffer (or buffer
+                                                   (find-file-noselect file))
 			    (funcall fun)
 			    (or buffer
 				(kill-buffer (current-buffer))))))))
@@ -6047,8 +6039,7 @@
 
 
 (defmacro pr-interface-save (&rest body)
-  `(save-excursion
-     (set-buffer pr-i-buffer)
+  `(with-current-buffer pr-i-buffer
      ,@body))
 
 
--- a/lisp/ps-bdf.el	Fri Nov 13 17:03:30 2009 +0000
+++ b/lisp/ps-bdf.el	Fri Nov 13 22:19:45 2009 +0000
@@ -95,8 +95,7 @@
   (and (file-readable-p bdfname)
        (let ((buf (generate-new-buffer " *bdf-work*"))
 	     (coding-system-for-read 'no-conversion))
-	 (save-excursion
-	   (set-buffer buf)
+	 (with-current-buffer buf
 	   (insert-file-contents bdfname)
 	   buf))))
 
@@ -225,8 +224,7 @@
 	(message "Reading %s..." bdfname)
       (error "BDF file %s doesn't exist" bdfname))
     (unwind-protect
-	(save-excursion
-	  (set-buffer buf)
+	(with-current-buffer buf
 	  (goto-char (point-min))
 	  (search-forward "\nFONTBOUNDINGBOX")
 	  (setq font-bounding-box
--- a/lisp/ps-print.el	Fri Nov 13 17:03:30 2009 +0000
+++ b/lisp/ps-print.el	Fri Nov 13 22:19:45 2009 +0000
@@ -4734,8 +4734,7 @@
   (ps-output 'prologue (if (stringp args) (list args) args)))
 
 (defun ps-flush-output ()
-  (save-excursion
-    (set-buffer ps-spool-buffer)
+  (with-current-buffer ps-spool-buffer
     (goto-char (point-max))
     (while ps-output-head
       (let ((it (car ps-output-head)))
@@ -4756,8 +4755,7 @@
 
 (defun ps-insert-file (fname)
   (ps-flush-output)
-  (save-excursion
-    (set-buffer ps-spool-buffer)
+  (with-current-buffer ps-spool-buffer
     (goto-char (point-max))
     (insert-file-contents fname)))
 
@@ -4840,8 +4838,7 @@
 
 
 (defun ps-get-boundingbox ()
-  (save-excursion
-    (set-buffer ps-spool-buffer)
+  (with-current-buffer ps-spool-buffer
     (save-excursion
       (if (re-search-forward ps-boundingbox-re nil t)
 	  (vector (string-to-number	; lower x
@@ -4909,8 +4906,7 @@
 	   ;; coordinate adjustment to center image
 	   ;; around x and y position
 	   (let ((box (ps-get-boundingbox)))
-	     (save-excursion
-	       (set-buffer ps-spool-buffer)
+	     (with-current-buffer ps-spool-buffer
 	       (save-excursion
 		 (if (re-search-backward "^--back--" nil t)
 		     (replace-match
@@ -5795,8 +5791,7 @@
 					     ps-line-number-step
 					   ps-zebra-stripe-height))))
   ;; spooling buffer
-  (save-excursion
-    (set-buffer ps-spool-buffer)
+  (with-current-buffer ps-spool-buffer
     (goto-char (point-max))
     (and (re-search-backward "^%%Trailer$" nil t)
 	 (delete-region (match-beginning 0) (point-max))))
@@ -6573,8 +6568,7 @@
 	  (and ps-razzle-dazzle (message "Wrote %s" filename)))
       ;; Else, spool to the printer
       (and ps-razzle-dazzle (message "Printing..."))
-      (save-excursion
-	(set-buffer ps-spool-buffer)
+      (with-current-buffer ps-spool-buffer
 	(let* ((coding-system-for-write 'raw-text-unix)
 	       (ps-printer-name (or ps-printer-name
 				    (and (boundp 'printer-name)
--- a/lisp/ps-samp.el	Fri Nov 13 17:03:30 2009 +0000
+++ b/lisp/ps-samp.el	Fri Nov 13 22:19:45 2009 +0000
@@ -72,8 +72,7 @@
 			 (symbol-value summary-buffer))
 		    summary-default)))
     (and (get-buffer ps-buf)
-	 (save-excursion
-	   (set-buffer ps-buf)
+	 (with-current-buffer ps-buf
 	   (ps-spool-buffer-with-faces)))))
 
 ;; Look in an article or mail message for the Subject: line.  To be
--- a/lisp/saveplace.el	Fri Nov 13 17:03:30 2009 +0000
+++ b/lisp/saveplace.el	Fri Nov 13 22:19:45 2009 +0000
@@ -205,8 +205,7 @@
 (defun save-place-alist-to-file ()
   (let ((file (expand-file-name save-place-file))
         (coding-system-for-write 'utf-8))
-    (save-excursion
-      (set-buffer (get-buffer-create " *Saved Places*"))
+    (with-current-buffer (get-buffer-create " *Saved Places*")
       (delete-region (point-min) (point-max))
       (when save-place-forget-unreadable-files
 	(save-place-forget-unreadable-files))
@@ -236,10 +235,9 @@
           ;; make sure that the alist does not get overwritten, and then
           ;; load it if it exists:
           (if (file-readable-p file)
-              (save-excursion
-                ;; don't want to use find-file because we have been
-                ;; adding hooks to it.
-                (set-buffer (get-buffer-create " *Saved Places*"))
+              ;; don't want to use find-file because we have been
+              ;; adding hooks to it.
+              (with-current-buffer (get-buffer-create " *Saved Places*")
                 (delete-region (point-min) (point-max))
                 (insert-file-contents file)
                 (goto-char (point-min))
@@ -275,8 +273,7 @@
       ;; put this into a save-excursion in case someone is counting on
       ;; another function in kill-emacs-hook to act on the last buffer
       ;; they were in:
-      (save-excursion
-	(set-buffer (car buf-list))
+      (with-current-buffer (car buf-list)
 	;; save-place checks buffer-file-name too, but we can avoid
 	;; overhead of function call by checking here too.
 	(and buffer-file-name (save-place-to-alist))
--- a/lisp/sb-image.el	Fri Nov 13 17:03:30 2009 +0000
+++ b/lisp/sb-image.el	Fri Nov 13 22:19:45 2009 +0000
@@ -85,8 +85,7 @@
 See `speedbar-expand-image-button-alist' for details."
   (interactive)
   (with-output-to-temp-buffer "*Speedbar Images*"
-    (save-excursion
-      (set-buffer "*Speedbar Images*")
+    (with-current-buffer "*Speedbar Images*"
       (goto-char (point-max))
       (insert "Speedbar image cache.\n\n")
       (let ((start (point)) (end nil))
--- a/lisp/scroll-bar.el	Fri Nov 13 17:03:30 2009 +0000
+++ b/lisp/scroll-bar.el	Fri Nov 13 22:19:45 2009 +0000
@@ -156,7 +156,7 @@
 
 ;;;; Buffer navigation using the scroll bar.
 
-;;; This was used for up-events on button 2, but no longer.
+;; This was used for up-events on button 2, but no longer.
 (defun scroll-bar-set-window-start (event)
   "Set the window start according to where the scroll bar is dragged.
 EVENT should be a scroll bar click or drag event."
@@ -164,8 +164,7 @@
   (let* ((end-position (event-end event))
 	 (window (nth 0 end-position))
 	 (portion-whole (nth 2 end-position)))
-    (save-excursion
-      (set-buffer (window-buffer window))
+    (with-current-buffer (window-buffer window)
       (save-excursion
 	(goto-char (+ (point-min)
 		      (scroll-bar-scale portion-whole
@@ -195,8 +194,7 @@
 	 portion-start
 	 next-portion-start
 	 (current-start (window-start window)))
-    (save-excursion
-      (set-buffer (window-buffer window))
+    (with-current-buffer (window-buffer window)
       (setq portion-start (scroll-bar-drag-position portion-whole))
       (setq next-portion-start (max
 				(scroll-bar-drag-position next-portion-whole)
@@ -212,8 +210,7 @@
   (let* ((start-position (event-start event))
 	 (window (nth 0 start-position))
 	 (portion-whole (nth 2 start-position)))
-    (save-excursion
-      (set-buffer (window-buffer window))
+    (with-current-buffer (window-buffer window)
       ;; Calculate position relative to the accessible part of the buffer.
       (goto-char (+ (point-min)
 		    (scroll-bar-scale portion-whole
@@ -339,7 +336,7 @@
 
 ;;;; Bindings.
 
-;;; For now, we'll set things up to work like xterm.
+;; For now, we'll set things up to work like xterm.
 (cond ((and (boundp 'x-toolkit-scroll-bars) x-toolkit-scroll-bars)
        (global-set-key [vertical-scroll-bar mouse-1]
 		       'scroll-bar-toolkit-scroll))
--- a/lisp/shadowfile.el	Fri Nov 13 17:03:30 2009 +0000
+++ b/lisp/shadowfile.el	Fri Nov 13 22:19:45 2009 +0000
@@ -707,8 +707,7 @@
 
 (defun shadow-save-todo-file ()
   (if (and shadow-todo-buffer (buffer-modified-p shadow-todo-buffer))
-      (save-excursion
-	(set-buffer shadow-todo-buffer)
+      (with-current-buffer shadow-todo-buffer
 	(condition-case nil		; have to continue even in case of
 	    (basic-save-buffer)		; error, otherwise kill-emacs might
 	  (error			; not work!
--- a/lisp/simple.el	Fri Nov 13 17:03:30 2009 +0000
+++ b/lisp/simple.el	Fri Nov 13 22:19:45 2009 +0000
@@ -2423,8 +2423,7 @@
 	      ;; Clear the output buffer, then run the command with
 	      ;; output there.
 	      (let ((directory default-directory))
-		(save-excursion
-		  (set-buffer buffer)
+		(with-current-buffer buffer
 		  (setq buffer-read-only nil)
 		  (if (not output-buffer)
 		      (setq default-directory directory))
@@ -3469,11 +3468,10 @@
    (list (read-buffer "Append to buffer: " (other-buffer (current-buffer) t))
 	 (region-beginning) (region-end)))
   (let ((oldbuf (current-buffer)))
-    (save-excursion
-      (let* ((append-to (get-buffer-create buffer))
-	     (windows (get-buffer-window-list append-to t t))
-	     point)
-	(set-buffer append-to)
+    (let* ((append-to (get-buffer-create buffer))
+           (windows (get-buffer-window-list append-to t t))
+           point)
+      (with-current-buffer append-to
 	(setq point (point))
 	(barf-if-buffer-read-only)
 	(insert-buffer-substring oldbuf start end)
@@ -3490,8 +3488,7 @@
 START and END specify the portion of the current buffer to be copied."
   (interactive "BPrepend to buffer: \nr")
   (let ((oldbuf (current-buffer)))
-    (save-excursion
-      (set-buffer (get-buffer-create buffer))
+    (with-current-buffer (get-buffer-create buffer)
       (barf-if-buffer-read-only)
       (save-excursion
 	(insert-buffer-substring oldbuf start end)))))
--- a/lisp/speedbar.el	Fri Nov 13 17:03:30 2009 +0000
+++ b/lisp/speedbar.el	Fri Nov 13 22:19:45 2009 +0000
@@ -1173,8 +1173,7 @@
 	       (with-no-warnings
 		 (specifier-instance has-modeline-p)))
 	   speedbar-buffer)
-      (save-excursion
-	(set-buffer speedbar-buffer)
+      (with-current-buffer speedbar-buffer
 	(let* ((w (or (speedbar-frame-width) 20))
 	       (p1 "<<")
 	       (p5 ">>")
@@ -1246,8 +1245,7 @@
 			       (current-buffer))
 			      speedbar-special-mode-key-map)
 			(select-frame cf))))))
-    (save-excursion
-      (set-buffer speedbar-buffer)
+    (with-current-buffer speedbar-buffer
       (use-local-map (or localmap
 			 (speedbar-initial-keymap)
 			 ;; This creates a small keymap we can glom the
@@ -1859,8 +1857,7 @@
   (if (stringp buffer) (setq buffer (get-buffer buffer)))
   (if (not (buffer-live-p buffer))
       nil
-    (save-excursion
-      (set-buffer buffer)
+    (with-current-buffer buffer
       (save-match-data
 	(let ((ms (symbol-name major-mode)) v)
 	  (if (not (string-match "-mode$" ms))
@@ -1893,8 +1890,7 @@
 
 (defun speedbar-remove-localized-speedbar-support (buffer)
   "Remove any traces that BUFFER supports speedbar in a specialized way."
-  (save-excursion
-    (set-buffer buffer)
+  (with-current-buffer buffer
     (kill-local-variable 'speedbar-special-mode-expansion-list)
     (kill-local-variable 'speedbar-special-mode-key-map)
     (kill-local-variable 'speedbar-easymenu-definition-special)))
@@ -2383,8 +2379,8 @@
 	      (or (speedbar-line-file)
 		  (speedbar-line-directory))))
 	 (methods (if (get-file-buffer f)
-		      (save-excursion (set-buffer (get-file-buffer f))
-				      speedbar-tag-hierarchy-method)
+		      (with-current-buffer (get-file-buffer f)
+                        speedbar-tag-hierarchy-method)
 		    speedbar-tag-hierarchy-method))
 	 (lst (if (fboundp 'copy-tree)
 		  (copy-tree lst)
@@ -2612,9 +2608,8 @@
 This should only be used by modes classified as special."
   (let ((funclst speedbar-special-mode-expansion-list)
 	(specialbuff (current-buffer)))
-    (save-excursion
-      (setq speedbar-desired-buffer specialbuff)
-      (set-buffer speedbar-buffer)
+    (setq speedbar-desired-buffer specialbuff)
+    (with-current-buffer speedbar-buffer
       ;; If we are leaving a directory, cache it.
       (if (not speedbar-shown-directories)
 	  ;; Do nothing
@@ -3887,8 +3882,8 @@
 				    (buffer-name (car bl))))
 	       (expchar (if known ?+ ??))
 	       (fn (if known 'speedbar-tag-file nil))
-	       (fname (save-excursion (set-buffer (car bl))
-				      (buffer-file-name))))
+	       (fname (with-current-buffer (car bl)
+                        (buffer-file-name))))
 	  (speedbar-make-tag-line 'bracket expchar fn
 				  (if fname (file-name-nondirectory fname))
 				  (buffer-name (car bl))
@@ -3928,8 +3923,7 @@
   "Add a note to the end of the last tag line.
 Argument BUFFER is the buffer being tested."
   (let (mod ro)
-    (save-excursion
-      (set-buffer buffer)
+    (with-current-buffer buffer
       (setq mod (buffer-modified-p)
 	    ro buffer-read-only))
     (if ro (speedbar-insert-button "%" nil nil nil nil t))))
@@ -3943,9 +3937,8 @@
 	     (speedbar-message "%s%s %S %d %s"
 			       (if (buffer-modified-p buffer) "* " "")
 			       item
-			       (save-excursion (set-buffer buffer) major-mode)
-			       (save-excursion (set-buffer buffer)
-					       (buffer-size))
+			       (with-current-buffer buffer major-mode)
+			       (with-current-buffer buffer (buffer-size))
 			       (or (buffer-file-name buffer) "<No file>"))))))
 
 (defun speedbar-buffers-line-directory (&optional depth)
@@ -3963,8 +3956,7 @@
 	      (if (save-excursion
 		    (end-of-line)
 		    (eq start (point)))
-		  (or (save-excursion (set-buffer buffer)
-				      default-directory)
+		  (or (with-current-buffer buffer default-directory)
 		      "")
 		(buffer-file-name buffer))))))))
 
--- a/lisp/strokes.el	Fri Nov 13 17:03:30 2009 +0000
+++ b/lisp/strokes.el	Fri Nov 13 22:19:45 2009 +0000
@@ -1536,8 +1536,7 @@
 (defun strokes-xpm-to-compressed-string (&optional xpm-buffer)
   "Convert XPM in XPM-BUFFER to compressed string representing the stroke.
 XPM-BUFFER defaults to ` *strokes-xpm*'."
-  (save-excursion
-    (set-buffer (setq xpm-buffer (or xpm-buffer " *strokes-xpm*")))
+  (with-current-buffer (setq xpm-buffer (or xpm-buffer " *strokes-xpm*"))
     (goto-char (point-min))
     (search-forward "/* pixels */")	; skip past header junk
     (forward-char 2)
@@ -1620,8 +1619,7 @@
 Optional FORCE non-nil will ignore the buffer's read-only status."
   (interactive)
   ;;  (interactive "*bStrokify buffer: ")
-  (save-excursion
-    (set-buffer (setq buffer (get-buffer (or buffer (current-buffer)))))
+  (with-current-buffer (setq buffer (get-buffer (or buffer (current-buffer))))
     (when (or (not buffer-read-only)
 	      force
 	      inhibit-read-only
@@ -1669,8 +1667,7 @@
   ;; buffer is killed?
   ;;  (interactive "*bUnstrokify buffer: ")
   (interactive)
-  (save-excursion
-    (set-buffer (setq buffer (or buffer (current-buffer))))
+  (with-current-buffer (setq buffer (or buffer (current-buffer)))
     (when (or (not buffer-read-only)
 	      force
 	      inhibit-read-only
@@ -1706,9 +1703,8 @@
 (defun strokes-xpm-for-compressed-string (compressed-string &optional bufname)
   "Convert the stroke represented by COMPRESSED-STRING into an XPM.
 Store XPM in buffer BUFNAME if supplied \(default is ` *strokes-xpm*'\)"
-  (save-excursion
-    (or bufname (setq bufname " *strokes-xpm*"))
-    (set-buffer (get-buffer-create bufname))
+  (or bufname (setq bufname " *strokes-xpm*"))
+  (with-current-buffer (get-buffer-create bufname)
     (erase-buffer)
     (insert compressed-string)
     (goto-char (point-min))
--- a/lisp/term.el	Fri Nov 13 17:03:30 2009 +0000
+++ b/lisp/term.el	Fri Nov 13 22:19:45 2009 +0000
@@ -1347,8 +1347,7 @@
     ;; If no process, or nuked process, crank up a new one and put buffer in
     ;; term mode.  Otherwise, leave buffer and existing process alone.
     (cond ((not (term-check-proc buffer))
-	   (save-excursion
-	     (set-buffer buffer)
+	   (with-current-buffer buffer
 	     (term-mode)) ; Install local vars, mode, keymap, ...
 	   (term-exec buffer name program startfile switches)))
     buffer))
@@ -1375,8 +1374,7 @@
 Blasts any old process running in the buffer.  Doesn't set the buffer mode.
 You can use this to cheaply run a series of processes in the same term
 buffer.  The hook `term-exec-hook' is run after each exec."
-  (save-excursion
-    (set-buffer buffer)
+  (with-current-buffer buffer
     (let ((proc (get-buffer-process buffer)))	; Blast any old process.
       (when proc (delete-process proc)))
     ;; Crank up a new process
@@ -1412,24 +1410,16 @@
       (if (null (buffer-name buffer))
 	  ;; buffer killed
 	  (set-process-buffer proc nil)
-	(let ((obuf (current-buffer)))
-	  ;; save-excursion isn't the right thing if
-	  ;; process-buffer is current-buffer
-	  (unwind-protect
-	      (progn
-		;; Write something in the compilation buffer
-		;; and hack its mode line.
-		(set-buffer buffer)
-		;; Get rid of local keymap.
-		(use-local-map nil)
-		(term-handle-exit (process-name proc)
-				  msg)
-		;; Since the buffer and mode line will show that the
-		;; process is dead, we can delete it now.  Otherwise it
-		;; will stay around until M-x list-processes.
-		(delete-process proc))
-	    (set-buffer obuf)))
-	))))
+	(with-current-buffer buffer
+          ;; Write something in the compilation buffer
+          ;; and hack its mode line.
+          ;; Get rid of local keymap.
+          (use-local-map nil)
+          (term-handle-exit (process-name proc) msg)
+          ;; Since the buffer and mode line will show that the
+          ;; process is dead, we can delete it now.  Otherwise it
+          ;; will stay around until M-x list-processes.
+          (delete-process proc))))))
 
 (defun term-handle-exit (process-name msg)
   "Write process exit (or other change) message MSG in the current buffer."
@@ -1557,8 +1547,7 @@
 	       (count 0)
 	       (ring (make-ring term-input-ring-size)))
 	   (unwind-protect
-	       (save-excursion
-		 (set-buffer history-buf)
+	       (with-current-buffer history-buf
 		 (widen)
 		 (erase-buffer)
 		 (insert-file-contents file)
@@ -1601,8 +1590,7 @@
 		(index (ring-length ring)))
 	   ;; Write it all out into a buffer first.  Much faster, but messier,
 	   ;; than writing it one line at a time.
-	   (save-excursion
-	     (set-buffer history-buf)
+	   (with-current-buffer history-buf
 	     (erase-buffer)
 	     (while (> index 0)
 	       (setq index (1- index))
@@ -2460,10 +2448,8 @@
 	       (y-or-n-p (format "Save buffer %s first? "
 				 (buffer-name buff))))
       ;; save BUFF.
-      (let ((old-buffer (current-buffer)))
-	(set-buffer buff)
-	(save-buffer)
-	(set-buffer old-buffer)))))
+      (with-current-buffer buff
+	(save-buffer)))))
 
 
 ;; (TERM-GET-SOURCE prompt prev-dir/file source-modes mustmatch-p)
@@ -3453,8 +3439,7 @@
 (defun term-display-buffer-line (buffer line)
   (let* ((window (display-buffer buffer t))
 	 (pos))
-    (save-excursion
-      (set-buffer buffer)
+    (with-current-buffer buffer
       (save-restriction
 	(widen)
 	(goto-char (point-min))
@@ -3896,8 +3881,7 @@
 	     (message "Output logging off."))
     (if (get-buffer name)
 	nil
-      (save-excursion
-	(set-buffer (get-buffer-create name))
+      (with-current-buffer (get-buffer-create name)
 	(fundamental-mode)
 	(buffer-disable-undo (current-buffer))
 	(erase-buffer)))
@@ -4169,8 +4153,7 @@
       (display-completion-list (sort completions 'string-lessp)))
     (message "Hit space to flush")
     (let (key first)
-      (if (save-excursion
-	    (set-buffer (get-buffer "*Completions*"))
+      (if (with-current-buffer (get-buffer "*Completions*")
 	    (setq key (read-key-sequence nil)
 		  first (aref key 0))
 	    (and (consp first)
@@ -4197,8 +4180,7 @@
     ;; If no process, or nuked process, crank up a new one and put buffer in
     ;; term mode.  Otherwise, leave buffer and existing process alone.
     (cond ((not (term-check-proc buffer))
-	   (save-excursion
-	     (set-buffer buffer)
+	   (with-current-buffer buffer
 	     (term-mode)) ; Install local vars, mode, keymap, ...
 	   (term-exec buffer name program startfile switches)))
     buffer))
@@ -4383,8 +4365,7 @@
                    :coding 'no-conversion
                    :noquery t))
          (buffer (process-buffer process)))
-    (save-excursion
-      (set-buffer buffer)
+    (with-current-buffer buffer
       (term-mode)
       (term-char-mode)
       (goto-char (point-max))
--- a/lisp/terminal.el	Fri Nov 13 17:03:30 2009 +0000
+++ b/lisp/terminal.el	Fri Nov 13 22:19:45 2009 +0000
@@ -326,8 +326,7 @@
 	     (message "Output logging off."))
     (if (get-buffer name)
 	nil
-      (save-excursion
-	(set-buffer (get-buffer-create name))
+      (with-current-buffer (get-buffer-create name)
 	(fundamental-mode)
 	(buffer-disable-undo (current-buffer))
 	(erase-buffer)))
@@ -610,8 +609,7 @@
 			       "%-"))
   (set-process-filter te-process
     (function (lambda (process string)
-		(save-excursion
-		  (set-buffer (process-buffer process))
+		(with-current-buffer (process-buffer process)
 		  (setq te-pending-output (nconc te-pending-output
 						 (list string))))
 		  (te-update-pending-output-display))))
@@ -874,27 +872,22 @@
 
 
 (defun te-filter (process string)
-  (let* ((obuf (current-buffer)))
-    ;; can't use save-excursion, as that preserves point, which we don't want
-    (unwind-protect
-	(progn
-	  (set-buffer (process-buffer process))
-	  (goto-char te-saved-point)
-	  (and (bufferp te-log-buffer)
-	       (if (null (buffer-name te-log-buffer))
-		   ;; killed
-		   (setq te-log-buffer nil)
-		 (set-buffer te-log-buffer)
-		 (goto-char (point-max))
-		 (insert-before-markers string)
-		 (set-buffer (process-buffer process))))
-	  (setq te-pending-output (nconc te-pending-output (list string)))
-	  (te-update-pending-output-display)
-	  (te-process-output (eq (current-buffer)
-				 (window-buffer (selected-window))))
-	  (set-buffer (process-buffer process))
-	  (setq te-saved-point (point)))
-      (set-buffer obuf))))
+  (with-current-buffer (process-buffer process)
+    (goto-char te-saved-point)
+    (and (bufferp te-log-buffer)
+         (if (null (buffer-name te-log-buffer))
+             ;; killed
+             (setq te-log-buffer nil)
+           (set-buffer te-log-buffer)
+           (goto-char (point-max))
+           (insert-before-markers string)
+           (set-buffer (process-buffer process))))
+    (setq te-pending-output (nconc te-pending-output (list string)))
+    (te-update-pending-output-display)
+    (te-process-output (eq (current-buffer)
+                           (window-buffer (selected-window))))
+    (set-buffer (process-buffer process))
+    (setq te-saved-point (point))))
 
 ;; (A version of the following comment which might be distractingly offensive
 ;; to some readers has been moved to term-nasty.el.)
@@ -1043,8 +1036,7 @@
   (cond ((eq (process-status process) 'run))
 	((null (buffer-name (process-buffer process)))) ;deleted
 	(t (let ((b (current-buffer)))
-	     (save-excursion
-	       (set-buffer (process-buffer process))
+	     (with-current-buffer (process-buffer process)
 	       (setq buffer-read-only nil)
 	       (fundamental-mode)
 	       (goto-char (point-max))
@@ -1097,27 +1089,26 @@
 and is non-nil after the terminal buffer has been set up and the
 subprocess started."
   (interactive
-    (cons (save-excursion
-	    (set-buffer (get-buffer-create "*terminal*"))
-	    (buffer-name (if (or (not (boundp 'te-process))
-				 (null te-process)
-				 (not (eq (process-status te-process)
-					  'run)))
-			     (current-buffer)
-			   (generate-new-buffer "*terminal*"))))
-	  (append
-	    (let* ((default-s
-		     ;; Default shell is same thing M-x shell uses.
-		     (or explicit-shell-file-name
-			 (getenv "ESHELL")
-			 (getenv "SHELL")
-			 "/bin/sh"))
-		   (s (read-string
-		       (format "Run program in emulator (default %s): "
-			       default-s))))
-	      (if (equal s "")
-		  (list default-s '())
-		(te-parse-program-and-args s))))))
+   (cons (with-current-buffer (get-buffer-create "*terminal*")
+           (buffer-name (if (or (not (boundp 'te-process))
+                                (null te-process)
+                                (not (eq (process-status te-process)
+                                         'run)))
+                            (current-buffer)
+                          (generate-new-buffer "*terminal*"))))
+         (append
+          (let* ((default-s
+                   ;; Default shell is same thing M-x shell uses.
+                   (or explicit-shell-file-name
+                       (getenv "ESHELL")
+                       (getenv "SHELL")
+                       "/bin/sh"))
+                 (s (read-string
+                     (format "Run program in emulator (default %s): "
+                             default-s))))
+            (if (equal s "")
+                (list default-s '())
+              (te-parse-program-and-args s))))))
   (switch-to-buffer buffer)
   (if (null width) (setq width (- (window-width (selected-window)) 1)))
   (if (null height) (setq height (- (window-height (selected-window)) 1)))
--- a/lisp/time-stamp.el	Fri Nov 13 17:03:30 2009 +0000
+++ b/lisp/time-stamp.el	Fri Nov 13 22:19:45 2009 +0000
@@ -660,8 +660,7 @@
 Suggests replacing OLD-FORM with NEW-FORM."
   (cond
    (time-stamp-conversion-warn
-    (save-excursion
-      (set-buffer (get-buffer-create "*Time-stamp-compatibility*"))
+    (with-current-buffer (get-buffer-create "*Time-stamp-compatibility*")
       (goto-char (point-max))
       (if (bobp)
 	  (progn
--- a/lisp/type-break.el	Fri Nov 13 17:03:30 2009 +0000
+++ b/lisp/type-break.el	Fri Nov 13 22:19:45 2009 +0000
@@ -1094,7 +1094,7 @@
 (defun type-break-force-mode-line-update (&optional all)
   "Force the mode-line of the current buffer to be redisplayed.
 With optional non-nil ALL, force redisplay of all mode-lines."
-  (and all (save-excursion (set-buffer (other-buffer))))
+  (and all (with-current-buffer (other-buffer)))
   (set-buffer-modified-p (buffer-modified-p)))
 
 ;; If an exception occurs in Emacs while running the post command hook, the
@@ -1108,9 +1108,9 @@
 
 
 ;;; Timer wrapper functions
-;;;
-;;; These shield type-break from variations in the interval timer packages
-;;; for different versions of Emacs.
+;;
+;; These shield type-break from variations in the interval timer packages
+;; for different versions of Emacs.
 
 (defun type-break-run-at-time (time repeat function)
   (condition-case nil (or (require 'timer) (require 'itimer)) (error nil))
--- a/lisp/userlock.el	Fri Nov 13 17:03:30 2009 +0000
+++ b/lisp/userlock.el	Fri Nov 13 22:19:45 2009 +0000
@@ -91,8 +91,7 @@
   intruder if (s)he ever unmodifies the file and then changes it again.
 You can <p>roceed; you edit at your own (and the other user's) risk.
 You can <q>uit; don't modify this file.")
-    (save-excursion
-      (set-buffer standard-output)
+    (with-current-buffer standard-output
       (help-mode))))
 
 (put
@@ -155,8 +154,7 @@
 
 Usually, you should type `n' and then `M-x revert-buffer',
 to get the latest version of the file, then make the change again.")
-    (save-excursion
-      (set-buffer standard-output)
+    (with-current-buffer standard-output
       (help-mode))))
 
 ;; arch-tag: a61c5b60-e1c8-44fd-894a-c617f4dfc639
--- a/lisp/vc-rcs.el	Fri Nov 13 17:03:30 2009 +0000
+++ b/lisp/vc-rcs.el	Fri Nov 13 22:19:45 2009 +0000
@@ -1055,65 +1055,64 @@
   (cond
    ((not (get-file-buffer file)) nil)
    ((let (status version locking-user)
-     (save-excursion
-      (set-buffer (get-file-buffer file))
-      (goto-char (point-min))
-      (cond
-       ;; search for $Id or $Header
-       ;; -------------------------
-       ;; The `\ 's below avoid an RCS 5.7 bug when checking in this file.
-       ((or (and (search-forward "$Id\ : " nil t)
-		 (looking-at "[^ ]+ \\([0-9.]+\\) "))
-	    (and (progn (goto-char (point-min))
-			(search-forward "$Header\ : " nil t))
-		 (looking-at "[^ ]+ \\([0-9.]+\\) ")))
-	(goto-char (match-end 0))
-	;; if found, store the revision number ...
-	(setq version (match-string-no-properties 1))
-	;; ... and check for the locking state
-	(cond
-	 ((looking-at
-	   (concat "[0-9]+[/-][01][0-9][/-][0-3][0-9] "             ; date
-	    "[0-2][0-9]:[0-5][0-9]+:[0-6][0-9]+\\([+-][0-9:]+\\)? " ; time
-	           "[^ ]+ [^ ]+ "))                       ; author & state
-	  (goto-char (match-end 0)) ; [0-6] in regexp handles leap seconds
-	  (cond
-	   ;; unlocked revision
-	   ((looking-at "\\$")
-	    (setq locking-user 'none)
-	    (setq status 'rev-and-lock))
-	   ;; revision is locked by some user
-	   ((looking-at "\\([^ ]+\\) \\$")
-	    (setq locking-user (match-string-no-properties 1))
-	    (setq status 'rev-and-lock))
-	   ;; everything else: false
-	   (nil)))
-	 ;; unexpected information in
-	 ;; keyword string --> quit
-	 (nil)))
-       ;; search for $Revision
-       ;; --------------------
-       ((re-search-forward (concat "\\$"
-				   "Revision: \\([0-9.]+\\) \\$")
-			   nil t)
-	;; if found, store the revision number ...
-	(setq version (match-string-no-properties 1))
-	;; and see if there's any lock information
-	(goto-char (point-min))
-	(if (re-search-forward (concat "\\$" "Locker:") nil t)
-	    (cond ((looking-at " \\([^ ]+\\) \\$")
-		   (setq locking-user (match-string-no-properties 1))
-		   (setq status 'rev-and-lock))
-		  ((looking-at " *\\$")
-		   (setq locking-user 'none)
-		   (setq status 'rev-and-lock))
-		  (t
-		   (setq locking-user 'none)
-		   (setq status 'rev-and-lock)))
-	  (setq status 'rev)))
-       ;; else: nothing found
-       ;; -------------------
-       (t nil)))
+      (with-current-buffer (get-file-buffer file)
+        (goto-char (point-min))
+        (cond
+         ;; search for $Id or $Header
+         ;; -------------------------
+         ;; The `\ 's below avoid an RCS 5.7 bug when checking in this file.
+         ((or (and (search-forward "$Id\ : " nil t)
+                   (looking-at "[^ ]+ \\([0-9.]+\\) "))
+              (and (progn (goto-char (point-min))
+                          (search-forward "$Header\ : " nil t))
+                   (looking-at "[^ ]+ \\([0-9.]+\\) ")))
+          (goto-char (match-end 0))
+          ;; if found, store the revision number ...
+          (setq version (match-string-no-properties 1))
+          ;; ... and check for the locking state
+          (cond
+           ((looking-at
+             (concat "[0-9]+[/-][01][0-9][/-][0-3][0-9] "             ; date
+              "[0-2][0-9]:[0-5][0-9]+:[0-6][0-9]+\\([+-][0-9:]+\\)? " ; time
+                     "[^ ]+ [^ ]+ "))                       ; author & state
+            (goto-char (match-end 0)) ; [0-6] in regexp handles leap seconds
+            (cond
+             ;; unlocked revision
+             ((looking-at "\\$")
+              (setq locking-user 'none)
+              (setq status 'rev-and-lock))
+             ;; revision is locked by some user
+             ((looking-at "\\([^ ]+\\) \\$")
+              (setq locking-user (match-string-no-properties 1))
+              (setq status 'rev-and-lock))
+             ;; everything else: false
+             (nil)))
+           ;; unexpected information in
+           ;; keyword string --> quit
+           (nil)))
+         ;; search for $Revision
+         ;; --------------------
+         ((re-search-forward (concat "\\$"
+                                     "Revision: \\([0-9.]+\\) \\$")
+                             nil t)
+          ;; if found, store the revision number ...
+          (setq version (match-string-no-properties 1))
+          ;; and see if there's any lock information
+          (goto-char (point-min))
+          (if (re-search-forward (concat "\\$" "Locker:") nil t)
+              (cond ((looking-at " \\([^ ]+\\) \\$")
+                     (setq locking-user (match-string-no-properties 1))
+                     (setq status 'rev-and-lock))
+                    ((looking-at " *\\$")
+                     (setq locking-user 'none)
+                     (setq status 'rev-and-lock))
+                    (t
+                     (setq locking-user 'none)
+                     (setq status 'rev-and-lock)))
+            (setq status 'rev)))
+         ;; else: nothing found
+         ;; -------------------
+         (t nil)))
      (if status (vc-file-setprop file 'vc-working-revision version))
      (and (eq status 'rev-and-lock)
 	  (vc-file-setprop file 'vc-state
--- a/lisp/whitespace.el	Fri Nov 13 17:03:30 2009 +0000
+++ b/lisp/whitespace.el	Fri Nov 13 22:19:45 2009 +0000
@@ -1942,8 +1942,7 @@
   (unless (get-buffer whitespace-help-buffer-name)
     (delete-other-windows)
     (let ((buffer (get-buffer-create whitespace-help-buffer-name)))
-      (save-excursion
-	(set-buffer buffer)
+      (with-current-buffer buffer
 	(erase-buffer)
 	(insert whitespace-help-text)
 	(whitespace-insert-option-mark
--- a/lisp/window.el	Fri Nov 13 17:03:30 2009 +0000
+++ b/lisp/window.el	Fri Nov 13 22:19:45 2009 +0000
@@ -1270,8 +1270,7 @@
 	 (setq size (+ (window-height) size)))
     (setq new-window (split-window nil size))
     (unless split-window-keep-point
-      (save-excursion
-	(set-buffer (window-buffer))
+      (with-current-buffer (window-buffer)
 	(goto-char (window-start))
 	(setq moved (vertical-motion (window-height)))
 	(set-window-start new-window (point))
--- a/lisp/x-dnd.el	Fri Nov 13 17:03:30 2009 +0000
+++ b/lisp/x-dnd.el	Fri Nov 13 22:19:45 2009 +0000
@@ -175,10 +175,10 @@
   (let ((buffer (when (window-live-p window)
 		  (window-buffer window)))
 	(current-state (x-dnd-get-state-for-frame window)))
-    (when (or (not (equal buffer (aref current-state 0)))
-	      (not (equal window (aref current-state 1)))
-	      (not (equal action (aref current-state 3))))
-      (save-excursion
+    (unless (and (equal buffer (aref current-state 0))
+                 (equal window (aref current-state 1))
+                 (equal action (aref current-state 3)))
+      (save-current-buffer
 	(when buffer (set-buffer buffer))
 	(let* ((action-type (funcall x-dnd-test-function
 				     window