1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-15 10:30:25 -08:00

* url-util.el (url-insert-entities-in-string):

* url-nfs.el (url-nfs-unescape):
* url-ldap.el (url-ldap):
* url-imap.el (url-imap):
* url-cid.el (url-cid-gnus, url-cid): Use with-current-buffer.
* erc.el (erc-display-line-1, erc-process-away):
* erc-truncate.el (erc-truncate-buffer-to-size):
Use with-current-buffer.
* term/ns-win.el (ns-scroll-bar-move, ns-face-at-pos):
* play/mpuz.el (mpuz-create-buffer):
* play/landmark.el (lm-prompt-for-move, lm-print-wts, lm-print-smell)
(lm-print-y,s,noise, lm-print-w0, lm-init):
* play/gomoku.el (gomoku-prompt-for-move):
* play/fortune.el (fortune-in-buffer):
* play/dissociate.el (dissociated-press):
* play/decipher.el (decipher-adjacency-list, decipher-display-regexp)
(decipher-analyze-buffer, decipher-stats-buffer,decipher-stats-buffer):
* mail/supercite.el (sc-eref-show):
* mail/smtpmail.el (smtpmail-send-it):
* mail/rmailsum.el (rmail-summary-next-labeled-message)
(rmail-summary-previous-labeled-message, rmail-summary-wipe)
(rmail-summary-undelete-many, rmail-summary-rmail-update)
(rmail-summary-goto-msg, rmail-summary-expunge)
(rmail-summary-get-new-mail, rmail-summary-search-backward)
(rmail-summary-add-label, rmail-summary-output-menu)
(rmail-summary-output-body):
* mail/rfc822.el (rfc822-addresses):
* mail/reporter.el (reporter-dump-variable, reporter-dump-state):
* mail/mailpost.el (post-mail-send-it):
* mail/hashcash.el (hashcash-generate-payment):
* mail/feedmail.el (feedmail-run-the-queue)
(feedmail-queue-send-edit-prompt-help-first)
(feedmail-send-it-immediately, feedmail-give-it-to-buffer-eater)
(feedmail-deduce-address-list):
* eshell/esh-ext.el (eshell-remote-command):
* eshell/em-unix.el (eshell-occur-mode-mouse-goto):
* emulation/viper-util.el (viper-glob-unix-files, viper-save-setting)
(viper-wildcard-to-regexp, viper-glob-mswindows-files)
(viper-save-string-in-file, viper-valid-marker):
* emulation/viper-keym.el (viper-toggle-key):
* emulation/viper-ex.el (ex-expand-filsyms, viper-get-ex-file)
(ex-edit, ex-global, ex-mark, ex-next-related-buffer, ex-quit)
(ex-get-inline-cmd-args, ex-tag, ex-command, ex-compile):
* emulation/viper-cmd.el (viper-exec-form-in-vi)
(viper-exec-form-in-emacs, viper-brac-function):
* emulation/viper.el (viper-delocalize-var):
* emulation/vip.el (vip-mode, vip-get-ex-token, vip-ex, vip-get-ex-pat)
(vip-get-ex-command, vip-get-ex-opt-gc, vip-get-ex-buffer)
(vip-get-ex-count, vip-get-ex-file, ex-edit, ex-global, ex-mark)
(ex-map, ex-unmap, ex-quit, ex-read, ex-tag, ex-command):
* emulation/vi.el (vi-switch-mode, vi-ex-cmd):
* emulation/edt.el (edt-electric-helpify):
* emulation/cua-rect.el (cua--rectangle-aux-replace):
* emulation/cua-gmrk.el (cua--insert-at-global-mark)
(cua--delete-at-global-mark, cua--copy-rectangle-to-global-mark)
(cua-indent-to-global-mark-column):
* calendar/diary-lib.el (calendar-mark-1):
* calendar/cal-hebrew.el (calendar-hebrew-mark-date-pattern):
Use with-current-buffer.
* emulation/viper.el (viper-delocalize-var): Use dolist.
This commit is contained in:
Stefan Monnier 2009-11-03 02:04:29 +00:00
parent 5b95556284
commit 937e6a5612
39 changed files with 324 additions and 364 deletions

View file

