;;; viper-cmd.el --- Vi command support for Viper
-;; Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
-;; 2005, 2006, 2007 Free Software Foundation, Inc.
+;; Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
+;; 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
;; Author: Michael Kifer <kifer@cs.stonybrook.edu>
+;; Package: viper
;; This file is part of GNU Emacs.
-;; GNU Emacs is free software; you can redistribute it and/or modify
+;; GNU Emacs is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 3, or (at your option)
-;; any later version.
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs; see the file COPYING. If not, write to the
-;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-;; Boston, MA 02110-1301, USA.
+;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
;;; Commentary:
(defvar iso-accents-mode)
(defvar quail-mode)
(defvar quail-current-str)
-(defvar zmacs-region-stays)
(defvar mark-even-if-inactive)
(defvar init-message)
-(defvar initial)
+(defvar viper-initial)
(defvar undo-beg-posn)
(defvar undo-end-posn)
+
+(eval-and-compile
+ (unless (fboundp 'declare-function) (defmacro declare-function (&rest r))))
;; end pacifier
(viper-set-replace-overlay (point-min) (point-min))
(viper-hide-replace-overlay)))
(if (eq viper-current-state 'insert-state)
- (let ((has-saved-cursor-color-in-insert-mode
- (stringp (viper-get-saved-cursor-color-in-insert-mode))))
- (or has-saved-cursor-color-in-insert-mode
- (string= (viper-get-cursor-color) viper-insert-state-cursor-color)
+ (let ((icolor (viper-frame-value viper-insert-state-cursor-color)))
+ (or (stringp (viper-get-saved-cursor-color-in-insert-mode))
+ (string= (viper-get-cursor-color) icolor)
;; save current color, if not already saved
(viper-save-cursor-color 'before-insert-mode))
;; set insert mode cursor color
- (viper-change-cursor-color viper-insert-state-cursor-color)))
- (if (and viper-emacs-state-cursor-color (eq viper-current-state 'emacs-state))
- (let ((has-saved-cursor-color-in-emacs-mode
- (stringp (viper-get-saved-cursor-color-in-emacs-mode))))
- (or has-saved-cursor-color-in-emacs-mode
- (string= (viper-get-cursor-color) viper-emacs-state-cursor-color)
- ;; save current color, if not already saved
- (viper-save-cursor-color 'before-emacs-mode))
- ;; set emacs mode cursor color
- (viper-change-cursor-color viper-emacs-state-cursor-color)))
+ (viper-change-cursor-color icolor)))
+ (let ((ecolor (viper-frame-value viper-emacs-state-cursor-color)))
+ (when (and ecolor (eq viper-current-state 'emacs-state))
+ (or (stringp (viper-get-saved-cursor-color-in-emacs-mode))
+ (string= (viper-get-cursor-color) ecolor)
+ ;; save current color, if not already saved
+ (viper-save-cursor-color 'before-emacs-mode))
+ ;; set emacs mode cursor color
+ (viper-change-cursor-color ecolor)))
(if (and (memq this-command '(dabbrev-expand hippie-expand))
(integerp viper-pre-command-point)
(markerp viper-insert-point)
(marker-position viper-insert-point)
(> viper-insert-point viper-pre-command-point))
- (viper-move-marker-locally viper-insert-point viper-pre-command-point))
- )
+ (viper-move-marker-locally viper-insert-point viper-pre-command-point)))
(defsubst viper-preserve-cursor-color ()
(or (memq this-command '(self-insert-command
(marker-position viper-insert-point))
(setq viper-pre-command-point (marker-position viper-insert-point))))
-(defsubst viper-R-state-post-command-sentinel ()
+(defun viper-R-state-post-command-sentinel ()
;; Restoring cursor color is needed despite
;; viper-replace-state-pre-command-sentinel: When you jump to another buffer
;; in another frame, the pre-command hook won't change cursor color to
;; will remain red. Restoring the default, below, prevents this.
(if (and (<= (viper-replace-start) (point))
(<= (point) (viper-replace-end)))
- (viper-change-cursor-color viper-replace-overlay-cursor-color)
- (viper-restore-cursor-color 'after-replace-mode)
- ))
+ (viper-change-cursor-color
+ (viper-frame-value viper-replace-overlay-cursor-color))
+ (viper-restore-cursor-color 'after-replace-mode)))
;; to speed up, don't change cursor color before self-insert
;; and common move commands
(if (= viper-last-posn-in-replace-region (viper-replace-end))
(viper-finish-change)))
- (if (viper-pos-within-region
- (point) (viper-replace-start) replace-boundary)
- (progn
- ;; the state may have changed in viper-finish-change above
- (if (eq viper-current-state 'replace-state)
- (viper-change-cursor-color viper-replace-overlay-cursor-color))
- (setq viper-last-posn-in-replace-region (point-marker))))
- ))
+ (when (viper-pos-within-region
+ (point) (viper-replace-start) replace-boundary)
+ ;; the state may have changed in viper-finish-change above
+ (if (eq viper-current-state 'replace-state)
+ (viper-change-cursor-color
+ (viper-frame-value viper-replace-overlay-cursor-color)))
+ (setq viper-last-posn-in-replace-region (point-marker)))))
;; terminate replace mode if changed Viper states.
(t (viper-finish-change))))
;; desirable that viper-pre-command-sentinel is the last hook and
;; viper-post-command-sentinel is the first hook.
- (viper-cond-compile-for-xemacs-or-emacs
- ;; xemacs
- (progn
- (make-local-hook 'viper-after-change-functions)
- (make-local-hook 'viper-before-change-functions)
- (make-local-hook 'viper-post-command-hooks)
- (make-local-hook 'viper-pre-command-hooks))
- nil ; emacs
- )
+ (when (featurep 'xemacs)
+ (make-local-hook 'viper-after-change-functions)
+ (make-local-hook 'viper-before-change-functions)
+ (make-local-hook 'viper-post-command-hooks)
+ (make-local-hook 'viper-pre-command-hooks))
(remove-hook 'post-command-hook 'viper-post-command-sentinel)
(add-hook 'post-command-hook 'viper-post-command-sentinel)
(assoc major-mode viper-emacs-state-modifier-alist))
viper-empty-keymap))
))
-
+
;; This var is not local in Emacs, so we make it local. It must be local
;; because although the stack of minor modes can be the same for all buffers,
;; the associated *keymaps* can be different. In Viper,
(viper-set-replace-overlay (point-min) (point-min)))
(viper-hide-replace-overlay)
- (let ((has-saved-cursor-color-in-insert-mode
- (stringp (viper-get-saved-cursor-color-in-insert-mode))))
- (or has-saved-cursor-color-in-insert-mode
- (string= (viper-get-cursor-color) viper-insert-state-cursor-color)
+ (let ((icolor (viper-frame-value viper-insert-state-cursor-color)))
+ (or (stringp (viper-get-saved-cursor-color-in-insert-mode))
+ (string= (viper-get-cursor-color) icolor)
(viper-save-cursor-color 'before-insert-mode))
- (viper-change-cursor-color viper-insert-state-cursor-color))
+ (viper-change-cursor-color icolor))
;; Protect against user errors in hooks
(condition-case conds
(viper-set-replace-overlay (point-min) (point-min)))
(viper-hide-replace-overlay)
- (if viper-emacs-state-cursor-color
- (let ((has-saved-cursor-color-in-emacs-mode
- (stringp (viper-get-saved-cursor-color-in-emacs-mode))))
- (or has-saved-cursor-color-in-emacs-mode
- (string= (viper-get-cursor-color) viper-emacs-state-cursor-color)
- (viper-save-cursor-color 'before-emacs-mode))
- (viper-change-cursor-color viper-emacs-state-cursor-color)))
+ (let ((ecolor (viper-frame-value viper-emacs-state-cursor-color)))
+ (when ecolor
+ (or (stringp (viper-get-saved-cursor-color-in-emacs-mode))
+ (string= (viper-get-cursor-color) ecolor)
+ (viper-save-cursor-color 'before-emacs-mode))
+ (viper-change-cursor-color ecolor)))
(viper-change-state 'emacs-state)
ARG is used as the prefix value for the executed command. If
EVENTS is a list of events, which become the beginning of the command."
(interactive "P")
- (if (viper= last-command-char ?\\)
+ (if (viper= (viper-last-command-char) ?\\)
(message "Switched to EMACS state for the next command..."))
(viper-escape-to-state arg events 'emacs-state))
;; this-command, last-command-char, last-command-event
(setq this-command com)
- (viper-cond-compile-for-xemacs-or-emacs
- ;; XEmacs represents key sequences as vectors
- (setq last-command-event
- (viper-copy-event (viper-seq-last-elt key))
- last-command-char (event-to-character last-command-event))
- ;; Emacs represents them as sequences (str or vec)
- (setq last-command-event
- (viper-copy-event (viper-seq-last-elt key))
- last-command-char last-command-event)
- )
+ (if (featurep 'xemacs)
+ ;; XEmacs represents key sequences as vectors
+ (setq last-command-event
+ (viper-copy-event (viper-seq-last-elt key))
+ last-command-char (event-to-character last-command-event))
+ ;; Emacs represents them as sequences (str or vec)
+ (setq last-command-event
+ (viper-copy-event (viper-seq-last-elt key))))
(if (commandp com)
;; pretend that current state is the state we excaped to
(defun viper-exec-form-in-vi (form)
- "Execute FORM in Vi state, regardless of the Ccurrent Vi state."
+ "Execute FORM in Vi state, regardless of the current Vi state."
(let ((buff (current-buffer))
result)
(viper-set-mode-vars-for 'vi-state)
(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))
(defun viper-exec-form-in-emacs (form)
"Execute FORM in Emacs, temporarily disabling Viper's minor modes.
-Similar to viper-escape-to-emacs, but accepts forms rather than keystrokes."
+Similar to `viper-escape-to-emacs', but accepts forms rather than keystrokes."
(let ((buff (current-buffer))
result)
(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))
;; bindings. By letting Viper know which files these modes are in, it will
;; arrange to reorganize minor-mode-map-alist so that things will work right.
(defun viper-harness-minor-mode (load-file)
- "Familiarize Viper with a minor mode defined in LOAD_FILE.
+ "Familiarize Viper with a minor mode defined in LOAD-FILE.
Minor modes that have their own keymaps may overshadow Viper keymaps.
This function is designed to make Viper aware of the packages that define
such minor modes.
Usage:
(viper-harness-minor-mode load-file)
-LOAD-FILE is a name of the file where the specific minor mode is defined.
+LOAD-FILE is the name of the file where the specific minor mode is defined.
Suffixes such as .el or .elc should be stripped."
(interactive "sEnter name of the load file: ")
If viper-no-multiple-ESC is 'twice double ESC would ding in vi-state.
Other ESC sequences are emulated via the current Emacs's major mode
keymap. This is more convenient on TTYs, since this won't block
-function keys such as up,down, etc. ESC will also will also work as
-a Meta key in this case. When viper-no-multiple-ESC is nil, ESC functions
-as a Meta key and any number of multiple escapes is allowed."
+function keys such as up, down, etc. ESC will also will also work as
+a Meta key in this case. When viper-no-multiple-ESC is nil, ESC works
+as a Meta key and any number of multiple escapes are allowed."
(interactive "P")
(let (char)
(cond ((and (not viper-no-multiple-ESC) (eq viper-current-state 'vi-state))
(let* ((first-key (elt keyseq 0))
(key-mod (event-modifiers first-key)))
(cond ((and (viper-ESC-event-p first-key)
- (not viper-translate-all-ESC-keysequences))
+ (not (viper-translate-all-ESC-keysequences)))
;; put keys following ESC on the unread list
;; and return ESC as the key-sequence
(viper-set-unread-command-events (viper-subseq keyseq 1))
;; then execute it with funcall and clear prefix-arg in order to not
;; confuse subsequent commands
(progn
- ;; last-command-char is the char we want emacs to think was typed
+ ;; last-command-event is the char we want emacs to think was typed
;; last. If com is not nil, the viper-digit-argument command was
;; called from within viper-prefix-arg command, such as `d', `w',
;; etc., i.e., the user typed, say, d2. In this case, `com' would be
;; viper-escape-to-vi (which is indicated by the fact that the
;; current state is not vi-state), then `event-char' represents the
;; vi command to be executed (e.g., `d', `w', etc). Again,
- ;; last-command-char must make emacs believe that this is the command
+ ;; last-command-event must make emacs believe that this is the command
;; we typed.
(cond ((eq event-char 'return) (setq event-char ?\C-m))
((eq event-char 'delete) (setq event-char ?\C-?))
((eq event-char 'backspace) (setq event-char ?\C-h))
((eq event-char 'space) (setq event-char ?\ )))
- (setq last-command-char (or com event-char))
+ (setq last-command-event
+ (if (featurep 'xemacs)
+ (character-to-event (or com event-char))
+ (or com event-char)))
(setq func (viper-exec-form-in-vi
`(key-binding (char-to-string ,event-char))))
(funcall func prefix-arg)
;; as com is non-nil, this means that we have a command to execute
(if (viper-memq-char (car com) '(?r ?R))
- ;; execute apropriate region command.
+ ;; execute appropriate region command.
(let ((char (car com)) (com (cdr com)))
(setq prefix-arg (cons value com))
(if (viper= char ?r)
;; gg acts as G0
((equal (car com) ?g) (viper-goto-line 0))
(t (error "Viper bell")))))
-
+
(if cmd-to-exec-at-end
(progn
- (setq last-command-char char)
(setq last-command-event
(viper-copy-event
(if (featurep 'xemacs) (character-to-event char) char)))
(interactive "P")
(viper-leave-region-active)
(viper-prefix-arg-value
- last-command-char (if (consp arg) (cdr arg) nil)))
+ (viper-last-command-char) (if (consp arg) (cdr arg) nil)))
(defun viper-command-argument (arg)
"Accept a motion command as an argument."
(let ((viper-intermediate-command 'viper-command-argument))
(condition-case nil
(viper-prefix-arg-com
- last-command-char
+ (viper-last-command-char)
(cond ((null arg) nil)
((consp arg) (car arg))
((integerp arg) arg)
where `com' is the command to be re-executed, `val' is the
argument to `com', `ch' is a flag for repeat, and `reg' is optional;
if it exists, it is the name of the register for `com'.
-If the prefix argument, ARG, is non-nil, it is used instead of `val'."
+If the prefix argument ARG is non-nil, it is used instead of `val'."
(interactive "P")
(let ((save-point (point)) ; save point before repeating prev cmd
;; Pass along that we are repeating a destructive command
(message " `.' runs %s%s"
(concat "`" (viper-array-to-string keys) "'")
(viper-abbreviate-string
- (viper-cond-compile-for-xemacs-or-emacs
- (replace-in-string ; xemacs
- (cond ((characterp text) (char-to-string text))
- ((stringp text) text)
- (t ""))
- "\n" "^J")
- text ; emacs
- )
+ (if (featurep 'xemacs)
+ (replace-in-string ; xemacs
+ (cond ((characterp text) (char-to-string text))
+ ((stringp text) text)
+ (t ""))
+ "\n" "^J")
+ text ; emacs
+ )
max-text-len
" inserting `" "'" " ......."))
))
require-final-newline
;; add newline only if we actually edited buffer. otherwise it
;; might unintentionally modify binary buffers
- (buffer-modified-p)
+ (buffer-modified-p)
(not (viper-is-in-minibuffer))
(not buffer-read-only))
;; text property may be read-only
(funcall hook)
))
-;; Thie is a temp hook that uses free variables init-message and initial.
+;; This is a temp hook that uses free variables init-message and viper-initial.
;; A dirty feature, but it is the simplest way to have it do the right thing.
-;; The INIT-MESSAGE and INITIAL vars come from the scope set by
+;; The INIT-MESSAGE and VIPER-INITIAL vars come from the scope set by
;; viper-read-string-with-history
(defun viper-minibuffer-standard-hook ()
(if (stringp init-message)
(viper-tmp-insert-at-eob init-message))
- (if (stringp initial)
- (progn
- ;; don't wait if we have unread events or in kbd macro
- (or unread-command-events
- executing-kbd-macro
- (sit-for 840))
- (if (fboundp 'minibuffer-prompt-end)
- (delete-region (minibuffer-prompt-end) (point-max))
- (erase-buffer))
- (insert initial))))
+ (when (stringp viper-initial)
+ ;; don't wait if we have unread events or in kbd macro
+ (or unread-command-events
+ executing-kbd-macro
+ (sit-for 840))
+ (if (fboundp 'minibuffer-prompt-end)
+ (delete-region (minibuffer-prompt-end) (point-max))
+ (erase-buffer))
+ (insert viper-initial)))
(defsubst viper-minibuffer-real-start ()
(if (fboundp 'minibuffer-prompt-end)
"Exit minibuffer Viper way."
(interactive)
(let (command)
- (setq command (local-key-binding (char-to-string last-command-char)))
+ (setq command (local-key-binding (char-to-string (viper-last-command-char))))
(run-hooks 'viper-minibuffer-exit-hook)
(if command
(command-execute command)
(setq cmd
(key-binding (setq key (read-key-sequence nil))))
(cond ((eq cmd 'self-insert-command)
- (viper-cond-compile-for-xemacs-or-emacs
- (insert (events-to-keys key)) ; xemacs
- (insert key) ; emacs
- ))
+ (if (featurep 'xemacs)
+ (insert (events-to-keys key)) ; xemacs
+ (insert key) ; emacs
+ ))
((memq cmd '(exit-minibuffer viper-exit-minibuffer))
nil)
(t (command-execute cmd)))
\f
;;; Reading string with history
-(defun viper-read-string-with-history (prompt &optional initial
+(defun viper-read-string-with-history (prompt &optional viper-initial
history-var default keymap
init-message)
- ;; Read string, prompting with PROMPT and inserting the INITIAL
+ ;; Read string, prompting with PROMPT and inserting the VIPER-INITIAL
;; value. Uses HISTORY-VAR. DEFAULT is the default value to accept if the
;; input is an empty string.
;; Default value is displayed until the user types something in the
temp-msg)
(setq keymap (or keymap minibuffer-local-map)
- initial (or initial "")
+ viper-initial (or viper-initial "")
temp-msg (if default
(format "(default %s) " default)
""))
(setq viper-incomplete-ex-cmd nil)
(setq val (read-from-minibuffer prompt
- (concat temp-msg initial val padding)
+ (concat temp-msg viper-initial val padding)
keymap nil history-var))
(setq minibuffer-setup-hook nil
padding (viper-array-to-string (this-command-keys))
(defun viper-replace-state-exit-cmd ()
"Binding for keys that cause Replace state to switch to Vi or to Insert.
-These keys are ESC, RET, and LineFeed"
+These keys are ESC, RET, and LineFeed."
(interactive)
(if overwrite-mode ; if in replace mode invoked via 'R'
(viper-finish-R-mode)
(let (com)
(if (eq this-command 'viper-intercept-ESC-key)
(setq com 'viper-exit-insert-state)
- (viper-set-unread-command-events last-input-char)
+ (viper-set-unread-command-events last-input-event)
(setq com (key-binding (viper-read-key-sequence nil))))
(condition-case conds
(if (or (< (point) (viper-replace-start))
(> (point) (viper-replace-end)))
(let (viper-replace-minor-mode com)
- (viper-set-unread-command-events last-input-char)
+ (viper-set-unread-command-events last-input-event)
(setq com (key-binding (read-key-sequence nil)))
(condition-case conds
(command-execute com)
(defun viper-next-line-carefully (arg)
(condition-case nil
;; do not use forward-line! need to keep column
- (with-no-warnings (next-line arg))
+ (let ((line-move-visual nil))
+ (if (featurep 'emacs)
+ (with-no-warnings (next-line arg))
+ (next-line arg)))
(error nil)))
(com (viper-getCom arg)))
(if com (viper-move-marker-locally 'viper-com-point (point)))
;; do not use forward-line! need to keep column
- (with-no-warnings (next-line val))
+ (let ((line-move-visual nil))
+ (if (featurep 'emacs)
+ (with-no-warnings (next-line val))
+ (next-line val)))
(if viper-ex-style-motion
(if (and (eolp) (not (bolp))) (backward-char 1)))
(setq this-command 'next-line)
(com (viper-getCom arg)))
(if com (viper-move-marker-locally 'viper-com-point (point)))
;; do not use forward-line! need to keep column
- (with-no-warnings (previous-line val))
+ (let ((line-move-visual nil))
+ (if (featurep 'emacs)
+ (with-no-warnings (previous-line val))
+ (previous-line val)))
(if viper-ex-style-motion
(if (and (eolp) (not (bolp))) (backward-char 1)))
(setq this-command 'previous-line)
;; (which is called from viper-search-forward/backward/next). If the value of
;; viper-search-scroll-threshold is negative - don't scroll.
(defun viper-adjust-window ()
- (let ((win-height (viper-cond-compile-for-xemacs-or-emacs
- (window-displayed-height) ; xemacs
- ;; emacs
- (1- (window-height)) ; adjust for modeline
- ))
+ (let ((win-height (if (featurep 'xemacs)
+ (window-displayed-height)
+ (1- (window-height)))) ; adjust for modeline
(pt (point))
at-top-p at-bottom-p
min-scroll direction)
viper-search-scroll-threshold))
(move-to-window-line -1) ; bottom
(setq at-bottom-p
- (<= (count-lines pt (point)) viper-search-scroll-threshold))
- )
+ (<= (count-lines pt (point)) viper-search-scroll-threshold)))
(cond (at-top-p (setq min-scroll (1- viper-search-scroll-threshold)
direction 1))
(at-bottom-p (setq min-scroll (1+ viper-search-scroll-threshold)
(if (and (eolp) (not (bolp))) (forward-char -1))
(if (not (looking-at "[][(){}]"))
(setq anchor-point (point)))
- (save-excursion
- (beginning-of-line)
- (setq beg-lim (point))
- (end-of-line)
- (setq end-lim (point)))
+ (setq beg-lim (point-at-bol)
+ end-lim (point-at-eol))
(cond ((re-search-forward "[][(){}]" end-lim t)
(backward-char) )
((re-search-backward "[][(){}]" beg-lim t))
\f
;; searching
+(defun viper-insert-isearch-string ()
+ "Insert `isearch' last search string."
+ (interactive)
+ (when isearch-string (insert isearch-string)))
+
(defun viper-if-string (prompt)
(if (memq viper-intermediate-command
'(viper-command-argument viper-digit-argument viper-repeat))
(setq viper-this-command-keys (this-command-keys)))
- (let ((s (viper-read-string-with-history
+ (let* ((keymap (let ((keymap (copy-keymap minibuffer-local-map)))
+ (define-key keymap [(control ?s)] 'viper-insert-isearch-string)
+ keymap))
+ (s (viper-read-string-with-history
prompt
nil ; no initial
'viper-search-history
- (car viper-search-history))))
+ (car viper-search-history)
+ keymap)))
(if (not (string= s ""))
(setq viper-s-string s))))
(defun viper-toggle-search-style (arg)
"Toggle the value of viper-case-fold-search/viper-re-search.
Without prefix argument, will ask which search style to toggle. With prefix
-arg 1,toggles viper-case-fold-search; with arg 2 toggles viper-re-search.
+arg 1, toggles viper-case-fold-search; with arg 2 toggles viper-re-search.
Although this function is bound to \\[viper-toggle-search-style], the most
convenient way to use it is to bind `//' to the macro
"///" 'vi-state
[2 (meta x) v i p e r - t o g g l e - s e a r c h - s t y l e return]
scope)
+ ;; XEmacs has no called-interactively-p
+ ;; (if (called-interactively-p 'interactive)
(if (interactive-p)
(message
"// and /// now toggle case-sensitivity and regexp search")))
"%%%" 'vi-state
[(meta x) v i p e r - t o g g l e - p a r s e - s e x p - i g n o r e - c o m m e n t s return]
't)
+ ;; XEmacs has no called-interactively-p. And interactive-p
+ ;; works fine here.
+ ;; (if (called-interactively-p 'interactive)
(if (interactive-p)
(message
"%%%%%% now toggles whether comments should be parsed for matching parentheses")))
"///" 'emacs-state
[2 (meta x) v i p e r - t o g g l e - s e a r c h - s t y l e return]
(or arg-majormode major-mode))
+ ;; called-interactively-p does not work for
+ ;; XEmacs. interactive-p is ok here.
+ ;; (if (called-interactively-p 'interactive)
(if (interactive-p)
(message
"// and /// now toggle case-sensitivity and regexp search.")))
(if (not (equal start-point (point)))
(push-mark start-point t)))
(search-failed
- (if (and (not fail-if-not-found) viper-search-wrap-around-t)
+ (if (and (not fail-if-not-found) viper-search-wrap-around)
(progn
(message "Search wrapped around BOTTOM of buffer")
(goto-char (point-min))
(if (not (equal start-point (point)))
(push-mark start-point t)))
(search-failed
- (if (and (not fail-if-not-found) viper-search-wrap-around-t)
+ (if (and (not fail-if-not-found) viper-search-wrap-around)
(progn
(message "Search wrapped around TOP of buffer")
(goto-char (point-max))
(setq viper-use-register nil)))
(if (and (bolp) viper-ex-style-editing)
(ding))
- (delete-backward-char val t)))
+ (delete-char (- val) t)))
(defun viper-del-backward-char-in-insert ()
(if (and viper-ex-style-editing (bolp))
(beep 1)
;; don't put on kill ring
- (delete-backward-char 1 nil)))
+ (delete-char -1 nil)))
(defun viper-del-backward-char-in-replace ()
"Delete one character in replace mode.
If `viper-delete-backwards-in-replace' is t, then DEL key actually deletes
-charecters. If it is nil, then the cursor just moves backwards, similarly
+characters. If it is nil, then the cursor just moves backwards, similarly
to Vi. The variable `viper-ex-style-editing', if t, doesn't let the
cursor move past the beginning of line."
(interactive)
(cond (viper-delete-backwards-in-replace
(cond ((not (bolp))
;; don't put on kill ring
- (delete-backward-char 1 nil))
+ (delete-char -1 nil))
(viper-ex-style-editing
(beep 1))
((bobp)
(beep 1))
(t
;; don't put on kill ring
- (delete-backward-char 1 nil))))
+ (delete-char -1 nil))))
(viper-ex-style-editing
(if (bolp)
(beep 1)
(insert-before-markers "@") ; put placeholder after the TAB
(untabify (viper-replace-start) (point))
;; del @, don't put on kill ring
- (delete-backward-char 1)
+ (delete-char -1)
(viper-set-replace-overlay-glyphs
viper-replace-region-start-delimiter
(indent-to (+ (current-column) viper-shift-width)))
(defun viper-backward-indent ()
- "Backtab, C-d in VI"
+ "Backtab, `C-d' in Vi."
(interactive)
(if viper-cted
(let ((p (point)) (c (current-column)) bol (indent t))
(progn
(if (eq ?^ (preceding-char))
(setq viper-preserve-indent t))
- (delete-backward-char 1)
+ (delete-char -1)
(setq p (point))
(setq indent nil)))
- (save-excursion
- (beginning-of-line)
- (setq bol (point)))
+ (setq bol (point-at-bol))
(if (re-search-backward "[^ \t]" bol 1) (forward-char))
(delete-region (point) p)
(if indent
viper-InvalidRegister reg)))))
(defun viper-brac-function (arg)
- "Function called by \[, the brac. View textmarkers and call \[\["
+ "Function called by \[, the brac. View textmarkers and call \[\[."
(interactive "P")
(let ((reg (read-char)))
(cond ((viper= ?\[ reg)
(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)
(if (re-search-backward "[^ \t]" nil t)
- (progn
- (beginning-of-line)
- (setq s (point))))
+ (setq s (point-at-bol)))
(goto-char pos)
(forward-line 1)
(if (re-search-forward "[^ \t]" nil t)
(setq viper-no-multiple-ESC t
viper-re-search t
viper-vi-style-in-minibuffer t
- viper-search-wrap-around-t t
+ viper-search-wrap-around t
viper-electric-mode nil
viper-want-emacs-keys-in-vi nil
viper-want-emacs-keys-in-insert nil))
;; if ENFORCE-BUFFER is not nil, error if CHAR is a marker in another buffer
(defun viper-register-to-point (char &optional enforce-buffer)
- "Like jump-to-register, but switches to another buffer in another window."
+ "Like `jump-to-register', but switches to another buffer in another window."
(interactive "cViper register to point: ")
(let ((val (get-register char)))
(cond
------------------------------
Before reporting a bug, please verify that it is related to Viper, and is
-not cause by other packages you are using.
+not caused by other packages you are using.
Don't report compilation warnings, unless you are certain that there is a
problem. These warnings are normal and unavoidable.
-;; arch-tag: 739a6450-5fda-44d0-88b0-325053d888c2
;;; viper-cmd.el ends here