aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lisp/ChangeLog92
-rw-r--r--lisp/allout.el8
-rw-r--r--lisp/apropos.el3
-rw-r--r--lisp/chistory.el3
-rw-r--r--lisp/dabbrev.el6
-rw-r--r--lisp/dired-aux.el6
-rw-r--r--lisp/dired.el3
-rw-r--r--lisp/disp-table.el3
-rw-r--r--lisp/dos-w32.el3
-rw-r--r--lisp/echistory.el3
-rw-r--r--lisp/ediff-diff.el9
-rw-r--r--lisp/ediff-mult.el10
-rw-r--r--lisp/ediff-util.el3
-rw-r--r--lisp/ediff-vers.el3
-rw-r--r--lisp/ediff.el6
-rw-r--r--lisp/ehelp.el6
-rw-r--r--lisp/emerge.el12
-rw-r--r--lisp/epa.el18
-rw-r--r--lisp/epg.el6
-rw-r--r--lisp/ezimage.el6
-rw-r--r--lisp/facemenu.el3
-rw-r--r--lisp/faces.el6
-rw-r--r--lisp/files.el3
-rw-r--r--lisp/filesets.el3
-rw-r--r--lisp/find-dired.el3
-rw-r--r--lisp/finder.el3
-rw-r--r--lisp/generic-x.el4
-rw-r--r--lisp/help-fns.el3
-rw-r--r--lisp/help-mode.el3
-rw-r--r--lisp/hippie-exp.el3
-rw-r--r--lisp/ido.el6
-rw-r--r--lisp/informat.el3
-rw-r--r--lisp/ledit.el20
-rw-r--r--lisp/macros.el3
-rw-r--r--lisp/menu-bar.el3
-rw-r--r--lisp/mouse-copy.el3
-rw-r--r--lisp/mouse.el6
-rw-r--r--lisp/novice.el13
-rw-r--r--lisp/printing.el29
-rw-r--r--lisp/ps-bdf.el6
-rw-r--r--lisp/ps-print.el18
-rw-r--r--lisp/ps-samp.el3
-rw-r--r--lisp/saveplace.el13
-rw-r--r--lisp/sb-image.el3
-rw-r--r--lisp/scroll-bar.el13
-rw-r--r--lisp/shadowfile.el3
-rw-r--r--lisp/simple.el15
-rw-r--r--lisp/speedbar.el36
-rw-r--r--lisp/strokes.el14
-rw-r--r--lisp/term.el61
-rw-r--r--lisp/terminal.el87
-rw-r--r--lisp/time-stamp.el3
-rw-r--r--lisp/type-break.el8
-rw-r--r--lisp/userlock.el6
-rw-r--r--lisp/vc-rcs.el117
-rw-r--r--lisp/whitespace.el3
-rw-r--r--lisp/window.el3
-rw-r--r--lisp/x-dnd.el8
58 files changed, 348 insertions, 401 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 9dd140a8a08..907292a0c2d 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,12 +1,94 @@
12009-11-13 Stefan Monnier <monnier@iro.umontreal.ca>
2
3 * x-dnd.el (x-dnd-maybe-call-test-function):
4 * window.el (split-window-vertically):
5 * whitespace.el (whitespace-help-on):
6 * vc-rcs.el (vc-rcs-consult-headers):
7 * userlock.el (ask-user-about-lock-help)
8 (ask-user-about-supersession-help):
9 * type-break.el (type-break-force-mode-line-update):
10 * time-stamp.el (time-stamp-conv-warn):
11 * terminal.el (te-set-output-log, te-more-break, te-filter)
12 (te-sentinel,terminal-emulator):
13 * term.el (make-term, term-exec, term-sentinel, term-read-input-ring)
14 (term-write-input-ring, term-check-source, term-start-output-log):
15 (term-display-buffer-line, term-dynamic-list-completions):
16 (term-ansi-make-term, serial-term):
17 * subr.el (selective-display):
18 * strokes.el (strokes-xpm-to-compressed-string, strokes-decode-buffer)
19 (strokes-encode-buffer, strokes-xpm-for-compressed-string):
20 * speedbar.el (speedbar-buffers-tail-notes, speedbar-buffers-item-info)
21 (speedbar-reconfigure-keymaps, speedbar-add-localized-speedbar-support)
22 (speedbar-remove-localized-speedbar-support)
23 (speedbar-set-mode-line-format, speedbar-create-tag-hierarchy)
24 (speedbar-update-special-contents, speedbar-buffer-buttons-engine)
25 (speedbar-buffers-line-directory):
26 * simple.el (shell-command-on-region, append-to-buffer)
27 (prepend-to-buffer):
28 * shadowfile.el (shadow-save-todo-file):
29 * scroll-bar.el (scroll-bar-set-window-start, scroll-bar-drag-1)
30 (scroll-bar-maybe-set-window-start):
31 * sb-image.el (speedbar-image-dump):
32 * saveplace.el (save-place-alist-to-file, save-places-to-alist)
33 (load-save-place-alist-from-file):
34 * ps-samp.el (ps-print-message-from-summary):
35 * ps-print.el (ps-flush-output, ps-insert-file, ps-get-boundingbox)
36 (ps-background-image, ps-begin-job, ps-do-despool):
37 * ps-bdf.el (bdf-find-file, bdf-read-font-info):
38 * printing.el (pr-interface, pr-ps-file-print, pr-find-buffer-visiting)
39 (pr-ps-message-from-summary, pr-lpr-message-from-summary):
40 (pr-call-process, pr-file-list, pr-interface-save):
41 * novice.el (disabled-command-function)
42 (enable-command, disable-command):
43 * mouse.el (mouse-buffer-menu-alist):
44 * mouse-copy.el (mouse-kill-preserving-secondary):
45 * macros.el (kbd-macro-query):
46 * ledit.el (ledit-go-to-lisp, ledit-go-to-liszt):
47 * informat.el (batch-info-validate):
48 * ido.el (ido-copy-current-word, ido-initiate-auto-merge):
49 * hippie-exp.el (try-expand-dabbrev-visible):
50 * help-mode.el (help-make-xrefs):
51 * help-fns.el (describe-variable):
52 * generic-x.el (bat-generic-mode-run-as-comint):
53 * finder.el (finder-mouse-select):
54 * find-dired.el (find-dired-sentinel):
55 * filesets.el (filesets-file-close):
56 * files.el (list-directory):
57 * faces.el (list-faces-display, describe-face):
58 * facemenu.el (list-colors-display):
59 * ezimage.el (ezimage-image-association-dump, ezimage-image-dump):
60 * epg.el (epg--process-filter, epg-cancel):
61 * epa.el (epa--marked-keys, epa--select-keys, epa-display-info)
62 (epa--read-signature-type):
63 * emerge.el (emerge-copy-as-kill-A, emerge-copy-as-kill-B)
64 (emerge-file-names):
65 * ehelp.el (electric-helpify):
66 * ediff.el (ediff-regions-wordwise, ediff-regions-linewise):
67 * ediff-vers.el (rcs-ediff-view-revision):
68 * ediff-util.el (ediff-setup):
69 * ediff-mult.el (ediff-append-custom-diff):
70 * ediff-diff.el (ediff-exec-process, ediff-process-sentinel)
71 (ediff-wordify):
72 * echistory.el (Electric-command-history-redo-expression):
73 * dos-w32.el (find-file-not-found-set-buffer-file-coding-system):
74 * disp-table.el (describe-display-table):
75 * dired.el (dired-find-buffer-nocreate):
76 * dired-aux.el (dired-rename-subdir, dired-dwim-target-directory):
77 * dabbrev.el (dabbrev--same-major-mode-p):
78 * chistory.el (list-command-history):
79 * apropos.el (apropos-documentation):
80 * allout.el (allout-obtain-passphrase):
81 (allout-copy-exposed-to-buffer):
82 (allout-verify-passphrase): Use with-current-buffer.
83
12009-11-13 Glenn Morris <rgm@gnu.org> 842009-11-13 Glenn Morris <rgm@gnu.org>
2 85
3 * Makefile.in (ELCFILES): Regenerate. 86 * Makefile.in (ELCFILES): Regenerate.
4 87
52009-11-13 Michael Albinus <michael.albinus@gmx.de> 882009-11-13 Michael Albinus <michael.albinus@gmx.de>
6 89
7 * net/dbus.el (dbus-registered-objects-table): Renamed from 90 * net/dbus.el (dbus-registered-objects-table): Rename from
8 `dbus-registered-functions-table', because it contains also 91 `dbus-registered-functions-table', because it contains also properties.
9 properties.
10 (dbus-unregister-object): Unregister also properties. 92 (dbus-unregister-object): Unregister also properties.
11 (dbus-get-property, dbus-set-property, dbus-get-all-properties): 93 (dbus-get-property, dbus-set-property, dbus-get-all-properties):
12 Use a timeout of 500 msec, in order to not block. 94 Use a timeout of 500 msec, in order to not block.
@@ -448,8 +530,8 @@
448 * custom.el (custom-declare-group): Purecopy standard-value. 530 * custom.el (custom-declare-group): Purecopy standard-value.
449 (custom-declare-group): Purecopy custom-prefix. 531 (custom-declare-group): Purecopy custom-prefix.
450 532
451 * international/mule.el (load-with-code-conversion): Call 533 * international/mule.el (load-with-code-conversion):
452 do-after-load-evaluation unconditionally. 534 Call do-after-load-evaluation unconditionally.
453 535
454 * emacs-lisp/bytecomp.el (byte-compile-output-file-form): Handle defvaralias. 536 * emacs-lisp/bytecomp.el (byte-compile-output-file-form): Handle defvaralias.
455 537
diff --git a/lisp/allout.el b/lisp/allout.el
index 46ecfed96da..e0b2536d2ae 100644
--- a/lisp/allout.el
+++ b/lisp/allout.el
@@ -5605,7 +5605,7 @@ alternate presentation format for the outline:
5605 (goto-char beg) 5605 (goto-char beg)
5606 (allout-topic-flat-index)) 5606 (allout-topic-flat-index))
5607 '(1)))) 5607 '(1))))
5608 (save-excursion (set-buffer tobuf)(erase-buffer)) 5608 (with-current-buffer tobuf (erase-buffer))
5609 (allout-process-exposed 'allout-insert-listified 5609 (allout-process-exposed 'allout-insert-listified
5610 beg 5610 beg
5611 end 5611 end
@@ -6283,8 +6283,7 @@ of the availability of a cached copy."
6283 6283
6284 ;; Symmetric hereon: 6284 ;; Symmetric hereon:
6285 6285
6286 (save-excursion 6286 (with-current-buffer allout-buffer
6287 (set-buffer allout-buffer)
6288 (let* ((hint (if (and (not (string= allout-passphrase-hint-string "")) 6287 (let* ((hint (if (and (not (string= allout-passphrase-hint-string ""))
6289 (or (equal allout-passphrase-hint-handling 'always) 6288 (or (equal allout-passphrase-hint-handling 'always)
6290 (and (equal allout-passphrase-hint-handling 6289 (and (equal allout-passphrase-hint-handling
@@ -6481,8 +6480,7 @@ Derived from value of `allout-passphrase-verifier-string'."
6481 "True if passphrase successfully decrypts verifier, nil otherwise. 6480 "True if passphrase successfully decrypts verifier, nil otherwise.
6482 6481
6483\"Otherwise\" includes absence of passphrase verifier." 6482\"Otherwise\" includes absence of passphrase verifier."
6484 (save-excursion 6483 (with-current-buffer allout-buffer
6485 (set-buffer allout-buffer)
6486 (and (boundp 'allout-passphrase-verifier-string) 6484 (and (boundp 'allout-passphrase-verifier-string)
6487 allout-passphrase-verifier-string 6485 allout-passphrase-verifier-string
6488 (allout-encrypt-string (allout-get-encryption-passphrase-verifier) 6486 (allout-encrypt-string (allout-get-encryption-passphrase-verifier)
diff --git a/lisp/apropos.el b/lisp/apropos.el
index 45463784cbc..1ee3bedbd31 100644
--- a/lisp/apropos.el
+++ b/lisp/apropos.el
@@ -736,8 +736,7 @@ Returns list of symbols and documentation found."
736 (apropos-sort-by-scores apropos-documentation-sort-by-scores) 736 (apropos-sort-by-scores apropos-documentation-sort-by-scores)
737 f v sf sv) 737 f v sf sv)
738 (unwind-protect 738 (unwind-protect
739 (save-excursion 739 (with-current-buffer standard-input
740 (set-buffer standard-input)
741 (apropos-documentation-check-doc-file) 740 (apropos-documentation-check-doc-file)
742 (if do-all 741 (if do-all
743 (mapatoms 742 (mapatoms
diff --git a/lisp/chistory.el b/lisp/chistory.el
index af25175f7c2..0220673ec02 100644
--- a/lisp/chistory.el
+++ b/lisp/chistory.el
@@ -116,8 +116,7 @@ The buffer is left in Command History mode."
116 (prin1 (car history)) 116 (prin1 (car history))
117 (terpri)) 117 (terpri))
118 (setq history (cdr history)))) 118 (setq history (cdr history))))
119 (save-excursion 119 (with-current-buffer "*Command History*"
120 (set-buffer "*Command History*")
121 (goto-char (point-min)) 120 (goto-char (point-min))
122 (if (eobp) 121 (if (eobp)
123 (error "No command history") 122 (error "No command history")
diff --git a/lisp/dabbrev.el b/lisp/dabbrev.el
index ab9cae6fed8..115d579a079 100644
--- a/lisp/dabbrev.el
+++ b/lisp/dabbrev.el
@@ -62,8 +62,7 @@
62;; the article for expansion): 62;; the article for expansion):
63;; (set (make-local-variable 'dabbrev-friend-buffer-function) 63;; (set (make-local-variable 'dabbrev-friend-buffer-function)
64;; (lambda (buffer) 64;; (lambda (buffer)
65;; (save-excursion 65;; (with-current-buffer buffer
66;; (set-buffer buffer)
67;; (memq major-mode '(news-reply-mode gnus-article-mode))))) 66;; (memq major-mode '(news-reply-mode gnus-article-mode)))))
68 67
69 68
@@ -594,8 +593,7 @@ See also `dabbrev-abbrev-char-regexp' and \\[dabbrev-completion]."
594;;; Checks if OTHER-BUFFER has the same major mode as current buffer. 593;;; Checks if OTHER-BUFFER has the same major mode as current buffer.
595(defun dabbrev--same-major-mode-p (other-buffer) 594(defun dabbrev--same-major-mode-p (other-buffer)
596 (eq major-mode 595 (eq major-mode
597 (save-excursion 596 (with-current-buffer other-buffer
598 (set-buffer other-buffer)
599 major-mode))) 597 major-mode)))
600 598
601;;; Back over all abbrev type characters and then moves forward over 599;;; Back over all abbrev type characters and then moves forward over
diff --git a/lisp/dired-aux.el b/lisp/dired-aux.el
index 95cdc7669bf..ffe02cacdac 100644
--- a/lisp/dired-aux.el
+++ b/lisp/dired-aux.el
@@ -1251,8 +1251,7 @@ Special value `always' suppresses confirmation."
1251 (let ((expanded-from-dir (expand-file-name from-dir)) 1251 (let ((expanded-from-dir (expand-file-name from-dir))
1252 (blist (buffer-list))) 1252 (blist (buffer-list)))
1253 (while blist 1253 (while blist
1254 (save-excursion 1254 (with-current-buffer (car blist)
1255 (set-buffer (car blist))
1256 (if (and buffer-file-name 1255 (if (and buffer-file-name
1257 (dired-in-this-tree buffer-file-name expanded-from-dir)) 1256 (dired-in-this-tree buffer-file-name expanded-from-dir))
1258 (let ((modflag (buffer-modified-p)) 1257 (let ((modflag (buffer-modified-p))
@@ -1530,8 +1529,7 @@ Optional arg HOW-TO determiness how to treat the target.
1530 ;; non-dired buffer may want to profit from this function, e.g. vm-uudecode 1529 ;; non-dired buffer may want to profit from this function, e.g. vm-uudecode
1531 (if dired-dwim-target 1530 (if dired-dwim-target
1532 (let* ((other-buf (window-buffer (next-window))) 1531 (let* ((other-buf (window-buffer (next-window)))
1533 (other-dir (save-excursion 1532 (other-dir (with-current-buffer other-buf
1534 (set-buffer other-buf)
1535 (and (eq major-mode 'dired-mode) 1533 (and (eq major-mode 'dired-mode)
1536 (dired-current-directory))))) 1534 (dired-current-directory)))))
1537 (or other-dir this-dir)) 1535 (or other-dir this-dir))
diff --git a/lisp/dired.el b/lisp/dired.el
index cf78354ad8f..d4e79485bcd 100644
--- a/lisp/dired.el
+++ b/lisp/dired.el
@@ -819,8 +819,7 @@ for a remote directory. This feature is used by Auto Revert Mode."
819 (while blist 819 (while blist
820 (if (null (buffer-name (cdr (car blist)))) 820 (if (null (buffer-name (cdr (car blist))))
821 (setq blist (cdr blist)) 821 (setq blist (cdr blist))
822 (save-excursion 822 (with-current-buffer (cdr (car blist))
823 (set-buffer (cdr (car blist)))
824 (if (and (eq major-mode mode) 823 (if (and (eq major-mode mode)
825 dired-directory ;; nil during find-alternate-file 824 dired-directory ;; nil during find-alternate-file
826 (equal dirname 825 (equal dirname
diff --git a/lisp/disp-table.el b/lisp/disp-table.el
index 91dc4a7fd34..5c1401bc604 100644
--- a/lisp/disp-table.el
+++ b/lisp/disp-table.el
@@ -87,8 +87,7 @@ Valid symbols are `truncation', `wrap', `escape', `control',
87 (princ "\nVertical window border glyph: ") 87 (princ "\nVertical window border glyph: ")
88 (prin1 (display-table-slot dt 'vertical-border)) 88 (prin1 (display-table-slot dt 'vertical-border))
89 (princ "\nCharacter display glyph sequences:\n") 89 (princ "\nCharacter display glyph sequences:\n")
90 (save-excursion 90 (with-current-buffer standard-output
91 (set-buffer standard-output)
92 (let ((vector (make-vector 256 nil)) 91 (let ((vector (make-vector 256 nil))
93 (i 0)) 92 (i 0))
94 (while (< i 256) 93 (while (< i 256)
diff --git a/lisp/dos-w32.el b/lisp/dos-w32.el
index 9bec5b7a1db..2c98417caea 100644
--- a/lisp/dos-w32.el
+++ b/lisp/dos-w32.el
@@ -197,8 +197,7 @@ set to the appropriate coding system, and the value of
197 (find-file filename))) 197 (find-file filename)))
198 198
199(defun find-file-not-found-set-buffer-file-coding-system () 199(defun find-file-not-found-set-buffer-file-coding-system ()
200 (save-excursion 200 (with-current-buffer (current-buffer)
201 (set-buffer (current-buffer))
202 (let ((coding buffer-file-coding-system)) 201 (let ((coding buffer-file-coding-system))
203 ;; buffer-file-coding-system is already set by 202 ;; buffer-file-coding-system is already set by
204 ;; find-operation-coding-system, which was called from 203 ;; find-operation-coding-system, which was called from
diff --git a/lisp/echistory.el b/lisp/echistory.el
index 3d783ffa8fa..8d1bfb92a00 100644
--- a/lisp/echistory.el
+++ b/lisp/echistory.el
@@ -34,8 +34,7 @@
34With prefix arg NOCONFIRM, execute current line as-is without editing." 34With prefix arg NOCONFIRM, execute current line as-is without editing."
35 (interactive "P") 35 (interactive "P")
36 (let (todo) 36 (let (todo)
37 (save-excursion 37 (with-current-buffer "*Command History*"
38 (set-buffer "*Command History*")
39 (beginning-of-line) 38 (beginning-of-line)
40 (setq todo (read (current-buffer))) 39 (setq todo (read (current-buffer)))
41 (if (boundp 'electric-history-in-progress) 40 (if (boundp 'electric-history-in-progress)
diff --git a/lisp/ediff-diff.el b/lisp/ediff-diff.el
index 75379f3da7a..7159657a816 100644
--- a/lisp/ediff-diff.el
+++ b/lisp/ediff-diff.el
@@ -1225,8 +1225,7 @@ delimiter regions"))
1225 (unwind-protect 1225 (unwind-protect
1226 (let ((directory default-directory) 1226 (let ((directory default-directory)
1227 proc) 1227 proc)
1228 (save-excursion 1228 (with-current-buffer buffer
1229 (set-buffer buffer)
1230 (erase-buffer) 1229 (erase-buffer)
1231 (setq default-directory directory) 1230 (setq default-directory directory)
1232 (if (or (memq system-type '(emx ms-dos windows-nt windows-95)) 1231 (if (or (memq system-type '(emx ms-dos windows-nt windows-95))
@@ -1283,8 +1282,7 @@ delimiter regions"))
1283 (if (and (memq (process-status process) '(exit signal)) 1282 (if (and (memq (process-status process) '(exit signal))
1284 (buffer-name (process-buffer process))) 1283 (buffer-name (process-buffer process)))
1285 (progn 1284 (progn
1286 (save-excursion 1285 (with-current-buffer (process-buffer process)
1287 (set-buffer (process-buffer process))
1288 (setq mode-line-process nil)) 1286 (setq mode-line-process nil))
1289 (delete-process process)))) 1287 (delete-process process))))
1290 1288
@@ -1354,8 +1352,7 @@ arguments to `skip-chars-forward'."
1354 ediff-forward-word-function) 1352 ediff-forward-word-function)
1355 ediff-forward-word-function)) 1353 ediff-forward-word-function))
1356 inbuf-syntax-tbl sv-point diff-string) 1354 inbuf-syntax-tbl sv-point diff-string)
1357 (save-excursion 1355 (with-current-buffer in-buffer
1358 (set-buffer in-buffer)
1359 (setq inbuf-syntax-tbl 1356 (setq inbuf-syntax-tbl
1360 (if control-buf 1357 (if control-buf
1361 (ediff-with-current-buffer control-buf 1358 (ediff-with-current-buffer control-buf
diff --git a/lisp/ediff-mult.el b/lisp/ediff-mult.el
index b9ffb373766..a1dfbded153 100644
--- a/lisp/ediff-mult.el
+++ b/lisp/ediff-mult.el
@@ -1639,8 +1639,7 @@ Useful commands:
1639 (cond ((ediff-buffer-live-p custom-diff-buf) 1639 (cond ((ediff-buffer-live-p custom-diff-buf)
1640 ;; for live session buffers we do them first because the user may 1640 ;; for live session buffers we do them first because the user may
1641 ;; have changed them with respect to the underlying files 1641 ;; have changed them with respect to the underlying files
1642 (save-excursion 1642 (with-current-buffer meta-diff-buff
1643 (set-buffer meta-diff-buff)
1644 (goto-char (point-max)) 1643 (goto-char (point-max))
1645 (insert-buffer-substring custom-diff-buf) 1644 (insert-buffer-substring custom-diff-buf)
1646 (insert "\n"))) 1645 (insert "\n")))
@@ -1649,8 +1648,8 @@ Useful commands:
1649 ediff-merge-directories 1648 ediff-merge-directories
1650 ediff-merge-directories-with-ancestor)) 1649 ediff-merge-directories-with-ancestor))
1651 ;; get diffs by calling shell command on ediff-custom-diff-program 1650 ;; get diffs by calling shell command on ediff-custom-diff-program
1652 (save-excursion 1651 (with-current-buffer
1653 (set-buffer (setq tmp-buf (get-buffer-create ediff-tmp-buffer))) 1652 (setq tmp-buf (get-buffer-create ediff-tmp-buffer))
1654 (erase-buffer) 1653 (erase-buffer)
1655 (shell-command 1654 (shell-command
1656 (format 1655 (format
@@ -1662,8 +1661,7 @@ Useful commands:
1662 ) 1661 )
1663 t) 1662 t)
1664 ) 1663 )
1665 (save-excursion 1664 (with-current-buffer meta-diff-buff
1666 (set-buffer meta-diff-buff)
1667 (goto-char (point-max)) 1665 (goto-char (point-max))
1668 (insert-buffer-substring tmp-buf) 1666 (insert-buffer-substring tmp-buf)
1669 (insert "\n"))) 1667 (insert "\n")))
diff --git a/lisp/ediff-util.el b/lisp/ediff-util.el
index d0be103b8a6..a6247395eff 100644
--- a/lisp/ediff-util.el
+++ b/lisp/ediff-util.el
@@ -343,8 +343,7 @@ to invocation.")
343 (setq buffer-C 343 (setq buffer-C
344 (get-buffer-create 344 (get-buffer-create
345 (ediff-unique-buffer-name "*ediff-merge" "*"))) 345 (ediff-unique-buffer-name "*ediff-merge" "*")))
346 (save-excursion 346 (with-current-buffer buffer-C
347 (set-buffer buffer-C)
348 (insert-buffer-substring buf) 347 (insert-buffer-substring buf)
349 (goto-char (point-min)) 348 (goto-char (point-min))
350 (funcall (ediff-with-current-buffer buf major-mode)) 349 (funcall (ediff-with-current-buffer buf major-mode))
diff --git a/lisp/ediff-vers.el b/lisp/ediff-vers.el
index f634890451d..b5c0c0bd942 100644
--- a/lisp/ediff-vers.el
+++ b/lisp/ediff-vers.el
@@ -123,8 +123,7 @@ comparison or merge operations are being performed."
123 (fundamental-mode)) 123 (fundamental-mode))
124 (let ((output-buffer (ediff-rcs-get-output-buffer filename buff))) 124 (let ((output-buffer (ediff-rcs-get-output-buffer filename buff)))
125 (delete-windows-on output-buffer) 125 (delete-windows-on output-buffer)
126 (save-excursion 126 (with-current-buffer output-buffer
127 (set-buffer output-buffer)
128 (apply 'call-process "co" nil t nil 127 (apply 'call-process "co" nil t nil
129 ;; -q: quiet (no diagnostics) 128 ;; -q: quiet (no diagnostics)
130 (append switches rcs-default-co-switches 129 (append switches rcs-default-co-switches
diff --git a/lisp/ediff.el b/lisp/ediff.el
index 5c53d1a6688..33f53130caf 100644
--- a/lisp/ediff.el
+++ b/lisp/ediff.el
@@ -977,8 +977,7 @@ lines. For large regions, use `ediff-regions-linewise'."
977 (buffer-B 977 (buffer-B
978 (ediff-clone-buffer-for-region-comparison buffer-B "-Region.B-")) 978 (ediff-clone-buffer-for-region-comparison buffer-B "-Region.B-"))
979 reg-A-beg reg-A-end reg-B-beg reg-B-end) 979 reg-A-beg reg-A-end reg-B-beg reg-B-end)
980 (save-excursion 980 (with-current-buffer buffer-A
981 (set-buffer buffer-A)
982 (setq reg-A-beg (region-beginning) 981 (setq reg-A-beg (region-beginning)
983 reg-A-end (region-end)) 982 reg-A-end (region-end))
984 (set-buffer buffer-B) 983 (set-buffer buffer-B)
@@ -1018,8 +1017,7 @@ lines. For small regions, use `ediff-regions-wordwise'."
1018 (buffer-B 1017 (buffer-B
1019 (ediff-clone-buffer-for-region-comparison buffer-B "-Region.B-")) 1018 (ediff-clone-buffer-for-region-comparison buffer-B "-Region.B-"))
1020 reg-A-beg reg-A-end reg-B-beg reg-B-end) 1019 reg-A-beg reg-A-end reg-B-beg reg-B-end)
1021 (save-excursion 1020 (with-current-buffer buffer-A
1022 (set-buffer buffer-A)
1023 (setq reg-A-beg (region-beginning) 1021 (setq reg-A-beg (region-beginning)
1024 reg-A-end (region-end)) 1022 reg-A-end (region-end))
1025 ;; enlarge the region to hold full lines 1023 ;; enlarge the region to hold full lines
diff --git a/lisp/ehelp.el b/lisp/ehelp.el
index 8f1eeefa95a..4e4e59fa6d5 100644
--- a/lisp/ehelp.el
+++ b/lisp/ehelp.el
@@ -321,8 +321,7 @@ will select it.)"
321 ;;>> suspend updating of the tick in order to allow 321 ;;>> suspend updating of the tick in order to allow
322 ;;>> things like momentary-string-display) 322 ;;>> things like momentary-string-display)
323 (and b 323 (and b
324 (save-excursion 324 (with-current-buffer b
325 (set-buffer b)
326 (set-buffer-modified-p t))) 325 (set-buffer-modified-p t)))
327 (fset 'help-print-return-message 'ignore) 326 (fset 'help-print-return-message 'ignore)
328 (call-interactively fun) 327 (call-interactively fun)
@@ -333,8 +332,7 @@ will select it.)"
333 (not (buffer-modified-p b))))) 332 (not (buffer-modified-p b)))))
334 (fset 'help-print-return-message p) 333 (fset 'help-print-return-message p)
335 (and b (buffer-name b) 334 (and b (buffer-name b)
336 (save-excursion 335 (with-current-buffer b
337 (set-buffer b)
338 (set-buffer-modified-p m)))))) 336 (set-buffer-modified-p m))))))
339 (with-electric-help 'ignore name t)))) 337 (with-electric-help 'ignore name t))))
340 338
diff --git a/lisp/emerge.el b/lisp/emerge.el
index ee19351a2e3..997077aa08f 100644
--- a/lisp/emerge.el
+++ b/lisp/emerge.el
@@ -2060,8 +2060,7 @@ With a negative argument, turn off Skip-Prefers mode."
2060 (A-end (1- (aref diff-vector 1))) 2060 (A-end (1- (aref diff-vector 1)))
2061 ;; so further kills don't append 2061 ;; so further kills don't append
2062 this-command) 2062 this-command)
2063 (save-excursion 2063 (with-current-buffer emerge-A-buffer
2064 (set-buffer emerge-A-buffer)
2065 (copy-region-as-kill A-begin A-end)))) 2064 (copy-region-as-kill A-begin A-end))))
2066 2065
2067(defun emerge-copy-as-kill-B () 2066(defun emerge-copy-as-kill-B ()
@@ -2074,8 +2073,7 @@ With a negative argument, turn off Skip-Prefers mode."
2074 (B-end (1- (aref diff-vector 3))) 2073 (B-end (1- (aref diff-vector 3)))
2075 ;; so further kills don't append 2074 ;; so further kills don't append
2076 this-command) 2075 this-command)
2077 (save-excursion 2076 (with-current-buffer emerge-B-buffer
2078 (set-buffer emerge-B-buffer)
2079 (copy-region-as-kill B-begin B-end)))) 2077 (copy-region-as-kill B-begin B-end))))
2080 2078
2081(defun emerge-insert-A (arg) 2079(defun emerge-insert-A (arg)
@@ -2170,8 +2168,7 @@ Use C-u l to reset the windows afterward."
2170 (princ (buffer-name)))) 2168 (princ (buffer-name))))
2171 (princ "\n"))) 2169 (princ "\n")))
2172 (princ emerge-output-description) 2170 (princ emerge-output-description)
2173 (save-excursion 2171 (with-current-buffer standard-output
2174 (set-buffer standard-output)
2175 (help-mode))))) 2172 (help-mode)))))
2176 2173
2177(defun emerge-join-differences (arg) 2174(defun emerge-join-differences (arg)
@@ -3020,8 +3017,7 @@ If some prefix of KEY has a non-prefix definition, it is redefined."
3020;; minor-mode indicator)) 3017;; minor-mode indicator))
3021;; (princ (documentation minor-mode))))) 3018;; (princ (documentation minor-mode)))))
3022;; (setq minor-modes (cdr minor-modes)))) 3019;; (setq minor-modes (cdr minor-modes))))
3023;; (save-excursion 3020;; (with-current-buffer standard-output
3024;; (set-buffer standard-output)
3025;; (help-mode)) 3021;; (help-mode))
3026;; (help-print-return-message))) 3022;; (help-print-return-message)))
3027 3023
diff --git a/lisp/epa.el b/lisp/epa.el
index 541d26724d5..d218925b58f 100644
--- a/lisp/epa.el
+++ b/lisp/epa.el
@@ -463,8 +463,7 @@ If ARG is non-nil, mark the key."
463 (apply #'epa--list-keys epa-list-keys-arguments)) 463 (apply #'epa--list-keys epa-list-keys-arguments))
464 464
465(defun epa--marked-keys () 465(defun epa--marked-keys ()
466 (or (save-excursion 466 (or (with-current-buffer epa-keys-buffer
467 (set-buffer epa-keys-buffer)
468 (goto-char (point-min)) 467 (goto-char (point-min))
469 (let (keys key) 468 (let (keys key)
470 (while (re-search-forward "^\\*" nil t) 469 (while (re-search-forward "^\\*" nil t)
@@ -479,11 +478,10 @@ If ARG is non-nil, mark the key."
479 (list key)))))) 478 (list key))))))
480 479
481(defun epa--select-keys (prompt keys) 480(defun epa--select-keys (prompt keys)
482 (save-excursion 481 (unless (and epa-keys-buffer
483 (unless (and epa-keys-buffer 482 (buffer-live-p epa-keys-buffer))
484 (buffer-live-p epa-keys-buffer)) 483 (setq epa-keys-buffer (generate-new-buffer "*Keys*")))
485 (setq epa-keys-buffer (generate-new-buffer "*Keys*"))) 484 (with-current-buffer epa-keys-buffer
486 (set-buffer epa-keys-buffer)
487 (epa-key-list-mode) 485 (epa-key-list-mode)
488 (let ((inhibit-read-only t) 486 (let ((inhibit-read-only t)
489 buffer-read-only) 487 buffer-read-only)
@@ -615,8 +613,7 @@ If SECRET is non-nil, list secret keys instead of public keys."
615 (setq epa-info-buffer (generate-new-buffer "*Info*"))) 613 (setq epa-info-buffer (generate-new-buffer "*Info*")))
616 (if (get-buffer-window epa-info-buffer) 614 (if (get-buffer-window epa-info-buffer)
617 (delete-window (get-buffer-window epa-info-buffer))) 615 (delete-window (get-buffer-window epa-info-buffer)))
618 (save-excursion 616 (with-current-buffer epa-info-buffer
619 (set-buffer epa-info-buffer)
620 (let ((inhibit-read-only t) 617 (let ((inhibit-read-only t)
621 buffer-read-only) 618 buffer-read-only)
622 (erase-buffer) 619 (erase-buffer)
@@ -716,8 +713,7 @@ If SECRET is non-nil, list secret keys instead of public keys."
716 (setq type 'detached)) 713 (setq type 'detached))
717 ((eq c ??) 714 ((eq c ??)
718 (with-output-to-temp-buffer "*Help*" 715 (with-output-to-temp-buffer "*Help*"
719 (save-excursion 716 (with-current-buffer standard-output
720 (set-buffer standard-output)
721 (insert "\ 717 (insert "\
722n - Create a normal signature 718n - Create a normal signature
723c - Create a cleartext signature 719c - Create a cleartext signature
diff --git a/lisp/epg.el b/lisp/epg.el
index b8eb2b48ea7..929f0637480 100644
--- a/lisp/epg.el
+++ b/lisp/epg.el
@@ -1143,8 +1143,7 @@ This function is for internal use only."
1143 (goto-char (point-max)) 1143 (goto-char (point-max))
1144 (insert input))) 1144 (insert input)))
1145 (if (buffer-live-p (process-buffer process)) 1145 (if (buffer-live-p (process-buffer process))
1146 (save-excursion 1146 (with-current-buffer (process-buffer process)
1147 (set-buffer (process-buffer process))
1148 (goto-char (point-max)) 1147 (goto-char (point-max))
1149 (insert input) 1148 (insert input)
1150 (unless epg-process-filter-running 1149 (unless epg-process-filter-running
@@ -1927,8 +1926,7 @@ You can then use `write-region' to write new data into the file."
1927 1926
1928(defun epg-cancel (context) 1927(defun epg-cancel (context)
1929 (if (buffer-live-p (process-buffer (epg-context-process context))) 1928 (if (buffer-live-p (process-buffer (epg-context-process context)))
1930 (save-excursion 1929 (with-current-buffer (process-buffer (epg-context-process context))
1931 (set-buffer (process-buffer (epg-context-process context)))
1932 (epg-context-set-result-for 1930 (epg-context-set-result-for
1933 epg-context 'error 1931 epg-context 'error
1934 (cons '(quit) 1932 (cons '(quit)
diff --git a/lisp/ezimage.el b/lisp/ezimage.el
index a677994926f..8923f783f14 100644
--- a/lisp/ezimage.el
+++ b/lisp/ezimage.el
@@ -300,8 +300,7 @@ Optional argument STRING is a string upon which to add text properties."
300See `ezimage-expand-image-button-alist' for details." 300See `ezimage-expand-image-button-alist' for details."
301 (interactive) 301 (interactive)
302 (with-output-to-temp-buffer "*Ezimage Images*" 302 (with-output-to-temp-buffer "*Ezimage Images*"
303 (save-excursion 303 (with-current-buffer "*Ezimage Images*"
304 (set-buffer "*Ezimage Images*")
305 (goto-char (point-max)) 304 (goto-char (point-max))
306 (insert "Ezimage image cache.\n\n") 305 (insert "Ezimage image cache.\n\n")
307 (let ((start (point)) (end nil)) 306 (let ((start (point)) (end nil))
@@ -324,8 +323,7 @@ See `ezimage-expand-image-button-alist' for details."
324See `ezimage-expand-image-button-alist' for details." 323See `ezimage-expand-image-button-alist' for details."
325 (interactive) 324 (interactive)
326 (with-output-to-temp-buffer "*Ezimage Images*" 325 (with-output-to-temp-buffer "*Ezimage Images*"
327 (save-excursion 326 (with-current-buffer "*Ezimage Images*"
328 (set-buffer "*Ezimage Images*")
329 (goto-char (point-max)) 327 (goto-char (point-max))
330 (insert "Ezimage image cache.\n\n") 328 (insert "Ezimage image cache.\n\n")
331 (let ((start (point)) (end nil)) 329 (let ((start (point)) (end nil))
diff --git a/lisp/facemenu.el b/lisp/facemenu.el
index d12d3d48bd3..c205efad7a7 100644
--- a/lisp/facemenu.el
+++ b/lisp/facemenu.el
@@ -494,8 +494,7 @@ argument BUFFER-NAME is nil, it defaults to *Colors*."
494 (if lc 494 (if lc
495 (setcdr lc nil))))) 495 (setcdr lc nil)))))
496 (with-help-window (or buffer-name "*Colors*") 496 (with-help-window (or buffer-name "*Colors*")
497 (save-excursion 497 (with-current-buffer standard-output
498 (set-buffer standard-output)
499 (setq truncate-lines t) 498 (setq truncate-lines t)
500 (if temp-buffer-show-function 499 (if temp-buffer-show-function
501 (list-colors-print list) 500 (list-colors-print list)
diff --git a/lisp/faces.el b/lisp/faces.el
index 1dff7d0547a..2c49cd8bae2 100644
--- a/lisp/faces.el
+++ b/lisp/faces.el
@@ -1273,8 +1273,7 @@ arg, prompt for a regular expression."
1273 (setq max-length (1+ max-length) 1273 (setq max-length (1+ max-length)
1274 line-format (format "%%-%ds" max-length)) 1274 line-format (format "%%-%ds" max-length))
1275 (with-help-window "*Faces*" 1275 (with-help-window "*Faces*"
1276 (save-excursion 1276 (with-current-buffer standard-output
1277 (set-buffer standard-output)
1278 (setq truncate-lines t) 1277 (setq truncate-lines t)
1279 (insert 1278 (insert
1280 (substitute-command-keys 1279 (substitute-command-keys
@@ -1362,8 +1361,7 @@ If FRAME is omitted or nil, use the selected frame."
1362 (if (not (listp face)) 1361 (if (not (listp face))
1363 (setq face (list face))) 1362 (setq face (list face)))
1364 (with-help-window (help-buffer) 1363 (with-help-window (help-buffer)
1365 (save-excursion 1364 (with-current-buffer standard-output
1366 (set-buffer standard-output)
1367 (dolist (f face) 1365 (dolist (f face)
1368 (if (stringp f) (setq f (intern f))) 1366 (if (stringp f) (setq f (intern f)))
1369 ;; We may get called for anonymous faces (i.e., faces 1367 ;; We may get called for anonymous faces (i.e., faces
diff --git a/lisp/files.el b/lisp/files.el
index 3fc64600786..1bde2be0ef0 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -5411,8 +5411,7 @@ and `list-directory-verbose-switches'."
5411 (princ "Directory ") 5411 (princ "Directory ")
5412 (princ dirname) 5412 (princ dirname)
5413 (terpri) 5413 (terpri)
5414 (save-excursion 5414 (with-current-buffer "*Directory*"
5415 (set-buffer "*Directory*")
5416 (let ((wildcard (not (file-directory-p dirname)))) 5415 (let ((wildcard (not (file-directory-p dirname))))
5417 (insert-directory dirname switches wildcard (not wildcard))))) 5416 (insert-directory dirname switches wildcard (not wildcard)))))
5418 ;; Finishing with-output-to-temp-buffer seems to clobber default-directory. 5417 ;; Finishing with-output-to-temp-buffer seems to clobber default-directory.
diff --git a/lisp/filesets.el b/lisp/filesets.el
index e287c149202..18cef4d24f7 100644
--- a/lisp/filesets.el
+++ b/lisp/filesets.el
@@ -1552,8 +1552,7 @@ First, save the buffer's contents using SAVE-FUNCTION. Then, kill buffer
1552if `buffer-modified-p' returns nil. 1552if `buffer-modified-p' returns nil.
1553 1553
1554SAVE-FUNCTION takes no argument, but works on the current buffer." 1554SAVE-FUNCTION takes no argument, but works on the current buffer."
1555 (save-excursion 1555 (with-current-buffer buffer
1556 (set-buffer buffer)
1557 (if (buffer-modified-p) 1556 (if (buffer-modified-p)
1558 (funcall save-function)) 1557 (funcall save-function))
1559 (if (not (buffer-modified-p)) 1558 (if (not (buffer-modified-p))
diff --git a/lisp/find-dired.el b/lisp/find-dired.el
index 2e0515bb469..98643f71777 100644
--- a/lisp/find-dired.el
+++ b/lisp/find-dired.el
@@ -291,8 +291,7 @@ Thus ARG can also contain additional grep options."
291 (let ((buf (process-buffer proc)) 291 (let ((buf (process-buffer proc))
292 (inhibit-read-only t)) 292 (inhibit-read-only t))
293 (if (buffer-name buf) 293 (if (buffer-name buf)
294 (save-excursion 294 (with-current-buffer buf
295 (set-buffer buf)
296 (let ((buffer-read-only nil)) 295 (let ((buffer-read-only nil))
297 (save-excursion 296 (save-excursion
298 (goto-char (point-max)) 297 (goto-char (point-max))
diff --git a/lisp/finder.el b/lisp/finder.el
index 4c696a3e2a4..cba3c832064 100644
--- a/lisp/finder.el
+++ b/lisp/finder.el
@@ -332,8 +332,7 @@ FILE should be in a form suitable for passing to `locate-library'."
332(defun finder-mouse-select (event) 332(defun finder-mouse-select (event)
333 "Select item in a finder buffer with the mouse." 333 "Select item in a finder buffer with the mouse."
334 (interactive "e") 334 (interactive "e")
335 (save-excursion 335 (with-current-buffer (window-buffer (posn-window (event-start event)))
336 (set-buffer (window-buffer (posn-window (event-start event))))
337 (goto-char (posn-point (event-start event))) 336 (goto-char (posn-point (event-start event)))
338 (finder-select))) 337 (finder-select)))
339 338
diff --git a/lisp/generic-x.el b/lisp/generic-x.el
index 06e663441bd..8113185ec75 100644
--- a/lisp/generic-x.el
+++ b/lisp/generic-x.el
@@ -546,9 +546,7 @@ like an INI file. You can add this hook to `find-file-hook'."
546 (require 'comint) 546 (require 'comint)
547 (let* ((file (buffer-file-name)) 547 (let* ((file (buffer-file-name))
548 (buf-name (concat "*" file "*"))) 548 (buf-name (concat "*" file "*")))
549 (save-excursion 549 (with-current-buffer (get-buffer-create buf-name)
550 (set-buffer
551 (get-buffer-create buf-name))
552 (erase-buffer) 550 (erase-buffer)
553 (comint-mode) 551 (comint-mode)
554 (comint-exec 552 (comint-exec
diff --git a/lisp/help-fns.el b/lisp/help-fns.el
index 9af6e38c491..15a68dfab7d 100644
--- a/lisp/help-fns.el
+++ b/lisp/help-fns.el
@@ -789,8 +789,7 @@ file local variable.\n")
789 (terpri) 789 (terpri)
790 (princ output)))) 790 (princ output))))
791 791
792 (save-excursion 792 (with-current-buffer standard-output
793 (set-buffer standard-output)
794 ;; Return the text we displayed. 793 ;; Return the text we displayed.
795 (buffer-string)))))))) 794 (buffer-string))))))))
796 795
diff --git a/lisp/help-mode.el b/lisp/help-mode.el
index 7c032b81cf2..641738770a2 100644
--- a/lisp/help-mode.el
+++ b/lisp/help-mode.el
@@ -413,8 +413,7 @@ A special reference `back' is made to return back through a stack of
413help buffers. Variable `help-back-label' specifies the text for 413help buffers. Variable `help-back-label' specifies the text for
414that." 414that."
415 (interactive "b") 415 (interactive "b")
416 (save-excursion 416 (with-current-buffer (or buffer (current-buffer))
417 (set-buffer (or buffer (current-buffer)))
418 (goto-char (point-min)) 417 (goto-char (point-min))
419 ;; Skip the header-type info, though it might be useful to parse 418 ;; Skip the header-type info, though it might be useful to parse
420 ;; it at some stage (e.g. "function in `library'"). 419 ;; it at some stage (e.g. "function in `library'").
diff --git a/lisp/hippie-exp.el b/lisp/hippie-exp.el
index fdce4f85109..e52fe07f8ae 100644
--- a/lisp/hippie-exp.el
+++ b/lisp/hippie-exp.el
@@ -1000,8 +1000,7 @@ string). It returns t if a new expansion is found, nil otherwise."
1000 (while (and (not (equal he-search-string "")) 1000 (while (and (not (equal he-search-string ""))
1001 (marker-position he-search-loc) 1001 (marker-position he-search-loc)
1002 (not expansion)) 1002 (not expansion))
1003 (save-excursion 1003 (with-current-buffer (marker-buffer he-search-loc)
1004 (set-buffer (marker-buffer he-search-loc))
1005 (goto-char he-search-loc) 1004 (goto-char he-search-loc)
1006 (setq expansion (he-dabbrev-search he-search-string () 1005 (setq expansion (he-dabbrev-search he-search-string ()
1007 (window-end he-search-window))) 1006 (window-end he-search-window)))
diff --git a/lisp/ido.el b/lisp/ido.el
index d8f2800739f..7317540db32 100644
--- a/lisp/ido.el
+++ b/lisp/ido.el
@@ -2975,8 +2975,7 @@ If repeated, insert text from buffer instead."
2975(defun ido-copy-current-word (all) 2975(defun ido-copy-current-word (all)
2976 "Insert current word (file or directory name) from current buffer." 2976 "Insert current word (file or directory name) from current buffer."
2977 (interactive "P") 2977 (interactive "P")
2978 (let ((word (save-excursion 2978 (let ((word (with-current-buffer ido-entry-buffer
2979 (set-buffer ido-entry-buffer)
2980 (let ((p (point)) start-line end-line start-name name) 2979 (let ((p (point)) start-line end-line start-name name)
2981 (if (and mark-active (/= p (mark))) 2980 (if (and mark-active (/= p (mark)))
2982 (setq start-name (mark)) 2981 (setq start-name (mark))
@@ -4184,8 +4183,7 @@ For details of keybindings, see `ido-find-file'."
4184 ido-text-init contents 4183 ido-text-init contents
4185 ido-rotate-temp t 4184 ido-rotate-temp t
4186 ido-exit 'refresh) 4185 ido-exit 'refresh)
4187 (save-excursion 4186 (with-current-buffer buffer
4188 (set-buffer buffer)
4189 (ido-tidy)) 4187 (ido-tidy))
4190 (throw 'ido contents)))) 4188 (throw 'ido contents))))
4191 4189
diff --git a/lisp/informat.el b/lisp/informat.el
index b78befba81e..57fa1da05ec 100644
--- a/lisp/informat.el
+++ b/lisp/informat.el
@@ -497,8 +497,7 @@ For example, invoke \"emacs -batch -f batch-info-validate $info/ ~/*.info\""
497 nil ;(message "Checking validity of info file %s... OK" file) 497 nil ;(message "Checking validity of info file %s... OK" file)
498 (message "----------------------------------------------------------------------") 498 (message "----------------------------------------------------------------------")
499 (message ">> PROBLEMS IN INFO FILE %s" file) 499 (message ">> PROBLEMS IN INFO FILE %s" file)
500 (save-excursion 500 (with-current-buffer loss-name
501 (set-buffer loss-name)
502 (princ (buffer-substring-no-properties 501 (princ (buffer-substring-no-properties
503 (point-min) (point-max)))) 502 (point-min) (point-max))))
504 (message "----------------------------------------------------------------------") 503 (message "----------------------------------------------------------------------")
diff --git a/lisp/ledit.el b/lisp/ledit.el
index a41f968dc5f..c63992b0a62 100644
--- a/lisp/ledit.el
+++ b/lisp/ledit.el
@@ -94,11 +94,10 @@
94 (if ledit-save-files 94 (if ledit-save-files
95 (save-some-buffers)) 95 (save-some-buffers))
96 (if (get-buffer ledit-buffer) 96 (if (get-buffer ledit-buffer)
97 (save-excursion 97 (with-current-buffer ledit-buffer
98 (set-buffer ledit-buffer) 98 (goto-char (point-min))
99 (goto-char (point-min)) 99 (write-region (point-min) (point-max) ledit-zap-file)
100 (write-region (point-min) (point-max) ledit-zap-file) 100 (erase-buffer)))
101 (erase-buffer)))
102 (suspend-emacs ledit-go-to-lisp-string) 101 (suspend-emacs ledit-go-to-lisp-string)
103 (load ledit-read-file t t)) 102 (load ledit-read-file t t))
104 103
@@ -108,12 +107,11 @@
108 (if ledit-save-files 107 (if ledit-save-files
109 (save-some-buffers)) 108 (save-some-buffers))
110 (if (get-buffer ledit-buffer) 109 (if (get-buffer ledit-buffer)
111 (save-excursion 110 (with-current-buffer ledit-buffer
112 (set-buffer ledit-buffer) 111 (goto-char (point-min))
113 (goto-char (point-min)) 112 (insert "(declare (macros t))\n")
114 (insert "(declare (macros t))\n") 113 (write-region (point-min) (point-max) ledit-compile-file)
115 (write-region (point-min) (point-max) ledit-compile-file) 114 (erase-buffer)))
116 (erase-buffer)))
117 (suspend-emacs ledit-go-to-liszt-string) 115 (suspend-emacs ledit-go-to-liszt-string)
118 (load ledit-read-file t t)) 116 (load ledit-read-file t t))
119 117
diff --git a/lisp/macros.el b/lisp/macros.el
index 974b19a394e..d27a5b752a6 100644
--- a/lisp/macros.el
+++ b/lisp/macros.el
@@ -209,8 +209,7 @@ Possibilities: \\<query-replace-map>
209\\[exit] Stop the macro entirely right now. 209\\[exit] Stop the macro entirely right now.
210\\[recenter] Redisplay the screen, then ask again. 210\\[recenter] Redisplay the screen, then ask again.
211\\[edit] Enter recursive edit; ask again when you exit from that.")) 211\\[edit] Enter recursive edit; ask again when you exit from that."))
212 (save-excursion 212 (with-current-buffer standard-output
213 (set-buffer standard-output)
214 (help-mode))))))))))) 213 (help-mode)))))))))))
215 214
216;;;###autoload 215;;;###autoload
diff --git a/lisp/menu-bar.el b/lisp/menu-bar.el
index ea1551b7f67..fbafd9077a0 100644
--- a/lisp/menu-bar.el
+++ b/lisp/menu-bar.el
@@ -1857,8 +1857,7 @@ Buffers menu is regenerated."
1857;;nil means the buffer shouldn't be listed. You can redefine this." 1857;;nil means the buffer shouldn't be listed. You can redefine this."
1858;; (if (string-match "\\` " (buffer-name buffer)) 1858;; (if (string-match "\\` " (buffer-name buffer))
1859;; nil 1859;; nil
1860;; (save-excursion 1860;; (with-current-buffer buffer
1861;; (set-buffer buffer)
1862;; (let ((size (buffer-size))) 1861;; (let ((size (buffer-size)))
1863;; (format "%s%s %-19s %6s %-15s %s" 1862;; (format "%s%s %-19s %6s %-15s %s"
1864;; (if (buffer-modified-p) "*" " ") 1863;; (if (buffer-modified-p) "*" " ")
diff --git a/lisp/mouse-copy.el b/lisp/mouse-copy.el
index 67d797f488f..86ddc4c5bfb 100644
--- a/lisp/mouse-copy.el
+++ b/lisp/mouse-copy.el
@@ -200,8 +200,7 @@ by johnh@ficus.cs.ucla.edu."
200 (window-buffer (posn-window (event-start click))) 200 (window-buffer (posn-window (event-start click)))
201 (current-buffer))) 201 (current-buffer)))
202 (error "Select or click on the buffer where the secondary selection is"))) 202 (error "Select or click on the buffer where the secondary selection is")))
203 (save-excursion 203 (with-current-buffer (overlay-buffer mouse-secondary-overlay)
204 (set-buffer (overlay-buffer mouse-secondary-overlay))
205 (kill-region (overlay-start mouse-secondary-overlay) 204 (kill-region (overlay-start mouse-secondary-overlay)
206 (overlay-end mouse-secondary-overlay))) 205 (overlay-end mouse-secondary-overlay)))
207 ;; (delete-overlay mouse-secondary-overlay) 206 ;; (delete-overlay mouse-secondary-overlay)
diff --git a/lisp/mouse.el b/lisp/mouse.el
index 943f53c781d..9ea4d8bff12 100644
--- a/lisp/mouse.el
+++ b/lisp/mouse.el
@@ -1975,12 +1975,10 @@ and selects that window."
1975 (format "%%-%ds %%s%%s %%s" maxlen) 1975 (format "%%-%ds %%s%%s %%s" maxlen)
1976 (buffer-name elt) 1976 (buffer-name elt)
1977 (if (buffer-modified-p elt) "*" " ") 1977 (if (buffer-modified-p elt) "*" " ")
1978 (save-excursion 1978 (with-current-buffer elt
1979 (set-buffer elt)
1980 (if buffer-read-only "%" " ")) 1979 (if buffer-read-only "%" " "))
1981 (or (buffer-file-name elt) 1980 (or (buffer-file-name elt)
1982 (save-excursion 1981 (with-current-buffer elt
1983 (set-buffer elt)
1984 (if list-buffers-directory 1982 (if list-buffers-directory
1985 (expand-file-name 1983 (expand-file-name
1986 list-buffers-directory))) 1984 list-buffers-directory)))
diff --git a/lisp/novice.el b/lisp/novice.el
index cb22433f778..963247dc40a 100644
--- a/lisp/novice.el
+++ b/lisp/novice.el
@@ -85,8 +85,7 @@ y to try it and enable it (no questions if you use it again).
85n to cancel--don't try the command, and it remains disabled. 85n to cancel--don't try the command, and it remains disabled.
86SPC to try the command just this once, but leave it disabled. 86SPC to try the command just this once, but leave it disabled.
87! to try it, and enable all disabled commands for this session only.") 87! to try it, and enable all disabled commands for this session only.")
88 (save-excursion 88 (with-current-buffer standard-output
89 (set-buffer standard-output)
90 (help-mode))) 89 (help-mode)))
91 (fit-window-to-buffer (get-buffer-window "*Disabled Command*")) 90 (fit-window-to-buffer (get-buffer-window "*Disabled Command*"))
92 (message "Type y, n, ! or SPC (the space bar): ") 91 (message "Type y, n, ! or SPC (the space bar): ")
@@ -135,9 +134,8 @@ to future sessions."
135 (eq system-type 'windows-nt) 134 (eq system-type 'windows-nt)
136 (file-exists-p "~/_emacs")) 135 (file-exists-p "~/_emacs"))
137 (setq init-file "~/_emacs"))) 136 (setq init-file "~/_emacs")))
138 (save-excursion 137 (with-current-buffer (find-file-noselect
139 (set-buffer (find-file-noselect 138 (substitute-in-file-name init-file))
140 (substitute-in-file-name init-file)))
141 (goto-char (point-min)) 139 (goto-char (point-min))
142 (if (search-forward (concat "(put '" (symbol-name command) " ") nil t) 140 (if (search-forward (concat "(put '" (symbol-name command) " ") nil t)
143 (delete-region 141 (delete-region
@@ -175,9 +173,8 @@ to future sessions."
175 (eq system-type 'windows-nt) 173 (eq system-type 'windows-nt)
176 (file-exists-p "~/_emacs")) 174 (file-exists-p "~/_emacs"))
177 (setq init-file "~/_emacs"))) 175 (setq init-file "~/_emacs")))
178 (save-excursion 176 (with-current-buffer (find-file-noselect
179 (set-buffer (find-file-noselect 177 (substitute-in-file-name init-file))
180 (substitute-in-file-name init-file)))
181 (goto-char (point-min)) 178 (goto-char (point-min))
182 (if (search-forward (concat "(put '" (symbol-name command) " ") nil t) 179 (if (search-forward (concat "(put '" (symbol-name command) " ") nil t)
183 (delete-region 180 (delete-region
diff --git a/lisp/printing.el b/lisp/printing.el
index 46b5f00d182..ddd4685880b 100644
--- a/lisp/printing.el
+++ b/lisp/printing.el
@@ -3953,8 +3953,7 @@ If BUFFER is nil, the current buffer is used for printing.
3953 3953
3954For more information, type \\[pr-interface-help]." 3954For more information, type \\[pr-interface-help]."
3955 (interactive) 3955 (interactive)
3956 (save-excursion 3956 (with-current-buffer (or buffer (current-buffer))
3957 (set-buffer (or buffer (current-buffer)))
3958 (pr-create-interface))) 3957 (pr-create-interface)))
3959 3958
3960 3959
@@ -4457,8 +4456,7 @@ image in a file with that name."
4457 (if (string= pr-ps-command "") 4456 (if (string= pr-ps-command "")
4458 ;; default action 4457 ;; default action
4459 (let ((ps-spool-buffer (get-buffer-create ps-spool-buffer-name))) 4458 (let ((ps-spool-buffer (get-buffer-create ps-spool-buffer-name)))
4460 (save-excursion 4459 (with-current-buffer ps-spool-buffer
4461 (set-buffer ps-spool-buffer)
4462 (erase-buffer) 4460 (erase-buffer)
4463 (insert-file-contents-literally file)) 4461 (insert-file-contents-literally file))
4464 (pr-despool-print)) 4462 (pr-despool-print))
@@ -5028,8 +5026,7 @@ Return only the dayname, if present, weekday, month, and year."
5028 (symbol-value summary-buffer)) 5026 (symbol-value summary-buffer))
5029 (symbol-value summary-default)))) 5027 (symbol-value summary-default))))
5030 (and (get-buffer buf) 5028 (and (get-buffer buf)
5031 (save-excursion 5029 (with-current-buffer buf
5032 (set-buffer buf)
5033 (pr-mode-print n-up filename header-list))))) 5030 (pr-mode-print n-up filename header-list)))))
5034 5031
5035 5032
@@ -5039,8 +5036,7 @@ Return only the dayname, if present, weekday, month, and year."
5039 (symbol-value summary-buffer)) 5036 (symbol-value summary-buffer))
5040 (symbol-value summary-default)))) 5037 (symbol-value summary-default))))
5041 (and (get-buffer buf) 5038 (and (get-buffer buf)
5042 (save-excursion 5039 (with-current-buffer buf
5043 (set-buffer buf)
5044 (pr-mode-lpr header-list))))) 5040 (pr-mode-lpr header-list)))))
5045 5041
5046 5042
@@ -5633,8 +5629,7 @@ If menu binding was not done, calls `pr-menu-bind'."
5633 status) 5629 status)
5634 (setq args (pr-remove-nil-from-list args)) 5630 (setq args (pr-remove-nil-from-list args))
5635 ;; *Printing Command Output* == show command & args 5631 ;; *Printing Command Output* == show command & args
5636 (save-excursion 5632 (with-current-buffer buffer
5637 (set-buffer buffer)
5638 (goto-char (point-max)) 5633 (goto-char (point-max))
5639 (insert (format "%s %S\n" cmd args))) 5634 (insert (format "%s %S\n" cmd args)))
5640 ;; *Printing Command Output* == show any return message from command 5635 ;; *Printing Command Output* == show any return message from command
@@ -5645,8 +5640,7 @@ If menu binding was not done, calls `pr-menu-bind'."
5645 ((quit error) 5640 ((quit error)
5646 (error-message-string data))))) 5641 (error-message-string data)))))
5647 ;; *Printing Command Output* == show exit status 5642 ;; *Printing Command Output* == show exit status
5648 (save-excursion 5643 (with-current-buffer buffer
5649 (set-buffer buffer)
5650 (goto-char (point-max)) 5644 (goto-char (point-max))
5651 (insert (format "Exit status: %s\n\n" status))) 5645 (insert (format "Exit status: %s\n\n" status)))
5652 ;; message if error status 5646 ;; message if error status
@@ -5839,8 +5833,7 @@ If menu binding was not done, calls `pr-menu-bind'."
5839 (blist (buffer-list)) 5833 (blist (buffer-list))
5840 found) 5834 found)
5841 (while (and (not found) blist) 5835 (while (and (not found) blist)
5842 (save-excursion 5836 (with-current-buffer (car blist)
5843 (set-buffer (car blist))
5844 (and (eq major-mode 'dired-mode) 5837 (and (eq major-mode 'dired-mode)
5845 (save-excursion 5838 (save-excursion
5846 (goto-char (point-min)) 5839 (goto-char (point-min))
@@ -5864,9 +5857,8 @@ If menu binding was not done, calls `pr-menu-bind'."
5864 pop-up-frames) 5857 pop-up-frames)
5865 (and (or buffer 5858 (and (or buffer
5866 (file-readable-p file)) 5859 (file-readable-p file))
5867 (save-excursion 5860 (with-current-buffer (or buffer
5868 (set-buffer (or buffer 5861 (find-file-noselect file))
5869 (find-file-noselect file)))
5870 (funcall fun) 5862 (funcall fun)
5871 (or buffer 5863 (or buffer
5872 (kill-buffer (current-buffer)))))))) 5864 (kill-buffer (current-buffer))))))))
@@ -6047,8 +6039,7 @@ COMMAND.exe, COMMAND.bat and COMMAND.com in this order."
6047 6039
6048 6040
6049(defmacro pr-interface-save (&rest body) 6041(defmacro pr-interface-save (&rest body)
6050 `(save-excursion 6042 `(with-current-buffer pr-i-buffer
6051 (set-buffer pr-i-buffer)
6052 ,@body)) 6043 ,@body))
6053 6044
6054 6045
diff --git a/lisp/ps-bdf.el b/lisp/ps-bdf.el
index 46c5f9842d5..2b99a16a4a7 100644
--- a/lisp/ps-bdf.el
+++ b/lisp/ps-bdf.el
@@ -95,8 +95,7 @@ If BDFNAME doesn't exist, return nil."
95 (and (file-readable-p bdfname) 95 (and (file-readable-p bdfname)
96 (let ((buf (generate-new-buffer " *bdf-work*")) 96 (let ((buf (generate-new-buffer " *bdf-work*"))
97 (coding-system-for-read 'no-conversion)) 97 (coding-system-for-read 'no-conversion))
98 (save-excursion 98 (with-current-buffer buf
99 (set-buffer buf)
100 (insert-file-contents bdfname) 99 (insert-file-contents bdfname)
101 buf)))) 100 buf))))
102 101
@@ -225,8 +224,7 @@ CODE, where N and CODE are in the following relation:
225 (message "Reading %s..." bdfname) 224 (message "Reading %s..." bdfname)
226 (error "BDF file %s doesn't exist" bdfname)) 225 (error "BDF file %s doesn't exist" bdfname))
227 (unwind-protect 226 (unwind-protect
228 (save-excursion 227 (with-current-buffer buf
229 (set-buffer buf)
230 (goto-char (point-min)) 228 (goto-char (point-min))
231 (search-forward "\nFONTBOUNDINGBOX") 229 (search-forward "\nFONTBOUNDINGBOX")
232 (setq font-bounding-box 230 (setq font-bounding-box
diff --git a/lisp/ps-print.el b/lisp/ps-print.el
index 8bf3d91607d..3f0538fa3c3 100644
--- a/lisp/ps-print.el
+++ b/lisp/ps-print.el
@@ -4734,8 +4734,7 @@ page-height == ((floor print-height ((th + ls) * zh)) * ((th + ls) * zh)) - th
4734 (ps-output 'prologue (if (stringp args) (list args) args))) 4734 (ps-output 'prologue (if (stringp args) (list args) args)))
4735 4735
4736(defun ps-flush-output () 4736(defun ps-flush-output ()
4737 (save-excursion 4737 (with-current-buffer ps-spool-buffer
4738 (set-buffer ps-spool-buffer)
4739 (goto-char (point-max)) 4738 (goto-char (point-max))
4740 (while ps-output-head 4739 (while ps-output-head
4741 (let ((it (car ps-output-head))) 4740 (let ((it (car ps-output-head)))
@@ -4756,8 +4755,7 @@ page-height == ((floor print-height ((th + ls) * zh)) * ((th + ls) * zh)) - th
4756 4755
4757(defun ps-insert-file (fname) 4756(defun ps-insert-file (fname)
4758 (ps-flush-output) 4757 (ps-flush-output)
4759 (save-excursion 4758 (with-current-buffer ps-spool-buffer
4760 (set-buffer ps-spool-buffer)
4761 (goto-char (point-max)) 4759 (goto-char (point-max))
4762 (insert-file-contents fname))) 4760 (insert-file-contents fname)))
4763 4761
@@ -4840,8 +4838,7 @@ page-height == ((floor print-height ((th + ls) * zh)) * ((th + ls) * zh)) - th
4840 4838
4841 4839
4842(defun ps-get-boundingbox () 4840(defun ps-get-boundingbox ()
4843 (save-excursion 4841 (with-current-buffer ps-spool-buffer
4844 (set-buffer ps-spool-buffer)
4845 (save-excursion 4842 (save-excursion
4846 (if (re-search-forward ps-boundingbox-re nil t) 4843 (if (re-search-forward ps-boundingbox-re nil t)
4847 (vector (string-to-number ; lower x 4844 (vector (string-to-number ; lower x
@@ -4909,8 +4906,7 @@ page-height == ((floor print-height ((th + ls) * zh)) * ((th + ls) * zh)) - th
4909 ;; coordinate adjustment to center image 4906 ;; coordinate adjustment to center image
4910 ;; around x and y position 4907 ;; around x and y position
4911 (let ((box (ps-get-boundingbox))) 4908 (let ((box (ps-get-boundingbox)))
4912 (save-excursion 4909 (with-current-buffer ps-spool-buffer
4913 (set-buffer ps-spool-buffer)
4914 (save-excursion 4910 (save-excursion
4915 (if (re-search-backward "^--back--" nil t) 4911 (if (re-search-backward "^--back--" nil t)
4916 (replace-match 4912 (replace-match
@@ -5795,8 +5791,7 @@ XSTART YSTART are the relative position for the first page in a sheet.")
5795 ps-line-number-step 5791 ps-line-number-step
5796 ps-zebra-stripe-height)))) 5792 ps-zebra-stripe-height))))
5797 ;; spooling buffer 5793 ;; spooling buffer
5798 (save-excursion 5794 (with-current-buffer ps-spool-buffer
5799 (set-buffer ps-spool-buffer)
5800 (goto-char (point-max)) 5795 (goto-char (point-max))
5801 (and (re-search-backward "^%%Trailer$" nil t) 5796 (and (re-search-backward "^%%Trailer$" nil t)
5802 (delete-region (match-beginning 0) (point-max)))) 5797 (delete-region (match-beginning 0) (point-max))))
@@ -6573,8 +6568,7 @@ If FACE is not a valid face name, use default face."
6573 (and ps-razzle-dazzle (message "Wrote %s" filename))) 6568 (and ps-razzle-dazzle (message "Wrote %s" filename)))
6574 ;; Else, spool to the printer 6569 ;; Else, spool to the printer
6575 (and ps-razzle-dazzle (message "Printing...")) 6570 (and ps-razzle-dazzle (message "Printing..."))
6576 (save-excursion 6571 (with-current-buffer ps-spool-buffer
6577 (set-buffer ps-spool-buffer)
6578 (let* ((coding-system-for-write 'raw-text-unix) 6572 (let* ((coding-system-for-write 'raw-text-unix)
6579 (ps-printer-name (or ps-printer-name 6573 (ps-printer-name (or ps-printer-name
6580 (and (boundp 'printer-name) 6574 (and (boundp 'printer-name)
diff --git a/lisp/ps-samp.el b/lisp/ps-samp.el
index ce2429fe57c..0288559ca31 100644
--- a/lisp/ps-samp.el
+++ b/lisp/ps-samp.el
@@ -72,8 +72,7 @@
72 (symbol-value summary-buffer)) 72 (symbol-value summary-buffer))
73 summary-default))) 73 summary-default)))
74 (and (get-buffer ps-buf) 74 (and (get-buffer ps-buf)
75 (save-excursion 75 (with-current-buffer ps-buf
76 (set-buffer ps-buf)
77 (ps-spool-buffer-with-faces))))) 76 (ps-spool-buffer-with-faces)))))
78 77
79;; Look in an article or mail message for the Subject: line. To be 78;; Look in an article or mail message for the Subject: line. To be
diff --git a/lisp/saveplace.el b/lisp/saveplace.el
index 6ef259b2aae..f58e15e6e5c 100644
--- a/lisp/saveplace.el
+++ b/lisp/saveplace.el
@@ -205,8 +205,7 @@ may have changed\) back to `save-place-alist'."
205(defun save-place-alist-to-file () 205(defun save-place-alist-to-file ()
206 (let ((file (expand-file-name save-place-file)) 206 (let ((file (expand-file-name save-place-file))
207 (coding-system-for-write 'utf-8)) 207 (coding-system-for-write 'utf-8))
208 (save-excursion 208 (with-current-buffer (get-buffer-create " *Saved Places*")
209 (set-buffer (get-buffer-create " *Saved Places*"))
210 (delete-region (point-min) (point-max)) 209 (delete-region (point-min) (point-max))
211 (when save-place-forget-unreadable-files 210 (when save-place-forget-unreadable-files
212 (save-place-forget-unreadable-files)) 211 (save-place-forget-unreadable-files))
@@ -236,10 +235,9 @@ may have changed\) back to `save-place-alist'."
236 ;; make sure that the alist does not get overwritten, and then 235 ;; make sure that the alist does not get overwritten, and then
237 ;; load it if it exists: 236 ;; load it if it exists:
238 (if (file-readable-p file) 237 (if (file-readable-p file)
239 (save-excursion 238 ;; don't want to use find-file because we have been
240 ;; don't want to use find-file because we have been 239 ;; adding hooks to it.
241 ;; adding hooks to it. 240 (with-current-buffer (get-buffer-create " *Saved Places*")
242 (set-buffer (get-buffer-create " *Saved Places*"))
243 (delete-region (point-min) (point-max)) 241 (delete-region (point-min) (point-max))
244 (insert-file-contents file) 242 (insert-file-contents file)
245 (goto-char (point-min)) 243 (goto-char (point-min))
@@ -275,8 +273,7 @@ may have changed\) back to `save-place-alist'."
275 ;; put this into a save-excursion in case someone is counting on 273 ;; put this into a save-excursion in case someone is counting on
276 ;; another function in kill-emacs-hook to act on the last buffer 274 ;; another function in kill-emacs-hook to act on the last buffer
277 ;; they were in: 275 ;; they were in:
278 (save-excursion 276 (with-current-buffer (car buf-list)
279 (set-buffer (car buf-list))
280 ;; save-place checks buffer-file-name too, but we can avoid 277 ;; save-place checks buffer-file-name too, but we can avoid
281 ;; overhead of function call by checking here too. 278 ;; overhead of function call by checking here too.
282 (and buffer-file-name (save-place-to-alist)) 279 (and buffer-file-name (save-place-to-alist))
diff --git a/lisp/sb-image.el b/lisp/sb-image.el
index 6140580cd3b..01fd67c879f 100644
--- a/lisp/sb-image.el
+++ b/lisp/sb-image.el
@@ -85,8 +85,7 @@ If we have an image associated with it, use that image."
85See `speedbar-expand-image-button-alist' for details." 85See `speedbar-expand-image-button-alist' for details."
86 (interactive) 86 (interactive)
87 (with-output-to-temp-buffer "*Speedbar Images*" 87 (with-output-to-temp-buffer "*Speedbar Images*"
88 (save-excursion 88 (with-current-buffer "*Speedbar Images*"
89 (set-buffer "*Speedbar Images*")
90 (goto-char (point-max)) 89 (goto-char (point-max))
91 (insert "Speedbar image cache.\n\n") 90 (insert "Speedbar image cache.\n\n")
92 (let ((start (point)) (end nil)) 91 (let ((start (point)) (end nil))
diff --git a/lisp/scroll-bar.el b/lisp/scroll-bar.el
index eed6921b7e7..f50bb12cbbe 100644
--- a/lisp/scroll-bar.el
+++ b/lisp/scroll-bar.el
@@ -156,7 +156,7 @@ Horizontal scroll bars aren't implemented yet."
156 156
157;;;; Buffer navigation using the scroll bar. 157;;;; Buffer navigation using the scroll bar.
158 158
159;;; This was used for up-events on button 2, but no longer. 159;; This was used for up-events on button 2, but no longer.
160(defun scroll-bar-set-window-start (event) 160(defun scroll-bar-set-window-start (event)
161 "Set the window start according to where the scroll bar is dragged. 161 "Set the window start according to where the scroll bar is dragged.
162EVENT should be a scroll bar click or drag event." 162EVENT should be a scroll bar click or drag event."
@@ -164,8 +164,7 @@ EVENT should be a scroll bar click or drag event."
164 (let* ((end-position (event-end event)) 164 (let* ((end-position (event-end event))
165 (window (nth 0 end-position)) 165 (window (nth 0 end-position))
166 (portion-whole (nth 2 end-position))) 166 (portion-whole (nth 2 end-position)))
167 (save-excursion 167 (with-current-buffer (window-buffer window)
168 (set-buffer (window-buffer window))
169 (save-excursion 168 (save-excursion
170 (goto-char (+ (point-min) 169 (goto-char (+ (point-min)
171 (scroll-bar-scale portion-whole 170 (scroll-bar-scale portion-whole
@@ -195,8 +194,7 @@ EVENT should be a scroll bar click or drag event."
195 portion-start 194 portion-start
196 next-portion-start 195 next-portion-start
197 (current-start (window-start window))) 196 (current-start (window-start window)))
198 (save-excursion 197 (with-current-buffer (window-buffer window)
199 (set-buffer (window-buffer window))
200 (setq portion-start (scroll-bar-drag-position portion-whole)) 198 (setq portion-start (scroll-bar-drag-position portion-whole))
201 (setq next-portion-start (max 199 (setq next-portion-start (max
202 (scroll-bar-drag-position next-portion-whole) 200 (scroll-bar-drag-position next-portion-whole)
@@ -212,8 +210,7 @@ EVENT should be a scroll bar click or drag event."
212 (let* ((start-position (event-start event)) 210 (let* ((start-position (event-start event))
213 (window (nth 0 start-position)) 211 (window (nth 0 start-position))
214 (portion-whole (nth 2 start-position))) 212 (portion-whole (nth 2 start-position)))
215 (save-excursion 213 (with-current-buffer (window-buffer window)
216 (set-buffer (window-buffer window))
217 ;; Calculate position relative to the accessible part of the buffer. 214 ;; Calculate position relative to the accessible part of the buffer.
218 (goto-char (+ (point-min) 215 (goto-char (+ (point-min)
219 (scroll-bar-scale portion-whole 216 (scroll-bar-scale portion-whole
@@ -339,7 +336,7 @@ EVENT should be a scroll bar click."
339 336
340;;;; Bindings. 337;;;; Bindings.
341 338
342;;; For now, we'll set things up to work like xterm. 339;; For now, we'll set things up to work like xterm.
343(cond ((and (boundp 'x-toolkit-scroll-bars) x-toolkit-scroll-bars) 340(cond ((and (boundp 'x-toolkit-scroll-bars) x-toolkit-scroll-bars)
344 (global-set-key [vertical-scroll-bar mouse-1] 341 (global-set-key [vertical-scroll-bar mouse-1]
345 'scroll-bar-toolkit-scroll)) 342 'scroll-bar-toolkit-scroll))
diff --git a/lisp/shadowfile.el b/lisp/shadowfile.el
index 7cd0e325da0..d2cf09b475b 100644
--- a/lisp/shadowfile.el
+++ b/lisp/shadowfile.el
@@ -707,8 +707,7 @@ With non-nil argument also saves the buffer."
707 707
708(defun shadow-save-todo-file () 708(defun shadow-save-todo-file ()
709 (if (and shadow-todo-buffer (buffer-modified-p shadow-todo-buffer)) 709 (if (and shadow-todo-buffer (buffer-modified-p shadow-todo-buffer))
710 (save-excursion 710 (with-current-buffer shadow-todo-buffer
711 (set-buffer shadow-todo-buffer)
712 (condition-case nil ; have to continue even in case of 711 (condition-case nil ; have to continue even in case of
713 (basic-save-buffer) ; error, otherwise kill-emacs might 712 (basic-save-buffer) ; error, otherwise kill-emacs might
714 (error ; not work! 713 (error ; not work!
diff --git a/lisp/simple.el b/lisp/simple.el
index e1d0f052ea0..d87ddab685d 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -2423,8 +2423,7 @@ specifies the value of ERROR-BUFFER."
2423 ;; Clear the output buffer, then run the command with 2423 ;; Clear the output buffer, then run the command with
2424 ;; output there. 2424 ;; output there.
2425 (let ((directory default-directory)) 2425 (let ((directory default-directory))
2426 (save-excursion 2426 (with-current-buffer buffer
2427 (set-buffer buffer)
2428 (setq buffer-read-only nil) 2427 (setq buffer-read-only nil)
2429 (if (not output-buffer) 2428 (if (not output-buffer)
2430 (setq default-directory directory)) 2429 (setq default-directory directory))
@@ -3469,11 +3468,10 @@ START and END specify the portion of the current buffer to be copied."
3469 (list (read-buffer "Append to buffer: " (other-buffer (current-buffer) t)) 3468 (list (read-buffer "Append to buffer: " (other-buffer (current-buffer) t))
3470 (region-beginning) (region-end))) 3469 (region-beginning) (region-end)))
3471 (let ((oldbuf (current-buffer))) 3470 (let ((oldbuf (current-buffer)))
3472 (save-excursion 3471 (let* ((append-to (get-buffer-create buffer))
3473 (let* ((append-to (get-buffer-create buffer)) 3472 (windows (get-buffer-window-list append-to t t))
3474 (windows (get-buffer-window-list append-to t t)) 3473 point)
3475 point) 3474 (with-current-buffer append-to
3476 (set-buffer append-to)
3477 (setq point (point)) 3475 (setq point (point))
3478 (barf-if-buffer-read-only) 3476 (barf-if-buffer-read-only)
3479 (insert-buffer-substring oldbuf start end) 3477 (insert-buffer-substring oldbuf start end)
@@ -3490,8 +3488,7 @@ BUFFER (or buffer name), START and END.
3490START and END specify the portion of the current buffer to be copied." 3488START and END specify the portion of the current buffer to be copied."
3491 (interactive "BPrepend to buffer: \nr") 3489 (interactive "BPrepend to buffer: \nr")
3492 (let ((oldbuf (current-buffer))) 3490 (let ((oldbuf (current-buffer)))
3493 (save-excursion 3491 (with-current-buffer (get-buffer-create buffer)
3494 (set-buffer (get-buffer-create buffer))
3495 (barf-if-buffer-read-only) 3492 (barf-if-buffer-read-only)
3496 (save-excursion 3493 (save-excursion
3497 (insert-buffer-substring oldbuf start end))))) 3494 (insert-buffer-substring oldbuf start end)))))
diff --git a/lisp/speedbar.el b/lisp/speedbar.el
index 2559057cc22..1266c0c1a07 100644
--- a/lisp/speedbar.el
+++ b/lisp/speedbar.el
@@ -1173,8 +1173,7 @@ frame and window to be the currently active frame and window."
1173 (with-no-warnings 1173 (with-no-warnings
1174 (specifier-instance has-modeline-p))) 1174 (specifier-instance has-modeline-p)))
1175 speedbar-buffer) 1175 speedbar-buffer)
1176 (save-excursion 1176 (with-current-buffer speedbar-buffer
1177 (set-buffer speedbar-buffer)
1178 (let* ((w (or (speedbar-frame-width) 20)) 1177 (let* ((w (or (speedbar-frame-width) 20))
1179 (p1 "<<") 1178 (p1 "<<")
1180 (p5 ">>") 1179 (p5 ">>")
@@ -1246,8 +1245,7 @@ and the existence of packages."
1246 (current-buffer)) 1245 (current-buffer))
1247 speedbar-special-mode-key-map) 1246 speedbar-special-mode-key-map)
1248 (select-frame cf)))))) 1247 (select-frame cf))))))
1249 (save-excursion 1248 (with-current-buffer speedbar-buffer
1250 (set-buffer speedbar-buffer)
1251 (use-local-map (or localmap 1249 (use-local-map (or localmap
1252 (speedbar-initial-keymap) 1250 (speedbar-initial-keymap)
1253 ;; This creates a small keymap we can glom the 1251 ;; This creates a small keymap we can glom the
@@ -1859,8 +1857,7 @@ of the special mode functions."
1859 (if (stringp buffer) (setq buffer (get-buffer buffer))) 1857 (if (stringp buffer) (setq buffer (get-buffer buffer)))
1860 (if (not (buffer-live-p buffer)) 1858 (if (not (buffer-live-p buffer))
1861 nil 1859 nil
1862 (save-excursion 1860 (with-current-buffer buffer
1863 (set-buffer buffer)
1864 (save-match-data 1861 (save-match-data
1865 (let ((ms (symbol-name major-mode)) v) 1862 (let ((ms (symbol-name major-mode)) v)
1866 (if (not (string-match "-mode$" ms)) 1863 (if (not (string-match "-mode$" ms))
@@ -1893,8 +1890,7 @@ of the special mode functions."
1893 1890
1894(defun speedbar-remove-localized-speedbar-support (buffer) 1891(defun speedbar-remove-localized-speedbar-support (buffer)
1895 "Remove any traces that BUFFER supports speedbar in a specialized way." 1892 "Remove any traces that BUFFER supports speedbar in a specialized way."
1896 (save-excursion 1893 (with-current-buffer buffer
1897 (set-buffer buffer)
1898 (kill-local-variable 'speedbar-special-mode-expansion-list) 1894 (kill-local-variable 'speedbar-special-mode-expansion-list)
1899 (kill-local-variable 'speedbar-special-mode-key-map) 1895 (kill-local-variable 'speedbar-special-mode-key-map)
1900 (kill-local-variable 'speedbar-easymenu-definition-special))) 1896 (kill-local-variable 'speedbar-easymenu-definition-special)))
@@ -2383,8 +2379,8 @@ the list."
2383 (or (speedbar-line-file) 2379 (or (speedbar-line-file)
2384 (speedbar-line-directory)))) 2380 (speedbar-line-directory))))
2385 (methods (if (get-file-buffer f) 2381 (methods (if (get-file-buffer f)
2386 (save-excursion (set-buffer (get-file-buffer f)) 2382 (with-current-buffer (get-file-buffer f)
2387 speedbar-tag-hierarchy-method) 2383 speedbar-tag-hierarchy-method)
2388 speedbar-tag-hierarchy-method)) 2384 speedbar-tag-hierarchy-method))
2389 (lst (if (fboundp 'copy-tree) 2385 (lst (if (fboundp 'copy-tree)
2390 (copy-tree lst) 2386 (copy-tree lst)
@@ -2612,9 +2608,8 @@ name will have the function FIND-FUN and not token."
2612This should only be used by modes classified as special." 2608This should only be used by modes classified as special."
2613 (let ((funclst speedbar-special-mode-expansion-list) 2609 (let ((funclst speedbar-special-mode-expansion-list)
2614 (specialbuff (current-buffer))) 2610 (specialbuff (current-buffer)))
2615 (save-excursion 2611 (setq speedbar-desired-buffer specialbuff)
2616 (setq speedbar-desired-buffer specialbuff) 2612 (with-current-buffer speedbar-buffer
2617 (set-buffer speedbar-buffer)
2618 ;; If we are leaving a directory, cache it. 2613 ;; If we are leaving a directory, cache it.
2619 (if (not speedbar-shown-directories) 2614 (if (not speedbar-shown-directories)
2620 ;; Do nothing 2615 ;; Do nothing
@@ -3887,8 +3882,8 @@ If TEMP is non-nil, then clicking on a buffer restores the previous display."
3887 (buffer-name (car bl)))) 3882 (buffer-name (car bl))))
3888 (expchar (if known ?+ ??)) 3883 (expchar (if known ?+ ??))
3889 (fn (if known 'speedbar-tag-file nil)) 3884 (fn (if known 'speedbar-tag-file nil))
3890 (fname (save-excursion (set-buffer (car bl)) 3885 (fname (with-current-buffer (car bl)
3891 (buffer-file-name)))) 3886 (buffer-file-name))))
3892 (speedbar-make-tag-line 'bracket expchar fn 3887 (speedbar-make-tag-line 'bracket expchar fn
3893 (if fname (file-name-nondirectory fname)) 3888 (if fname (file-name-nondirectory fname))
3894 (buffer-name (car bl)) 3889 (buffer-name (car bl))
@@ -3928,8 +3923,7 @@ If TEMP is non-nil, then clicking on a buffer restores the previous display."
3928 "Add a note to the end of the last tag line. 3923 "Add a note to the end of the last tag line.
3929Argument BUFFER is the buffer being tested." 3924Argument BUFFER is the buffer being tested."
3930 (let (mod ro) 3925 (let (mod ro)
3931 (save-excursion 3926 (with-current-buffer buffer
3932 (set-buffer buffer)
3933 (setq mod (buffer-modified-p) 3927 (setq mod (buffer-modified-p)
3934 ro buffer-read-only)) 3928 ro buffer-read-only))
3935 (if ro (speedbar-insert-button "%" nil nil nil nil t)))) 3929 (if ro (speedbar-insert-button "%" nil nil nil nil t))))
@@ -3943,9 +3937,8 @@ Argument BUFFER is the buffer being tested."
3943 (speedbar-message "%s%s %S %d %s" 3937 (speedbar-message "%s%s %S %d %s"
3944 (if (buffer-modified-p buffer) "* " "") 3938 (if (buffer-modified-p buffer) "* " "")
3945 item 3939 item
3946 (save-excursion (set-buffer buffer) major-mode) 3940 (with-current-buffer buffer major-mode)
3947 (save-excursion (set-buffer buffer) 3941 (with-current-buffer buffer (buffer-size))
3948 (buffer-size))
3949 (or (buffer-file-name buffer) "<No file>")))))) 3942 (or (buffer-file-name buffer) "<No file>"))))))
3950 3943
3951(defun speedbar-buffers-line-directory (&optional depth) 3944(defun speedbar-buffers-line-directory (&optional depth)
@@ -3963,8 +3956,7 @@ Optional argument DEPTH specifies the current depth of the back search."
3963 (if (save-excursion 3956 (if (save-excursion
3964 (end-of-line) 3957 (end-of-line)
3965 (eq start (point))) 3958 (eq start (point)))
3966 (or (save-excursion (set-buffer buffer) 3959 (or (with-current-buffer buffer default-directory)
3967 default-directory)
3968 "") 3960 "")
3969 (buffer-file-name buffer)))))))) 3961 (buffer-file-name buffer))))))))
3970 3962
diff --git a/lisp/strokes.el b/lisp/strokes.el
index d033f779980..ba5ca20a2c1 100644
--- a/lisp/strokes.el
+++ b/lisp/strokes.el
@@ -1536,8 +1536,7 @@ Encode/decode your strokes with \\[strokes-encode-buffer],
1536(defun strokes-xpm-to-compressed-string (&optional xpm-buffer) 1536(defun strokes-xpm-to-compressed-string (&optional xpm-buffer)
1537 "Convert XPM in XPM-BUFFER to compressed string representing the stroke. 1537 "Convert XPM in XPM-BUFFER to compressed string representing the stroke.
1538XPM-BUFFER defaults to ` *strokes-xpm*'." 1538XPM-BUFFER defaults to ` *strokes-xpm*'."
1539 (save-excursion 1539 (with-current-buffer (setq xpm-buffer (or xpm-buffer " *strokes-xpm*"))
1540 (set-buffer (setq xpm-buffer (or xpm-buffer " *strokes-xpm*")))
1541 (goto-char (point-min)) 1540 (goto-char (point-min))
1542 (search-forward "/* pixels */") ; skip past header junk 1541 (search-forward "/* pixels */") ; skip past header junk
1543 (forward-char 2) 1542 (forward-char 2)
@@ -1620,8 +1619,7 @@ Optional BUFFER defaults to the current buffer.
1620Optional FORCE non-nil will ignore the buffer's read-only status." 1619Optional FORCE non-nil will ignore the buffer's read-only status."
1621 (interactive) 1620 (interactive)
1622 ;; (interactive "*bStrokify buffer: ") 1621 ;; (interactive "*bStrokify buffer: ")
1623 (save-excursion 1622 (with-current-buffer (setq buffer (get-buffer (or buffer (current-buffer))))
1624 (set-buffer (setq buffer (get-buffer (or buffer (current-buffer)))))
1625 (when (or (not buffer-read-only) 1623 (when (or (not buffer-read-only)
1626 force 1624 force
1627 inhibit-read-only 1625 inhibit-read-only
@@ -1669,8 +1667,7 @@ Optional FORCE non-nil will ignore the buffer's read-only status."
1669 ;; buffer is killed? 1667 ;; buffer is killed?
1670 ;; (interactive "*bUnstrokify buffer: ") 1668 ;; (interactive "*bUnstrokify buffer: ")
1671 (interactive) 1669 (interactive)
1672 (save-excursion 1670 (with-current-buffer (setq buffer (or buffer (current-buffer)))
1673 (set-buffer (setq buffer (or buffer (current-buffer))))
1674 (when (or (not buffer-read-only) 1671 (when (or (not buffer-read-only)
1675 force 1672 force
1676 inhibit-read-only 1673 inhibit-read-only
@@ -1706,9 +1703,8 @@ Optional FORCE non-nil will ignore the buffer's read-only status."
1706(defun strokes-xpm-for-compressed-string (compressed-string &optional bufname) 1703(defun strokes-xpm-for-compressed-string (compressed-string &optional bufname)
1707 "Convert the stroke represented by COMPRESSED-STRING into an XPM. 1704 "Convert the stroke represented by COMPRESSED-STRING into an XPM.
1708Store XPM in buffer BUFNAME if supplied \(default is ` *strokes-xpm*'\)" 1705Store XPM in buffer BUFNAME if supplied \(default is ` *strokes-xpm*'\)"
1709 (save-excursion 1706 (or bufname (setq bufname " *strokes-xpm*"))
1710 (or bufname (setq bufname " *strokes-xpm*")) 1707 (with-current-buffer (get-buffer-create bufname)
1711 (set-buffer (get-buffer-create bufname))
1712 (erase-buffer) 1708 (erase-buffer)
1713 (insert compressed-string) 1709 (insert compressed-string)
1714 (goto-char (point-min)) 1710 (goto-char (point-min))
diff --git a/lisp/term.el b/lisp/term.el
index 97d2fa5a74e..61dd3f415f0 100644
--- a/lisp/term.el
+++ b/lisp/term.el
@@ -1347,8 +1347,7 @@ the process. Any more args are arguments to PROGRAM."
1347 ;; If no process, or nuked process, crank up a new one and put buffer in 1347 ;; If no process, or nuked process, crank up a new one and put buffer in
1348 ;; term mode. Otherwise, leave buffer and existing process alone. 1348 ;; term mode. Otherwise, leave buffer and existing process alone.
1349 (cond ((not (term-check-proc buffer)) 1349 (cond ((not (term-check-proc buffer))
1350 (save-excursion 1350 (with-current-buffer buffer
1351 (set-buffer buffer)
1352 (term-mode)) ; Install local vars, mode, keymap, ... 1351 (term-mode)) ; Install local vars, mode, keymap, ...
1353 (term-exec buffer name program startfile switches))) 1352 (term-exec buffer name program startfile switches)))
1354 buffer)) 1353 buffer))
@@ -1375,8 +1374,7 @@ commands to use in that buffer.
1375Blasts any old process running in the buffer. Doesn't set the buffer mode. 1374Blasts any old process running in the buffer. Doesn't set the buffer mode.
1376You can use this to cheaply run a series of processes in the same term 1375You can use this to cheaply run a series of processes in the same term
1377buffer. The hook `term-exec-hook' is run after each exec." 1376buffer. The hook `term-exec-hook' is run after each exec."
1378 (save-excursion 1377 (with-current-buffer buffer
1379 (set-buffer buffer)
1380 (let ((proc (get-buffer-process buffer))) ; Blast any old process. 1378 (let ((proc (get-buffer-process buffer))) ; Blast any old process.
1381 (when proc (delete-process proc))) 1379 (when proc (delete-process proc)))
1382 ;; Crank up a new process 1380 ;; Crank up a new process
@@ -1412,24 +1410,16 @@ The main purpose is to get rid of the local keymap."
1412 (if (null (buffer-name buffer)) 1410 (if (null (buffer-name buffer))
1413 ;; buffer killed 1411 ;; buffer killed
1414 (set-process-buffer proc nil) 1412 (set-process-buffer proc nil)
1415 (let ((obuf (current-buffer))) 1413 (with-current-buffer buffer
1416 ;; save-excursion isn't the right thing if 1414 ;; Write something in the compilation buffer
1417 ;; process-buffer is current-buffer 1415 ;; and hack its mode line.
1418 (unwind-protect 1416 ;; Get rid of local keymap.
1419 (progn 1417 (use-local-map nil)
1420 ;; Write something in the compilation buffer 1418 (term-handle-exit (process-name proc) msg)
1421 ;; and hack its mode line. 1419 ;; Since the buffer and mode line will show that the
1422 (set-buffer buffer) 1420 ;; process is dead, we can delete it now. Otherwise it
1423 ;; Get rid of local keymap. 1421 ;; will stay around until M-x list-processes.
1424 (use-local-map nil) 1422 (delete-process proc))))))
1425 (term-handle-exit (process-name proc)
1426 msg)
1427 ;; Since the buffer and mode line will show that the
1428 ;; process is dead, we can delete it now. Otherwise it
1429 ;; will stay around until M-x list-processes.
1430 (delete-process proc))
1431 (set-buffer obuf)))
1432 ))))
1433 1423
1434(defun term-handle-exit (process-name msg) 1424(defun term-handle-exit (process-name msg)
1435 "Write process exit (or other change) message MSG in the current buffer." 1425 "Write process exit (or other change) message MSG in the current buffer."
@@ -1557,8 +1547,7 @@ See also `term-input-ignoredups' and `term-write-input-ring'."
1557 (count 0) 1547 (count 0)
1558 (ring (make-ring term-input-ring-size))) 1548 (ring (make-ring term-input-ring-size)))
1559 (unwind-protect 1549 (unwind-protect
1560 (save-excursion 1550 (with-current-buffer history-buf
1561 (set-buffer history-buf)
1562 (widen) 1551 (widen)
1563 (erase-buffer) 1552 (erase-buffer)
1564 (insert-file-contents file) 1553 (insert-file-contents file)
@@ -1601,8 +1590,7 @@ See also `term-read-input-ring'."
1601 (index (ring-length ring))) 1590 (index (ring-length ring)))
1602 ;; Write it all out into a buffer first. Much faster, but messier, 1591 ;; Write it all out into a buffer first. Much faster, but messier,
1603 ;; than writing it one line at a time. 1592 ;; than writing it one line at a time.
1604 (save-excursion 1593 (with-current-buffer history-buf
1605 (set-buffer history-buf)
1606 (erase-buffer) 1594 (erase-buffer)
1607 (while (> index 0) 1595 (while (> index 0)
1608 (setq index (1- index)) 1596 (setq index (1- index))
@@ -2460,10 +2448,8 @@ See `term-prompt-regexp'."
2460 (y-or-n-p (format "Save buffer %s first? " 2448 (y-or-n-p (format "Save buffer %s first? "
2461 (buffer-name buff)))) 2449 (buffer-name buff))))
2462 ;; save BUFF. 2450 ;; save BUFF.
2463 (let ((old-buffer (current-buffer))) 2451 (with-current-buffer buff
2464 (set-buffer buff) 2452 (save-buffer)))))
2465 (save-buffer)
2466 (set-buffer old-buffer)))))
2467 2453
2468 2454
2469;; (TERM-GET-SOURCE prompt prev-dir/file source-modes mustmatch-p) 2455;; (TERM-GET-SOURCE prompt prev-dir/file source-modes mustmatch-p)
@@ -3453,8 +3439,7 @@ The top-most line is line 0."
3453(defun term-display-buffer-line (buffer line) 3439(defun term-display-buffer-line (buffer line)
3454 (let* ((window (display-buffer buffer t)) 3440 (let* ((window (display-buffer buffer t))
3455 (pos)) 3441 (pos))
3456 (save-excursion 3442 (with-current-buffer buffer
3457 (set-buffer buffer)
3458 (save-restriction 3443 (save-restriction
3459 (widen) 3444 (widen)
3460 (goto-char (point-min)) 3445 (goto-char (point-min))
@@ -3896,8 +3881,7 @@ if KIND is 1, erase from home to point; else erase from home to point-max."
3896 (message "Output logging off.")) 3881 (message "Output logging off."))
3897 (if (get-buffer name) 3882 (if (get-buffer name)
3898 nil 3883 nil
3899 (save-excursion 3884 (with-current-buffer (get-buffer-create name)
3900 (set-buffer (get-buffer-create name))
3901 (fundamental-mode) 3885 (fundamental-mode)
3902 (buffer-disable-undo (current-buffer)) 3886 (buffer-disable-undo (current-buffer))
3903 (erase-buffer))) 3887 (erase-buffer)))
@@ -4169,8 +4153,7 @@ Typing SPC flushes the help buffer."
4169 (display-completion-list (sort completions 'string-lessp))) 4153 (display-completion-list (sort completions 'string-lessp)))
4170 (message "Hit space to flush") 4154 (message "Hit space to flush")
4171 (let (key first) 4155 (let (key first)
4172 (if (save-excursion 4156 (if (with-current-buffer (get-buffer "*Completions*")
4173 (set-buffer (get-buffer "*Completions*"))
4174 (setq key (read-key-sequence nil) 4157 (setq key (read-key-sequence nil)
4175 first (aref key 0)) 4158 first (aref key 0))
4176 (and (consp first) 4159 (and (consp first)
@@ -4197,8 +4180,7 @@ the process. Any more args are arguments to PROGRAM."
4197 ;; If no process, or nuked process, crank up a new one and put buffer in 4180 ;; If no process, or nuked process, crank up a new one and put buffer in
4198 ;; term mode. Otherwise, leave buffer and existing process alone. 4181 ;; term mode. Otherwise, leave buffer and existing process alone.
4199 (cond ((not (term-check-proc buffer)) 4182 (cond ((not (term-check-proc buffer))
4200 (save-excursion 4183 (with-current-buffer buffer
4201 (set-buffer buffer)
4202 (term-mode)) ; Install local vars, mode, keymap, ... 4184 (term-mode)) ; Install local vars, mode, keymap, ...
4203 (term-exec buffer name program startfile switches))) 4185 (term-exec buffer name program startfile switches)))
4204 buffer)) 4186 buffer))
@@ -4383,8 +4365,7 @@ use in that buffer.
4383 :coding 'no-conversion 4365 :coding 'no-conversion
4384 :noquery t)) 4366 :noquery t))
4385 (buffer (process-buffer process))) 4367 (buffer (process-buffer process)))
4386 (save-excursion 4368 (with-current-buffer buffer
4387 (set-buffer buffer)
4388 (term-mode) 4369 (term-mode)
4389 (term-char-mode) 4370 (term-char-mode)
4390 (goto-char (point-max)) 4371 (goto-char (point-max))
diff --git a/lisp/terminal.el b/lisp/terminal.el
index a015a918047..1ac96aad1d2 100644
--- a/lisp/terminal.el
+++ b/lisp/terminal.el
@@ -326,8 +326,7 @@ Very poor man's file transfer protocol."
326 (message "Output logging off.")) 326 (message "Output logging off."))
327 (if (get-buffer name) 327 (if (get-buffer name)
328 nil 328 nil
329 (save-excursion 329 (with-current-buffer (get-buffer-create name)
330 (set-buffer (get-buffer-create name))
331 (fundamental-mode) 330 (fundamental-mode)
332 (buffer-disable-undo (current-buffer)) 331 (buffer-disable-undo (current-buffer))
333 (erase-buffer))) 332 (erase-buffer)))
@@ -610,8 +609,7 @@ together with a command \\<terminal-edit-map>to return to terminal emulation: \\
610 "%-")) 609 "%-"))
611 (set-process-filter te-process 610 (set-process-filter te-process
612 (function (lambda (process string) 611 (function (lambda (process string)
613 (save-excursion 612 (with-current-buffer (process-buffer process)
614 (set-buffer (process-buffer process))
615 (setq te-pending-output (nconc te-pending-output 613 (setq te-pending-output (nconc te-pending-output
616 (list string)))) 614 (list string))))
617 (te-update-pending-output-display)))) 615 (te-update-pending-output-display))))
@@ -874,27 +872,22 @@ move to start of new line, clear to end of line."
874 872
875 873
876(defun te-filter (process string) 874(defun te-filter (process string)
877 (let* ((obuf (current-buffer))) 875 (with-current-buffer (process-buffer process)
878 ;; can't use save-excursion, as that preserves point, which we don't want 876 (goto-char te-saved-point)
879 (unwind-protect 877 (and (bufferp te-log-buffer)
880 (progn 878 (if (null (buffer-name te-log-buffer))
881 (set-buffer (process-buffer process)) 879 ;; killed
882 (goto-char te-saved-point) 880 (setq te-log-buffer nil)
883 (and (bufferp te-log-buffer) 881 (set-buffer te-log-buffer)
884 (if (null (buffer-name te-log-buffer)) 882 (goto-char (point-max))
885 ;; killed 883 (insert-before-markers string)
886 (setq te-log-buffer nil) 884 (set-buffer (process-buffer process))))
887 (set-buffer te-log-buffer) 885 (setq te-pending-output (nconc te-pending-output (list string)))
888 (goto-char (point-max)) 886 (te-update-pending-output-display)
889 (insert-before-markers string) 887 (te-process-output (eq (current-buffer)
890 (set-buffer (process-buffer process)))) 888 (window-buffer (selected-window))))
891 (setq te-pending-output (nconc te-pending-output (list string))) 889 (set-buffer (process-buffer process))
892 (te-update-pending-output-display) 890 (setq te-saved-point (point))))
893 (te-process-output (eq (current-buffer)
894 (window-buffer (selected-window))))
895 (set-buffer (process-buffer process))
896 (setq te-saved-point (point)))
897 (set-buffer obuf))))
898 891
899;; (A version of the following comment which might be distractingly offensive 892;; (A version of the following comment which might be distractingly offensive
900;; to some readers has been moved to term-nasty.el.) 893;; to some readers has been moved to term-nasty.el.)
@@ -1043,8 +1036,7 @@ move to start of new line, clear to end of line."
1043 (cond ((eq (process-status process) 'run)) 1036 (cond ((eq (process-status process) 'run))
1044 ((null (buffer-name (process-buffer process)))) ;deleted 1037 ((null (buffer-name (process-buffer process)))) ;deleted
1045 (t (let ((b (current-buffer))) 1038 (t (let ((b (current-buffer)))
1046 (save-excursion 1039 (with-current-buffer (process-buffer process)
1047 (set-buffer (process-buffer process))
1048 (setq buffer-read-only nil) 1040 (setq buffer-read-only nil)
1049 (fundamental-mode) 1041 (fundamental-mode)
1050 (goto-char (point-max)) 1042 (goto-char (point-max))
@@ -1097,27 +1089,26 @@ This function calls the value of terminal-mode-hook if that exists
1097and is non-nil after the terminal buffer has been set up and the 1089and is non-nil after the terminal buffer has been set up and the
1098subprocess started." 1090subprocess started."
1099 (interactive 1091 (interactive
1100 (cons (save-excursion 1092 (cons (with-current-buffer (get-buffer-create "*terminal*")
1101 (set-buffer (get-buffer-create "*terminal*")) 1093 (buffer-name (if (or (not (boundp 'te-process))
1102 (buffer-name (if (or (not (boundp 'te-process)) 1094 (null te-process)
1103 (null te-process) 1095 (not (eq (process-status te-process)
1104 (not (eq (process-status te-process) 1096 'run)))
1105 'run))) 1097 (current-buffer)
1106 (current-buffer) 1098 (generate-new-buffer "*terminal*"))))
1107 (generate-new-buffer "*terminal*")))) 1099 (append
1108 (append 1100 (let* ((default-s
1109 (let* ((default-s 1101 ;; Default shell is same thing M-x shell uses.
1110 ;; Default shell is same thing M-x shell uses. 1102 (or explicit-shell-file-name
1111 (or explicit-shell-file-name 1103 (getenv "ESHELL")
1112 (getenv "ESHELL") 1104 (getenv "SHELL")
1113 (getenv "SHELL") 1105 "/bin/sh"))
1114 "/bin/sh")) 1106 (s (read-string
1115 (s (read-string 1107 (format "Run program in emulator (default %s): "
1116 (format "Run program in emulator (default %s): " 1108 default-s))))
1117 default-s)))) 1109 (if (equal s "")
1118 (if (equal s "") 1110 (list default-s '())
1119 (list default-s '()) 1111 (te-parse-program-and-args s))))))
1120 (te-parse-program-and-args s))))))
1121 (switch-to-buffer buffer) 1112 (switch-to-buffer buffer)
1122 (if (null width) (setq width (- (window-width (selected-window)) 1))) 1113 (if (null width) (setq width (- (window-width (selected-window)) 1)))
1123 (if (null height) (setq height (- (window-height (selected-window)) 1))) 1114 (if (null height) (setq height (- (window-height (selected-window)) 1)))
diff --git a/lisp/time-stamp.el b/lisp/time-stamp.el
index d2adad1e82f..6996086c0ff 100644
--- a/lisp/time-stamp.el
+++ b/lisp/time-stamp.el
@@ -660,8 +660,7 @@ The new forms being recommended now will continue to work then.")
660Suggests replacing OLD-FORM with NEW-FORM." 660Suggests replacing OLD-FORM with NEW-FORM."
661 (cond 661 (cond
662 (time-stamp-conversion-warn 662 (time-stamp-conversion-warn
663 (save-excursion 663 (with-current-buffer (get-buffer-create "*Time-stamp-compatibility*")
664 (set-buffer (get-buffer-create "*Time-stamp-compatibility*"))
665 (goto-char (point-max)) 664 (goto-char (point-max))
666 (if (bobp) 665 (if (bobp)
667 (progn 666 (progn
diff --git a/lisp/type-break.el b/lisp/type-break.el
index a72de04256e..4c150ca575a 100644
--- a/lisp/type-break.el
+++ b/lisp/type-break.el
@@ -1094,7 +1094,7 @@ FRAC should be the inverse of the fractional value; for example, a value of
1094(defun type-break-force-mode-line-update (&optional all) 1094(defun type-break-force-mode-line-update (&optional all)
1095 "Force the mode-line of the current buffer to be redisplayed. 1095 "Force the mode-line of the current buffer to be redisplayed.
1096With optional non-nil ALL, force redisplay of all mode-lines." 1096With optional non-nil ALL, force redisplay of all mode-lines."
1097 (and all (save-excursion (set-buffer (other-buffer)))) 1097 (and all (with-current-buffer (other-buffer)))
1098 (set-buffer-modified-p (buffer-modified-p))) 1098 (set-buffer-modified-p (buffer-modified-p)))
1099 1099
1100;; If an exception occurs in Emacs while running the post command hook, the 1100;; If an exception occurs in Emacs while running the post command hook, the
@@ -1108,9 +1108,9 @@ With optional non-nil ALL, force redisplay of all mode-lines."
1108 1108
1109 1109
1110;;; Timer wrapper functions 1110;;; Timer wrapper functions
1111;;; 1111;;
1112;;; These shield type-break from variations in the interval timer packages 1112;; These shield type-break from variations in the interval timer packages
1113;;; for different versions of Emacs. 1113;; for different versions of Emacs.
1114 1114
1115(defun type-break-run-at-time (time repeat function) 1115(defun type-break-run-at-time (time repeat function)
1116 (condition-case nil (or (require 'timer) (require 'itimer)) (error nil)) 1116 (condition-case nil (or (require 'timer) (require 'itimer)) (error nil))
diff --git a/lisp/userlock.el b/lisp/userlock.el
index 93848cb4943..58b6c604666 100644
--- a/lisp/userlock.el
+++ b/lisp/userlock.el
@@ -91,8 +91,7 @@ You can <s>teal the file; the other user becomes the
91 intruder if (s)he ever unmodifies the file and then changes it again. 91 intruder if (s)he ever unmodifies the file and then changes it again.
92You can <p>roceed; you edit at your own (and the other user's) risk. 92You can <p>roceed; you edit at your own (and the other user's) risk.
93You can <q>uit; don't modify this file.") 93You can <q>uit; don't modify this file.")
94 (save-excursion 94 (with-current-buffer standard-output
95 (set-buffer standard-output)
96 (help-mode)))) 95 (help-mode))))
97 96
98(put 97(put
@@ -155,8 +154,7 @@ If you say `n', the change you started to make will be aborted.
155 154
156Usually, you should type `n' and then `M-x revert-buffer', 155Usually, you should type `n' and then `M-x revert-buffer',
157to get the latest version of the file, then make the change again.") 156to get the latest version of the file, then make the change again.")
158 (save-excursion 157 (with-current-buffer standard-output
159 (set-buffer standard-output)
160 (help-mode)))) 158 (help-mode))))
161 159
162;; arch-tag: a61c5b60-e1c8-44fd-894a-c617f4dfc639 160;; arch-tag: a61c5b60-e1c8-44fd-894a-c617f4dfc639
diff --git a/lisp/vc-rcs.el b/lisp/vc-rcs.el
index 7352cbc4b6d..ddc27e4b36c 100644
--- a/lisp/vc-rcs.el
+++ b/lisp/vc-rcs.el
@@ -1055,65 +1055,64 @@ Returns: nil if no headers were found
1055 (cond 1055 (cond
1056 ((not (get-file-buffer file)) nil) 1056 ((not (get-file-buffer file)) nil)
1057 ((let (status version locking-user) 1057 ((let (status version locking-user)
1058 (save-excursion 1058 (with-current-buffer (get-file-buffer file)
1059 (set-buffer (get-file-buffer file)) 1059 (goto-char (point-min))
1060 (goto-char (point-min)) 1060 (cond
1061 (cond 1061 ;; search for $Id or $Header
1062 ;; search for $Id or $Header 1062 ;; -------------------------
1063 ;; ------------------------- 1063 ;; The `\ 's below avoid an RCS 5.7 bug when checking in this file.
1064 ;; The `\ 's below avoid an RCS 5.7 bug when checking in this file. 1064 ((or (and (search-forward "$Id\ : " nil t)
1065 ((or (and (search-forward "$Id\ : " nil t) 1065 (looking-at "[^ ]+ \\([0-9.]+\\) "))
1066 (looking-at "[^ ]+ \\([0-9.]+\\) ")) 1066 (and (progn (goto-char (point-min))
1067 (and (progn (goto-char (point-min)) 1067 (search-forward "$Header\ : " nil t))
1068 (search-forward "$Header\ : " nil t)) 1068 (looking-at "[^ ]+ \\([0-9.]+\\) ")))
1069 (looking-at "[^ ]+ \\([0-9.]+\\) "))) 1069 (goto-char (match-end 0))
1070 (goto-char (match-end 0)) 1070 ;; if found, store the revision number ...
1071 ;; if found, store the revision number ... 1071 (setq version (match-string-no-properties 1))
1072 (setq version (match-string-no-properties 1)) 1072 ;; ... and check for the locking state
1073 ;; ... and check for the locking state 1073 (cond
1074 (cond 1074 ((looking-at
1075 ((looking-at 1075 (concat "[0-9]+[/-][01][0-9][/-][0-3][0-9] " ; date
1076 (concat "[0-9]+[/-][01][0-9][/-][0-3][0-9] " ; date 1076 "[0-2][0-9]:[0-5][0-9]+:[0-6][0-9]+\\([+-][0-9:]+\\)? " ; time
1077 "[0-2][0-9]:[0-5][0-9]+:[0-6][0-9]+\\([+-][0-9:]+\\)? " ; time 1077 "[^ ]+ [^ ]+ ")) ; author & state
1078 "[^ ]+ [^ ]+ ")) ; author & state 1078 (goto-char (match-end 0)) ; [0-6] in regexp handles leap seconds
1079 (goto-char (match-end 0)) ; [0-6] in regexp handles leap seconds 1079 (cond
1080 (cond 1080 ;; unlocked revision
1081 ;; unlocked revision 1081 ((looking-at "\\$")
1082 ((looking-at "\\$") 1082 (setq locking-user 'none)
1083 (setq locking-user 'none) 1083 (setq status 'rev-and-lock))
1084 (setq status 'rev-and-lock)) 1084 ;; revision is locked by some user
1085 ;; revision is locked by some user 1085 ((looking-at "\\([^ ]+\\) \\$")
1086 ((looking-at "\\([^ ]+\\) \\$") 1086 (setq locking-user (match-string-no-properties 1))
1087 (setq locking-user (match-string-no-properties 1)) 1087 (setq status 'rev-and-lock))
1088 (setq status 'rev-and-lock)) 1088 ;; everything else: false
1089 ;; everything else: false 1089 (nil)))
1090 (nil))) 1090 ;; unexpected information in
1091 ;; unexpected information in 1091 ;; keyword string --> quit
1092 ;; keyword string --> quit 1092 (nil)))
1093 (nil))) 1093 ;; search for $Revision
1094 ;; search for $Revision 1094 ;; --------------------
1095 ;; -------------------- 1095 ((re-search-forward (concat "\\$"
1096 ((re-search-forward (concat "\\$" 1096 "Revision: \\([0-9.]+\\) \\$")
1097 "Revision: \\([0-9.]+\\) \\$") 1097 nil t)
1098 nil t) 1098 ;; if found, store the revision number ...
1099 ;; if found, store the revision number ... 1099 (setq version (match-string-no-properties 1))
1100 (setq version (match-string-no-properties 1)) 1100 ;; and see if there's any lock information
1101 ;; and see if there's any lock information 1101 (goto-char (point-min))
1102 (goto-char (point-min)) 1102 (if (re-search-forward (concat "\\$" "Locker:") nil t)
1103 (if (re-search-forward (concat "\\$" "Locker:") nil t) 1103 (cond ((looking-at " \\([^ ]+\\) \\$")
1104 (cond ((looking-at " \\([^ ]+\\) \\$") 1104 (setq locking-user (match-string-no-properties 1))
1105 (setq locking-user (match-string-no-properties 1)) 1105 (setq status 'rev-and-lock))
1106 (setq status 'rev-and-lock)) 1106 ((looking-at " *\\$")
1107 ((looking-at " *\\$") 1107 (setq locking-user 'none)
1108 (setq locking-user 'none) 1108 (setq status 'rev-and-lock))
1109 (setq status 'rev-and-lock)) 1109 (t
1110 (t 1110 (setq locking-user 'none)
1111 (setq locking-user 'none) 1111 (setq status 'rev-and-lock)))
1112 (setq status 'rev-and-lock))) 1112 (setq status 'rev)))
1113 (setq status 'rev))) 1113 ;; else: nothing found
1114 ;; else: nothing found 1114 ;; -------------------
1115 ;; ------------------- 1115 (t nil)))
1116 (t nil)))
1117 (if status (vc-file-setprop file 'vc-working-revision version)) 1116 (if status (vc-file-setprop file 'vc-working-revision version))
1118 (and (eq status 'rev-and-lock) 1117 (and (eq status 'rev-and-lock)
1119 (vc-file-setprop file 'vc-state 1118 (vc-file-setprop file 'vc-state
diff --git a/lisp/whitespace.el b/lisp/whitespace.el
index 4529180c7ee..492712eea0d 100644
--- a/lisp/whitespace.el
+++ b/lisp/whitespace.el
@@ -1942,8 +1942,7 @@ cleaning up these problems."
1942 (unless (get-buffer whitespace-help-buffer-name) 1942 (unless (get-buffer whitespace-help-buffer-name)
1943 (delete-other-windows) 1943 (delete-other-windows)
1944 (let ((buffer (get-buffer-create whitespace-help-buffer-name))) 1944 (let ((buffer (get-buffer-create whitespace-help-buffer-name)))
1945 (save-excursion 1945 (with-current-buffer buffer
1946 (set-buffer buffer)
1947 (erase-buffer) 1946 (erase-buffer)
1948 (insert whitespace-help-text) 1947 (insert whitespace-help-text)
1949 (whitespace-insert-option-mark 1948 (whitespace-insert-option-mark
diff --git a/lisp/window.el b/lisp/window.el
index 1c77795d098..857d3719c5f 100644
--- a/lisp/window.el
+++ b/lisp/window.el
@@ -1270,8 +1270,7 @@ window."
1270 (setq size (+ (window-height) size))) 1270 (setq size (+ (window-height) size)))
1271 (setq new-window (split-window nil size)) 1271 (setq new-window (split-window nil size))
1272 (unless split-window-keep-point 1272 (unless split-window-keep-point
1273 (save-excursion 1273 (with-current-buffer (window-buffer)
1274 (set-buffer (window-buffer))
1275 (goto-char (window-start)) 1274 (goto-char (window-start))
1276 (setq moved (vertical-motion (window-height))) 1275 (setq moved (vertical-motion (window-height)))
1277 (set-window-start new-window (point)) 1276 (set-window-start new-window (point))
diff --git a/lisp/x-dnd.el b/lisp/x-dnd.el
index b75d650416c..b6171eba0a4 100644
--- a/lisp/x-dnd.el
+++ b/lisp/x-dnd.el
@@ -175,10 +175,10 @@ action and type we got from `x-dnd-test-function'."
175 (let ((buffer (when (window-live-p window) 175 (let ((buffer (when (window-live-p window)
176 (window-buffer window))) 176 (window-buffer window)))
177 (current-state (x-dnd-get-state-for-frame window))) 177 (current-state (x-dnd-get-state-for-frame window)))
178 (when (or (not (equal buffer (aref current-state 0))) 178 (unless (and (equal buffer (aref current-state 0))
179 (not (equal window (aref current-state 1))) 179 (equal window (aref current-state 1))
180 (not (equal action (aref current-state 3)))) 180 (equal action (aref current-state 3)))
181 (save-excursion 181 (save-current-buffer
182 (when buffer (set-buffer buffer)) 182 (when buffer (set-buffer buffer))
183 (let* ((action-type (funcall x-dnd-test-function 183 (let* ((action-type (funcall x-dnd-test-function
184 window 184 window