* 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

@ -1,3 +1,58 @@
2009-11-03 Stefan Monnier <monnier@iro.umontreal.ca>
* 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.
2009-11-03 Chong Yidong <cyd@stupidchicken.com>
* comint.el (comint-replace-by-expanded-history-before-point):
@ -27,8 +82,8 @@
* textmodes/sgml-mode.el (sgml-mode-facemenu-add-face-function):
Support face colors.
* textmodes/tex-mode.el (tex-facemenu-add-face-function): New
function. Support face colors (Bug#1168).
* textmodes/tex-mode.el (tex-facemenu-add-face-function):
New function. Support face colors (Bug#1168).
(tex-common-initialization): Use it.
* facemenu.el (facemenu-enable-faces-p): Enable facemenu if the

View file

@ -646,8 +646,7 @@ A value of 0 in any position is a wildcard. Optional argument COLOR is
passed to `calendar-mark-visible-date' as MARK."
;; FIXME not the same as the Bahai and Islamic cases, so can't use
;; calendar-mark-1.
(save-excursion
(set-buffer calendar-buffer)
(with-current-buffer calendar-buffer
(if (and (not (zerop month)) (not (zerop day)))
(if (not (zerop year))
;; Fully specified Hebrew date.

View file

@ -1506,8 +1506,7 @@ Optional argument COLOR is passed to `calendar-mark-visible-date' as MARK."
The function FROMABS converts absolute dates to the appropriate date system.
The function TOABS carries out the inverse operation. Optional argument
COLOR is passed to `calendar-mark-visible-date' as MARK."
(save-excursion
(set-buffer calendar-buffer)
(with-current-buffer calendar-buffer
(if (and (not (zerop month)) (not (zerop day)))
(if (not (zerop year))
;; Fully specified date.

View file

@ -110,8 +110,7 @@ With prefix argument, don't jump to global mark when cancelling it."
(defun cua--insert-at-global-mark (str &optional msg)
;; Insert string at global marker and move marker
(save-excursion
(set-buffer (marker-buffer cua--global-mark-marker))
(with-current-buffer (marker-buffer cua--global-mark-marker)
(goto-char (marker-position cua--global-mark-marker))
(insert-for-yank str)
(cua--activate-global-mark))
@ -123,8 +122,7 @@ With prefix argument, don't jump to global mark when cancelling it."
(defun cua--delete-at-global-mark (arg &optional msg)
;; Delete chars at global marker
(save-excursion
(set-buffer (marker-buffer cua--global-mark-marker))
(with-current-buffer (marker-buffer cua--global-mark-marker)
(goto-char (marker-position cua--global-mark-marker))
(delete-char arg))
(if msg
@ -190,8 +188,7 @@ With prefix argument, don't jump to global mark when cancelling it."
(if (cua--global-mark-active)
(let ((src-buf (current-buffer))
(text (cua--extract-rectangle)))
(save-excursion
(set-buffer (marker-buffer cua--global-mark-marker))
(with-current-buffer (marker-buffer cua--global-mark-marker)
(goto-char (marker-position cua--global-mark-marker))
(if as-text
(while text
@ -309,8 +306,7 @@ With prefix argument, don't jump to global mark when cancelling it."
(interactive "*")
(if (cua--global-mark-active)
(let (col)
(save-excursion
(set-buffer (marker-buffer cua--global-mark-marker))
(with-current-buffer (marker-buffer cua--global-mark-marker)
(goto-char (marker-position cua--global-mark-marker))
(setq col (current-column)))
(if cua--rectangle

View file

@ -1198,8 +1198,7 @@ The numbers are formatted according to the FORMAT string."
(- (cua--rectangle-right) (cua--rectangle-left) -1)))
(r (or setup-fct (cua--extract-rectangle)))
y z (tr 0))
(save-excursion
(set-buffer auxbuf)
(with-current-buffer auxbuf
(erase-buffer)
(if setup-fct
(funcall setup-fct)

View file

@ -2657,8 +2657,7 @@ G-C-\\: Split Window | FNDNXT | Yank | CUT |
(progn
(message "%s..." (capitalize (symbol-name fun)))
(and b
(save-excursion
(set-buffer b)
(with-current-buffer b
(set-buffer-modified-p t)))
(fset 'help-print-return-message 'ignore)
(call-interactively fun)
@ -2669,8 +2668,7 @@ G-C-\\: Split Window | FNDNXT | Yank | CUT |
(not (buffer-modified-p b)))))
(fset 'help-print-return-message p)
(and b (buffer-name b)
(save-excursion
(set-buffer b)
(with-current-buffer b
(set-buffer-modified-p m))))))
(with-electric-help 'delete-other-windows name t))))

View file

@ -79,8 +79,7 @@
(if (null mode-cmd)
(with-output-to-temp-buffer "*Help*"
(princ (substitute-command-keys "Possible major modes to switch to: \\{vi-tilde-map}"))
(save-excursion
(set-buffer standard-output)
(with-current-buffer standard-output
(help-mode)))
(setq prefix-arg arg) ; prefix arg will be passed down
(command-execute mode-cmd nil) ; may need to save mode-line-format etc
@ -499,8 +498,7 @@ set sw=n M-x set-variable vi-shift-width n "
;; (cond ((string-match "s"))))
(with-output-to-temp-buffer "*Help*"
(princ (documentation 'vi-ex-cmd))
(save-excursion
(set-buffer standard-output)
(with-current-buffer standard-output
(help-mode))))
(defun vi-undefined ()

View file

@ -419,10 +419,9 @@ Type `n' to quit this window for now.\n")
(goto-char (point-min))
(if (y-or-n-p "Inhibit VIP startup message? ")
(progn
(save-excursion
(set-buffer
(find-file-noselect
(substitute-in-file-name vip-startup-file)))
(with-current-buffer
(find-file-noselect
(substitute-in-file-name vip-startup-file))
(goto-char (point-max))
(insert "\n(setq vip-inhibit-startup-message t)\n")
(save-buffer)
@ -2158,8 +2157,7 @@ is a command.")
(defun vip-get-ex-token ()
"get an ex-token which is either an address or a command.
a token has type \(command, address, end-mark\) and value."
(save-window-excursion
(set-buffer " *ex-working-space*")
(with-current-buffer " *ex-working-space*"
(skip-chars-forward " \t")
(cond ((looking-at "[k#]")
(setq ex-token-type "command")
@ -2262,8 +2260,7 @@ a token has type \(command, address, end-mark\) and value."
ex-g-variant nil))
(let ((com-str (or string (vip-read-string ":")))
(address nil) (cont t) (dot (point)))
(save-window-excursion
(set-buffer (get-buffer-create " *ex-working-space*"))
(with-current-buffer (get-buffer-create " *ex-working-space*")
(delete-region (point-min) (point-max))
(insert com-str "\n")
(goto-char (point-min)))
@ -2282,8 +2279,7 @@ a token has type \(command, address, end-mark\) and value."
(setq cont nil))
(t
(vip-execute-ex-command)
(save-window-excursion
(set-buffer " *ex-working-space*")
(with-current-buffer " *ex-working-space*"
(skip-chars-forward " \t")
(cond ((looking-at "|")
(forward-char 1))
@ -2307,8 +2303,7 @@ a token has type \(command, address, end-mark\) and value."
(defun vip-get-ex-pat ()
"get a regular expression and set ex-variant if found"
(save-window-excursion
(set-buffer " *ex-working-space*")
(with-current-buffer " *ex-working-space*"
(skip-chars-forward " \t")
(if (looking-at "!")
(progn
@ -2334,8 +2329,7 @@ a token has type \(command, address, end-mark\) and value."
(defun vip-get-ex-command ()
"get an ex command"
(save-window-excursion
(set-buffer " *ex-working-space*")
(with-current-buffer " *ex-working-space*"
(if (looking-at "/") (forward-char 1))
(skip-chars-forward " \t")
(cond ((looking-at "[a-z]")
@ -2349,8 +2343,7 @@ a token has type \(command, address, end-mark\) and value."
(defun vip-get-ex-opt-gc ()
"get an ex option g or c"
(save-window-excursion
(set-buffer " *ex-working-space*")
(with-current-buffer " *ex-working-space*"
(if (looking-at "/") (forward-char 1))
(skip-chars-forward " \t")
(cond ((looking-at "g")
@ -2458,8 +2451,7 @@ a token has type \(command, address, end-mark\) and value."
(setq ex-buffer nil)
(setq ex-count nil)
(setq ex-flag nil)
(save-window-excursion
(set-buffer " *ex-working-space*")
(with-current-buffer " *ex-working-space*"
(skip-chars-forward " \t")
(if (looking-at "[a-zA-Z]")
(progn
@ -2483,8 +2475,7 @@ a token has type \(command, address, end-mark\) and value."
(setq ex-variant nil
ex-count nil
ex-flag nil)
(save-window-excursion
(set-buffer " *ex-working-space*")
(with-current-buffer " *ex-working-space*"
(skip-chars-forward " \t")
(if (looking-at "!")
(progn
@ -2510,8 +2501,7 @@ a token has type \(command, address, end-mark\) and value."
ex-variant nil
ex-append nil
ex-offset nil)
(save-window-excursion
(set-buffer " *ex-working-space*")
(with-current-buffer " *ex-working-space*"
(skip-chars-forward " \t")
(if (looking-at "!")
(progn
@ -2680,8 +2670,7 @@ a token has type \(command, address, end-mark\) and value."
(goto-char (point-min))
(if ex-offset
(progn
(save-window-excursion
(set-buffer " *ex-working-space*")
(with-current-buffer " *ex-working-space*"
(delete-region (point-min) (point-max))
(insert ex-offset "\n")
(goto-char (point-min)))
@ -2733,19 +2722,18 @@ a token has type \(command, address, end-mark\) and value."
(if (bobp) (setq cont nil)
(forward-line -1)
(end-of-line)))))
(save-window-excursion
(set-buffer " *ex-working-space*")
(setq com-str (buffer-substring (1+ (point)) (1- (point-max)))))
(while marks
(goto-char (car marks))
; report progress of execution on a slow machine.
;(message "Executing global command...")
;(if (zerop (% mark-count 10))
;(message "Executing global command...%d" mark-count))
(vip-ex com-str)
(setq mark-count (1- mark-count))
(setq marks (cdr marks)))))
;(message "Executing global command...done")))
(with-current-buffer " *ex-working-space*"
(setq com-str (buffer-substring (1+ (point)) (1- (point-max)))))
(while marks
(goto-char (car marks))
;; report progress of execution on a slow machine.
;;(message "Executing global command...")
;;(if (zerop (% mark-count 10))
;; (message "Executing global command...%d" mark-count))
(vip-ex com-str)
(setq mark-count (1- mark-count))
(setq marks (cdr marks)))))
;;(message "Executing global command...done")))
(defun ex-line (com)
"ex line commands. COM is join, shift-right or shift-left."
@ -2801,8 +2789,7 @@ a token has type \(command, address, end-mark\) and value."
(if (null ex-addresses)
(setq ex-addresses
(cons (point) nil)))
(save-window-excursion
(set-buffer " *ex-working-space*")
(with-current-buffer " *ex-working-space*"
(skip-chars-forward " \t")
(if (looking-at "[a-z]")
(progn
@ -2821,8 +2808,7 @@ a token has type \(command, address, end-mark\) and value."
(defun ex-map ()
"ex map"
(let (char string)
(save-window-excursion
(set-buffer " *ex-working-space*")
(with-current-buffer " *ex-working-space*"
(skip-chars-forward " \t")
(setq char (char-to-string (following-char)))
(forward-char 1)
@ -2847,8 +2833,7 @@ a token has type \(command, address, end-mark\) and value."
(defun ex-unmap ()
"ex unmap"
(let (char)
(save-window-excursion
(set-buffer " *ex-working-space*")
(with-current-buffer " *ex-working-space*"
(skip-chars-forward " \t")
(setq char (char-to-string (following-char)))
(forward-char 1)
@ -2870,8 +2855,7 @@ a token has type \(command, address, end-mark\) and value."
(defun ex-quit ()
"ex quit"
(let (char)
(save-window-excursion
(set-buffer " *ex-working-space*")
(with-current-buffer " *ex-working-space*"
(skip-chars-forward " \t")
(setq char (following-char)))
(if (= char ?!) (kill-emacs t) (save-buffers-kill-emacs))))
@ -2883,8 +2867,7 @@ a token has type \(command, address, end-mark\) and value."
(goto-char point)
(if (not (= point 0)) (with-no-warnings (next-line 1)))
(beginning-of-line)
(save-window-excursion
(set-buffer " *ex-working-space*")
(with-current-buffer " *ex-working-space*"
(skip-chars-forward " \t")
(if (looking-at "!")
(progn
@ -2981,8 +2964,7 @@ vip-s-string"
(defun ex-tag ()
"ex tag"
(let (tag)
(save-window-excursion
(set-buffer " *ex-working-space*")
(with-current-buffer " *ex-working-space*"
(skip-chars-forward " \t")
(set-mark (point))
(skip-chars-forward "^ |\t\n")
@ -3045,8 +3027,7 @@ vip-s-string"
(defun ex-command ()
"execute shell command"
(let (command)
(save-window-excursion
(set-buffer " *ex-working-space*")
(with-current-buffer " *ex-working-space*"
(skip-chars-forward " \t")
(set-mark (point))
(end-of-line)

View file

@ -903,8 +903,7 @@ Vi's prefix argument will be used. Otherwise, the prefix argument passed to
(signal 'quit nil)))
(if (not (equal buff (current-buffer))) ; cmd switched buffer
(save-excursion
(set-buffer buff)
(with-current-buffer buff
(viper-set-mode-vars-for viper-current-state)))
(viper-set-mode-vars-for viper-current-state)
result))
@ -917,8 +916,7 @@ Similar to viper-escape-to-emacs, but accepts forms rather than keystrokes."
(viper-set-mode-vars-for 'emacs-state)
(setq result (eval form))
(if (not (equal buff (current-buffer))) ; cmd switched buffer
(save-excursion
(set-buffer buff)
(with-current-buffer buff
(viper-set-mode-vars-for viper-current-state)))
(viper-set-mode-vars-for viper-current-state)
result))
@ -4697,8 +4695,7 @@ One can use `` and '' to temporarily jump 1 step back."
(with-output-to-temp-buffer " *viper-info*"
(if (and buf pos)
(progn
(save-excursion
(set-buffer buf)
(with-current-buffer buf
(setq line-no (1+ (count-lines (point-min) val)))
(goto-char pos)
(beginning-of-line)

View file

@ -946,16 +946,14 @@ reversed."
;; Expand \% and \# in ex command
(defun ex-expand-filsyms (cmd buf)
(let (cf pf ret)
(save-excursion
(set-buffer buf)
(with-current-buffer buf
(setq cf buffer-file-name)
(setq pf (ex-next nil t))) ; this finds alternative file name
(if (and (null cf) (string-match "[^\\]%\\|\\`%" cmd))
(error "No current file to substitute for `%%'"))
(if (and (null pf) (string-match "[^\\]#\\|\\`#" cmd))
(error "No alternate file to substitute for `#'"))
(save-excursion
(set-buffer (get-buffer-create viper-ex-tmp-buf-name))
(with-current-buffer (get-buffer-create viper-ex-tmp-buf-name)
(erase-buffer)
(insert cmd)
(goto-char (point-min))
@ -984,9 +982,8 @@ reversed."
ex-cmdfile nil
ex-cmdfile-args "")
(save-excursion
(save-window-excursion
(setq viper-ex-work-buf (get-buffer-create viper-ex-work-buf-name))
(set-buffer viper-ex-work-buf)
(with-current-buffer (setq viper-ex-work-buf
(get-buffer-create viper-ex-work-buf-name))
(skip-chars-forward " \t")
(if (looking-at "!")
(if (and (not (viper-looking-back "[ \t]"))
@ -1289,9 +1286,8 @@ reversed."
(switch-to-buffer file))
(if ex-offset
(progn
(save-window-excursion
(setq viper-ex-work-buf (get-buffer-create viper-ex-work-buf-name))
(set-buffer viper-ex-work-buf)
(with-current-buffer (setq viper-ex-work-buf
(get-buffer-create viper-ex-work-buf-name))
(delete-region (point-min) (point-max))
(insert ex-offset "\n")
(goto-char (point-min)))
@ -1372,9 +1368,8 @@ reversed."
(if (bobp) (setq cont nil)
(forward-line -1)
(end-of-line)))))
(save-window-excursion
(setq viper-ex-work-buf (get-buffer-create viper-ex-work-buf-name))
(set-buffer viper-ex-work-buf)
(with-current-buffer (setq viper-ex-work-buf
(get-buffer-create viper-ex-work-buf-name))
;; com-str is the command string, i.e., g/pattern/ or v/pattern'
(setq com-str (buffer-substring (1+ (point)) (1- (point-max)))))
(while ex-g-marks
@ -1453,18 +1448,17 @@ reversed."
(setq char (string-to-char name))
(error "`%s': Spurious text \"%s\" after mark name"
name (substring name 1)))
(save-window-excursion
(setq viper-ex-work-buf (get-buffer-create viper-ex-work-buf-name))
(set-buffer viper-ex-work-buf)
(skip-chars-forward " \t")
(if (looking-at "[a-z]")
(progn
(setq char (following-char))
(forward-char 1)
(skip-chars-forward " \t")
(if (not (looking-at "[\n|]"))
(error "`%s': %s" ex-token viper-SpuriousText)))
(error "`%s' requires a following letter" ex-token))))
(with-current-buffer (setq viper-ex-work-buf
(get-buffer-create viper-ex-work-buf-name))
(skip-chars-forward " \t")
(if (looking-at "[a-z]")
(progn
(setq char (following-char))
(forward-char 1)
(skip-chars-forward " \t")
(if (not (looking-at "[\n|]"))
(error "`%s': %s" ex-token viper-SpuriousText)))
(error "`%s' requires a following letter" ex-token))))
(save-excursion
(goto-char (car ex-addresses))
(point-to-register (viper-int-to-char (1+ (- char ?a)))))))
@ -1560,8 +1554,7 @@ reversed."
(select-window wind)))
(save-window-excursion (select-window wind) (sit-for 1)))
(save-excursion
(set-buffer buf)
(with-current-buffer buf
(setq viper-related-files-and-buffers-ring old-ring))
(setq viper-local-search-start-marker (point-marker))
@ -1588,9 +1581,8 @@ reversed."
;; Ex quit command
(defun ex-quit ()
;; skip "!", if it is q!. In Viper q!, w!, etc., behave as q, w, etc.
(save-excursion
(setq viper-ex-work-buf (get-buffer-create viper-ex-work-buf-name))
(set-buffer viper-ex-work-buf)
(with-current-buffer (setq viper-ex-work-buf
(get-buffer-create viper-ex-work-buf-name))
(if (looking-at "!") (forward-char 1)))
(if (< viper-expert-level 3)
(save-buffers-kill-emacs)
@ -1837,9 +1829,8 @@ reversed."
;; Optional 3d arg is a string that should replace ' ' to prevent its
;; special meaning
(defun ex-get-inline-cmd-args (regex-forw &optional chars-back replace-str)
(save-excursion
(setq viper-ex-work-buf (get-buffer-create viper-ex-work-buf-name))
(set-buffer viper-ex-work-buf)
(with-current-buffer (setq viper-ex-work-buf
(get-buffer-create viper-ex-work-buf-name))
(goto-char (point-min))
(re-search-forward regex-forw nil t)
(let ((beg (point))
@ -1987,9 +1978,8 @@ Please contact your system administrator. "
;; Ex tag command
(defun ex-tag ()
(let (tag)
(save-window-excursion
(setq viper-ex-work-buf (get-buffer-create viper-ex-work-buf-name))
(set-buffer viper-ex-work-buf)
(with-current-buffer (setq viper-ex-work-buf
(get-buffer-create viper-ex-work-buf-name))
(skip-chars-forward " \t")
(set-mark (point))
(skip-chars-forward "^ |\t\n")
@ -2148,9 +2138,8 @@ Please contact your system administrator. "
;; Execute shell command
(defun ex-command ()
(let (command)
(save-window-excursion
(setq viper-ex-work-buf (get-buffer-create viper-ex-work-buf-name))
(set-buffer viper-ex-work-buf)
(with-current-buffer (setq viper-ex-work-buf
(get-buffer-create viper-ex-work-buf-name))
(skip-chars-forward " \t")
(setq command (buffer-substring (point) (point-max)))
(end-of-line))
@ -2178,9 +2167,8 @@ Please contact your system administrator. "
If no args are given, then it runs the last compile command.
Type 'mak ' (including the space) to run make with no args."
(let (args)
(save-window-excursion
(setq viper-ex-work-buf (get-buffer-create viper-ex-work-buf-name))
(set-buffer viper-ex-work-buf)
(with-current-buffer (setq viper-ex-work-buf
(get-buffer-create viper-ex-work-buf-name))
(setq args (buffer-substring (point) (point-max)))
(end-of-line))
;; Remove the newline that may (will?) be at the end of the args

View file

@ -165,8 +165,7 @@ Enter as a sexp. Examples: \"\\C-z\", [(control ?z)]."
[(control ?z)])))
(mapc
(lambda (buf)
(save-excursion
(set-buffer buf)
(with-current-buffer buf
(when (and (boundp 'viper-insert-basic-map)
(keymapp viper-insert-basic-map))
(when old-value

View file

@ -409,8 +409,7 @@ Otherwise return the normal value."
(command (cond (viper-ms-style-os-p (format "\"ls -1 -d %s\"" filespec))
(t (format "ls -1 -d %s" filespec))))
status)
(save-excursion
(set-buffer (get-buffer-create viper-ex-tmp-buf-name))
(with-current-buffer (get-buffer-create viper-ex-tmp-buf-name)
(erase-buffer)
(setq status
(if gshell-options
@ -467,8 +466,7 @@ Otherwise return the normal value."
;; convert MS-DOS wildcards to regexp
(defun viper-wildcard-to-regexp (wcard)
(save-excursion
(set-buffer (get-buffer-create viper-ex-tmp-buf-name))
(with-current-buffer (get-buffer-create viper-ex-tmp-buf-name)
(erase-buffer)
(insert wcard)
(goto-char (point-min))
@ -488,8 +486,7 @@ Otherwise return the normal value."
(defun viper-glob-mswindows-files (filespec)
(let ((case-fold-search t)
tmp tmp2)
(save-excursion
(set-buffer (get-buffer-create viper-ex-tmp-buf-name))
(with-current-buffer (get-buffer-create viper-ex-tmp-buf-name)
(erase-buffer)
(insert filespec)
(goto-char (point-min))
@ -654,8 +651,7 @@ Otherwise return the normal value."
(buf (find-file-noselect (substitute-in-file-name custom-file)))
)
(message "%s" (or message ""))
(save-excursion
(set-buffer buf)
(with-current-buffer buf
(goto-char (point-min))
(if (re-search-forward regexp nil t)
(let ((reg-end (1- (match-end 0))))
@ -678,8 +674,7 @@ Otherwise return the normal value."
;; match this pattern.
(defun viper-save-string-in-file (string custom-file &optional pattern)
(let ((buf (find-file-noselect (substitute-in-file-name custom-file))))
(save-excursion
(set-buffer buf)
(with-current-buffer buf
(let (buffer-read-only)
(goto-char (point-min))
(if pattern (delete-matching-lines pattern))
@ -889,8 +884,7 @@ Otherwise return the normal value."
(if (and (markerp marker) (marker-buffer marker))
(let ((buf (marker-buffer marker))
(pos (marker-position marker)))
(save-excursion
(set-buffer buf)
(with-current-buffer buf
(and (<= pos (point-max)) (<= (point-min) pos))))))
(defsubst viper-mark-marker ()

View file

@ -647,10 +647,9 @@ This startup message appears whenever you load Viper, unless you type `y' now."
;; Remove local value in all existing buffers
;; This doesn't delocalize vars (which would have been desirable)
(defun viper-delocalize-var (symbol)
(mapcar (lambda (buf) (save-excursion
(set-buffer buf)
(kill-local-variable symbol)))
(buffer-list)))
(dolist (buf (buffer-list))
(with-current-buffer buf
(kill-local-variable symbol))))
(defun viper-go-away ()

View file

@ -1,3 +1,9 @@
2009-11-03 Stefan Monnier <monnier@iro.umontreal.ca>
* erc.el (erc-display-line-1, erc-process-away):
* erc-truncate.el (erc-truncate-buffer-to-size):
Use with-current-buffer.
2009-10-24 Glenn Morris <rgm@gnu.org>
* erc-dcc.el (pcomplete-erc-all-nicks):

View file

@ -66,8 +66,7 @@ region is logged if `erc-logging-enabled' returns non-nil."
(unless (get-buffer buffer)
(error "erc-truncate-buffer-to-size: %S is not a buffer" buffer)))
(when (> (buffer-size buffer) (+ size 512))
(save-excursion
(set-buffer buffer)
(with-current-buffer buffer
;; Note that when erc-insert-post-hook runs, the buffer is
;; narrowed to the new message. So do this delicate widening.
;; I am not sure, I think this was not recommended behavior in

View file

@ -2358,8 +2358,7 @@ If `erc-insert-this' is still t, STRING gets inserted into the buffer.
Afterwards, `erc-insert-modify' and `erc-insert-post-hook' get called.
If STRING is nil, the function does nothing."
(when string
(save-excursion
(set-buffer (or buffer (process-buffer erc-server-process)))
(with-current-buffer (or buffer (process-buffer erc-server-process))
(let ((insert-position (or (marker-position erc-insert-marker)
(point-max))))
(let ((string string) ;; FIXME! Can this be removed?
@ -4513,8 +4512,7 @@ If non-nil, return from being away."
;; away must be set to NIL BEFORE sending anything to prevent
;; an infinite recursion
(setq erc-away nil)
(save-excursion
(set-buffer (erc-active-buffer))
(with-current-buffer (erc-active-buffer)
(when erc-public-away-p
(erc-send-action
(erc-default-target)

View file

@ -667,8 +667,7 @@ Concatenate FILE(s), or standard input, to standard output.")
"In Occur mode, go to the occurrence whose line you click on."
(interactive "e")
(let (pos)
(save-excursion
(set-buffer (window-buffer (posn-window (event-end event))))
(with-current-buffer (window-buffer (posn-window (event-end event)))
(save-excursion
(goto-char (posn-point (event-end event)))
(setq pos (occur-mode-find-occurrence))))

View file

@ -194,10 +194,8 @@ causing the user to wonder if anything's really going on..."
(mapconcat 'shell-quote-argument
(append (list command) args) " ")
outbuf errbuf))
(eshell-print (save-excursion (set-buffer outbuf)
(buffer-string)))
(eshell-error (save-excursion (set-buffer errbuf)
(buffer-string))))
(eshell-print (with-current-buffer outbuf (buffer-string)))
(eshell-error (with-current-buffer errbuf (buffer-string))))
(eshell-close-handles exitcode 'nil)
(kill-buffer outbuf)
(kill-buffer errbuf))))

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."

View file

@ -681,8 +681,7 @@ ciphertext."
(interactive (list (upcase (following-char))))
(decipher-analyze)
(let (start end)
(save-excursion
(set-buffer (decipher-stats-buffer))
(with-current-buffer (decipher-stats-buffer)
(goto-char (point-min))
(or (re-search-forward (format "^%c: " cipher-char) nil t)
(error "Character `%c' is not used in ciphertext" cipher-char))
@ -730,8 +729,7 @@ START-REGEXP matches the first line to display.
END-REGEXP matches the line after that which ends the display.
The ending line is included in the display unless it is blank."
(let (start end)
(save-excursion
(set-buffer (decipher-stats-buffer))
(with-current-buffer (decipher-stats-buffer)
(goto-char (point-min))
(re-search-forward start-regexp)
(beginning-of-line)
@ -926,9 +924,8 @@ Creates the statistics buffer if it doesn't exist."
(aref decipher--after i)))
freq-list)
total-chars (+ total-chars (aref decipher--freqs i)))))
(save-excursion
;; Switch to statistics buffer, creating it if necessary:
(set-buffer (decipher-stats-buffer t))
;; Switch to statistics buffer, creating it if necessary:
(with-current-buffer (decipher-stats-buffer t)
;; This can't happen, but it never hurts to double-check:
(or (eq major-mode 'decipher-stats-mode)
(error "Buffer %s is not in Decipher-Stats mode" (buffer-name)))
@ -1024,8 +1021,7 @@ if it can't, it signals an error."
;; See if decipher-stats-buffer exists:
((and (bufferp decipher-stats-buffer)
(buffer-name decipher-stats-buffer))
(or (save-excursion
(set-buffer decipher-stats-buffer)
(or (with-current-buffer decipher-stats-buffer
(eq major-mode 'decipher-stats-mode))
(error "Buffer %s is not in Decipher-Stats mode"
(buffer-name decipher-stats-buffer)))
@ -1041,8 +1037,7 @@ if it can't, it signals an error."
;; We just lost track of the statistics buffer:
(get-buffer stats-name)
(generate-new-buffer stats-name))))
(save-excursion
(set-buffer decipher-stats-buffer)
(with-current-buffer decipher-stats-buffer
(decipher-stats-mode))
decipher-stats-buffer)
;; Give up:
@ -1052,22 +1047,21 @@ if it can't, it signals an error."
(provide 'decipher)
;;;(defun decipher-show-undo-list ()
;;; "Display the undo list (for debugging purposes)."
;;; (interactive)
;;; (with-output-to-temp-buffer "*Decipher Undo*"
;;; (let ((undo-list decipher-undo-list)
;;; undo-rec undo-map)
;;; (save-excursion
;;; (set-buffer "*Decipher Undo*")
;;; (while (setq undo-rec (pop undo-list))
;;; (or (consp (car undo-rec))
;;; (setq undo-rec (list undo-rec)))
;;; (insert ?\()
;;; (while (setq undo-map (pop undo-rec))
;;; (insert (cdr undo-map) (car undo-map) ?\ ))
;;; (delete-backward-char 1)
;;; (insert ")\n"))))))
;;(defun decipher-show-undo-list ()
;; "Display the undo list (for debugging purposes)."
;; (interactive)
;; (with-output-to-temp-buffer "*Decipher Undo*"
;; (let ((undo-list decipher-undo-list)
;; undo-rec undo-map)
;; (with-current-buffer "*Decipher Undo*"
;; (while (setq undo-rec (pop undo-list))
;; (or (consp (car undo-rec))
;; (setq undo-rec (list undo-rec)))
;; (insert ?\()
;; (while (setq undo-map (pop undo-rec))
;; (insert (cdr undo-map) (car undo-map) ?\ ))
;; (delete-backward-char 1)
;; (insert ")\n"))))))
;; arch-tag: 8f094d88-ffe1-4f99-afe3-a5e81dd939d9
;;; decipher.el ends here

View file

@ -62,8 +62,7 @@ Default is 2."
(setq last-query-point (point-max))
t))))
(let (start end)
(save-excursion
(set-buffer inbuf)
(with-current-buffer inbuf
(setq start (point))
(if (eq move-function 'forward-char)
(progn
@ -81,8 +80,7 @@ Default is 2."
(end-of-line)
(and (> (current-column) fill-column)
(do-auto-fill)))))
(save-excursion
(set-buffer inbuf)
(with-current-buffer inbuf
(if (eobp)
(goto-char (point-min))
(let ((overlap

View file

@ -293,8 +293,7 @@ when supplied, specifies the file to choose the fortune from."
(fort-file (expand-file-name
(substitute-in-file-name
(or file fortune-file)))))
(save-excursion
(set-buffer fortune-buffer)
(with-current-buffer fortune-buffer
(toggle-read-only 0)
(erase-buffer)

View file

@ -939,6 +939,7 @@ If the game is finished, this command requests for another game."
"Your move?"))
;; This may seem silly, but if one omits the following line (or a similar
;; one), the cursor may very well go to some place where POINT is not.
;; FIXME: this can't be right!! --Stef
(save-excursion (set-buffer (other-buffer))))
(defun gomoku-prompt-for-other-game ()

View file

@ -827,6 +827,7 @@ If the game is finished, this command requests for another game."
"Your move?"))
;; This may seem silly, but if one omits the following line (or a similar
;; one), the cursor may very well go to some place where POINT is not.
;; FIXME: this can't be right!! --Stef
(save-excursion (set-buffer (other-buffer))))
(defun lm-prompt-for-other-game ()
@ -1178,15 +1179,13 @@ because it is overwritten by \"One moment please\"."
(defun lm-print-wts ()
(interactive)
(save-excursion
(set-buffer "*lm-wts*")
(with-current-buffer "*lm-wts*"
(insert "==============================\n")
(mapc 'lm-print-wts-int lm-directions)))
(defun lm-print-moves (moves)
(interactive)
(save-excursion
(set-buffer "*lm-moves*")
(with-current-buffer "*lm-moves*"
(insert (format "%S\n" moves))))
@ -1200,8 +1199,7 @@ because it is overwritten by \"One moment please\"."
(defun lm-print-y,s,noise ()
(interactive)
(save-excursion
(set-buffer "*lm-y,s,noise*")
(with-current-buffer "*lm-y,s,noise*"
(insert "==============================\n")
(mapc 'lm-print-y,s,noise-int lm-directions)))
@ -1212,8 +1210,7 @@ because it is overwritten by \"One moment please\"."
(defun lm-print-smell ()
(interactive)
(save-excursion
(set-buffer "*lm-smell*")
(with-current-buffer "*lm-smell*"
(insert "==============================\n")
(insert (format "tree: %S \n" (get 'z 't)))
(mapc 'lm-print-smell-int lm-directions)))
@ -1225,14 +1222,12 @@ because it is overwritten by \"One moment please\"."
(defun lm-print-w0 ()
(interactive)
(save-excursion
(set-buffer "*lm-w0*")
(with-current-buffer "*lm-w0*"
(insert "==============================\n")
(mapc 'lm-print-w0-int lm-directions)))
(defun lm-blackbox ()
(save-excursion
(set-buffer "*lm-blackbox*")
(with-current-buffer "*lm-blackbox*"
(insert "==============================\n")
(insert "I smell: ")
(mapc (lambda (direction)
@ -1556,35 +1551,32 @@ If the game is finished, this command requests for another game."
(lm-plot-landmarks)
(if lm-debug
(progn
(save-excursion
(set-buffer (get-buffer-create "*lm-w0*"))
(erase-buffer)
(set-buffer (get-buffer-create "*lm-moves*"))
(set-buffer (get-buffer-create "*lm-wts*"))
(erase-buffer)
(set-buffer (get-buffer-create "*lm-y,s,noise*"))
(erase-buffer)
(set-buffer (get-buffer-create "*lm-smell*"))
(erase-buffer)
(set-buffer (get-buffer-create "*lm-blackbox*"))
(erase-buffer)
(set-buffer (get-buffer-create "*lm-distance*"))
(erase-buffer))))
(save-current-buffer
(set-buffer (get-buffer-create "*lm-w0*"))
(erase-buffer)
(set-buffer (get-buffer-create "*lm-moves*"))
(set-buffer (get-buffer-create "*lm-wts*"))
(erase-buffer)
(set-buffer (get-buffer-create "*lm-y,s,noise*"))
(erase-buffer)
(set-buffer (get-buffer-create "*lm-smell*"))
(erase-buffer)
(set-buffer (get-buffer-create "*lm-blackbox*"))
(erase-buffer)
(set-buffer (get-buffer-create "*lm-distance*"))
(erase-buffer)))
(lm-set-landmark-signal-strengths)
(mapc (lambda (direction)
(put direction 'y_t 0.0))
lm-directions)
(dolist (direction lm-directions)
(put direction 'y_t 0.0))
(if (not save-weights)
(progn
(mapc 'lm-fix-weights-for lm-directions)
(mapc (lambda (direction)
(put direction 'w0 lm-initial-w0))
lm-directions))
(dolist (direction lm-directions)
(put direction 'w0 lm-initial-w0)))
(message "Weights preserved for this run."))
(if auto-start

View file

@ -298,8 +298,7 @@ You may abort a game by typing \\<mpuz-mode-map>\\[mpuz-offer-abort]."
(let ((buf (get-buffer-create "*Mult Puzzle*"))
(face '(face mpuz-text))
buffer-read-only)
(save-excursion
(set-buffer buf)
(with-current-buffer buf
(erase-buffer)
(insert mpuz-framework)
(set-text-properties 13 42 face)

View file

@ -1085,8 +1085,7 @@ On Nextstep, put TEXT in the pasteboard; PUSH is ignored."
(let* ((pos (event-end event))
(window (nth 0 pos))
(scale (nth 2 pos)))
(save-excursion
(set-buffer (window-buffer window))
(with-current-buffer (window-buffer window)
(cond
((eq (car scale) (cdr scale))
(goto-char (point-max)))
@ -1169,8 +1168,7 @@ the operating system.")
((eq window-pos 'vertical-line)
'default)
((consp window-pos)
(save-excursion
(set-buffer buffer)
(with-current-buffer buffer
(let ((p (car (compute-motion (window-start window)
(cons (nth 0 edges) (nth 1 edges))
(window-end window)

View file

@ -1,3 +1,11 @@
2009-11-03 Stefan Monnier <monnier@iro.umontreal.ca>
* 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.
2009-10-01 Glenn Morris <rgm@gnu.org>
* url-http.el (url-dav-file-attributes): Fix declaration.

View file

@ -35,8 +35,7 @@
(setq part (mm-get-content-id cid))
(if (not part)
(message "Unknown CID encountered: %s" cid)
(setq data (save-excursion
(set-buffer (mm-handle-buffer part))
(setq data (with-current-buffer (mm-handle-buffer part)
(buffer-string))
content-type (mm-handle-type part)
encoding (symbol-name (mm-handle-encoding part)))
@ -55,8 +54,7 @@
(cond
((fboundp 'mm-get-content-id)
;; Using Pterodactyl Gnus or later
(save-excursion
(set-buffer (generate-new-buffer " *url-cid*"))
(with-current-buffer (generate-new-buffer " *url-cid*")
(url-cid-gnus (url-filename url))))
(t
(message "Unable to handle CID URL: %s" url))))

View file

@ -52,8 +52,7 @@
(defun url-imap (url)
(unless (vectorp url)
(signal 'wrong-type-error (list "Need a pre-parsed URL." url)))
(save-excursion
(set-buffer (generate-new-buffer " *url-imap*"))
(with-current-buffer (generate-new-buffer " *url-imap*")
(mm-disable-multibyte)
(let* ((host (url-host url))
(port (url-port url))

View file

@ -121,8 +121,7 @@ URL can be a URL string, or a URL vector of the type returned by
(setq url (url-generic-parse-url (url-unhex-string url)))
(if (not (vectorp url))
(error "Argument is not a valid URL")))
(save-excursion
(set-buffer (generate-new-buffer " *url-ldap*"))
(with-current-buffer (generate-new-buffer " *url-ldap*")
(setq url-current-object url)
(insert "Content-type: text/html\r\n\r\n")
(if (not (fboundp 'ldap-search-internal))

View file

@ -42,8 +42,7 @@
Each can be used any number of times.")
(defun url-nfs-unescape (format host port user pass file)
(save-excursion
(set-buffer (get-buffer-create " *nfs-parse*"))
(with-current-buffer (get-buffer-create " *nfs-parse*")
(erase-buffer)
(insert format)
(goto-char (point-min))

View file

@ -140,8 +140,7 @@ Also replaces the \" character, so that the result may be safely used as
> ==> &gt;
\" ==> &quot;"
(if (string-match "[&<>\"]" string)
(save-excursion
(set-buffer (get-buffer-create " *entity*"))
(with-current-buffer (get-buffer-create " *entity*")
(erase-buffer)
(buffer-disable-undo (current-buffer))
(insert string)