1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-28 08:11:05 -08:00

* x-dnd.el (x-dnd-maybe-call-test-function):

* window.el (split-window-vertically):
* whitespace.el (whitespace-help-on):
* vc-rcs.el (vc-rcs-consult-headers):
* userlock.el (ask-user-about-lock-help)
(ask-user-about-supersession-help):
* type-break.el (type-break-force-mode-line-update):
* time-stamp.el (time-stamp-conv-warn):
* terminal.el (te-set-output-log, te-more-break, te-filter)
(te-sentinel,terminal-emulator):
* term.el (make-term, term-exec, term-sentinel, term-read-input-ring)
(term-write-input-ring, term-check-source, term-start-output-log):
(term-display-buffer-line, term-dynamic-list-completions):
(term-ansi-make-term, serial-term):
* subr.el (selective-display):
* strokes.el (strokes-xpm-to-compressed-string, strokes-decode-buffer)
(strokes-encode-buffer, strokes-xpm-for-compressed-string):
* speedbar.el (speedbar-buffers-tail-notes, speedbar-buffers-item-info)
(speedbar-reconfigure-keymaps, speedbar-add-localized-speedbar-support)
(speedbar-remove-localized-speedbar-support)
(speedbar-set-mode-line-format, speedbar-create-tag-hierarchy)
(speedbar-update-special-contents, speedbar-buffer-buttons-engine)
(speedbar-buffers-line-directory):
* simple.el (shell-command-on-region, append-to-buffer)
(prepend-to-buffer):
* shadowfile.el (shadow-save-todo-file):
* scroll-bar.el (scroll-bar-set-window-start, scroll-bar-drag-1)
(scroll-bar-maybe-set-window-start):
* sb-image.el (speedbar-image-dump):
* saveplace.el (save-place-alist-to-file, save-places-to-alist)
(load-save-place-alist-from-file):
* ps-samp.el (ps-print-message-from-summary):
* ps-print.el (ps-flush-output, ps-insert-file, ps-get-boundingbox)
(ps-background-image, ps-begin-job, ps-do-despool):
* ps-bdf.el (bdf-find-file, bdf-read-font-info):
* printing.el (pr-interface, pr-ps-file-print, pr-find-buffer-visiting)
(pr-ps-message-from-summary, pr-lpr-message-from-summary):
(pr-call-process, pr-file-list, pr-interface-save):
* novice.el (disabled-command-function)
(enable-command, disable-command):
* mouse.el (mouse-buffer-menu-alist):
* mouse-copy.el (mouse-kill-preserving-secondary):
* macros.el (kbd-macro-query):
* ledit.el (ledit-go-to-lisp, ledit-go-to-liszt):
* informat.el (batch-info-validate):
* ido.el (ido-copy-current-word, ido-initiate-auto-merge):
* hippie-exp.el (try-expand-dabbrev-visible):
* help-mode.el (help-make-xrefs):
* help-fns.el (describe-variable):
* generic-x.el (bat-generic-mode-run-as-comint):
* finder.el (finder-mouse-select):
* find-dired.el (find-dired-sentinel):
* filesets.el (filesets-file-close):
* files.el (list-directory):
* faces.el (list-faces-display, describe-face):
* facemenu.el (list-colors-display):
* ezimage.el (ezimage-image-association-dump, ezimage-image-dump):
* epg.el (epg--process-filter, epg-cancel):
* epa.el (epa--marked-keys, epa--select-keys, epa-display-info)
(epa--read-signature-type):
* emerge.el (emerge-copy-as-kill-A, emerge-copy-as-kill-B)
(emerge-file-names):
* ehelp.el (electric-helpify):
* ediff.el (ediff-regions-wordwise, ediff-regions-linewise):
* ediff-vers.el (rcs-ediff-view-revision):
* ediff-util.el (ediff-setup):
* ediff-mult.el (ediff-append-custom-diff):
* ediff-diff.el (ediff-exec-process, ediff-process-sentinel)
(ediff-wordify):
* echistory.el (Electric-command-history-redo-expression):
* dos-w32.el (find-file-not-found-set-buffer-file-coding-system):
* disp-table.el (describe-display-table):
* dired.el (dired-find-buffer-nocreate):
* dired-aux.el (dired-rename-subdir, dired-dwim-target-directory):
* dabbrev.el (dabbrev--same-major-mode-p):
* chistory.el (list-command-history):
* apropos.el (apropos-documentation):
* allout.el (allout-obtain-passphrase):
(allout-copy-exposed-to-buffer):
(allout-verify-passphrase): Use with-current-buffer.
This commit is contained in:
Stefan Monnier 2009-11-13 22:19:45 +00:00
parent 2ccbc060d2
commit 7fdbcd8387
58 changed files with 348 additions and 401 deletions

View file

@ -1,12 +1,94 @@
2009-11-13 Stefan Monnier <monnier@iro.umontreal.ca>
* x-dnd.el (x-dnd-maybe-call-test-function):
* window.el (split-window-vertically):
* whitespace.el (whitespace-help-on):
* vc-rcs.el (vc-rcs-consult-headers):
* userlock.el (ask-user-about-lock-help)
(ask-user-about-supersession-help):
* type-break.el (type-break-force-mode-line-update):
* time-stamp.el (time-stamp-conv-warn):
* terminal.el (te-set-output-log, te-more-break, te-filter)
(te-sentinel,terminal-emulator):
* term.el (make-term, term-exec, term-sentinel, term-read-input-ring)
(term-write-input-ring, term-check-source, term-start-output-log):
(term-display-buffer-line, term-dynamic-list-completions):
(term-ansi-make-term, serial-term):
* subr.el (selective-display):
* strokes.el (strokes-xpm-to-compressed-string, strokes-decode-buffer)
(strokes-encode-buffer, strokes-xpm-for-compressed-string):
* speedbar.el (speedbar-buffers-tail-notes, speedbar-buffers-item-info)
(speedbar-reconfigure-keymaps, speedbar-add-localized-speedbar-support)
(speedbar-remove-localized-speedbar-support)
(speedbar-set-mode-line-format, speedbar-create-tag-hierarchy)
(speedbar-update-special-contents, speedbar-buffer-buttons-engine)
(speedbar-buffers-line-directory):
* simple.el (shell-command-on-region, append-to-buffer)
(prepend-to-buffer):
* shadowfile.el (shadow-save-todo-file):
* scroll-bar.el (scroll-bar-set-window-start, scroll-bar-drag-1)
(scroll-bar-maybe-set-window-start):
* sb-image.el (speedbar-image-dump):
* saveplace.el (save-place-alist-to-file, save-places-to-alist)
(load-save-place-alist-from-file):
* ps-samp.el (ps-print-message-from-summary):
* ps-print.el (ps-flush-output, ps-insert-file, ps-get-boundingbox)
(ps-background-image, ps-begin-job, ps-do-despool):
* ps-bdf.el (bdf-find-file, bdf-read-font-info):
* printing.el (pr-interface, pr-ps-file-print, pr-find-buffer-visiting)
(pr-ps-message-from-summary, pr-lpr-message-from-summary):
(pr-call-process, pr-file-list, pr-interface-save):
* novice.el (disabled-command-function)
(enable-command, disable-command):
* mouse.el (mouse-buffer-menu-alist):
* mouse-copy.el (mouse-kill-preserving-secondary):
* macros.el (kbd-macro-query):
* ledit.el (ledit-go-to-lisp, ledit-go-to-liszt):
* informat.el (batch-info-validate):
* ido.el (ido-copy-current-word, ido-initiate-auto-merge):
* hippie-exp.el (try-expand-dabbrev-visible):
* help-mode.el (help-make-xrefs):
* help-fns.el (describe-variable):
* generic-x.el (bat-generic-mode-run-as-comint):
* finder.el (finder-mouse-select):
* find-dired.el (find-dired-sentinel):
* filesets.el (filesets-file-close):
* files.el (list-directory):
* faces.el (list-faces-display, describe-face):
* facemenu.el (list-colors-display):
* ezimage.el (ezimage-image-association-dump, ezimage-image-dump):
* epg.el (epg--process-filter, epg-cancel):
* epa.el (epa--marked-keys, epa--select-keys, epa-display-info)
(epa--read-signature-type):
* emerge.el (emerge-copy-as-kill-A, emerge-copy-as-kill-B)
(emerge-file-names):
* ehelp.el (electric-helpify):
* ediff.el (ediff-regions-wordwise, ediff-regions-linewise):
* ediff-vers.el (rcs-ediff-view-revision):
* ediff-util.el (ediff-setup):
* ediff-mult.el (ediff-append-custom-diff):
* ediff-diff.el (ediff-exec-process, ediff-process-sentinel)
(ediff-wordify):
* echistory.el (Electric-command-history-redo-expression):
* dos-w32.el (find-file-not-found-set-buffer-file-coding-system):
* disp-table.el (describe-display-table):
* dired.el (dired-find-buffer-nocreate):
* dired-aux.el (dired-rename-subdir, dired-dwim-target-directory):
* dabbrev.el (dabbrev--same-major-mode-p):
* chistory.el (list-command-history):
* apropos.el (apropos-documentation):
* allout.el (allout-obtain-passphrase):
(allout-copy-exposed-to-buffer):
(allout-verify-passphrase): Use with-current-buffer.
2009-11-13 Glenn Morris <rgm@gnu.org> 2009-11-13 Glenn Morris <rgm@gnu.org>
* Makefile.in (ELCFILES): Regenerate. * Makefile.in (ELCFILES): Regenerate.
2009-11-13 Michael Albinus <michael.albinus@gmx.de> 2009-11-13 Michael Albinus <michael.albinus@gmx.de>
* net/dbus.el (dbus-registered-objects-table): Renamed from * net/dbus.el (dbus-registered-objects-table): Rename from
`dbus-registered-functions-table', because it contains also `dbus-registered-functions-table', because it contains also properties.
properties.
(dbus-unregister-object): Unregister also properties. (dbus-unregister-object): Unregister also properties.
(dbus-get-property, dbus-set-property, dbus-get-all-properties): (dbus-get-property, dbus-set-property, dbus-get-all-properties):
Use a timeout of 500 msec, in order to not block. Use a timeout of 500 msec, in order to not block.
@ -448,8 +530,8 @@
* custom.el (custom-declare-group): Purecopy standard-value. * custom.el (custom-declare-group): Purecopy standard-value.
(custom-declare-group): Purecopy custom-prefix. (custom-declare-group): Purecopy custom-prefix.
* international/mule.el (load-with-code-conversion): Call * international/mule.el (load-with-code-conversion):
do-after-load-evaluation unconditionally. Call do-after-load-evaluation unconditionally.
* emacs-lisp/bytecomp.el (byte-compile-output-file-form): Handle defvaralias. * emacs-lisp/bytecomp.el (byte-compile-output-file-form): Handle defvaralias.

View file

