summaryrefslogtreecommitdiff
path: root/lisp/emulation
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/emulation')
-rw-r--r--lisp/emulation/cua-gmrk.el12
-rw-r--r--lisp/emulation/cua-rect.el3
-rw-r--r--lisp/emulation/edt.el6
-rw-r--r--lisp/emulation/vi.el6
-rw-r--r--lisp/emulation/vip.el83
-rw-r--r--lisp/emulation/viper-cmd.el9
-rw-r--r--lisp/emulation/viper-ex.el72
-rw-r--r--lisp/emulation/viper-keym.el3
-rw-r--r--lisp/emulation/viper-util.el18
-rw-r--r--lisp/emulation/viper.el7
10 files changed, 84 insertions, 135 deletions
diff --git a/lisp/emulation/cua-gmrk.el b/lisp/emulation/cua-gmrk.el
index 4f0f480673b..03ce53d7af7 100644
--- a/lisp/emulation/cua-gmrk.el
+++ b/lisp/emulation/cua-gmrk.el
@@ -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
diff --git a/lisp/emulation/cua-rect.el b/lisp/emulation/cua-rect.el
index f809aa9f57c..df9f7469707 100644
--- a/lisp/emulation/cua-rect.el
+++ b/lisp/emulation/cua-rect.el
@@ -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)
diff --git a/lisp/emulation/edt.el b/lisp/emulation/edt.el
index a11e06130a5..6457925efa6 100644
--- a/lisp/emulation/edt.el
+++ b/lisp/emulation/edt.el
@@ -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))))
diff --git a/lisp/emulation/vi.el b/lisp/emulation/vi.el
index 64f610f4a13..a65dd44e39e 100644
--- a/lisp/emulation/vi.el
+++ b/lisp/emulation/vi.el
@@ -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 ()
diff --git a/lisp/emulation/vip.el b/lisp/emulation/vip.el
index 560a7e6e849..96bbf38f066 100644
--- a/lisp/emulation/vip.el
+++ b/lisp/emulation/vip.el
@@ -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)
diff --git a/lisp/emulation/viper-cmd.el b/lisp/emulation/viper-cmd.el
index 53a4517b476..fdaeb13f3e2 100644
--- a/lisp/emulation/viper-cmd.el
+++ b/lisp/emulation/viper-cmd.el
@@ -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)
diff --git a/lisp/emulation/viper-ex.el b/lisp/emulation/viper-ex.el
index fcc98db3204..f156b677f5d 100644
--- a/lisp/emulation/viper-ex.el
+++ b/lisp/emulation/viper-ex.el
@@ -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
diff --git a/lisp/emulation/viper-keym.el b/lisp/emulation/viper-keym.el
index 31f8deb5d34..453a23329ad 100644
--- a/lisp/emulation/viper-keym.el
+++ b/lisp/emulation/viper-keym.el
@@ -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
diff --git a/lisp/emulation/viper-util.el b/lisp/emulation/viper-util.el
index 1ee1acaee98..503265c8b85 100644
--- a/lisp/emulation/viper-util.el
+++ b/lisp/emulation/viper-util.el
@@ -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 ()
diff --git a/lisp/emulation/viper.el b/lisp/emulation/viper.el
index a179e163933..c6194c65bdc 100644
--- a/lisp/emulation/viper.el
+++ b/lisp/emulation/viper.el
@@ -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 ()