;;; vip.el --- a VI Package for GNU Emacs
-;; Copyright (C) 1986, 1987, 1988, 1992, 1993, 1998, 2001, 2002, 2003,
-;; 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+;; Copyright (C) 1986-1988, 1992-1993, 1998, 2001-2011
+;; Free Software Foundation, Inc.
;; Author: Masahiko Sato <ms@sail.stanford.edu>
;; Keywords: emulations
"How to reexecute last destructive command. Value is list (M-COM VAL COM).")
(defcustom vip-shift-width 8
- "*The number of columns shifted by > and < command."
+ "The number of columns shifted by > and < command."
:type 'integer
:group 'vip)
(defcustom vip-re-replace nil
- "*If t then do regexp replace, if nil then do string replace."
+ "If t then do regexp replace, if nil then do string replace."
:type 'boolean
:group 'vip)
"For use by \";\" command.")
(defcustom vip-search-wrap-around t
- "*If t, search wraps around."
+ "If t, search wraps around."
:type 'boolean
:group 'vip)
(defcustom vip-re-search nil
- "*If t, search is reg-exp search, otherwise vanilla search."
+ "If t, search is reg-exp search, otherwise vanilla search."
:type 'boolean
:group 'vip)
"If t, search is forward.")
(defcustom vip-case-fold-search nil
- "*If t, search ignores cases."
+ "If t, search ignores cases."
:type 'boolean
:group 'vip)
(defcustom vip-re-query-replace nil
- "*If t then do regexp replace, if nil then do string replace."
+ "If t then do regexp replace, if nil then do string replace."
:type 'boolean
:group 'vip)
(defcustom vip-open-with-indent nil
- "*If t, indent when open a new line."
+ "If t, indent when open a new line."
:type 'boolean
:group 'vip)
(defcustom vip-help-in-insert-mode nil
- "*If t then C-h is bound to help-command in insert mode.
+ "If t then C-h is bound to help-command in insert mode.
If nil then it is bound to `delete-backward-char'."
:type 'boolean
:group 'vip)
(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)
(defun vip-digit-argument (arg)
"Begin numeric argument for the next command."
(interactive "P")
- (vip-prefix-arg-value last-command-char nil
+ (vip-prefix-arg-value last-command-event nil
(if (consp arg) (cdr arg) nil)))
(defun vip-command-argument (arg)
(interactive "P")
(condition-case conditions
(vip-prefix-arg-com
- last-command-char
+ last-command-event
(cond ((null arg) nil)
((consp arg) (car arg))
((numberp arg) arg)
(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")
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)))
(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))
(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
(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]")
(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")
(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
(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
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
(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)))
(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."
(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
(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)
(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)
(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))))
(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
(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")
(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)
(provide 'vip)
-;; arch-tag: bff623ef-48f7-41d4-9aa3-2e840c9ab415
;;; vip.el ends here