@ -1628,8 +1628,7 @@ backup file names and the like)."
(if (and already-buffer (not (file-exists-p maybe-file)))
;; we have gotten rid of the file associated with the
;; buffer, so update the buffer's notion of that
(save-excursion
(set-buffer already-buffer)
(with-current-buffer already-buffer
(setq buffer-file-name nil)))))
(error (setq messages-skipped (1+ messages-skipped))))
(kill-buffer blobby-buffer)
@ -1801,7 +1800,8 @@ see the variable feedmail-prompt-before-queue-user-alist.
")
(and (stringp feedmail-prompt-before-queue-help-supplement)
(princ feedmail-prompt-before-queue-help-supplement))
(save-excursion (set-buffer standard-output) (if (fboundp 'help-mode) (help-mode)))))
(with-current-buffer standard-output
(if (fboundp 'help-mode) (help-mode)))))
(defun feedmail-look-at-queue-directory (queue-directory)
"Find out some things about a queue directory.
@ -1970,7 +1970,7 @@ mapped to mostly alphanumerics for safety."
(mail-header-separator mail-header-separator)
)
(unwind-protect
(save-excursion
(save-current-buffer
(set-buffer feedmail-error-buffer) (erase-buffer)
(set-buffer feedmail-prepped-text-buffer) (erase-buffer)
@ -2075,18 +2075,17 @@ mapped to mostly alphanumerics for safety."
(if (and (not feedmail-queue-runner-is-active) (setq also-file (buffer-file-name feedmail-raw-text-buffer)))
(progn ; if a file but not running the queue, offer to delete it
(setq also-file (expand-file-name also-file))
(if (or feedmail-queue-auto-file-nuke
(y-or-n-p (format "FQM: Delete message file %s? " also-file)))
(save-excursion
;; if we delete the affiliated file, get rid
;; of the file name association and make sure we
;; don't annoy people with a prompt on exit
(delete-file also-file)
(set-buffer feedmail-raw-text-buffer)
(setq buffer-offer-save nil)
(setq buffer-file-name nil)
)
)))
(when (or feedmail-queue-auto-file-nuke
(y-or-n-p
(format "FQM: Delete message file %s? "
also-file)))
;; if we delete the affiliated file, get rid
;; of the file name association and make sure we
;; don't annoy people with a prompt on exit
(delete-file also-file)
(with-current-buffer feedmail-raw-text-buffer
(setq buffer-offer-save nil)
(setq buffer-file-name nil)))))
(goto-char (point-min))
;; re-insert and handle any Fcc fields (and, optionally, any Bcc).
(if fcc (letf (((default-value 'buffer-file-type)
@ -2197,18 +2196,19 @@ fiddle-plex, as described in the documentation for the variable
(mapcar
'(lambda (feedmail-spray-this-address)
(let ((spray-buffer (get-buffer-create " *FQM Outgoing Email Spray*")))
(save-excursion
(set-buffer spray-buffer)
(with-current-buffer spray-buffer
(erase-buffer)
;; not life's most efficient methodology, but spraying isn't
;; an every-5-minutes event either
(insert-buffer-substring feedmail-prepped-text-buffer)
;; There's a good case to me made that each separate transmission of
;; a message in the spray should have a distinct Message-Id:. There
;; is also a less compelling argument in the other direction. I think
;; they technically should have distinct Message-Id:s, but I doubt that
;; anyone cares, practically. If someone complains about it, I'll add
;; it.
;; There's a good case to me made that each separate
;; transmission of a message in the spray should
;; have a distinct Message-Id:. There is also a less
;; compelling argument in the other direction.
;; I think they technically should have distinct
;; Message-Id:s, but I doubt that anyone cares,
;; practically. If someone complains about it, I'll
;; add it.
(feedmail-fiddle-list-of-spray-fiddle-plexes feedmail-spray-address-fiddle-plex-list)
;; this (let ) is just in case some buffer eater
;; is cheating and using the global variable name instead
@ -2593,8 +2593,8 @@ been weeded out."
(this-line)
(this-line-end))
(unwind-protect
(save-excursion
(set-buffer (get-buffer-create " *FQM scratch*")) (erase-buffer)
(with-current-buffer (get-buffer-create " *FQM scratch*")
(erase-buffer)
(insert-buffer-substring message-buffer header-start header-end)
(goto-char (point-min))
(let ((case-fold-search t))

View file

@ -161,8 +161,7 @@ For example, you may want to set this to '(\"-Z2\") to reduce header length."
"Generate a hashcash payment by finding a VAL-bit collison on STR."
(if (and (> val 0)
hashcash-path)
(save-excursion
(set-buffer (get-buffer-create " *hashcash*"))
(with-current-buffer (get-buffer-create " *hashcash*")
(erase-buffer)
(apply 'call-process hashcash-path nil t nil
"-m" "-q" "-b" (number-to-string val) str

View file

@ -36,8 +36,7 @@ site-init."
delimline
(mailbuf (current-buffer)))
(unwind-protect
(save-excursion
(set-buffer tembuf)
(with-current-buffer tembuf
(erase-buffer)
(insert-buffer-substring mailbuf)
(goto-char (point-max))
@ -73,8 +72,7 @@ site-init."
(if (re-search-forward "^Subject:[ \t]*\n" delimline t)
(replace-match ""))
(if mail-interactive
(save-excursion
(set-buffer errbuf)
(with-current-buffer errbuf
(erase-buffer))))
(let ((m (default-file-modes)))
(unwind-protect
@ -91,8 +89,7 @@ site-init."
(if mail-interactive '("-watch") '("-nowatch"))
(list temfile)))
(if mail-interactive
(save-excursion
(set-buffer errbuf)
(with-current-buffer errbuf
(goto-char (point-min))
(while (re-search-forward "\n\n* *" nil t)
(replace-match "; "))

View file

@ -174,8 +174,7 @@ composed.")
MAILBUF is the mail buffer being composed."
(reporter-update-status)
(condition-case nil
(let ((val (save-excursion
(set-buffer reporter-eval-buffer)
(let ((val (with-current-buffer reporter-eval-buffer
(symbol-value varsym)))
(sym (symbol-name varsym))
(print-escape-newlines t)
@ -201,8 +200,7 @@ MAILBUF is the mail buffer being composed."
(reporter-beautify-list maxwidth compact-p))))
(insert "\n"))
(void-variable
(save-excursion
(set-buffer mailbuf)
(with-current-buffer mailbuf
(mail-position-on-field "X-Reporter-Void-Vars-Found")
(end-of-line)
(insert (symbol-name varsym) " ")))
@ -247,8 +245,7 @@ dumped."
(condition-case fault
(let ((mailbuf (current-buffer))
(elbuf (get-buffer-create " *tmp-reporter-buffer*")))
(save-excursion
(set-buffer elbuf)
(with-current-buffer elbuf
(emacs-lisp-mode)
(erase-buffer)
(insert "(setq\n")

View file

@ -278,44 +278,44 @@
(list (substring header-text (match-beginning 1) (match-end 1)))
(let ((buf (generate-new-buffer " rfc822")))
(unwind-protect
(save-excursion
(set-buffer buf)
(make-local-variable 'case-fold-search)
(setq case-fold-search nil) ;For speed(?)
(insert header-text)
;; unfold continuation lines
(goto-char (point-min))
(with-current-buffer buf
(make-local-variable 'case-fold-search)
(setq case-fold-search nil) ;For speed(?)
(insert header-text)
;; unfold continuation lines
(goto-char (point-min))
(while (re-search-forward "\\([^\\]\\(\\\\\\\\\\)*\\)\n[ \t]" nil t)
(replace-match "\\1 " t))
(while (re-search-forward "\\([^\\]\\(\\\\\\\\\\)*\\)\n[ \t]"
nil t)
(replace-match "\\1 " t))
(goto-char (point-min))
(let ((list ())
tem
;; This is for rfc822-bad-address. Give it a non-nil
;; initial value to prevent rfc822-bad-address from
;; raising a wrong-type-argument error
(rfc822-address-start (point)))
(catch 'address ; this is for rfc822-bad-address
(rfc822-nuke-whitespace)
(while (not (eobp))
(setq rfc822-address-start (point))
(setq tem
(cond ((rfc822-looking-at ?\,)
nil)
((looking-at "[][\000-\037@;:\\.>)]")
(forward-char)
(rfc822-bad-address
(format "Strange character \\%c found"
(preceding-char))))
(t
(rfc822-addresses-1 t))))
(cond ((null tem))
((stringp tem)
(setq list (cons tem list)))
(t
(setq list (nconc (nreverse tem) list)))))
(nreverse list))))
(goto-char (point-min))
(let ((list ())
tem
;; This is for rfc822-bad-address. Give it a non-nil
;; initial value to prevent rfc822-bad-address from
;; raising a wrong-type-argument error
(rfc822-address-start (point)))
(catch 'address ; this is for rfc822-bad-address
(rfc822-nuke-whitespace)
(while (not (eobp))
(setq rfc822-address-start (point))
(setq tem
(cond ((rfc822-looking-at ?\,)
nil)
((looking-at "[][\000-\037@;:\\.>)]")
(forward-char)
(rfc822-bad-address
(format "Strange character \\%c found"
(preceding-char))))
(t
(rfc822-addresses-1 t))))
(cond ((null tem))
((stringp tem)
(setq list (cons tem list)))
(t
(setq list (nconc (nreverse tem) list)))))
(nreverse list))))
(and buf (kill-buffer buf))))))
(provide 'rfc822)

View file

@ -643,8 +643,7 @@ non-deleted messages."
With prefix argument N moves forward N messages with these labels."
(interactive "p\nsMove to next msg with labels: ")
(let (msg)
(save-excursion
(set-buffer rmail-buffer)
(with-current-buffer rmail-buffer
(rmail-next-labeled-message n labels)
(setq msg rmail-current-message))
(rmail-summary-goto-msg msg)))
@ -654,8 +653,7 @@ With prefix argument N moves forward N messages with these labels."
With prefix argument N moves backward N messages with these labels."
(interactive "p\nsMove to previous msg with labels: ")
(let (msg)
(save-excursion
(set-buffer rmail-buffer)
(with-current-buffer rmail-buffer
(rmail-previous-labeled-message n labels)
(setq msg rmail-current-message))
(rmail-summary-goto-msg msg)))
@ -809,8 +807,7 @@ Optional prefix ARG means undelete ARG previous messages."
(defun rmail-summary-undelete-many (&optional n)
"Undelete all deleted msgs, optional prefix arg N means undelete N prev msgs."
(interactive "P")
(save-excursion
(set-buffer rmail-buffer)
(with-current-buffer rmail-buffer
(let* ((init-msg (if n rmail-current-message rmail-total-messages))
(rmail-current-message init-msg)
(n (or n rmail-total-messages))
@ -967,8 +964,7 @@ Search, the `unseen' attribute is restored.")
(rmail-show-message msg-num t))
(select-window owin))
(if (buffer-name rmail-buffer)
(save-excursion
(set-buffer rmail-buffer)
(with-current-buffer rmail-buffer
(rmail-show-message msg-num t))))))
(rmail-summary-update-highlight nil)))))
@ -1206,7 +1202,7 @@ Returns non-nil if message N was found."
(curmsg (string-to-number
(buffer-substring (point)
(min (point-max) (+ 6 (point))))))
(total (save-excursion (set-buffer buf) rmail-total-messages)))
(total (with-current-buffer buf rmail-total-messages)))
;; If message number N was specified, find that message's line
;; or set message-not-found.
;; If N wasn't specified or that message can't be found.
@ -1368,7 +1364,7 @@ Position it according to WHERE which can be BEG or END"
(defun rmail-summary-wipe ()
"Kill and wipe away Rmail summary, remaining within Rmail."
(interactive)
(save-excursion (set-buffer rmail-buffer) (setq rmail-summary-buffer nil))
(with-current-buffer rmail-buffer (setq rmail-summary-buffer nil))
(let ((local-rmail-buffer rmail-buffer))
(kill-buffer (current-buffer))
;; Delete window if not only one.
@ -1380,8 +1376,7 @@ Position it according to WHERE which can be BEG or END"
(defun rmail-summary-expunge ()
"Actually erase all deleted messages and recompute summary headers."
(interactive)
(save-excursion
(set-buffer rmail-buffer)
(with-current-buffer rmail-buffer
(when (rmail-expunge-confirmed)
(rmail-only-expunge)))
(rmail-update-summary))
@ -1405,8 +1400,7 @@ argument says to read a file name and use that file as the inbox."
(list (if current-prefix-arg
(read-file-name "Get new mail from file: "))))
(let (msg)
(save-excursion
(set-buffer rmail-buffer)
(with-current-buffer rmail-buffer
(rmail-get-new-mail file-name)
;; Get the proper new message number.
(setq msg rmail-current-message))
@ -1493,12 +1487,8 @@ Interactively, empty argument means use same regexp used last time."
(prefix-numeric-value current-prefix-arg))))
;; Don't use save-excursion because that prevents point from moving
;; properly in the summary buffer.
(let ((buffer (current-buffer)))
(unwind-protect
(progn
(set-buffer rmail-buffer)
(rmail-search regexp (- n)))
(set-buffer buffer))))
(with-current-buffer rmail-buffer
(rmail-search regexp (- n))))
(defun rmail-summary-search (regexp &optional n)
"Show message containing next match for REGEXP.
@ -1556,21 +1546,17 @@ Interactively, empty argument means use same regexp used last time."
(defun rmail-summary-add-label (label)
"Add LABEL to labels associated with current Rmail message.
Completion is performed over known labels when reading."
(interactive (list (save-excursion
(set-buffer rmail-buffer)
(interactive (list (with-current-buffer rmail-buffer
(rmail-read-label "Add label"))))
(save-excursion
(set-buffer rmail-buffer)
(with-current-buffer rmail-buffer
(rmail-add-label label)))
(defun rmail-summary-kill-label (label)
"Remove LABEL from labels associated with current Rmail message.
Completion is performed over known labels when reading."
(interactive (list (save-excursion
(set-buffer rmail-buffer)
(interactive (list (with-current-buffer rmail-buffer
(rmail-read-label "Kill label"))))
(save-excursion
(set-buffer rmail-buffer)
(with-current-buffer rmail-buffer
(rmail-set-label label nil)))
;;;; *** Rmail Summary Mailing Commands ***
@ -1737,8 +1723,7 @@ Also set the default for subsequent \\[rmail-output-to-babyl-file] commands.
The variables `rmail-secondary-file-directory' and
`rmail-secondary-file-regexp' control which files are offered in the menu."
(interactive)
(save-excursion
(set-buffer rmail-buffer)
(with-current-buffer rmail-buffer
(let ((rmail-delete-after-output nil))
(call-interactively 'rmail-output-menu)))
(if rmail-delete-after-output
@ -1767,8 +1752,7 @@ The variables `rmail-secondary-file-directory' and
"Write this message body to the file FILE-NAME.
FILE-NAME defaults, interactively, from the Subject field of the message."
(interactive)
(save-excursion
(set-buffer rmail-buffer)
(with-current-buffer rmail-buffer
(let ((rmail-delete-after-output nil))
(if file-name
(rmail-output-body-to-file file-name)

View file

@ -242,8 +242,7 @@ The list is in preference order.")
(let ((sendmail-coding-system smtpmail-code-conv-from))
(select-message-coding-system)))))
(unwind-protect
(save-excursion
(set-buffer tembuf)
(with-current-buffer tembuf
(erase-buffer)
;; Use the same `buffer-file-coding-system' as in the mail
;; buffer, otherwise any `write-region' invocations (e.g., in

View file

@ -1669,23 +1669,22 @@ header style to use, unless not supplied or invalid, in which case
(if sc-electric-circular-p
0
(progn (error msg "follow") (1- last))))))
(save-excursion
(set-buffer sc-electric-bufname)
(let ((buffer-read-only nil))
(erase-buffer)
(goto-char (point-min))
(sc-eref-insert-selected)
;; now shrink the window to just contain the electric reference
;; header.
(let ((hdrlines (count-lines (point-min) (point-max)))
(winlines (1- (window-height))))
(if (/= hdrlines winlines)
(if (> hdrlines winlines)
;; we have to enlarge the window
(enlarge-window (- hdrlines winlines))
;; we have to shrink the window
(shrink-window (- winlines (max hdrlines
window-min-height))))))))))
(with-current-buffer sc-electric-bufname
(let ((inhibit-read-only t))
(erase-buffer)
(goto-char (point-min))
(sc-eref-insert-selected)
;; now shrink the window to just contain the electric reference
;; header.
(let ((hdrlines (count-lines (point-min) (point-max)))
(winlines (1- (window-height))))
(if (/= hdrlines winlines)
(if (> hdrlines winlines)
;; we have to enlarge the window
(enlarge-window (- hdrlines winlines))
;; we have to shrink the window
(shrink-window (- winlines (max hdrlines
window-min-height))))))))))
(defun sc-eref-next ()
"Display next reference in other buffer."