aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/emulation
diff options
context:
space:
mode:
authorStefan Monnier2009-11-03 02:04:29 +0000
committerStefan Monnier2009-11-03 02:04:29 +0000
commit937e6a5612df742722aadd1e2d190f3ef7165952 (patch)
tree73d0557ae4f7cf3370b39413fa723cf3570b2db5 /lisp/emulation
parent5b95556284173d0cebc3b1378166c207afb3c495 (diff)
downloademacs-937e6a5612df742722aadd1e2d190f3ef7165952.tar.gz
emacs-937e6a5612df742722aadd1e2d190f3ef7165952.zip
* 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.
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."
110 110
111(defun cua--insert-at-global-mark (str &optional msg) 111(defun cua--insert-at-global-mark (str &optional msg)
112 ;; Insert string at global marker and move marker 112 ;; Insert string at global marker and move marker
113 (save-excursion 113 (with-current-buffer (marker-buffer cua--global-mark-marker)
114 (set-buffer (marker-buffer cua--global-mark-marker))
115 (goto-char (marker-position cua--global-mark-marker)) 114 (goto-char (marker-position cua--global-mark-marker))
116 (insert-for-yank str) 115 (insert-for-yank str)
117 (cua--activate-global-mark)) 116 (cua--activate-global-mark))
@@ -123,8 +122,7 @@ With prefix argument, don't jump to global mark when cancelling it."
123 122
124(defun cua--delete-at-global-mark (arg &optional msg) 123(defun cua--delete-at-global-mark (arg &optional msg)
125 ;; Delete chars at global marker 124 ;; Delete chars at global marker
126 (save-excursion 125 (with-current-buffer (marker-buffer cua--global-mark-marker)
127 (set-buffer (marker-buffer cua--global-mark-marker))
128 (goto-char (marker-position cua--global-mark-marker)) 126 (goto-char (marker-position cua--global-mark-marker))
129 (delete-char arg)) 127 (delete-char arg))
130 (if msg 128 (if msg
@@ -190,8 +188,7 @@ With prefix argument, don't jump to global mark when cancelling it."
190 (if (cua--global-mark-active) 188 (if (cua--global-mark-active)
191 (let ((src-buf (current-buffer)) 189 (let ((src-buf (current-buffer))
192 (text (cua--extract-rectangle))) 190 (text (cua--extract-rectangle)))
193 (save-excursion 191 (with-current-buffer (marker-buffer cua--global-mark-marker)
194 (set-buffer (marker-buffer cua--global-mark-marker))
195 (goto-char (marker-position cua--global-mark-marker)) 192 (goto-char (marker-position cua--global-mark-marker))
196 (if as-text 193 (if as-text
197 (while text 194 (while text
@@ -309,8 +306,7 @@ With prefix argument, don't jump to global mark when cancelling it."
309 (interactive "*") 306 (interactive "*")
310 (if (cua--global-mark-active) 307 (if (cua--global-mark-active)
311 (let (col) 308 (let (col)
312 (save-excursion 309 (with-current-buffer (marker-buffer cua--global-mark-marker)
313 (set-buffer (marker-buffer cua--global-mark-marker))
314 (goto-char (marker-position cua--global-mark-marker)) 310 (goto-char (marker-position cua--global-mark-marker))
315 (setq col (current-column))) 311 (setq col (current-column)))
316 (if cua--rectangle 312 (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."
1198 (- (cua--rectangle-right) (cua--rectangle-left) -1))) 1198 (- (cua--rectangle-right) (cua--rectangle-left) -1)))
1199 (r (or setup-fct (cua--extract-rectangle))) 1199 (r (or setup-fct (cua--extract-rectangle)))
1200 y z (tr 0)) 1200 y z (tr 0))
1201 (save-excursion 1201 (with-current-buffer auxbuf
1202 (set-buffer auxbuf)
1203 (erase-buffer) 1202 (erase-buffer)
1204 (if setup-fct 1203 (if setup-fct
1205 (funcall setup-fct) 1204 (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 |
2657 (progn 2657 (progn
2658 (message "%s..." (capitalize (symbol-name fun))) 2658 (message "%s..." (capitalize (symbol-name fun)))
2659 (and b 2659 (and b
2660 (save-excursion 2660 (with-current-buffer b
2661 (set-buffer b)
2662 (set-buffer-modified-p t))) 2661 (set-buffer-modified-p t)))
2663 (fset 'help-print-return-message 'ignore) 2662 (fset 'help-print-return-message 'ignore)
2664 (call-interactively fun) 2663 (call-interactively fun)
@@ -2669,8 +2668,7 @@ G-C-\\: Split Window | FNDNXT | Yank | CUT |
2669 (not (buffer-modified-p b))))) 2668 (not (buffer-modified-p b)))))
2670 (fset 'help-print-return-message p) 2669 (fset 'help-print-return-message p)
2671 (and b (buffer-name b) 2670 (and b (buffer-name b)
2672 (save-excursion 2671 (with-current-buffer b
2673 (set-buffer b)
2674 (set-buffer-modified-p m)))))) 2672 (set-buffer-modified-p m))))))
2675 (with-electric-help 'delete-other-windows name t)))) 2673 (with-electric-help 'delete-other-windows name t))))
2676 2674
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 @@
79 (if (null mode-cmd) 79 (if (null mode-cmd)
80 (with-output-to-temp-buffer "*Help*" 80 (with-output-to-temp-buffer "*Help*"
81 (princ (substitute-command-keys "Possible major modes to switch to: \\{vi-tilde-map}")) 81 (princ (substitute-command-keys "Possible major modes to switch to: \\{vi-tilde-map}"))
82 (save-excursion 82 (with-current-buffer standard-output
83 (set-buffer standard-output)
84 (help-mode))) 83 (help-mode)))
85 (setq prefix-arg arg) ; prefix arg will be passed down 84 (setq prefix-arg arg) ; prefix arg will be passed down
86 (command-execute mode-cmd nil) ; may need to save mode-line-format etc 85 (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 "
499;; (cond ((string-match "s")))) 498;; (cond ((string-match "s"))))
500 (with-output-to-temp-buffer "*Help*" 499 (with-output-to-temp-buffer "*Help*"
501 (princ (documentation 'vi-ex-cmd)) 500 (princ (documentation 'vi-ex-cmd))
502 (save-excursion 501 (with-current-buffer standard-output
503 (set-buffer standard-output)
504 (help-mode)))) 502 (help-mode))))
505 503
506(defun vi-undefined () 504(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")
419 (goto-char (point-min)) 419 (goto-char (point-min))
420 (if (y-or-n-p "Inhibit VIP startup message? ") 420 (if (y-or-n-p "Inhibit VIP startup message? ")
421 (progn 421 (progn
422 (save-excursion 422 (with-current-buffer
423 (set-buffer 423 (find-file-noselect
424 (find-file-noselect 424 (substitute-in-file-name vip-startup-file))
425 (substitute-in-file-name vip-startup-file)))
426 (goto-char (point-max)) 425 (goto-char (point-max))
427 (insert "\n(setq vip-inhibit-startup-message t)\n") 426 (insert "\n(setq vip-inhibit-startup-message t)\n")
428 (save-buffer) 427 (save-buffer)
@@ -2158,8 +2157,7 @@ is a command.")
2158(defun vip-get-ex-token () 2157(defun vip-get-ex-token ()
2159 "get an ex-token which is either an address or a command. 2158 "get an ex-token which is either an address or a command.
2160a token has type \(command, address, end-mark\) and value." 2159a token has type \(command, address, end-mark\) and value."
2161 (save-window-excursion 2160 (with-current-buffer " *ex-working-space*"
2162 (set-buffer " *ex-working-space*")
2163 (skip-chars-forward " \t") 2161 (skip-chars-forward " \t")
2164 (cond ((looking-at "[k#]") 2162 (cond ((looking-at "[k#]")
2165 (setq ex-token-type "command") 2163 (setq ex-token-type "command")
@@ -2262,8 +2260,7 @@ a token has type \(command, address, end-mark\) and value."
2262 ex-g-variant nil)) 2260 ex-g-variant nil))
2263 (let ((com-str (or string (vip-read-string ":"))) 2261 (let ((com-str (or string (vip-read-string ":")))
2264 (address nil) (cont t) (dot (point))) 2262 (address nil) (cont t) (dot (point)))
2265 (save-window-excursion 2263 (with-current-buffer (get-buffer-create " *ex-working-space*")
2266 (set-buffer (get-buffer-create " *ex-working-space*"))
2267 (delete-region (point-min) (point-max)) 2264 (delete-region (point-min) (point-max))
2268 (insert com-str "\n") 2265 (insert com-str "\n")
2269 (goto-char (point-min))) 2266 (goto-char (point-min)))
@@ -2282,8 +2279,7 @@ a token has type \(command, address, end-mark\) and value."
2282 (setq cont nil)) 2279 (setq cont nil))
2283 (t 2280 (t
2284 (vip-execute-ex-command) 2281 (vip-execute-ex-command)
2285 (save-window-excursion 2282 (with-current-buffer " *ex-working-space*"
2286 (set-buffer " *ex-working-space*")
2287 (skip-chars-forward " \t") 2283 (skip-chars-forward " \t")
2288 (cond ((looking-at "|") 2284 (cond ((looking-at "|")
2289 (forward-char 1)) 2285 (forward-char 1))
@@ -2307,8 +2303,7 @@ a token has type \(command, address, end-mark\) and value."
2307 2303
2308(defun vip-get-ex-pat () 2304(defun vip-get-ex-pat ()
2309 "get a regular expression and set ex-variant if found" 2305 "get a regular expression and set ex-variant if found"
2310 (save-window-excursion 2306 (with-current-buffer " *ex-working-space*"
2311 (set-buffer " *ex-working-space*")
2312 (skip-chars-forward " \t") 2307 (skip-chars-forward " \t")
2313 (if (looking-at "!") 2308 (if (looking-at "!")
2314 (progn 2309 (progn
@@ -2334,8 +2329,7 @@ a token has type \(command, address, end-mark\) and value."
2334 2329
2335(defun vip-get-ex-command () 2330(defun vip-get-ex-command ()
2336 "get an ex command" 2331 "get an ex command"
2337 (save-window-excursion 2332 (with-current-buffer " *ex-working-space*"
2338 (set-buffer " *ex-working-space*")
2339 (if (looking-at "/") (forward-char 1)) 2333 (if (looking-at "/") (forward-char 1))
2340 (skip-chars-forward " \t") 2334 (skip-chars-forward " \t")
2341 (cond ((looking-at "[a-z]") 2335 (cond ((looking-at "[a-z]")
@@ -2349,8 +2343,7 @@ a token has type \(command, address, end-mark\) and value."
2349 2343
2350(defun vip-get-ex-opt-gc () 2344(defun vip-get-ex-opt-gc ()
2351 "get an ex option g or c" 2345 "get an ex option g or c"
2352 (save-window-excursion 2346 (with-current-buffer " *ex-working-space*"
2353 (set-buffer " *ex-working-space*")
2354 (if (looking-at "/") (forward-char 1)) 2347 (if (looking-at "/") (forward-char 1))
2355 (skip-chars-forward " \t") 2348 (skip-chars-forward " \t")
2356 (cond ((looking-at "g") 2349 (cond ((looking-at "g")
@@ -2458,8 +2451,7 @@ a token has type \(command, address, end-mark\) and value."
2458 (setq ex-buffer nil) 2451 (setq ex-buffer nil)
2459 (setq ex-count nil) 2452 (setq ex-count nil)
2460 (setq ex-flag nil) 2453 (setq ex-flag nil)
2461 (save-window-excursion 2454 (with-current-buffer " *ex-working-space*"
2462 (set-buffer " *ex-working-space*")
2463 (skip-chars-forward " \t") 2455 (skip-chars-forward " \t")
2464 (if (looking-at "[a-zA-Z]") 2456 (if (looking-at "[a-zA-Z]")
2465 (progn 2457 (progn
@@ -2483,8 +2475,7 @@ a token has type \(command, address, end-mark\) and value."
2483 (setq ex-variant nil 2475 (setq ex-variant nil
2484 ex-count nil 2476 ex-count nil
2485 ex-flag nil) 2477 ex-flag nil)
2486 (save-window-excursion 2478 (with-current-buffer " *ex-working-space*"
2487 (set-buffer " *ex-working-space*")
2488 (skip-chars-forward " \t") 2479 (skip-chars-forward " \t")
2489 (if (looking-at "!") 2480 (if (looking-at "!")
2490 (progn 2481 (progn
@@ -2510,8 +2501,7 @@ a token has type \(command, address, end-mark\) and value."
2510 ex-variant nil 2501 ex-variant nil
2511 ex-append nil 2502 ex-append nil
2512 ex-offset nil) 2503 ex-offset nil)
2513 (save-window-excursion 2504 (with-current-buffer " *ex-working-space*"
2514 (set-buffer " *ex-working-space*")
2515 (skip-chars-forward " \t") 2505 (skip-chars-forward " \t")
2516 (if (looking-at "!") 2506 (if (looking-at "!")
2517 (progn 2507 (progn
@@ -2680,8 +2670,7 @@ a token has type \(command, address, end-mark\) and value."
2680 (goto-char (point-min)) 2670 (goto-char (point-min))
2681 (if ex-offset 2671 (if ex-offset
2682 (progn 2672 (progn
2683 (save-window-excursion 2673 (with-current-buffer " *ex-working-space*"
2684 (set-buffer " *ex-working-space*")
2685 (delete-region (point-min) (point-max)) 2674 (delete-region (point-min) (point-max))
2686 (insert ex-offset "\n") 2675 (insert ex-offset "\n")
2687 (goto-char (point-min))) 2676 (goto-char (point-min)))
@@ -2733,19 +2722,18 @@ a token has type \(command, address, end-mark\) and value."
2733 (if (bobp) (setq cont nil) 2722 (if (bobp) (setq cont nil)
2734 (forward-line -1) 2723 (forward-line -1)
2735 (end-of-line))))) 2724 (end-of-line)))))
2736 (save-window-excursion 2725 (with-current-buffer " *ex-working-space*"
2737 (set-buffer " *ex-working-space*") 2726 (setq com-str (buffer-substring (1+ (point)) (1- (point-max)))))
2738 (setq com-str (buffer-substring (1+ (point)) (1- (point-max))))) 2727 (while marks
2739 (while marks 2728 (goto-char (car marks))
2740 (goto-char (car marks)) 2729 ;; report progress of execution on a slow machine.
2741 ; report progress of execution on a slow machine. 2730 ;;(message "Executing global command...")
2742 ;(message "Executing global command...") 2731 ;;(if (zerop (% mark-count 10))
2743 ;(if (zerop (% mark-count 10)) 2732 ;; (message "Executing global command...%d" mark-count))
2744 ;(message "Executing global command...%d" mark-count)) 2733 (vip-ex com-str)
2745 (vip-ex com-str) 2734 (setq mark-count (1- mark-count))
2746 (setq mark-count (1- mark-count)) 2735 (setq marks (cdr marks)))))
2747 (setq marks (cdr marks))))) 2736;;(message "Executing global command...done")))
2748 ;(message "Executing global command...done")))
2749 2737
2750(defun ex-line (com) 2738(defun ex-line (com)
2751 "ex line commands. COM is join, shift-right or shift-left." 2739 "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."
2801 (if (null ex-addresses) 2789 (if (null ex-addresses)
2802 (setq ex-addresses 2790 (setq ex-addresses
2803 (cons (point) nil))) 2791 (cons (point) nil)))
2804 (save-window-excursion 2792 (with-current-buffer " *ex-working-space*"
2805 (set-buffer " *ex-working-space*")
2806 (skip-chars-forward " \t") 2793 (skip-chars-forward " \t")
2807 (if (looking-at "[a-z]") 2794 (if (looking-at "[a-z]")
2808 (progn 2795 (progn
@@ -2821,8 +2808,7 @@ a token has type \(command, address, end-mark\) and value."
2821(defun ex-map () 2808(defun ex-map ()
2822 "ex map" 2809 "ex map"
2823 (let (char string) 2810 (let (char string)
2824 (save-window-excursion 2811 (with-current-buffer " *ex-working-space*"
2825 (set-buffer " *ex-working-space*")
2826 (skip-chars-forward " \t") 2812 (skip-chars-forward " \t")
2827 (setq char (char-to-string (following-char))) 2813 (setq char (char-to-string (following-char)))
2828 (forward-char 1) 2814 (forward-char 1)
@@ -2847,8 +2833,7 @@ a token has type \(command, address, end-mark\) and value."
2847(defun ex-unmap () 2833(defun ex-unmap ()
2848 "ex unmap" 2834 "ex unmap"
2849 (let (char) 2835 (let (char)
2850 (save-window-excursion 2836 (with-current-buffer " *ex-working-space*"
2851 (set-buffer " *ex-working-space*")
2852 (skip-chars-forward " \t") 2837 (skip-chars-forward " \t")
2853 (setq char (char-to-string (following-char))) 2838 (setq char (char-to-string (following-char)))
2854 (forward-char 1) 2839 (forward-char 1)
@@ -2870,8 +2855,7 @@ a token has type \(command, address, end-mark\) and value."
2870(defun ex-quit () 2855(defun ex-quit ()
2871 "ex quit" 2856 "ex quit"
2872 (let (char) 2857 (let (char)
2873 (save-window-excursion 2858 (with-current-buffer " *ex-working-space*"
2874 (set-buffer " *ex-working-space*")
2875 (skip-chars-forward " \t") 2859 (skip-chars-forward " \t")
2876 (setq char (following-char))) 2860 (setq char (following-char)))
2877 (if (= char ?!) (kill-emacs t) (save-buffers-kill-emacs)))) 2861 (if (= char ?!) (kill-emacs t) (save-buffers-kill-emacs))))
@@ -2883,8 +2867,7 @@ a token has type \(command, address, end-mark\) and value."
2883 (goto-char point) 2867 (goto-char point)
2884 (if (not (= point 0)) (with-no-warnings (next-line 1))) 2868 (if (not (= point 0)) (with-no-warnings (next-line 1)))
2885 (beginning-of-line) 2869 (beginning-of-line)
2886 (save-window-excursion 2870 (with-current-buffer " *ex-working-space*"
2887 (set-buffer " *ex-working-space*")
2888 (skip-chars-forward " \t") 2871 (skip-chars-forward " \t")
2889 (if (looking-at "!") 2872 (if (looking-at "!")
2890 (progn 2873 (progn
@@ -2981,8 +2964,7 @@ vip-s-string"
2981(defun ex-tag () 2964(defun ex-tag ()
2982 "ex tag" 2965 "ex tag"
2983 (let (tag) 2966 (let (tag)
2984 (save-window-excursion 2967 (with-current-buffer " *ex-working-space*"
2985 (set-buffer " *ex-working-space*")
2986 (skip-chars-forward " \t") 2968 (skip-chars-forward " \t")
2987 (set-mark (point)) 2969 (set-mark (point))
2988 (skip-chars-forward "^ |\t\n") 2970 (skip-chars-forward "^ |\t\n")
@@ -3045,8 +3027,7 @@ vip-s-string"
3045(defun ex-command () 3027(defun ex-command ()
3046 "execute shell command" 3028 "execute shell command"
3047 (let (command) 3029 (let (command)
3048 (save-window-excursion 3030 (with-current-buffer " *ex-working-space*"
3049 (set-buffer " *ex-working-space*")
3050 (skip-chars-forward " \t") 3031 (skip-chars-forward " \t")
3051 (set-mark (point)) 3032 (set-mark (point))
3052 (end-of-line) 3033 (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
903 (signal 'quit nil))) 903 (signal 'quit nil)))
904 904
905 (if (not (equal buff (current-buffer))) ; cmd switched buffer 905 (if (not (equal buff (current-buffer))) ; cmd switched buffer
906 (save-excursion 906 (with-current-buffer buff
907 (set-buffer buff)
908 (viper-set-mode-vars-for viper-current-state))) 907 (viper-set-mode-vars-for viper-current-state)))
909 (viper-set-mode-vars-for viper-current-state) 908 (viper-set-mode-vars-for viper-current-state)
910 result)) 909 result))
@@ -917,8 +916,7 @@ Similar to viper-escape-to-emacs, but accepts forms rather than keystrokes."
917 (viper-set-mode-vars-for 'emacs-state) 916 (viper-set-mode-vars-for 'emacs-state)
918 (setq result (eval form)) 917 (setq result (eval form))
919 (if (not (equal buff (current-buffer))) ; cmd switched buffer 918 (if (not (equal buff (current-buffer))) ; cmd switched buffer
920 (save-excursion 919 (with-current-buffer buff
921 (set-buffer buff)
922 (viper-set-mode-vars-for viper-current-state))) 920 (viper-set-mode-vars-for viper-current-state)))
923 (viper-set-mode-vars-for viper-current-state) 921 (viper-set-mode-vars-for viper-current-state)
924 result)) 922 result))
@@ -4697,8 +4695,7 @@ One can use `` and '' to temporarily jump 1 step back."
4697 (with-output-to-temp-buffer " *viper-info*" 4695 (with-output-to-temp-buffer " *viper-info*"
4698 (if (and buf pos) 4696 (if (and buf pos)
4699 (progn 4697 (progn
4700 (save-excursion 4698 (with-current-buffer buf
4701 (set-buffer buf)
4702 (setq line-no (1+ (count-lines (point-min) val))) 4699 (setq line-no (1+ (count-lines (point-min) val)))
4703 (goto-char pos) 4700 (goto-char pos)
4704 (beginning-of-line) 4701 (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."
946;; Expand \% and \# in ex command 946;; Expand \% and \# in ex command
947(defun ex-expand-filsyms (cmd buf) 947(defun ex-expand-filsyms (cmd buf)
948 (let (cf pf ret) 948 (let (cf pf ret)
949 (save-excursion 949 (with-current-buffer buf
950 (set-buffer buf)
951 (setq cf buffer-file-name) 950 (setq cf buffer-file-name)
952 (setq pf (ex-next nil t))) ; this finds alternative file name 951 (setq pf (ex-next nil t))) ; this finds alternative file name
953 (if (and (null cf) (string-match "[^\\]%\\|\\`%" cmd)) 952 (if (and (null cf) (string-match "[^\\]%\\|\\`%" cmd))
954 (error "No current file to substitute for `%%'")) 953 (error "No current file to substitute for `%%'"))
955 (if (and (null pf) (string-match "[^\\]#\\|\\`#" cmd)) 954 (if (and (null pf) (string-match "[^\\]#\\|\\`#" cmd))
956 (error "No alternate file to substitute for `#'")) 955 (error "No alternate file to substitute for `#'"))
957 (save-excursion 956 (with-current-buffer (get-buffer-create viper-ex-tmp-buf-name)
958 (set-buffer (get-buffer-create viper-ex-tmp-buf-name))
959 (erase-buffer) 957 (erase-buffer)
960 (insert cmd) 958 (insert cmd)
961 (goto-char (point-min)) 959 (goto-char (point-min))
@@ -984,9 +982,8 @@ reversed."
984 ex-cmdfile nil 982 ex-cmdfile nil
985 ex-cmdfile-args "") 983 ex-cmdfile-args "")
986 (save-excursion 984 (save-excursion
987 (save-window-excursion 985 (with-current-buffer (setq viper-ex-work-buf
988 (setq viper-ex-work-buf (get-buffer-create viper-ex-work-buf-name)) 986 (get-buffer-create viper-ex-work-buf-name))
989 (set-buffer viper-ex-work-buf)
990 (skip-chars-forward " \t") 987 (skip-chars-forward " \t")
991 (if (looking-at "!") 988 (if (looking-at "!")
992 (if (and (not (viper-looking-back "[ \t]")) 989 (if (and (not (viper-looking-back "[ \t]"))
@@ -1289,9 +1286,8 @@ reversed."
1289 (switch-to-buffer file)) 1286 (switch-to-buffer file))
1290 (if ex-offset 1287 (if ex-offset
1291 (progn 1288 (progn
1292 (save-window-excursion 1289 (with-current-buffer (setq viper-ex-work-buf
1293 (setq viper-ex-work-buf (get-buffer-create viper-ex-work-buf-name)) 1290 (get-buffer-create viper-ex-work-buf-name))
1294 (set-buffer viper-ex-work-buf)
1295 (delete-region (point-min) (point-max)) 1291 (delete-region (point-min) (point-max))
1296 (insert ex-offset "\n") 1292 (insert ex-offset "\n")
1297 (goto-char (point-min))) 1293 (goto-char (point-min)))
@@ -1372,9 +1368,8 @@ reversed."
1372 (if (bobp) (setq cont nil) 1368 (if (bobp) (setq cont nil)
1373 (forward-line -1) 1369 (forward-line -1)
1374 (end-of-line))))) 1370 (end-of-line)))))
1375 (save-window-excursion 1371 (with-current-buffer (setq viper-ex-work-buf
1376 (setq viper-ex-work-buf (get-buffer-create viper-ex-work-buf-name)) 1372 (get-buffer-create viper-ex-work-buf-name))
1377 (set-buffer viper-ex-work-buf)
1378 ;; com-str is the command string, i.e., g/pattern/ or v/pattern' 1373 ;; com-str is the command string, i.e., g/pattern/ or v/pattern'
1379 (setq com-str (buffer-substring (1+ (point)) (1- (point-max))))) 1374 (setq com-str (buffer-substring (1+ (point)) (1- (point-max)))))
1380 (while ex-g-marks 1375 (while ex-g-marks
@@ -1453,18 +1448,17 @@ reversed."
1453 (setq char (string-to-char name)) 1448 (setq char (string-to-char name))
1454 (error "`%s': Spurious text \"%s\" after mark name" 1449 (error "`%s': Spurious text \"%s\" after mark name"
1455 name (substring name 1))) 1450 name (substring name 1)))
1456 (save-window-excursion 1451 (with-current-buffer (setq viper-ex-work-buf
1457 (setq viper-ex-work-buf (get-buffer-create viper-ex-work-buf-name)) 1452 (get-buffer-create viper-ex-work-buf-name))
1458 (set-buffer viper-ex-work-buf) 1453 (skip-chars-forward " \t")
1459 (skip-chars-forward " \t") 1454 (if (looking-at "[a-z]")
1460 (if (looking-at "[a-z]") 1455 (progn
1461 (progn 1456 (setq char (following-char))
1462 (setq char (following-char)) 1457 (forward-char 1)
1463 (forward-char 1) 1458 (skip-chars-forward " \t")
1464 (skip-chars-forward " \t") 1459 (if (not (looking-at "[\n|]"))
1465 (if (not (looking-at "[\n|]")) 1460 (error "`%s': %s" ex-token viper-SpuriousText)))
1466 (error "`%s': %s" ex-token viper-SpuriousText))) 1461 (error "`%s' requires a following letter" ex-token))))
1467 (error "`%s' requires a following letter" ex-token))))
1468 (save-excursion 1462 (save-excursion
1469 (goto-char (car ex-addresses)) 1463 (goto-char (car ex-addresses))
1470 (point-to-register (viper-int-to-char (1+ (- char ?a))))))) 1464 (point-to-register (viper-int-to-char (1+ (- char ?a)))))))
@@ -1560,8 +1554,7 @@ reversed."
1560 (select-window wind))) 1554 (select-window wind)))
1561 (save-window-excursion (select-window wind) (sit-for 1))) 1555 (save-window-excursion (select-window wind) (sit-for 1)))
1562 1556
1563 (save-excursion 1557 (with-current-buffer buf
1564 (set-buffer buf)
1565 (setq viper-related-files-and-buffers-ring old-ring)) 1558 (setq viper-related-files-and-buffers-ring old-ring))
1566 1559
1567 (setq viper-local-search-start-marker (point-marker)) 1560 (setq viper-local-search-start-marker (point-marker))
@@ -1588,9 +1581,8 @@ reversed."
1588;; Ex quit command 1581;; Ex quit command
1589(defun ex-quit () 1582(defun ex-quit ()
1590 ;; skip "!", if it is q!. In Viper q!, w!, etc., behave as q, w, etc. 1583 ;; skip "!", if it is q!. In Viper q!, w!, etc., behave as q, w, etc.
1591 (save-excursion 1584 (with-current-buffer (setq viper-ex-work-buf
1592 (setq viper-ex-work-buf (get-buffer-create viper-ex-work-buf-name)) 1585 (get-buffer-create viper-ex-work-buf-name))
1593 (set-buffer viper-ex-work-buf)
1594 (if (looking-at "!") (forward-char 1))) 1586 (if (looking-at "!") (forward-char 1)))
1595 (if (< viper-expert-level 3) 1587 (if (< viper-expert-level 3)
1596 (save-buffers-kill-emacs) 1588 (save-buffers-kill-emacs)
@@ -1837,9 +1829,8 @@ reversed."
1837;; Optional 3d arg is a string that should replace ' ' to prevent its 1829;; Optional 3d arg is a string that should replace ' ' to prevent its
1838;; special meaning 1830;; special meaning
1839(defun ex-get-inline-cmd-args (regex-forw &optional chars-back replace-str) 1831(defun ex-get-inline-cmd-args (regex-forw &optional chars-back replace-str)
1840 (save-excursion 1832 (with-current-buffer (setq viper-ex-work-buf
1841 (setq viper-ex-work-buf (get-buffer-create viper-ex-work-buf-name)) 1833 (get-buffer-create viper-ex-work-buf-name))
1842 (set-buffer viper-ex-work-buf)
1843 (goto-char (point-min)) 1834 (goto-char (point-min))
1844 (re-search-forward regex-forw nil t) 1835 (re-search-forward regex-forw nil t)
1845 (let ((beg (point)) 1836 (let ((beg (point))
@@ -1987,9 +1978,8 @@ Please contact your system administrator. "
1987;; Ex tag command 1978;; Ex tag command
1988(defun ex-tag () 1979(defun ex-tag ()
1989 (let (tag) 1980 (let (tag)
1990 (save-window-excursion 1981 (with-current-buffer (setq viper-ex-work-buf
1991 (setq viper-ex-work-buf (get-buffer-create viper-ex-work-buf-name)) 1982 (get-buffer-create viper-ex-work-buf-name))
1992 (set-buffer viper-ex-work-buf)
1993 (skip-chars-forward " \t") 1983 (skip-chars-forward " \t")
1994 (set-mark (point)) 1984 (set-mark (point))
1995 (skip-chars-forward "^ |\t\n") 1985 (skip-chars-forward "^ |\t\n")
@@ -2148,9 +2138,8 @@ Please contact your system administrator. "
2148;; Execute shell command 2138;; Execute shell command
2149(defun ex-command () 2139(defun ex-command ()
2150 (let (command) 2140 (let (command)
2151 (save-window-excursion 2141 (with-current-buffer (setq viper-ex-work-buf
2152 (setq viper-ex-work-buf (get-buffer-create viper-ex-work-buf-name)) 2142 (get-buffer-create viper-ex-work-buf-name))
2153 (set-buffer viper-ex-work-buf)
2154 (skip-chars-forward " \t") 2143 (skip-chars-forward " \t")
2155 (setq command (buffer-substring (point) (point-max))) 2144 (setq command (buffer-substring (point) (point-max)))
2156 (end-of-line)) 2145 (end-of-line))
@@ -2178,9 +2167,8 @@ Please contact your system administrator. "
2178If no args are given, then it runs the last compile command. 2167If no args are given, then it runs the last compile command.
2179Type 'mak ' (including the space) to run make with no args." 2168Type 'mak ' (including the space) to run make with no args."
2180 (let (args) 2169 (let (args)
2181 (save-window-excursion 2170 (with-current-buffer (setq viper-ex-work-buf
2182 (setq viper-ex-work-buf (get-buffer-create viper-ex-work-buf-name)) 2171 (get-buffer-create viper-ex-work-buf-name))
2183 (set-buffer viper-ex-work-buf)
2184 (setq args (buffer-substring (point) (point-max))) 2172 (setq args (buffer-substring (point) (point-max)))
2185 (end-of-line)) 2173 (end-of-line))
2186 ;; Remove the newline that may (will?) be at the end of the args 2174 ;; 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)]."
165 [(control ?z)]))) 165 [(control ?z)])))
166 (mapc 166 (mapc
167 (lambda (buf) 167 (lambda (buf)
168 (save-excursion 168 (with-current-buffer buf
169 (set-buffer buf)
170 (when (and (boundp 'viper-insert-basic-map) 169 (when (and (boundp 'viper-insert-basic-map)
171 (keymapp viper-insert-basic-map)) 170 (keymapp viper-insert-basic-map))
172 (when old-value 171 (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."
409 (command (cond (viper-ms-style-os-p (format "\"ls -1 -d %s\"" filespec)) 409 (command (cond (viper-ms-style-os-p (format "\"ls -1 -d %s\"" filespec))
410 (t (format "ls -1 -d %s" filespec)))) 410 (t (format "ls -1 -d %s" filespec))))
411 status) 411 status)
412 (save-excursion 412 (with-current-buffer (get-buffer-create viper-ex-tmp-buf-name)
413 (set-buffer (get-buffer-create viper-ex-tmp-buf-name))
414 (erase-buffer) 413 (erase-buffer)
415 (setq status 414 (setq status
416 (if gshell-options 415 (if gshell-options
@@ -467,8 +466,7 @@ Otherwise return the normal value."
467 466
468;; convert MS-DOS wildcards to regexp 467;; convert MS-DOS wildcards to regexp
469(defun viper-wildcard-to-regexp (wcard) 468(defun viper-wildcard-to-regexp (wcard)
470 (save-excursion 469 (with-current-buffer (get-buffer-create viper-ex-tmp-buf-name)
471 (set-buffer (get-buffer-create viper-ex-tmp-buf-name))
472 (erase-buffer) 470 (erase-buffer)
473 (insert wcard) 471 (insert wcard)
474 (goto-char (point-min)) 472 (goto-char (point-min))
@@ -488,8 +486,7 @@ Otherwise return the normal value."
488(defun viper-glob-mswindows-files (filespec) 486(defun viper-glob-mswindows-files (filespec)
489 (let ((case-fold-search t) 487 (let ((case-fold-search t)
490 tmp tmp2) 488 tmp tmp2)
491 (save-excursion 489 (with-current-buffer (get-buffer-create viper-ex-tmp-buf-name)
492 (set-buffer (get-buffer-create viper-ex-tmp-buf-name))
493 (erase-buffer) 490 (erase-buffer)
494 (insert filespec) 491 (insert filespec)
495 (goto-char (point-min)) 492 (goto-char (point-min))
@@ -654,8 +651,7 @@ Otherwise return the normal value."
654 (buf (find-file-noselect (substitute-in-file-name custom-file))) 651 (buf (find-file-noselect (substitute-in-file-name custom-file)))
655 ) 652 )
656 (message "%s" (or message "")) 653 (message "%s" (or message ""))
657 (save-excursion 654 (with-current-buffer buf
658 (set-buffer buf)
659 (goto-char (point-min)) 655 (goto-char (point-min))
660 (if (re-search-forward regexp nil t) 656 (if (re-search-forward regexp nil t)
661 (let ((reg-end (1- (match-end 0)))) 657 (let ((reg-end (1- (match-end 0))))
@@ -678,8 +674,7 @@ Otherwise return the normal value."
678;; match this pattern. 674;; match this pattern.
679(defun viper-save-string-in-file (string custom-file &optional pattern) 675(defun viper-save-string-in-file (string custom-file &optional pattern)
680 (let ((buf (find-file-noselect (substitute-in-file-name custom-file)))) 676 (let ((buf (find-file-noselect (substitute-in-file-name custom-file))))
681 (save-excursion 677 (with-current-buffer buf
682 (set-buffer buf)
683 (let (buffer-read-only) 678 (let (buffer-read-only)
684 (goto-char (point-min)) 679 (goto-char (point-min))
685 (if pattern (delete-matching-lines pattern)) 680 (if pattern (delete-matching-lines pattern))
@@ -889,8 +884,7 @@ Otherwise return the normal value."
889 (if (and (markerp marker) (marker-buffer marker)) 884 (if (and (markerp marker) (marker-buffer marker))
890 (let ((buf (marker-buffer marker)) 885 (let ((buf (marker-buffer marker))
891 (pos (marker-position marker))) 886 (pos (marker-position marker)))
892 (save-excursion 887 (with-current-buffer buf
893 (set-buffer buf)
894 (and (<= pos (point-max)) (<= (point-min) pos)))))) 888 (and (<= pos (point-max)) (<= (point-min) pos))))))
895 889
896(defsubst viper-mark-marker () 890(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."
647;; Remove local value in all existing buffers 647;; Remove local value in all existing buffers
648;; This doesn't delocalize vars (which would have been desirable) 648;; This doesn't delocalize vars (which would have been desirable)
649(defun viper-delocalize-var (symbol) 649(defun viper-delocalize-var (symbol)
650 (mapcar (lambda (buf) (save-excursion 650 (dolist (buf (buffer-list))
651 (set-buffer buf) 651 (with-current-buffer buf
652 (kill-local-variable symbol))) 652 (kill-local-variable symbol))))
653 (buffer-list)))
654 653
655 654
656(defun viper-go-away () 655(defun viper-go-away ()