@ -5605,7 +5605,7 @@ alternate presentation format for the outline:
(goto-char beg) (goto-char beg)
(allout-topic-flat-index)) (allout-topic-flat-index))
'(1)))) '(1))))
(save-excursion (set-buffer tobuf)(erase-buffer)) (with-current-buffer tobuf (erase-buffer))
(allout-process-exposed 'allout-insert-listified (allout-process-exposed 'allout-insert-listified
beg beg
end end
@ -6283,8 +6283,7 @@ of the availability of a cached copy."
;; Symmetric hereon: ;; Symmetric hereon:
(save-excursion (with-current-buffer allout-buffer
(set-buffer allout-buffer)
(let* ((hint (if (and (not (string= allout-passphrase-hint-string "")) (let* ((hint (if (and (not (string= allout-passphrase-hint-string ""))
(or (equal allout-passphrase-hint-handling 'always) (or (equal allout-passphrase-hint-handling 'always)
(and (equal allout-passphrase-hint-handling (and (equal allout-passphrase-hint-handling
@ -6481,8 +6480,7 @@ Derived from value of `allout-passphrase-verifier-string'."
"True if passphrase successfully decrypts verifier, nil otherwise. "True if passphrase successfully decrypts verifier, nil otherwise.
\"Otherwise\" includes absence of passphrase verifier." \"Otherwise\" includes absence of passphrase verifier."
(save-excursion (with-current-buffer allout-buffer
(set-buffer allout-buffer)
(and (boundp 'allout-passphrase-verifier-string) (and (boundp 'allout-passphrase-verifier-string)
allout-passphrase-verifier-string allout-passphrase-verifier-string
(allout-encrypt-string (allout-get-encryption-passphrase-verifier) (allout-encrypt-string (allout-get-encryption-passphrase-verifier)

View file

@ -736,8 +736,7 @@ Returns list of symbols and documentation found."
(apropos-sort-by-scores apropos-documentation-sort-by-scores) (apropos-sort-by-scores apropos-documentation-sort-by-scores)
f v sf sv) f v sf sv)
(unwind-protect (unwind-protect
(save-excursion (with-current-buffer standard-input
(set-buffer standard-input)
(apropos-documentation-check-doc-file) (apropos-documentation-check-doc-file)
(if do-all (if do-all
(mapatoms (mapatoms

View file

@ -116,8 +116,7 @@ The buffer is left in Command History mode."
(prin1 (car history)) (prin1 (car history))
(terpri)) (terpri))
(setq history (cdr history)))) (setq history (cdr history))))
(save-excursion (with-current-buffer "*Command History*"
(set-buffer "*Command History*")
(goto-char (point-min)) (goto-char (point-min))
(if (eobp) (if (eobp)
(error "No command history") (error "No command history")

View file

@ -62,8 +62,7 @@
;; the article for expansion): ;; the article for expansion):
;; (set (make-local-variable 'dabbrev-friend-buffer-function) ;; (set (make-local-variable 'dabbrev-friend-buffer-function)
;; (lambda (buffer) ;; (lambda (buffer)
;; (save-excursion ;; (with-current-buffer buffer
;; (set-buffer buffer)
;; (memq major-mode '(news-reply-mode gnus-article-mode))))) ;; (memq major-mode '(news-reply-mode gnus-article-mode)))))
@ -594,8 +593,7 @@ See also `dabbrev-abbrev-char-regexp' and \\[dabbrev-completion]."
;;; Checks if OTHER-BUFFER has the same major mode as current buffer. ;;; Checks if OTHER-BUFFER has the same major mode as current buffer.
(defun dabbrev--same-major-mode-p (other-buffer) (defun dabbrev--same-major-mode-p (other-buffer)
(eq major-mode (eq major-mode
(save-excursion (with-current-buffer other-buffer
(set-buffer other-buffer)
major-mode))) major-mode)))
;;; Back over all abbrev type characters and then moves forward over ;;; Back over all abbrev type characters and then moves forward over

View file

@ -1251,8 +1251,7 @@ Special value `always' suppresses confirmation."
(let ((expanded-from-dir (expand-file-name from-dir)) (let ((expanded-from-dir (expand-file-name from-dir))
(blist (buffer-list))) (blist (buffer-list)))
(while blist (while blist
(save-excursion (with-current-buffer (car blist)
(set-buffer (car blist))
(if (and buffer-file-name (if (and buffer-file-name
(dired-in-this-tree buffer-file-name expanded-from-dir)) (dired-in-this-tree buffer-file-name expanded-from-dir))
(let ((modflag (buffer-modified-p)) (let ((modflag (buffer-modified-p))
@ -1530,8 +1529,7 @@ Optional arg HOW-TO determiness how to treat the target.
;; non-dired buffer may want to profit from this function, e.g. vm-uudecode ;; non-dired buffer may want to profit from this function, e.g. vm-uudecode
(if dired-dwim-target (if dired-dwim-target
(let* ((other-buf (window-buffer (next-window))) (let* ((other-buf (window-buffer (next-window)))
(other-dir (save-excursion (other-dir (with-current-buffer other-buf
(set-buffer other-buf)
(and (eq major-mode 'dired-mode) (and (eq major-mode 'dired-mode)
(dired-current-directory))))) (dired-current-directory)))))
(or other-dir this-dir)) (or other-dir this-dir))

View file

@ -819,8 +819,7 @@ for a remote directory. This feature is used by Auto Revert Mode."
(while blist (while blist
(if (null (buffer-name (cdr (car blist)))) (if (null (buffer-name (cdr (car blist))))
(setq blist (cdr blist)) (setq blist (cdr blist))
(save-excursion (with-current-buffer (cdr (car blist))
(set-buffer (cdr (car blist)))
(if (and (eq major-mode mode) (if (and (eq major-mode mode)
dired-directory ;; nil during find-alternate-file dired-directory ;; nil during find-alternate-file
(equal dirname (equal dirname

View file

@ -87,8 +87,7 @@ Valid symbols are `truncation', `wrap', `escape', `control',
(princ "\nVertical window border glyph: ") (princ "\nVertical window border glyph: ")
(prin1 (display-table-slot dt 'vertical-border)) (prin1 (display-table-slot dt 'vertical-border))
(princ "\nCharacter display glyph sequences:\n") (princ "\nCharacter display glyph sequences:\n")
(save-excursion (with-current-buffer standard-output
(set-buffer standard-output)
(let ((vector (make-vector 256 nil)) (let ((vector (make-vector 256 nil))
(i 0)) (i 0))
(while (< i 256) (while (< i 256)

View file

@ -197,8 +197,7 @@ set to the appropriate coding system, and the value of
(find-file filename))) (find-file filename)))
(defun find-file-not-found-set-buffer-file-coding-system () (defun find-file-not-found-set-buffer-file-coding-system ()
(save-excursion (with-current-buffer (current-buffer)
(set-buffer (current-buffer))
(let ((coding buffer-file-coding-system)) (let ((coding buffer-file-coding-system))
;; buffer-file-coding-system is already set by ;; buffer-file-coding-system is already set by
;; find-operation-coding-system, which was called from ;; find-operation-coding-system, which was called from

View file

@ -34,8 +34,7 @@
With prefix arg NOCONFIRM, execute current line as-is without editing." With prefix arg NOCONFIRM, execute current line as-is without editing."
(interactive "P") (interactive "P")
(let (todo) (let (todo)
(save-excursion (with-current-buffer "*Command History*"
(set-buffer "*Command History*")
(beginning-of-line) (beginning-of-line)
(setq todo (read (current-buffer))) (setq todo (read (current-buffer)))
(if (boundp 'electric-history-in-progress) (if (boundp 'electric-history-in-progress)

View file

@ -1225,8 +1225,7 @@ delimiter regions"))
(unwind-protect (unwind-protect
(let ((directory default-directory) (let ((directory default-directory)
proc) proc)
(save-excursion (with-current-buffer buffer
(set-buffer buffer)
(erase-buffer) (erase-buffer)
(setq default-directory directory) (setq default-directory directory)
(if (or (memq system-type '(emx ms-dos windows-nt windows-95)) (if (or (memq system-type '(emx ms-dos windows-nt windows-95))
@ -1283,8 +1282,7 @@ delimiter regions"))
(if (and (memq (process-status process) '(exit signal)) (if (and (memq (process-status process) '(exit signal))
(buffer-name (process-buffer process))) (buffer-name (process-buffer process)))
(progn (progn
(save-excursion (with-current-buffer (process-buffer process)
(set-buffer (process-buffer process))
(setq mode-line-process nil)) (setq mode-line-process nil))
(delete-process process)))) (delete-process process))))
@ -1354,8 +1352,7 @@ arguments to `skip-chars-forward'."
ediff-forward-word-function) ediff-forward-word-function)
ediff-forward-word-function)) ediff-forward-word-function))
inbuf-syntax-tbl sv-point diff-string) inbuf-syntax-tbl sv-point diff-string)
(save-excursion (with-current-buffer in-buffer
(set-buffer in-buffer)
(setq inbuf-syntax-tbl (setq inbuf-syntax-tbl
(if control-buf (if control-buf
(ediff-with-current-buffer control-buf (ediff-with-current-buffer control-buf

View file

@ -1639,8 +1639,7 @@ Useful commands:
(cond ((ediff-buffer-live-p custom-diff-buf) (cond ((ediff-buffer-live-p custom-diff-buf)
;; for live session buffers we do them first because the user may ;; for live session buffers we do them first because the user may
;; have changed them with respect to the underlying files ;; have changed them with respect to the underlying files
(save-excursion (with-current-buffer meta-diff-buff
(set-buffer meta-diff-buff)
(goto-char (point-max)) (goto-char (point-max))
(insert-buffer-substring custom-diff-buf) (insert-buffer-substring custom-diff-buf)
(insert "\n"))) (insert "\n")))
@ -1649,8 +1648,8 @@ Useful commands:
ediff-merge-directories ediff-merge-directories
ediff-merge-directories-with-ancestor)) ediff-merge-directories-with-ancestor))
;; get diffs by calling shell command on ediff-custom-diff-program ;; get diffs by calling shell command on ediff-custom-diff-program
(save-excursion (with-current-buffer
(set-buffer (setq tmp-buf (get-buffer-create ediff-tmp-buffer))) (setq tmp-buf (get-buffer-create ediff-tmp-buffer))
(erase-buffer) (erase-buffer)
(shell-command (shell-command
(format (format
@ -1662,8 +1661,7 @@ Useful commands:
) )
t) t)
) )
(save-excursion (with-current-buffer meta-diff-buff
(set-buffer meta-diff-buff)
(goto-char (point-max)) (goto-char (point-max))
(insert-buffer-substring tmp-buf) (insert-buffer-substring tmp-buf)
(insert "\n"))) (insert "\n")))

View file

@ -343,8 +343,7 @@ to invocation.")
(setq buffer-C (setq buffer-C
(get-buffer-create (get-buffer-create
(ediff-unique-buffer-name "*ediff-merge" "*"))) (ediff-unique-buffer-name "*ediff-merge" "*")))
(save-excursion (with-current-buffer buffer-C
(set-buffer buffer-C)
(insert-buffer-substring buf) (insert-buffer-substring buf)
(goto-char (point-min)) (goto-char (point-min))
(funcall (ediff-with-current-buffer buf major-mode)) (funcall (ediff-with-current-buffer buf major-mode))

View file

@ -123,8 +123,7 @@ comparison or merge operations are being performed."
(fundamental-mode)) (fundamental-mode))
(let ((output-buffer (ediff-rcs-get-output-buffer filename buff))) (let ((output-buffer (ediff-rcs-get-output-buffer filename buff)))
(delete-windows-on output-buffer) (delete-windows-on output-buffer)
(save-excursion (with-current-buffer output-buffer
(set-buffer output-buffer)
(apply 'call-process "co" nil t nil (apply 'call-process "co" nil t nil
;; -q: quiet (no diagnostics) ;; -q: quiet (no diagnostics)
(append switches rcs-default-co-switches (append switches rcs-default-co-switches

View file

@ -977,8 +977,7 @@ lines. For large regions, use `ediff-regions-linewise'."
(buffer-B (buffer-B
(ediff-clone-buffer-for-region-comparison buffer-B "-Region.B-")) (ediff-clone-buffer-for-region-comparison buffer-B "-Region.B-"))
reg-A-beg reg-A-end reg-B-beg reg-B-end) reg-A-beg reg-A-end reg-B-beg reg-B-end)
(save-excursion (with-current-buffer buffer-A
(set-buffer buffer-A)
(setq reg-A-beg (region-beginning) (setq reg-A-beg (region-beginning)
reg-A-end (region-end)) reg-A-end (region-end))
(set-buffer buffer-B) (set-buffer buffer-B)
@ -1018,8 +1017,7 @@ lines. For small regions, use `ediff-regions-wordwise'."
(buffer-B (buffer-B
(ediff-clone-buffer-for-region-comparison buffer-B "-Region.B-")) (ediff-clone-buffer-for-region-comparison buffer-B "-Region.B-"))
reg-A-beg reg-A-end reg-B-beg reg-B-end) reg-A-beg reg-A-end reg-B-beg reg-B-end)
(save-excursion (with-current-buffer buffer-A
(set-buffer buffer-A)
(setq reg-A-beg (region-beginning) (setq reg-A-beg (region-beginning)
reg-A-end (region-end)) reg-A-end (region-end))
;; enlarge the region to hold full lines ;; enlarge the region to hold full lines

View file

@ -321,8 +321,7 @@ will select it.)"
;;>> suspend updating of the tick in order to allow ;;>> suspend updating of the tick in order to allow
;;>> things like momentary-string-display) ;;>> things like momentary-string-display)
(and b (and b
(save-excursion (with-current-buffer b
(set-buffer b)
(set-buffer-modified-p t))) (set-buffer-modified-p t)))
(fset 'help-print-return-message 'ignore) (fset 'help-print-return-message 'ignore)
(call-interactively fun) (call-interactively fun)
@ -333,8 +332,7 @@ will select it.)"
(not (buffer-modified-p b))))) (not (buffer-modified-p b)))))
(fset 'help-print-return-message p) (fset 'help-print-return-message p)
(and b (buffer-name b) (and b (buffer-name b)
(save-excursion (with-current-buffer b
(set-buffer b)
(set-buffer-modified-p m)))))) (set-buffer-modified-p m))))))
(with-electric-help 'ignore name t)))) (with-electric-help 'ignore name t))))

View file

@ -2060,8 +2060,7 @@ With a negative argument, turn off Skip-Prefers mode."
(A-end (1- (aref diff-vector 1))) (A-end (1- (aref diff-vector 1)))
;; so further kills don't append ;; so further kills don't append
this-command) this-command)
(save-excursion (with-current-buffer emerge-A-buffer
(set-buffer emerge-A-buffer)
(copy-region-as-kill A-begin A-end)))) (copy-region-as-kill A-begin A-end))))
(defun emerge-copy-as-kill-B () (defun emerge-copy-as-kill-B ()
@ -2074,8 +2073,7 @@ With a negative argument, turn off Skip-Prefers mode."
(B-end (1- (aref diff-vector 3))) (B-end (1- (aref diff-vector 3)))
;; so further kills don't append ;; so further kills don't append
this-command) this-command)
(save-excursion (with-current-buffer emerge-B-buffer
(set-buffer emerge-B-buffer)
(copy-region-as-kill B-begin B-end)))) (copy-region-as-kill B-begin B-end))))
(defun emerge-insert-A (arg) (defun emerge-insert-A (arg)
@ -2170,8 +2168,7 @@ Use C-u l to reset the windows afterward."
(princ (buffer-name)))) (princ (buffer-name))))
(princ "\n"))) (princ "\n")))
(princ emerge-output-description) (princ emerge-output-description)
(save-excursion (with-current-buffer standard-output
(set-buffer standard-output)
(help-mode))))) (help-mode)))))
(defun emerge-join-differences (arg) (defun emerge-join-differences (arg)
@ -3020,8 +3017,7 @@ If some prefix of KEY has a non-prefix definition, it is redefined."
;; minor-mode indicator)) ;; minor-mode indicator))
;; (princ (documentation minor-mode))))) ;; (princ (documentation minor-mode)))))
;; (setq minor-modes (cdr minor-modes)))) ;; (setq minor-modes (cdr minor-modes))))
;; (save-excursion ;; (with-current-buffer standard-output
;; (set-buffer standard-output)
;; (help-mode)) ;; (help-mode))
;; (help-print-return-message))) ;; (help-print-return-message)))

View file

@ -463,8 +463,7 @@ If ARG is non-nil, mark the key."
(apply #'epa--list-keys epa-list-keys-arguments)) (apply #'epa--list-keys epa-list-keys-arguments))
(defun epa--marked-keys () (defun epa--marked-keys ()
(or (save-excursion (or (with-current-buffer epa-keys-buffer
(set-buffer epa-keys-buffer)
(goto-char (point-min)) (goto-char (point-min))
(let (keys key) (let (keys key)
(while (re-search-forward "^\\*" nil t) (while (re-search-forward "^\\*" nil t)
@ -479,11 +478,10 @@ If ARG is non-nil, mark the key."
(list key)))))) (list key))))))
(defun epa--select-keys (prompt keys) (defun epa--select-keys (prompt keys)
(save-excursion (unless (and epa-keys-buffer
(unless (and epa-keys-buffer (buffer-live-p epa-keys-buffer))
(buffer-live-p epa-keys-buffer)) (setq epa-keys-buffer (generate-new-buffer "*Keys*")))
(setq epa-keys-buffer (generate-new-buffer "*Keys*"))) (with-current-buffer epa-keys-buffer
(set-buffer epa-keys-buffer)
(epa-key-list-mode) (epa-key-list-mode)
(let ((inhibit-read-only t) (let ((inhibit-read-only t)
buffer-read-only) buffer-read-only)
@ -615,8 +613,7 @@ If SECRET is non-nil, list secret keys instead of public keys."
(setq epa-info-buffer (generate-new-buffer "*Info*"))) (setq epa-info-buffer (generate-new-buffer "*Info*")))
(if (get-buffer-window epa-info-buffer) (if (get-buffer-window epa-info-buffer)
(delete-window (get-buffer-window epa-info-buffer))) (delete-window (get-buffer-window epa-info-buffer)))
(save-excursion (with-current-buffer epa-info-buffer
(set-buffer epa-info-buffer)
(let ((inhibit-read-only t) (let ((inhibit-read-only t)
buffer-read-only) buffer-read-only)
(erase-buffer) (erase-buffer)
@ -716,8 +713,7 @@ If SECRET is non-nil, list secret keys instead of public keys."
(setq type 'detached)) (setq type 'detached))
((eq c ??) ((eq c ??)
(with-output-to-temp-buffer "*Help*" (with-output-to-temp-buffer "*Help*"
(save-excursion (with-current-buffer standard-output
(set-buffer standard-output)
(insert "\ (insert "\
n - Create a normal signature n - Create a normal signature
c - Create a cleartext signature c - Create a cleartext signature

View file

@ -1143,8 +1143,7 @@ This function is for internal use only."
(goto-char (point-max)) (goto-char (point-max))
(insert input))) (insert input)))
(if (buffer-live-p (process-buffer process)) (if (buffer-live-p (process-buffer process))
(save-excursion (with-current-buffer (process-buffer process)
(set-buffer (process-buffer process))
(goto-char (point-max)) (goto-char (point-max))
(insert input) (insert input)
(unless epg-process-filter-running (unless epg-process-filter-running
@ -1927,8 +1926,7 @@ You can then use `write-region' to write new data into the file."
(defun epg-cancel (context) (defun epg-cancel (context)
(if (buffer-live-p (process-buffer (epg-context-process context))) (if (buffer-live-p (process-buffer (epg-context-process context)))
(save-excursion (with-current-buffer (process-buffer (epg-context-process context))
(set-buffer (process-buffer (epg-context-process context)))
(epg-context-set-result-for (epg-context-set-result-for
epg-context 'error epg-context 'error
(cons '(quit) (cons '(quit)

View file

@ -300,8 +300,7 @@ Optional argument STRING is a string upon which to add text properties."
See `ezimage-expand-image-button-alist' for details." See `ezimage-expand-image-button-alist' for details."
(interactive) (interactive)
(with-output-to-temp-buffer "*Ezimage Images*" (with-output-to-temp-buffer "*Ezimage Images*"
(save-excursion (with-current-buffer "*Ezimage Images*"
(set-buffer "*Ezimage Images*")
(goto-char (point-max)) (goto-char (point-max))
(insert "Ezimage image cache.\n\n") (insert "Ezimage image cache.\n\n")
(let ((start (point)) (end nil)) (let ((start (point)) (end nil))
@ -324,8 +323,7 @@ See `ezimage-expand-image-button-alist' for details."
See `ezimage-expand-image-button-alist' for details." See `ezimage-expand-image-button-alist' for details."
(interactive) (interactive)
(with-output-to-temp-buffer "*Ezimage Images*" (with-output-to-temp-buffer "*Ezimage Images*"
(save-excursion (with-current-buffer "*Ezimage Images*"
(set-buffer "*Ezimage Images*")
(goto-char (point-max)) (goto-char (point-max))
(insert "Ezimage image cache.\n\n") (insert "Ezimage image cache.\n\n")
(let ((start (point)) (end nil)) (let ((start (point)) (end nil))

View file

@ -494,8 +494,7 @@ argument BUFFER-NAME is nil, it defaults to *Colors*."
(if lc (if lc
(setcdr lc nil))))) (setcdr lc nil)))))
(with-help-window (or buffer-name "*Colors*") (with-help-window (or buffer-name "*Colors*")
(save-excursion (with-current-buffer standard-output
(set-buffer standard-output)
(setq truncate-lines t) (setq truncate-lines t)
(if temp-buffer-show-function (if temp-buffer-show-function
(list-colors-print list) (list-colors-print list)

View file

@ -1273,8 +1273,7 @@ arg, prompt for a regular expression."
(setq max-length (1+ max-length) (setq max-length (1+ max-length)
line-format (format "%%-%ds" max-length)) line-format (format "%%-%ds" max-length))
(with-help-window "*Faces*" (with-help-window "*Faces*"
(save-excursion (with-current-buffer standard-output
(set-buffer standard-output)
(setq truncate-lines t) (setq truncate-lines t)
(insert (insert
(substitute-command-keys (substitute-command-keys
@ -1362,8 +1361,7 @@ If FRAME is omitted or nil, use the selected frame."
(if (not (listp face)) (if (not (listp face))
(setq face (list face))) (setq face (list face)))
(with-help-window (help-buffer) (with-help-window (help-buffer)
(save-excursion (with-current-buffer standard-output
(set-buffer standard-output)
(dolist (f face) (dolist (f face)
(if (stringp f) (setq f (intern f))) (if (stringp f) (setq f (intern f)))
;; We may get called for anonymous faces (i.e., faces ;; We may get called for anonymous faces (i.e., faces

View file

@ -5411,8 +5411,7 @@ and `list-directory-verbose-switches'."
(princ "Directory ") (princ "Directory ")
(princ dirname) (princ dirname)
(terpri) (terpri)
(save-excursion (with-current-buffer "*Directory*"
(set-buffer "*Directory*")
(let ((wildcard (not (file-directory-p dirname)))) (let ((wildcard (not (file-directory-p dirname))))
(insert-directory dirname switches wildcard (not wildcard))))) (insert-directory dirname switches wildcard (not wildcard)))))
;; Finishing with-output-to-temp-buffer seems to clobber default-directory. ;; Finishing with-output-to-temp-buffer seems to clobber default-directory.

View file

@ -1552,8 +1552,7 @@ First, save the buffer's contents using SAVE-FUNCTION. Then, kill buffer
if `buffer-modified-p' returns nil. if `buffer-modified-p' returns nil.
SAVE-FUNCTION takes no argument, but works on the current buffer." SAVE-FUNCTION takes no argument, but works on the current buffer."
(save-excursion (with-current-buffer buffer
(set-buffer buffer)
(if (buffer-modified-p) (if (buffer-modified-p)
(funcall save-function)) (funcall save-function))
(if (not (buffer-modified-p)) (if (not (buffer-modified-p))

View file

@ -291,8 +291,7 @@ Thus ARG can also contain additional grep options."
(let ((buf (process-buffer proc)) (let ((buf (process-buffer proc))
(inhibit-read-only t)) (inhibit-read-only t))
(if (buffer-name buf) (if (buffer-name buf)
(save-excursion (with-current-buffer buf
(set-buffer buf)
(let ((buffer-read-only nil)) (let ((buffer-read-only nil))
(save-excursion (save-excursion
(goto-char (point-max)) (goto-char (point-max))

View file

@ -332,8 +332,7 @@ FILE should be in a form suitable for passing to `locate-library'."
(defun finder-mouse-select (event) (defun finder-mouse-select (event)
"Select item in a finder buffer with the mouse." "Select item in a finder buffer with the mouse."
(interactive "e") (interactive "e")
(save-excursion (with-current-buffer (window-buffer (posn-window (event-start event)))
(set-buffer (window-buffer (posn-window (event-start event))))
(goto-char (posn-point (event-start event))) (goto-char (posn-point (event-start event)))
(finder-select))) (finder-select)))

View file

@ -546,9 +546,7 @@ like an INI file. You can add this hook to `find-file-hook'."
(require 'comint) (require 'comint)
(let* ((file (buffer-file-name)) (let* ((file (buffer-file-name))
(buf-name (concat "*" file "*"))) (buf-name (concat "*" file "*")))
(save-excursion (with-current-buffer (get-buffer-create buf-name)
(set-buffer
(get-buffer-create buf-name))
(erase-buffer) (erase-buffer)
(comint-mode) (comint-mode)
(comint-exec (comint-exec

View file

@ -789,8 +789,7 @@ file local variable.\n")
(terpri) (terpri)
(princ output)))) (princ output))))
(save-excursion (with-current-buffer standard-output
(set-buffer standard-output)
;; Return the text we displayed. ;; Return the text we displayed.
(buffer-string)))))))) (buffer-string))))))))

View file

@ -413,8 +413,7 @@ A special reference `back' is made to return back through a stack of
help buffers. Variable `help-back-label' specifies the text for help buffers. Variable `help-back-label' specifies the text for
that." that."
(interactive "b") (interactive "b")
(save-excursion (with-current-buffer (or buffer (current-buffer))
(set-buffer (or buffer (current-buffer)))
(goto-char (point-min)) (goto-char (point-min))
;; Skip the header-type info, though it might be useful to parse ;; Skip the header-type info, though it might be useful to parse
;; it at some stage (e.g. "function in `library'"). ;; it at some stage (e.g. "function in `library'").

View file

@ -1000,8 +1000,7 @@ string). It returns t if a new expansion is found, nil otherwise."
(while (and (not (equal he-search-string "")) (while (and (not (equal he-search-string ""))
(marker-position he-search-loc) (marker-position he-search-loc)
(not expansion)) (not expansion))
(save-excursion (with-current-buffer (marker-buffer he-search-loc)
(set-buffer (marker-buffer he-search-loc))
(goto-char he-search-loc) (goto-char he-search-loc)
(setq expansion (he-dabbrev-search he-search-string () (setq expansion (he-dabbrev-search he-search-string ()
(window-end he-search-window))) (window-end he-search-window)))

View file

@ -2975,8 +2975,7 @@ If repeated, insert text from buffer instead."
(defun ido-copy-current-word (all) (defun ido-copy-current-word (all)
"Insert current word (file or directory name) from current buffer." "Insert current word (file or directory name) from current buffer."
(interactive "P") (interactive "P")
(let ((word (save-excursion (let ((word (with-current-buffer ido-entry-buffer
(set-buffer ido-entry-buffer)
(let ((p (point)) start-line end-line start-name name) (let ((p (point)) start-line end-line start-name name)
(if (and mark-active (/= p (mark))) (if (and mark-active (/= p (mark)))
(setq start-name (mark)) (setq start-name (mark))
@ -4184,8 +4183,7 @@ For details of keybindings, see `ido-find-file'."
ido-text-init contents ido-text-init contents
ido-rotate-temp t ido-rotate-temp t
ido-exit 'refresh) ido-exit 'refresh)
(save-excursion (with-current-buffer buffer
(set-buffer buffer)
(ido-tidy)) (ido-tidy))
(throw 'ido contents)))) (throw 'ido contents))))

View file

@ -497,8 +497,7 @@ For example, invoke \"emacs -batch -f batch-info-validate $info/ ~/*.info\""
nil ;(message "Checking validity of info file %s... OK" file) nil ;(message "Checking validity of info file %s... OK" file)
(message "----------------------------------------------------------------------") (message "----------------------------------------------------------------------")
(message ">> PROBLEMS IN INFO FILE %s" file) (message ">> PROBLEMS IN INFO FILE %s" file)
(save-excursion (with-current-buffer loss-name
(set-buffer loss-name)
(princ (buffer-substring-no-properties (princ (buffer-substring-no-properties
(point-min) (point-max)))) (point-min) (point-max))))
(message "----------------------------------------------------------------------") (message "----------------------------------------------------------------------")

View file

@ -94,11 +94,10 @@
(if ledit-save-files (if ledit-save-files
(save-some-buffers)) (save-some-buffers))
(if (get-buffer ledit-buffer) (if (get-buffer ledit-buffer)
(save-excursion (with-current-buffer ledit-buffer
(set-buffer ledit-buffer) (goto-char (point-min))
(goto-char (point-min)) (write-region (point-min) (point-max) ledit-zap-file)
(write-region (point-min) (point-max) ledit-zap-file) (erase-buffer)))
(erase-buffer)))
(suspend-emacs ledit-go-to-lisp-string) (suspend-emacs ledit-go-to-lisp-string)
(load ledit-read-file t t)) (load ledit-read-file t t))
@ -108,12 +107,11 @@
(if ledit-save-files (if ledit-save-files
(save-some-buffers)) (save-some-buffers))
(if (get-buffer ledit-buffer) (if (get-buffer ledit-buffer)
(save-excursion (with-current-buffer ledit-buffer
(set-buffer ledit-buffer) (goto-char (point-min))
(goto-char (point-min)) (insert "(declare (macros t))\n")
(insert "(declare (macros t))\n") (write-region (point-min) (point-max) ledit-compile-file)
(write-region (point-min) (point-max) ledit-compile-file) (erase-buffer)))
(erase-buffer)))
(suspend-emacs ledit-go-to-liszt-string) (suspend-emacs ledit-go-to-liszt-string)
(load ledit-read-file t t)) (load ledit-read-file t t))

View file

@ -209,8 +209,7 @@ Possibilities: \\<query-replace-map>
\\[exit] Stop the macro entirely right now. \\[exit] Stop the macro entirely right now.
\\[recenter] Redisplay the screen, then ask again. \\[recenter] Redisplay the screen, then ask again.
\\[edit] Enter recursive edit; ask again when you exit from that.")) \\[edit] Enter recursive edit; ask again when you exit from that."))
(save-excursion (with-current-buffer standard-output
(set-buffer standard-output)
(help-mode))))))))))) (help-mode)))))))))))
;;;###autoload ;;;###autoload

View file

@ -1857,8 +1857,7 @@ Buffers menu is regenerated."
;;nil means the buffer shouldn't be listed. You can redefine this." ;;nil means the buffer shouldn't be listed. You can redefine this."
;; (if (string-match "\\` " (buffer-name buffer)) ;; (if (string-match "\\` " (buffer-name buffer))
;; nil ;; nil
;; (save-excursion ;; (with-current-buffer buffer
;; (set-buffer buffer)
;; (let ((size (buffer-size))) ;; (let ((size (buffer-size)))
;; (format "%s%s %-19s %6s %-15s %s" ;; (format "%s%s %-19s %6s %-15s %s"
;; (if (buffer-modified-p) "*" " ") ;; (if (buffer-modified-p) "*" " ")

View file

@ -200,8 +200,7 @@ by johnh@ficus.cs.ucla.edu."
(window-buffer (posn-window (event-start click))) (window-buffer (posn-window (event-start click)))
(current-buffer))) (current-buffer)))
(error "Select or click on the buffer where the secondary selection is"))) (error "Select or click on the buffer where the secondary selection is")))
(save-excursion (with-current-buffer (overlay-buffer mouse-secondary-overlay)
(set-buffer (overlay-buffer mouse-secondary-overlay))
(kill-region (overlay-start mouse-secondary-overlay) (kill-region (overlay-start mouse-secondary-overlay)
(overlay-end mouse-secondary-overlay))) (overlay-end mouse-secondary-overlay)))
;; (delete-overlay mouse-secondary-overlay) ;; (delete-overlay mouse-secondary-overlay)

View file

@ -1975,12 +1975,10 @@ and selects that window."
(format "%%-%ds %%s%%s %%s" maxlen) (format "%%-%ds %%s%%s %%s" maxlen)
(buffer-name elt) (buffer-name elt)
(if (buffer-modified-p elt) "*" " ") (if (buffer-modified-p elt) "*" " ")
(save-excursion (with-current-buffer elt
(set-buffer elt)
(if buffer-read-only "%" " ")) (if buffer-read-only "%" " "))
(or (buffer-file-name elt) (or (buffer-file-name elt)
(save-excursion (with-current-buffer elt
(set-buffer elt)
(if list-buffers-directory (if list-buffers-directory
(expand-file-name (expand-file-name
list-buffers-directory))) list-buffers-directory)))

View file

@ -85,8 +85,7 @@ y to try it and enable it (no questions if you use it again).
n to cancel--don't try the command, and it remains disabled. n to cancel--don't try the command, and it remains disabled.
SPC to try the command just this once, but leave it disabled. SPC to try the command just this once, but leave it disabled.
! to try it, and enable all disabled commands for this session only.") ! to try it, and enable all disabled commands for this session only.")
(save-excursion (with-current-buffer standard-output
(set-buffer standard-output)
(help-mode))) (help-mode)))
(fit-window-to-buffer (get-buffer-window "*Disabled Command*")) (fit-window-to-buffer (get-buffer-window "*Disabled Command*"))
(message "Type y, n, ! or SPC (the space bar): ") (message "Type y, n, ! or SPC (the space bar): ")
@ -135,9 +134,8 @@ to future sessions."
(eq system-type 'windows-nt) (eq system-type 'windows-nt)
(file-exists-p "~/_emacs")) (file-exists-p "~/_emacs"))
(setq init-file "~/_emacs"))) (setq init-file "~/_emacs")))
(save-excursion (with-current-buffer (find-file-noselect
(set-buffer (find-file-noselect (substitute-in-file-name init-file))
(substitute-in-file-name init-file)))
(goto-char (point-min)) (goto-char (point-min))
(if (search-forward (concat "(put '" (symbol-name command) " ") nil t) (if (search-forward (concat "(put '" (symbol-name command) " ") nil t)
(delete-region (delete-region
@ -175,9 +173,8 @@ to future sessions."
(eq system-type 'windows-nt) (eq system-type 'windows-nt)
(file-exists-p "~/_emacs")) (file-exists-p "~/_emacs"))
(setq init-file "~/_emacs"))) (setq init-file "~/_emacs")))
(save-excursion (with-current-buffer (find-file-noselect
(set-buffer (find-file-noselect (substitute-in-file-name init-file))
(substitute-in-file-name init-file)))
(goto-char (point-min)) (goto-char (point-min))
(if (search-forward (concat "(put '" (symbol-name command) " ") nil t) (if (search-forward (concat "(put '" (symbol-name command) " ") nil t)
(delete-region (delete-region

View file

@ -3953,8 +3953,7 @@ If BUFFER is nil, the current buffer is used for printing.
For more information, type \\[pr-interface-help]." For more information, type \\[pr-interface-help]."
(interactive) (interactive)
(save-excursion (with-current-buffer (or buffer (current-buffer))
(set-buffer (or buffer (current-buffer)))
(pr-create-interface))) (pr-create-interface)))
@ -4457,8 +4456,7 @@ image in a file with that name."
(if (string= pr-ps-command "") (if (string= pr-ps-command "")
;; default action ;; default action
(let ((ps-spool-buffer (get-buffer-create ps-spool-buffer-name))) (let ((ps-spool-buffer (get-buffer-create ps-spool-buffer-name)))
(save-excursion (with-current-buffer ps-spool-buffer
(set-buffer ps-spool-buffer)
(erase-buffer) (erase-buffer)
(insert-file-contents-literally file)) (insert-file-contents-literally file))
(pr-despool-print)) (pr-despool-print))
@ -5028,8 +5026,7 @@ Return only the dayname, if present, weekday, month, and year."
(symbol-value summary-buffer)) (symbol-value summary-buffer))
(symbol-value summary-default)))) (symbol-value summary-default))))
(and (get-buffer buf) (and (get-buffer buf)
(save-excursion (with-current-buffer buf
(set-buffer buf)
(pr-mode-print n-up filename header-list))))) (pr-mode-print n-up filename header-list)))))
@ -5039,8 +5036,7 @@ Return only the dayname, if present, weekday, month, and year."
(symbol-value summary-buffer)) (symbol-value summary-buffer))
(symbol-value summary-default)))) (symbol-value summary-default))))
(and (get-buffer buf) (and (get-buffer buf)
(save-excursion (with-current-buffer buf
(set-buffer buf)
(pr-mode-lpr header-list))))) (pr-mode-lpr header-list)))))
@ -5633,8 +5629,7 @@ If menu binding was not done, calls `pr-menu-bind'."
status) status)
(setq args (pr-remove-nil-from-list args)) (setq args (pr-remove-nil-from-list args))
;; *Printing Command Output* == show command & args ;; *Printing Command Output* == show command & args
(save-excursion (with-current-buffer buffer
(set-buffer buffer)
(goto-char (point-max)) (goto-char (point-max))
(insert (format "%s %S\n" cmd args))) (insert (format "%s %S\n" cmd args)))
;; *Printing Command Output* == show any return message from command ;; *Printing Command Output* == show any return message from command
@ -5645,8 +5640,7 @@ If menu binding was not done, calls `pr-menu-bind'."
((quit error) ((quit error)
(error-message-string data))))) (error-message-string data)))))
;; *Printing Command Output* == show exit status ;; *Printing Command Output* == show exit status
(save-excursion (with-current-buffer buffer
(set-buffer buffer)
(goto-char (point-max)) (goto-char (point-max))
(insert (format "Exit status: %s\n\n" status))) (insert (format "Exit status: %s\n\n" status)))
;; message if error status ;; message if error status
@ -5839,8 +5833,7 @@ If menu binding was not done, calls `pr-menu-bind'."
(blist (buffer-list)) (blist (buffer-list))
found) found)
(while (and (not found) blist) (while (and (not found) blist)
(save-excursion (with-current-buffer (car blist)
(set-buffer (car blist))
(and (eq major-mode 'dired-mode) (and (eq major-mode 'dired-mode)
(save-excursion (save-excursion
(goto-char (point-min)) (goto-char (point-min))
@ -5864,9 +5857,8 @@ If menu binding was not done, calls `pr-menu-bind'."
pop-up-frames) pop-up-frames)
(and (or buffer (and (or buffer
(file-readable-p file)) (file-readable-p file))
(save-excursion (with-current-buffer (or buffer
(set-buffer (or buffer (find-file-noselect file))
(find-file-noselect file)))
(funcall fun) (funcall fun)
(or buffer (or buffer
(kill-buffer (current-buffer)))))))) (kill-buffer (current-buffer))))))))
@ -6047,8 +6039,7 @@ COMMAND.exe, COMMAND.bat and COMMAND.com in this order."
(defmacro pr-interface-save (&rest body) (defmacro pr-interface-save (&rest body)
`(save-excursion `(with-current-buffer pr-i-buffer
(set-buffer pr-i-buffer)
,@body)) ,@body))

View file

@ -95,8 +95,7 @@ If BDFNAME doesn't exist, return nil."
(and (file-readable-p bdfname) (and (file-readable-p bdfname)
(let ((buf (generate-new-buffer " *bdf-work*")) (let ((buf (generate-new-buffer " *bdf-work*"))
(coding-system-for-read 'no-conversion)) (coding-system-for-read 'no-conversion))
(save-excursion (with-current-buffer buf
(set-buffer buf)
(insert-file-contents bdfname) (insert-file-contents bdfname)
buf)))) buf))))
@ -225,8 +224,7 @@ CODE, where N and CODE are in the following relation:
(message "Reading %s..." bdfname) (message "Reading %s..." bdfname)
(error "BDF file %s doesn't exist" bdfname)) (error "BDF file %s doesn't exist" bdfname))
(unwind-protect (unwind-protect
(save-excursion (with-current-buffer buf
(set-buffer buf)
(goto-char (point-min)) (goto-char (point-min))
(search-forward "\nFONTBOUNDINGBOX") (search-forward "\nFONTBOUNDINGBOX")
(setq font-bounding-box (setq font-bounding-box

View file

@ -4734,8 +4734,7 @@ page-height == ((floor print-height ((th + ls) * zh)) * ((th + ls) * zh)) - th
(ps-output 'prologue (if (stringp args) (list args) args))) (ps-output 'prologue (if (stringp args) (list args) args)))
(defun ps-flush-output () (defun ps-flush-output ()
(save-excursion (with-current-buffer ps-spool-buffer
(set-buffer ps-spool-buffer)
(goto-char (point-max)) (goto-char (point-max))
(while ps-output-head (while ps-output-head
(let ((it (car ps-output-head))) (let ((it (car ps-output-head)))
@ -4756,8 +4755,7 @@ page-height == ((floor print-height ((th + ls) * zh)) * ((th + ls) * zh)) - th
(defun ps-insert-file (fname) (defun ps-insert-file (fname)
(ps-flush-output) (ps-flush-output)
(save-excursion (with-current-buffer ps-spool-buffer
(set-buffer ps-spool-buffer)
(goto-char (point-max)) (goto-char (point-max))
(insert-file-contents fname))) (insert-file-contents fname)))
@ -4840,8 +4838,7 @@ page-height == ((floor print-height ((th + ls) * zh)) * ((th + ls) * zh)) - th
(defun ps-get-boundingbox () (defun ps-get-boundingbox ()
(save-excursion (with-current-buffer ps-spool-buffer
(set-buffer ps-spool-buffer)
(save-excursion (save-excursion
(if (re-search-forward ps-boundingbox-re nil t) (if (re-search-forward ps-boundingbox-re nil t)
(vector (string-to-number ; lower x (vector (string-to-number ; lower x
@ -4909,8 +4906,7 @@ page-height == ((floor print-height ((th + ls) * zh)) * ((th + ls) * zh)) - th
;; coordinate adjustment to center image ;; coordinate adjustment to center image
;; around x and y position ;; around x and y position
(let ((box (ps-get-boundingbox))) (let ((box (ps-get-boundingbox)))
(save-excursion (with-current-buffer ps-spool-buffer
(set-buffer ps-spool-buffer)
(save-excursion (save-excursion
(if (re-search-backward "^--back--" nil t) (if (re-search-backward "^--back--" nil t)
(replace-match (replace-match
@ -5795,8 +5791,7 @@ XSTART YSTART are the relative position for the first page in a sheet.")
ps-line-number-step ps-line-number-step
ps-zebra-stripe-height)))) ps-zebra-stripe-height))))
;; spooling buffer ;; spooling buffer
(save-excursion (with-current-buffer ps-spool-buffer
(set-buffer ps-spool-buffer)
(goto-char (point-max)) (goto-char (point-max))
(and (re-search-backward "^%%Trailer$" nil t) (and (re-search-backward "^%%Trailer$" nil t)
(delete-region (match-beginning 0) (point-max)))) (delete-region (match-beginning 0) (point-max))))
@ -6573,8 +6568,7 @@ If FACE is not a valid face name, use default face."
(and ps-razzle-dazzle (message "Wrote %s" filename))) (and ps-razzle-dazzle (message "Wrote %s" filename)))
;; Else, spool to the printer ;; Else, spool to the printer
(and ps-razzle-dazzle (message "Printing...")) (and ps-razzle-dazzle (message "Printing..."))
(save-excursion (with-current-buffer ps-spool-buffer
(set-buffer ps-spool-buffer)
(let* ((coding-system-for-write 'raw-text-unix) (let* ((coding-system-for-write 'raw-text-unix)
(ps-printer-name (or ps-printer-name (ps-printer-name (or ps-printer-name
(and (boundp 'printer-name) (and (boundp 'printer-name)

View file

@ -72,8 +72,7 @@
(symbol-value summary-buffer)) (symbol-value summary-buffer))
summary-default))) summary-default)))
(and (get-buffer ps-buf) (and (get-buffer ps-buf)
(save-excursion (with-current-buffer ps-buf
(set-buffer ps-buf)
(ps-spool-buffer-with-faces))))) (ps-spool-buffer-with-faces)))))
;; Look in an article or mail message for the Subject: line. To be ;; Look in an article or mail message for the Subject: line. To be

View file

@ -205,8 +205,7 @@ may have changed\) back to `save-place-alist'."
(defun save-place-alist-to-file () (defun save-place-alist-to-file ()
(let ((file (expand-file-name save-place-file)) (let ((file (expand-file-name save-place-file))
(coding-system-for-write 'utf-8)) (coding-system-for-write 'utf-8))
(save-excursion (with-current-buffer (get-buffer-create " *Saved Places*")
(set-buffer (get-buffer-create " *Saved Places*"))
(delete-region (point-min) (point-max)) (delete-region (point-min) (point-max))
(when save-place-forget-unreadable-files (when save-place-forget-unreadable-files
(save-place-forget-unreadable-files)) (save-place-forget-unreadable-files))
@ -236,10 +235,9 @@ may have changed\) back to `save-place-alist'."
;; make sure that the alist does not get overwritten, and then ;; make sure that the alist does not get overwritten, and then
;; load it if it exists: ;; load it if it exists:
(if (file-readable-p file) (if (file-readable-p file)
(save-excursion ;; don't want to use find-file because we have been
;; don't want to use find-file because we have been ;; adding hooks to it.
;; adding hooks to it. (with-current-buffer (get-buffer-create " *Saved Places*")
(set-buffer (get-buffer-create " *Saved Places*"))
(delete-region (point-min) (point-max)) (delete-region (point-min) (point-max))
(insert-file-contents file) (insert-file-contents file)
(goto-char (point-min)) (goto-char (point-min))
@ -275,8 +273,7 @@ may have changed\) back to `save-place-alist'."
;; put this into a save-excursion in case someone is counting on ;; put this into a save-excursion in case someone is counting on
;; another function in kill-emacs-hook to act on the last buffer ;; another function in kill-emacs-hook to act on the last buffer
;; they were in: ;; they were in:
(save-excursion (with-current-buffer (car buf-list)
(set-buffer (car buf-list))
;; save-place checks buffer-file-name too, but we can avoid ;; save-place checks buffer-file-name too, but we can avoid
;; overhead of function call by checking here too. ;; overhead of function call by checking here too.
(and buffer-file-name (save-place-to-alist)) (and buffer-file-name (save-place-to-alist))

View file

@ -85,8 +85,7 @@ If we have an image associated with it, use that image."
See `speedbar-expand-image-button-alist' for details." See `speedbar-expand-image-button-alist' for details."
(interactive) (interactive)
(with-output-to-temp-buffer "*Speedbar Images*" (with-output-to-temp-buffer "*Speedbar Images*"
(save-excursion (with-current-buffer "*Speedbar Images*"
(set-buffer "*Speedbar Images*")
(goto-char (point-max)) (goto-char (point-max))
(insert "Speedbar image cache.\n\n") (insert "Speedbar image cache.\n\n")
(let ((start (point)) (end nil)) (let ((start (point)) (end nil))

View file

@ -156,7 +156,7 @@ Horizontal scroll bars aren't implemented yet."
;;;; Buffer navigation using the scroll bar. ;;;; Buffer navigation using the scroll bar.
;;; This was used for up-events on button 2, but no longer. ;; This was used for up-events on button 2, but no longer.
(defun scroll-bar-set-window-start (event) (defun scroll-bar-set-window-start (event)
"Set the window start according to where the scroll bar is dragged. "Set the window start according to where the scroll bar is dragged.
EVENT should be a scroll bar click or drag event." EVENT should be a scroll bar click or drag event."
@ -164,8 +164,7 @@ EVENT should be a scroll bar click or drag event."
(let* ((end-position (event-end event)) (let* ((end-position (event-end event))
(window (nth 0 end-position)) (window (nth 0 end-position))
(portion-whole (nth 2 end-position))) (portion-whole (nth 2 end-position)))
(save-excursion (with-current-buffer (window-buffer window)
(set-buffer (window-buffer window))
(save-excursion (save-excursion
(goto-char (+ (point-min) (goto-char (+ (point-min)
(scroll-bar-scale portion-whole (scroll-bar-scale portion-whole
@ -195,8 +194,7 @@ EVENT should be a scroll bar click or drag event."
portion-start portion-start
next-portion-start next-portion-start
(current-start (window-start window))) (current-start (window-start window)))
(save-excursion (with-current-buffer (window-buffer window)
(set-buffer (window-buffer window))
(setq portion-start (scroll-bar-drag-position portion-whole)) (setq portion-start (scroll-bar-drag-position portion-whole))
(setq next-portion-start (max (setq next-portion-start (max
(scroll-bar-drag-position next-portion-whole) (scroll-bar-drag-position next-portion-whole)
@ -212,8 +210,7 @@ EVENT should be a scroll bar click or drag event."
(let* ((start-position (event-start event)) (let* ((start-position (event-start event))
(window (nth 0 start-position)) (window (nth 0 start-position))
(portion-whole (nth 2 start-position))) (portion-whole (nth 2 start-position)))
(save-excursion (with-current-buffer (window-buffer window)
(set-buffer (window-buffer window))
;; Calculate position relative to the accessible part of the buffer. ;; Calculate position relative to the accessible part of the buffer.
(goto-char (+ (point-min) (goto-char (+ (point-min)
(scroll-bar-scale portion-whole (scroll-bar-scale portion-whole
@ -339,7 +336,7 @@ EVENT should be a scroll bar click."
;;;; Bindings. ;;;; Bindings.
;;; For now, we'll set things up to work like xterm. ;; For now, we'll set things up to work like xterm.
(cond ((and (boundp 'x-toolkit-scroll-bars) x-toolkit-scroll-bars) (cond ((and (boundp 'x-toolkit-scroll-bars) x-toolkit-scroll-bars)
(global-set-key [vertical-scroll-bar mouse-1] (global-set-key [vertical-scroll-bar mouse-1]
'scroll-bar-toolkit-scroll)) 'scroll-bar-toolkit-scroll))

View file

@ -707,8 +707,7 @@ With non-nil argument also saves the buffer."
(defun shadow-save-todo-file () (defun shadow-save-todo-file ()
(if (and shadow-todo-buffer (buffer-modified-p shadow-todo-buffer)) (if (and shadow-todo-buffer (buffer-modified-p shadow-todo-buffer))
(save-excursion (with-current-buffer shadow-todo-buffer
(set-buffer shadow-todo-buffer)
(condition-case nil ; have to continue even in case of (condition-case nil ; have to continue even in case of
(basic-save-buffer) ; error, otherwise kill-emacs might (basic-save-buffer) ; error, otherwise kill-emacs might
(error ; not work! (error ; not work!

View file

@ -2423,8 +2423,7 @@ specifies the value of ERROR-BUFFER."
;; Clear the output buffer, then run the command with ;; Clear the output buffer, then run the command with
;; output there. ;; output there.
(let ((directory default-directory)) (let ((directory default-directory))
(save-excursion (with-current-buffer buffer
(set-buffer buffer)
(setq buffer-read-only nil) (setq buffer-read-only nil)
(if (not output-buffer) (if (not output-buffer)
(setq default-directory directory)) (setq default-directory directory))
@ -3469,11 +3468,10 @@ START and END specify the portion of the current buffer to be copied."
(list (read-buffer "Append to buffer: " (other-buffer (current-buffer) t)) (list (read-buffer "Append to buffer: " (other-buffer (current-buffer) t))
(region-beginning) (region-end))) (region-beginning) (region-end)))
(let ((oldbuf (current-buffer))) (let ((oldbuf (current-buffer)))
(save-excursion (let* ((append-to (get-buffer-create buffer))
(let* ((append-to (get-buffer-create buffer)) (windows (get-buffer-window-list append-to t t))
(windows (get-buffer-window-list append-to t t)) point)
point) (with-current-buffer append-to
(set-buffer append-to)
(setq point (point)) (setq point (point))
(barf-if-buffer-read-only) (barf-if-buffer-read-only)
(insert-buffer-substring oldbuf start end) (insert-buffer-substring oldbuf start end)
@ -3490,8 +3488,7 @@ BUFFER (or buffer name), START and END.
START and END specify the portion of the current buffer to be copied." START and END specify the portion of the current buffer to be copied."
(interactive "BPrepend to buffer: \nr") (interactive "BPrepend to buffer: \nr")
(let ((oldbuf (current-buffer))) (let ((oldbuf (current-buffer)))
(save-excursion (with-current-buffer (get-buffer-create buffer)
(set-buffer (get-buffer-create buffer))
(barf-if-buffer-read-only) (barf-if-buffer-read-only)
(save-excursion (save-excursion
(insert-buffer-substring oldbuf start end))))) (insert-buffer-substring oldbuf start end)))))

View file

@ -1173,8 +1173,7 @@ frame and window to be the currently active frame and window."
(with-no-warnings (with-no-warnings
(specifier-instance has-modeline-p))) (specifier-instance has-modeline-p)))
speedbar-buffer) speedbar-buffer)
(save-excursion (with-current-buffer speedbar-buffer
(set-buffer speedbar-buffer)
(let* ((w (or (speedbar-frame-width) 20)) (let* ((w (or (speedbar-frame-width) 20))
(p1 "<<") (p1 "<<")
(p5 ">>") (p5 ">>")
@ -1246,8 +1245,7 @@ and the existence of packages."
(current-buffer)) (current-buffer))
speedbar-special-mode-key-map) speedbar-special-mode-key-map)
(select-frame cf)))))) (select-frame cf))))))
(save-excursion (with-current-buffer speedbar-buffer
(set-buffer speedbar-buffer)
(use-local-map (or localmap (use-local-map (or localmap
(speedbar-initial-keymap) (speedbar-initial-keymap)
;; This creates a small keymap we can glom the ;; This creates a small keymap we can glom the
@ -1859,8 +1857,7 @@ of the special mode functions."
(if (stringp buffer) (setq buffer (get-buffer buffer))) (if (stringp buffer) (setq buffer (get-buffer buffer)))
(if (not (buffer-live-p buffer)) (if (not (buffer-live-p buffer))
nil nil
(save-excursion (with-current-buffer buffer
(set-buffer buffer)
(save-match-data (save-match-data
(let ((ms (symbol-name major-mode)) v) (let ((ms (symbol-name major-mode)) v)
(if (not (string-match "-mode$" ms)) (if (not (string-match "-mode$" ms))
@ -1893,8 +1890,7 @@ of the special mode functions."
(defun speedbar-remove-localized-speedbar-support (buffer) (defun speedbar-remove-localized-speedbar-support (buffer)
"Remove any traces that BUFFER supports speedbar in a specialized way." "Remove any traces that BUFFER supports speedbar in a specialized way."
(save-excursion (with-current-buffer buffer
(set-buffer buffer)
(kill-local-variable 'speedbar-special-mode-expansion-list) (kill-local-variable 'speedbar-special-mode-expansion-list)
(kill-local-variable 'speedbar-special-mode-key-map) (kill-local-variable 'speedbar-special-mode-key-map)
(kill-local-variable 'speedbar-easymenu-definition-special))) (kill-local-variable 'speedbar-easymenu-definition-special)))
@ -2383,8 +2379,8 @@ the list."
(or (speedbar-line-file) (or (speedbar-line-file)
(speedbar-line-directory)))) (speedbar-line-directory))))
(methods (if (get-file-buffer f) (methods (if (get-file-buffer f)
(save-excursion (set-buffer (get-file-buffer f)) (with-current-buffer (get-file-buffer f)
speedbar-tag-hierarchy-method) speedbar-tag-hierarchy-method)
speedbar-tag-hierarchy-method)) speedbar-tag-hierarchy-method))
(lst (if (fboundp 'copy-tree) (lst (if (fboundp 'copy-tree)
(copy-tree lst) (copy-tree lst)
@ -2612,9 +2608,8 @@ name will have the function FIND-FUN and not token."
This should only be used by modes classified as special." This should only be used by modes classified as special."
(let ((funclst speedbar-special-mode-expansion-list) (let ((funclst speedbar-special-mode-expansion-list)
(specialbuff (current-buffer))) (specialbuff (current-buffer)))
(save-excursion (setq speedbar-desired-buffer specialbuff)
(setq speedbar-desired-buffer specialbuff) (with-current-buffer speedbar-buffer
(set-buffer speedbar-buffer)
;; If we are leaving a directory, cache it. ;; If we are leaving a directory, cache it.
(if (not speedbar-shown-directories) (if (not speedbar-shown-directories)
;; Do nothing ;; Do nothing
@ -3887,8 +3882,8 @@ If TEMP is non-nil, then clicking on a buffer restores the previous display."
(buffer-name (car bl)))) (buffer-name (car bl))))
(expchar (if known ?+ ??)) (expchar (if known ?+ ??))
(fn (if known 'speedbar-tag-file nil)) (fn (if known 'speedbar-tag-file nil))
(fname (save-excursion (set-buffer (car bl)) (fname (with-current-buffer (car bl)
(buffer-file-name)))) (buffer-file-name))))
(speedbar-make-tag-line 'bracket expchar fn (speedbar-make-tag-line 'bracket expchar fn
(if fname (file-name-nondirectory fname)) (if fname (file-name-nondirectory fname))
(buffer-name (car bl)) (buffer-name (car bl))
@ -3928,8 +3923,7 @@ If TEMP is non-nil, then clicking on a buffer restores the previous display."
"Add a note to the end of the last tag line. "Add a note to the end of the last tag line.
Argument BUFFER is the buffer being tested." Argument BUFFER is the buffer being tested."
(let (mod ro) (let (mod ro)
(save-excursion (with-current-buffer buffer
(set-buffer buffer)
(setq mod (buffer-modified-p) (setq mod (buffer-modified-p)
ro buffer-read-only)) ro buffer-read-only))
(if ro (speedbar-insert-button "%" nil nil nil nil t)))) (if ro (speedbar-insert-button "%" nil nil nil nil t))))
@ -3943,9 +3937,8 @@ Argument BUFFER is the buffer being tested."
(speedbar-message "%s%s %S %d %s" (speedbar-message "%s%s %S %d %s"
(if (buffer-modified-p buffer) "* " "") (if (buffer-modified-p buffer) "* " "")
item item
(save-excursion (set-buffer buffer) major-mode) (with-current-buffer buffer major-mode)
(save-excursion (set-buffer buffer) (with-current-buffer buffer (buffer-size))
(buffer-size))
(or (buffer-file-name buffer) "<No file>")))))) (or (buffer-file-name buffer) "<No file>"))))))
(defun speedbar-buffers-line-directory (&optional depth) (defun speedbar-buffers-line-directory (&optional depth)
@ -3963,8 +3956,7 @@ Optional argument DEPTH specifies the current depth of the back search."
(if (save-excursion (if (save-excursion
(end-of-line) (end-of-line)
(eq start (point))) (eq start (point)))
(or (save-excursion (set-buffer buffer) (or (with-current-buffer buffer default-directory)
default-directory)
"") "")
(buffer-file-name buffer)))))))) (buffer-file-name buffer))))))))

View file

@ -1536,8 +1536,7 @@ Encode/decode your strokes with \\[strokes-encode-buffer],
(defun strokes-xpm-to-compressed-string (&optional xpm-buffer) (defun strokes-xpm-to-compressed-string (&optional xpm-buffer)
"Convert XPM in XPM-BUFFER to compressed string representing the stroke. "Convert XPM in XPM-BUFFER to compressed string representing the stroke.
XPM-BUFFER defaults to ` *strokes-xpm*'." XPM-BUFFER defaults to ` *strokes-xpm*'."
(save-excursion (with-current-buffer (setq xpm-buffer (or xpm-buffer " *strokes-xpm*"))
(set-buffer (setq xpm-buffer (or xpm-buffer " *strokes-xpm*")))
(goto-char (point-min)) (goto-char (point-min))
(search-forward "/* pixels */") ; skip past header junk (search-forward "/* pixels */") ; skip past header junk
(forward-char 2) (forward-char 2)
@ -1620,8 +1619,7 @@ Optional BUFFER defaults to the current buffer.
Optional FORCE non-nil will ignore the buffer's read-only status." Optional FORCE non-nil will ignore the buffer's read-only status."
(interactive) (interactive)
;; (interactive "*bStrokify buffer: ") ;; (interactive "*bStrokify buffer: ")
(save-excursion (with-current-buffer (setq buffer (get-buffer (or buffer (current-buffer))))
(set-buffer (setq buffer (get-buffer (or buffer (current-buffer)))))
(when (or (not buffer-read-only) (when (or (not buffer-read-only)
force force
inhibit-read-only inhibit-read-only
@ -1669,8 +1667,7 @@ Optional FORCE non-nil will ignore the buffer's read-only status."
;; buffer is killed? ;; buffer is killed?
;; (interactive "*bUnstrokify buffer: ") ;; (interactive "*bUnstrokify buffer: ")
(interactive) (interactive)
(save-excursion (with-current-buffer (setq buffer (or buffer (current-buffer)))
(set-buffer (setq buffer (or buffer (current-buffer))))
(when (or (not buffer-read-only) (when (or (not buffer-read-only)
force force
inhibit-read-only inhibit-read-only
@ -1706,9 +1703,8 @@ Optional FORCE non-nil will ignore the buffer's read-only status."
(defun strokes-xpm-for-compressed-string (compressed-string &optional bufname) (defun strokes-xpm-for-compressed-string (compressed-string &optional bufname)
"Convert the stroke represented by COMPRESSED-STRING into an XPM. "Convert the stroke represented by COMPRESSED-STRING into an XPM.
Store XPM in buffer BUFNAME if supplied \(default is ` *strokes-xpm*'\)" Store XPM in buffer BUFNAME if supplied \(default is ` *strokes-xpm*'\)"
(save-excursion (or bufname (setq bufname " *strokes-xpm*"))
(or bufname (setq bufname " *strokes-xpm*")) (with-current-buffer (get-buffer-create bufname)
(set-buffer (get-buffer-create bufname))
(erase-buffer) (erase-buffer)
(insert compressed-string) (insert compressed-string)
(goto-char (point-min)) (goto-char (point-min))

View file

@ -1347,8 +1347,7 @@ the process. Any more args are arguments to PROGRAM."
;; If no process, or nuked process, crank up a new one and put buffer in ;; If no process, or nuked process, crank up a new one and put buffer in
;; term mode. Otherwise, leave buffer and existing process alone. ;; term mode. Otherwise, leave buffer and existing process alone.
(cond ((not (term-check-proc buffer)) (cond ((not (term-check-proc buffer))
(save-excursion (with-current-buffer buffer
(set-buffer buffer)
(term-mode)) ; Install local vars, mode, keymap, ... (term-mode)) ; Install local vars, mode, keymap, ...
(term-exec buffer name program startfile switches))) (term-exec buffer name program startfile switches)))
buffer)) buffer))
@ -1375,8 +1374,7 @@ commands to use in that buffer.
Blasts any old process running in the buffer. Doesn't set the buffer mode. Blasts any old process running in the buffer. Doesn't set the buffer mode.
You can use this to cheaply run a series of processes in the same term You can use this to cheaply run a series of processes in the same term
buffer. The hook `term-exec-hook' is run after each exec." buffer. The hook `term-exec-hook' is run after each exec."
(save-excursion (with-current-buffer buffer
(set-buffer buffer)
(let ((proc (get-buffer-process buffer))) ; Blast any old process. (let ((proc (get-buffer-process buffer))) ; Blast any old process.
(when proc (delete-process proc))) (when proc (delete-process proc)))
;; Crank up a new process ;; Crank up a new process
@ -1412,24 +1410,16 @@ The main purpose is to get rid of the local keymap."
(if (null (buffer-name buffer)) (if (null (buffer-name buffer))
;; buffer killed ;; buffer killed
(set-process-buffer proc nil) (set-process-buffer proc nil)
(let ((obuf (current-buffer))) (with-current-buffer buffer
;; save-excursion isn't the right thing if ;; Write something in the compilation buffer
;; process-buffer is current-buffer ;; and hack its mode line.
(unwind-protect ;; Get rid of local keymap.
(progn (use-local-map nil)
;; Write something in the compilation buffer (term-handle-exit (process-name proc) msg)
;; and hack its mode line. ;; Since the buffer and mode line will show that the
(set-buffer buffer) ;; process is dead, we can delete it now. Otherwise it
;; Get rid of local keymap. ;; will stay around until M-x list-processes.
(use-local-map nil) (delete-process proc))))))
(term-handle-exit (process-name proc)
msg)
;; Since the buffer and mode line will show that the
;; process is dead, we can delete it now. Otherwise it
;; will stay around until M-x list-processes.
(delete-process proc))
(set-buffer obuf)))
))))
(defun term-handle-exit (process-name msg) (defun term-handle-exit (process-name msg)
"Write process exit (or other change) message MSG in the current buffer." "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'."
(count 0) (count 0)
(ring (make-ring term-input-ring-size))) (ring (make-ring term-input-ring-size)))
(unwind-protect (unwind-protect
(save-excursion (with-current-buffer history-buf
(set-buffer history-buf)
(widen) (widen)
(erase-buffer) (erase-buffer)
(insert-file-contents file) (insert-file-contents file)
@ -1601,8 +1590,7 @@ See also `term-read-input-ring'."
(index (ring-length ring))) (index (ring-length ring)))
;; Write it all out into a buffer first. Much faster, but messier, ;; Write it all out into a buffer first. Much faster, but messier,
;; than writing it one line at a time. ;; than writing it one line at a time.
(save-excursion (with-current-buffer history-buf
(set-buffer history-buf)
(erase-buffer) (erase-buffer)
(while (> index 0) (while (> index 0)
(setq index (1- index)) (setq index (1- index))
@ -2460,10 +2448,8 @@ See `term-prompt-regexp'."
(y-or-n-p (format "Save buffer %s first? " (y-or-n-p (format "Save buffer %s first? "
(buffer-name buff)))) (buffer-name buff))))
;; save BUFF. ;; save BUFF.
(let ((old-buffer (current-buffer))) (with-current-buffer buff
(set-buffer buff) (save-buffer)))))
(save-buffer)
(set-buffer old-buffer)))))
;; (TERM-GET-SOURCE prompt prev-dir/file source-modes mustmatch-p) ;; (TERM-GET-SOURCE prompt prev-dir/file source-modes mustmatch-p)
@ -3453,8 +3439,7 @@ The top-most line is line 0."
(defun term-display-buffer-line (buffer line) (defun term-display-buffer-line (buffer line)
(let* ((window (display-buffer buffer t)) (let* ((window (display-buffer buffer t))
(pos)) (pos))
(save-excursion (with-current-buffer buffer
(set-buffer buffer)
(save-restriction (save-restriction
(widen) (widen)
(goto-char (point-min)) (goto-char (point-min))
@ -3896,8 +3881,7 @@ if KIND is 1, erase from home to point; else erase from home to point-max."
(message "Output logging off.")) (message "Output logging off."))
(if (get-buffer name) (if (get-buffer name)
nil nil
(save-excursion (with-current-buffer (get-buffer-create name)
(set-buffer (get-buffer-create name))
(fundamental-mode) (fundamental-mode)
(buffer-disable-undo (current-buffer)) (buffer-disable-undo (current-buffer))
(erase-buffer))) (erase-buffer)))
@ -4169,8 +4153,7 @@ Typing SPC flushes the help buffer."
(display-completion-list (sort completions 'string-lessp))) (display-completion-list (sort completions 'string-lessp)))
(message "Hit space to flush") (message "Hit space to flush")
(let (key first) (let (key first)
(if (save-excursion (if (with-current-buffer (get-buffer "*Completions*")
(set-buffer (get-buffer "*Completions*"))
(setq key (read-key-sequence nil) (setq key (read-key-sequence nil)
first (aref key 0)) first (aref key 0))
(and (consp first) (and (consp first)
@ -4197,8 +4180,7 @@ the process. Any more args are arguments to PROGRAM."
;; If no process, or nuked process, crank up a new one and put buffer in ;; If no process, or nuked process, crank up a new one and put buffer in
;; term mode. Otherwise, leave buffer and existing process alone. ;; term mode. Otherwise, leave buffer and existing process alone.
(cond ((not (term-check-proc buffer)) (cond ((not (term-check-proc buffer))
(save-excursion (with-current-buffer buffer
(set-buffer buffer)
(term-mode)) ; Install local vars, mode, keymap, ... (term-mode)) ; Install local vars, mode, keymap, ...
(term-exec buffer name program startfile switches))) (term-exec buffer name program startfile switches)))
buffer)) buffer))
@ -4383,8 +4365,7 @@ use in that buffer.
:coding 'no-conversion :coding 'no-conversion
:noquery t)) :noquery t))
(buffer (process-buffer process))) (buffer (process-buffer process)))
(save-excursion (with-current-buffer buffer
(set-buffer buffer)
(term-mode) (term-mode)
(term-char-mode) (term-char-mode)
(goto-char (point-max)) (goto-char (point-max))

View file

@ -326,8 +326,7 @@ Very poor man's file transfer protocol."
(message "Output logging off.")) (message "Output logging off."))
(if (get-buffer name) (if (get-buffer name)
nil nil
(save-excursion (with-current-buffer (get-buffer-create name)
(set-buffer (get-buffer-create name))
(fundamental-mode) (fundamental-mode)
(buffer-disable-undo (current-buffer)) (buffer-disable-undo (current-buffer))
(erase-buffer))) (erase-buffer)))
@ -610,8 +609,7 @@ together with a command \\<terminal-edit-map>to return to terminal emulation: \\
"%-")) "%-"))
(set-process-filter te-process (set-process-filter te-process
(function (lambda (process string) (function (lambda (process string)
(save-excursion (with-current-buffer (process-buffer process)
(set-buffer (process-buffer process))
(setq te-pending-output (nconc te-pending-output (setq te-pending-output (nconc te-pending-output
(list string)))) (list string))))
(te-update-pending-output-display)))) (te-update-pending-output-display))))
@ -874,27 +872,22 @@ move to start of new line, clear to end of line."
(defun te-filter (process string) (defun te-filter (process string)
(let* ((obuf (current-buffer))) (with-current-buffer (process-buffer process)
;; can't use save-excursion, as that preserves point, which we don't want (goto-char te-saved-point)
(unwind-protect (and (bufferp te-log-buffer)
(progn (if (null (buffer-name te-log-buffer))
(set-buffer (process-buffer process)) ;; killed
(goto-char te-saved-point) (setq te-log-buffer nil)
(and (bufferp te-log-buffer) (set-buffer te-log-buffer)
(if (null (buffer-name te-log-buffer)) (goto-char (point-max))
;; killed (insert-before-markers string)
(setq te-log-buffer nil) (set-buffer (process-buffer process))))
(set-buffer te-log-buffer) (setq te-pending-output (nconc te-pending-output (list string)))
(goto-char (point-max)) (te-update-pending-output-display)
(insert-before-markers string) (te-process-output (eq (current-buffer)
(set-buffer (process-buffer process)))) (window-buffer (selected-window))))
(setq te-pending-output (nconc te-pending-output (list string))) (set-buffer (process-buffer process))
(te-update-pending-output-display) (setq te-saved-point (point))))
(te-process-output (eq (current-buffer)
(window-buffer (selected-window))))
(set-buffer (process-buffer process))
(setq te-saved-point (point)))
(set-buffer obuf))))
;; (A version of the following comment which might be distractingly offensive ;; (A version of the following comment which might be distractingly offensive
;; to some readers has been moved to term-nasty.el.) ;; 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."
(cond ((eq (process-status process) 'run)) (cond ((eq (process-status process) 'run))
((null (buffer-name (process-buffer process)))) ;deleted ((null (buffer-name (process-buffer process)))) ;deleted
(t (let ((b (current-buffer))) (t (let ((b (current-buffer)))
(save-excursion (with-current-buffer (process-buffer process)
(set-buffer (process-buffer process))
(setq buffer-read-only nil) (setq buffer-read-only nil)
(fundamental-mode) (fundamental-mode)
(goto-char (point-max)) (goto-char (point-max))
@ -1097,27 +1089,26 @@ This function calls the value of terminal-mode-hook if that exists
and is non-nil after the terminal buffer has been set up and the and is non-nil after the terminal buffer has been set up and the
subprocess started." subprocess started."
(interactive (interactive
(cons (save-excursion (cons (with-current-buffer (get-buffer-create "*terminal*")
(set-buffer (get-buffer-create "*terminal*")) (buffer-name (if (or (not (boundp 'te-process))
(buffer-name (if (or (not (boundp 'te-process)) (null te-process)
(null te-process) (not (eq (process-status te-process)
(not (eq (process-status te-process) 'run)))
'run))) (current-buffer)
(current-buffer) (generate-new-buffer "*terminal*"))))
(generate-new-buffer "*terminal*")))) (append
(append (let* ((default-s
(let* ((default-s ;; Default shell is same thing M-x shell uses.
;; Default shell is same thing M-x shell uses. (or explicit-shell-file-name
(or explicit-shell-file-name (getenv "ESHELL")
(getenv "ESHELL") (getenv "SHELL")
(getenv "SHELL") "/bin/sh"))
"/bin/sh")) (s (read-string
(s (read-string (format "Run program in emulator (default %s): "
(format "Run program in emulator (default %s): " default-s))))
default-s)))) (if (equal s "")
(if (equal s "") (list default-s '())
(list default-s '()) (te-parse-program-and-args s))))))
(te-parse-program-and-args s))))))
(switch-to-buffer buffer) (switch-to-buffer buffer)
(if (null width) (setq width (- (window-width (selected-window)) 1))) (if (null width) (setq width (- (window-width (selected-window)) 1)))
(if (null height) (setq height (- (window-height (selected-window)) 1))) (if (null height) (setq height (- (window-height (selected-window)) 1)))

View file

@ -660,8 +660,7 @@ The new forms being recommended now will continue to work then.")
Suggests replacing OLD-FORM with NEW-FORM." Suggests replacing OLD-FORM with NEW-FORM."
(cond (cond
(time-stamp-conversion-warn (time-stamp-conversion-warn
(save-excursion (with-current-buffer (get-buffer-create "*Time-stamp-compatibility*")
(set-buffer (get-buffer-create "*Time-stamp-compatibility*"))
(goto-char (point-max)) (goto-char (point-max))
(if (bobp) (if (bobp)
(progn (progn

View file

@ -1094,7 +1094,7 @@ FRAC should be the inverse of the fractional value; for example, a value of
(defun type-break-force-mode-line-update (&optional all) (defun type-break-force-mode-line-update (&optional all)
"Force the mode-line of the current buffer to be redisplayed. "Force the mode-line of the current buffer to be redisplayed.
With optional non-nil ALL, force redisplay of all mode-lines." With optional non-nil ALL, force redisplay of all mode-lines."
(and all (save-excursion (set-buffer (other-buffer)))) (and all (with-current-buffer (other-buffer)))
(set-buffer-modified-p (buffer-modified-p))) (set-buffer-modified-p (buffer-modified-p)))
;; If an exception occurs in Emacs while running the post command hook, the ;; 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."
;;; Timer wrapper functions ;;; Timer wrapper functions
;;; ;;
;;; These shield type-break from variations in the interval timer packages ;; These shield type-break from variations in the interval timer packages
;;; for different versions of Emacs. ;; for different versions of Emacs.
(defun type-break-run-at-time (time repeat function) (defun type-break-run-at-time (time repeat function)
(condition-case nil (or (require 'timer) (require 'itimer)) (error nil)) (condition-case nil (or (require 'timer) (require 'itimer)) (error nil))

View file

@ -91,8 +91,7 @@ You can <s>teal the file; the other user becomes the
intruder if (s)he ever unmodifies the file and then changes it again. intruder if (s)he ever unmodifies the file and then changes it again.
You can <p>roceed; you edit at your own (and the other user's) risk. You can <p>roceed; you edit at your own (and the other user's) risk.
You can <q>uit; don't modify this file.") You can <q>uit; don't modify this file.")
(save-excursion (with-current-buffer standard-output
(set-buffer standard-output)
(help-mode)))) (help-mode))))
(put (put
@ -155,8 +154,7 @@ If you say `n', the change you started to make will be aborted.
Usually, you should type `n' and then `M-x revert-buffer', Usually, you should type `n' and then `M-x revert-buffer',
to get the latest version of the file, then make the change again.") to get the latest version of the file, then make the change again.")
(save-excursion (with-current-buffer standard-output
(set-buffer standard-output)
(help-mode)))) (help-mode))))
;; arch-tag: a61c5b60-e1c8-44fd-894a-c617f4dfc639 ;; arch-tag: a61c5b60-e1c8-44fd-894a-c617f4dfc639

View file

@ -1055,65 +1055,64 @@ Returns: nil if no headers were found
(cond (cond
((not (get-file-buffer file)) nil) ((not (get-file-buffer file)) nil)
((let (status version locking-user) ((let (status version locking-user)
(save-excursion (with-current-buffer (get-file-buffer file)
(set-buffer (get-file-buffer file)) (goto-char (point-min))
(goto-char (point-min)) (cond
(cond ;; search for $Id or $Header
;; search for $Id or $Header ;; -------------------------
;; ------------------------- ;; The `\ 's below avoid an RCS 5.7 bug when checking in this file.
;; The `\ 's below avoid an RCS 5.7 bug when checking in this file. ((or (and (search-forward "$Id\ : " nil t)
((or (and (search-forward "$Id\ : " nil t) (looking-at "[^ ]+ \\([0-9.]+\\) "))
(looking-at "[^ ]+ \\([0-9.]+\\) ")) (and (progn (goto-char (point-min))
(and (progn (goto-char (point-min)) (search-forward "$Header\ : " nil t))
(search-forward "$Header\ : " nil t)) (looking-at "[^ ]+ \\([0-9.]+\\) ")))
(looking-at "[^ ]+ \\([0-9.]+\\) "))) (goto-char (match-end 0))
(goto-char (match-end 0)) ;; if found, store the revision number ...
;; if found, store the revision number ... (setq version (match-string-no-properties 1))
(setq version (match-string-no-properties 1)) ;; ... and check for the locking state
;; ... and check for the locking state (cond
(cond ((looking-at
((looking-at (concat "[0-9]+[/-][01][0-9][/-][0-3][0-9] " ; date
(concat "[0-9]+[/-][01][0-9][/-][0-3][0-9] " ; date "[0-2][0-9]:[0-5][0-9]+:[0-6][0-9]+\\([+-][0-9:]+\\)? " ; time
"[0-2][0-9]:[0-5][0-9]+:[0-6][0-9]+\\([+-][0-9:]+\\)? " ; time "[^ ]+ [^ ]+ ")) ; author & state
"[^ ]+ [^ ]+ ")) ; author & state (goto-char (match-end 0)) ; [0-6] in regexp handles leap seconds
(goto-char (match-end 0)) ; [0-6] in regexp handles leap seconds (cond
(cond ;; unlocked revision
;; unlocked revision ((looking-at "\\$")
((looking-at "\\$") (setq locking-user 'none)
(setq locking-user 'none) (setq status 'rev-and-lock))
(setq status 'rev-and-lock)) ;; revision is locked by some user
;; revision is locked by some user ((looking-at "\\([^ ]+\\) \\$")
((looking-at "\\([^ ]+\\) \\$") (setq locking-user (match-string-no-properties 1))
(setq locking-user (match-string-no-properties 1)) (setq status 'rev-and-lock))
(setq status 'rev-and-lock)) ;; everything else: false
;; everything else: false (nil)))
(nil))) ;; unexpected information in
;; unexpected information in ;; keyword string --> quit
;; keyword string --> quit (nil)))
(nil))) ;; search for $Revision
;; search for $Revision ;; --------------------
;; -------------------- ((re-search-forward (concat "\\$"
((re-search-forward (concat "\\$" "Revision: \\([0-9.]+\\) \\$")
"Revision: \\([0-9.]+\\) \\$") nil t)
nil t) ;; if found, store the revision number ...
;; if found, store the revision number ... (setq version (match-string-no-properties 1))
(setq version (match-string-no-properties 1)) ;; and see if there's any lock information
;; and see if there's any lock information (goto-char (point-min))
(goto-char (point-min)) (if (re-search-forward (concat "\\$" "Locker:") nil t)
(if (re-search-forward (concat "\\$" "Locker:") nil t) (cond ((looking-at " \\([^ ]+\\) \\$")
(cond ((looking-at " \\([^ ]+\\) \\$") (setq locking-user (match-string-no-properties 1))
(setq locking-user (match-string-no-properties 1)) (setq status 'rev-and-lock))
(setq status 'rev-and-lock)) ((looking-at " *\\$")
((looking-at " *\\$") (setq locking-user 'none)
(setq locking-user 'none) (setq status 'rev-and-lock))
(setq status 'rev-and-lock)) (t
(t (setq locking-user 'none)
(setq locking-user 'none) (setq status 'rev-and-lock)))
(setq status 'rev-and-lock))) (setq status 'rev)))
(setq status 'rev))) ;; else: nothing found
;; else: nothing found ;; -------------------
;; ------------------- (t nil)))
(t nil)))
(if status (vc-file-setprop file 'vc-working-revision version)) (if status (vc-file-setprop file 'vc-working-revision version))
(and (eq status 'rev-and-lock) (and (eq status 'rev-and-lock)
(vc-file-setprop file 'vc-state (vc-file-setprop file 'vc-state

View file

@ -1942,8 +1942,7 @@ cleaning up these problems."
(unless (get-buffer whitespace-help-buffer-name) (unless (get-buffer whitespace-help-buffer-name)
(delete-other-windows) (delete-other-windows)
(let ((buffer (get-buffer-create whitespace-help-buffer-name))) (let ((buffer (get-buffer-create whitespace-help-buffer-name)))
(save-excursion (with-current-buffer buffer
(set-buffer buffer)
(erase-buffer) (erase-buffer)
(insert whitespace-help-text) (insert whitespace-help-text)
(whitespace-insert-option-mark (whitespace-insert-option-mark

View file

@ -1270,8 +1270,7 @@ window."
(setq size (+ (window-height) size))) (setq size (+ (window-height) size)))
(setq new-window (split-window nil size)) (setq new-window (split-window nil size))
(unless split-window-keep-point (unless split-window-keep-point
(save-excursion (with-current-buffer (window-buffer)
(set-buffer (window-buffer))
(goto-char (window-start)) (goto-char (window-start))
(setq moved (vertical-motion (window-height))) (setq moved (vertical-motion (window-height)))
(set-window-start new-window (point)) (set-window-start new-window (point))

View file

@ -175,10 +175,10 @@ action and type we got from `x-dnd-test-function'."
(let ((buffer (when (window-live-p window) (let ((buffer (when (window-live-p window)
(window-buffer window))) (window-buffer window)))
(current-state (x-dnd-get-state-for-frame window))) (current-state (x-dnd-get-state-for-frame window)))
(when (or (not (equal buffer (aref current-state 0))) (unless (and (equal buffer (aref current-state 0))
(not (equal window (aref current-state 1))) (equal window (aref current-state 1))
(not (equal action (aref current-state 3)))) (equal action (aref current-state 3)))
(save-excursion (save-current-buffer
(when buffer (set-buffer buffer)) (when buffer (set-buffer buffer))
(let* ((action-type (funcall x-dnd-test-function (let* ((action-type (funcall x-dnd-test-function
window window