Commit 937e6a56 authored by Stefan Monnier's avatar Stefan Monnier
Browse files

* 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.
parent 5b955562
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
......
......@@ -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.
......
......@@ -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.
......
......@@ -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
......
......@@ -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)
......
......@@ -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))))
......
......@@ -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 ()
......
......@@ -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)
......
......@@ -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)
......
......@@ -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
......
......@@ -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
......
......@@ -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)))
)