mirror of
https://git.savannah.gnu.org/git/emacs.git
synced 2025-01-20 18:17:20 +00:00
Small viper clean-up
* lisp/emulation/viper-cmd.el (viper-set-searchstyle-toggling-macros) (viper-set-parsing-style-toggling-macro) (viper-set-emacs-state-searchstyle-macros): Use called-interactively-p on Emacs. (viper-looking-back): Make it an obsolete alias. Update callers. * lisp/emulation/viper-ex.el: Load viper-keym, not viper-cmd. Use looking-back rather than viper-looking-back. (viper-tmp-insert-at-eob, viper-enlarge-region) (viper-read-string-with-history, viper-register-to-point) (viper-append-to-register, viper-change-state-to-vi) (viper-backward-char-carefully, viper-forward-char-carefully) (viper-Put-back, viper-put-back, viper-add-newline-at-eob-if-necessary) (viper-change-state-to-emacs): Declare. * lisp/emulation/viper-macs.el: Load viper-mous, viper-ex, not viper-cmd. (viper-change-state-to-insert, viper-change-state-to-vi): Declare. * lisp/emulation/viper-mous.el: Do not load viper-cmd. (viper-backward-char-carefully, viper-forward-char-carefully) (viper-forward-word, viper-adjust-window): Declare.
This commit is contained in:
parent
5f70c1698a
commit
9c6906f675
@ -1,5 +1,24 @@
|
||||
2013-05-22 Glenn Morris <rgm@gnu.org>
|
||||
|
||||
* emulation/viper-cmd.el (viper-set-searchstyle-toggling-macros)
|
||||
(viper-set-parsing-style-toggling-macro)
|
||||
(viper-set-emacs-state-searchstyle-macros):
|
||||
Use called-interactively-p on Emacs.
|
||||
(viper-looking-back): Make it an obsolete alias. Update callers.
|
||||
* emulation/viper-ex.el: Load viper-keym, not viper-cmd.
|
||||
Use looking-back rather than viper-looking-back.
|
||||
(viper-tmp-insert-at-eob, viper-enlarge-region)
|
||||
(viper-read-string-with-history, viper-register-to-point)
|
||||
(viper-append-to-register, viper-change-state-to-vi)
|
||||
(viper-backward-char-carefully, viper-forward-char-carefully)
|
||||
(viper-Put-back, viper-put-back, viper-add-newline-at-eob-if-necessary)
|
||||
(viper-change-state-to-emacs): Declare.
|
||||
* emulation/viper-macs.el: Load viper-mous, viper-ex, not viper-cmd.
|
||||
(viper-change-state-to-insert, viper-change-state-to-vi): Declare.
|
||||
* emulation/viper-mous.el: Do not load viper-cmd.
|
||||
(viper-backward-char-carefully, viper-forward-char-carefully)
|
||||
(viper-forward-word, viper-adjust-window): Declare.
|
||||
|
||||
* vc/ediff.el (ediff-version): Use called-interactively-p on Emacs.
|
||||
|
||||
* progmodes/idlw-help.el (idlwave-help-fontify):
|
||||
|
@ -3781,9 +3781,9 @@ If MAJOR-MODE is set, set the macros only in that major mode."
|
||||
"///" '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)
|
||||
(if (if (featurep 'xemacs)
|
||||
(interactive-p)
|
||||
(called-interactively-p 'interactive))
|
||||
(message
|
||||
"// and /// now toggle case-sensitivity and regexp search")))
|
||||
(viper-unrecord-kbd-macro "//" 'vi-state)
|
||||
@ -3806,10 +3806,9 @@ With a prefix argument, unsets the macro."
|
||||
"%%%" '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)
|
||||
(if (if (featurep 'xemacs)
|
||||
(interactive-p)
|
||||
(called-interactively-p 'interactive))
|
||||
(message
|
||||
"%%%%%% now toggles whether comments should be parsed for matching parentheses")))
|
||||
(viper-unrecord-kbd-macro "%%%" 'vi-state))))
|
||||
@ -3838,10 +3837,9 @@ the macros are set in the current major mode.
|
||||
"///" '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)
|
||||
(if (if (featurep 'xemacs)
|
||||
(interactive-p)
|
||||
(called-interactively-p 'interactive))
|
||||
(message
|
||||
"// and /// now toggle case-sensitivity and regexp search.")))
|
||||
(viper-unrecord-kbd-macro "//" 'emacs-state)
|
||||
@ -4608,10 +4606,7 @@ One can use `` and '' to temporarily jump 1 step back."
|
||||
|
||||
;; Input Mode Indentation
|
||||
|
||||
;; Returns t, if the string before point matches the regexp STR.
|
||||
(defsubst viper-looking-back (str)
|
||||
(and (save-excursion (re-search-backward str nil t))
|
||||
(= (point) (match-end 0))))
|
||||
(define-obsolete-function-alias 'viper-looking-back 'looking-back "24.4")
|
||||
|
||||
|
||||
(defun viper-forward-indent ()
|
||||
@ -4625,7 +4620,7 @@ One can use `` and '' to temporarily jump 1 step back."
|
||||
(interactive)
|
||||
(if viper-cted
|
||||
(let ((p (point)) (c (current-column)) bol (indent t))
|
||||
(if (viper-looking-back "[0^]")
|
||||
(if (looking-back "[0^]")
|
||||
(progn
|
||||
(if (eq ?^ (preceding-char))
|
||||
(setq viper-preserve-indent t))
|
||||
@ -4637,7 +4632,7 @@ One can use `` and '' to temporarily jump 1 step back."
|
||||
(delete-region (point) p)
|
||||
(if indent
|
||||
(indent-to (- c viper-shift-width)))
|
||||
(if (or (bolp) (viper-looking-back "[^ \t]"))
|
||||
(if (or (bolp) (looking-back "[^ \t]"))
|
||||
(setq viper-cted nil)))))
|
||||
|
||||
;; do smart indent
|
||||
|
@ -39,14 +39,7 @@
|
||||
(defvar viper-case-fold-search)
|
||||
(defvar explicit-shell-file-name)
|
||||
(defvar compile-command)
|
||||
|
||||
;; loading happens only in non-interactive compilation
|
||||
;; in order to spare non-viperized emacs from being viperized
|
||||
(if noninteractive
|
||||
(eval-when-compile
|
||||
(if (not (featurep 'viper-cmd))
|
||||
(require 'viper-cmd))
|
||||
))
|
||||
(require 'viper-keym)
|
||||
;; end pacifier
|
||||
|
||||
(require 'viper-util)
|
||||
@ -462,7 +455,7 @@ reversed."
|
||||
(while (and (not (eolp)) cont)
|
||||
;;(re-search-forward "[^/]*/")
|
||||
(re-search-forward "[^/]*\\(/\\|\n\\)")
|
||||
(if (not (viper-looking-back "[^\\\\]\\(\\\\\\\\\\)*\\\\/"))
|
||||
(if (not (looking-back "[^\\\\]\\(\\\\\\\\\\)*\\\\/"))
|
||||
(setq cont nil))))
|
||||
(backward-char 1)
|
||||
(setq ex-token (buffer-substring (point) (mark t)))
|
||||
@ -475,7 +468,7 @@ reversed."
|
||||
(while (and (not (eolp)) cont)
|
||||
;;(re-search-forward "[^\\?]*\\?")
|
||||
(re-search-forward "[^\\?]*\\(\\?\\|\n\\)")
|
||||
(if (not (viper-looking-back "[^\\\\]\\(\\\\\\\\\\)*\\\\\\?"))
|
||||
(if (not (looking-back "[^\\\\]\\(\\\\\\\\\\)*\\\\\\?"))
|
||||
(setq cont nil))
|
||||
(backward-char 1)
|
||||
(if (not (looking-at "\n")) (forward-char 1))))
|
||||
@ -553,11 +546,13 @@ reversed."
|
||||
(setq viper-ex-work-buf (get-buffer-create viper-ex-work-buf-name))
|
||||
(set-buffer viper-ex-work-buf)
|
||||
(goto-char (point-max)))
|
||||
(cond ((viper-looking-back quit-regex1) (exit-minibuffer))
|
||||
((viper-looking-back stay-regex) (insert " "))
|
||||
((viper-looking-back quit-regex2) (exit-minibuffer))
|
||||
(cond ((looking-back quit-regex1) (exit-minibuffer))
|
||||
((looking-back stay-regex) (insert " "))
|
||||
((looking-back quit-regex2) (exit-minibuffer))
|
||||
(t (insert " ")))))
|
||||
|
||||
(declare-function viper-tmp-insert-at-eob "viper-cmd" (msg))
|
||||
|
||||
;; complete Ex command
|
||||
(defun ex-cmd-complete ()
|
||||
(interactive)
|
||||
@ -568,14 +563,14 @@ reversed."
|
||||
save-pos (point)))
|
||||
|
||||
(if (or (= dist 0)
|
||||
(viper-looking-back "\\([ \t]*['`][ \t]*[a-z]*\\)")
|
||||
(viper-looking-back
|
||||
(looking-back "\\([ \t]*['`][ \t]*[a-z]*\\)")
|
||||
(looking-back
|
||||
"^[ \t]*[a-zA-Z!=>&~][ \t]*[/?]*[ \t]+[a-zA-Z!=>&~]+"))
|
||||
;; Preceding characters are not the ones allowed in an Ex command
|
||||
;; or we have typed past command name.
|
||||
;; Note: we didn't do parsing, so there can be surprises.
|
||||
(if (or (viper-looking-back "[a-zA-Z!=>&~][ \t]*[/?]*[ \t]*")
|
||||
(viper-looking-back "\\([ \t]*['`][ \t]*[a-z]*\\)")
|
||||
(if (or (looking-back "[a-zA-Z!=>&~][ \t]*[/?]*[ \t]*")
|
||||
(looking-back "\\([ \t]*['`][ \t]*[a-z]*\\)")
|
||||
(looking-at "[^ \t\n\C-m]"))
|
||||
nil
|
||||
(with-output-to-temp-buffer "*Completions*"
|
||||
@ -605,6 +600,11 @@ reversed."
|
||||
)))
|
||||
|
||||
|
||||
(declare-function viper-enlarge-region "viper-cmd" (beg end))
|
||||
(declare-function viper-read-string-with-history "viper-cmd"
|
||||
(prompt &optional viper-initial history-var
|
||||
default keymap init-message))
|
||||
|
||||
;; Read Ex commands
|
||||
;; ARG is a prefix argument. If given, the ex command runs on the region
|
||||
;;(without the user having to specify the address :a,b
|
||||
@ -746,7 +746,7 @@ reversed."
|
||||
(if (member ex-token '("global" "vglobal"))
|
||||
(error "Missing closing delimiter for global regexp")
|
||||
(goto-char (point-max))))
|
||||
(if (not (viper-looking-back
|
||||
(if (not (looking-back
|
||||
(format "[^\\\\]\\(\\\\\\\\\\)*\\\\%c" c)))
|
||||
(setq cont nil)
|
||||
;; we are at an escaped delimiter: unescape it and continue
|
||||
@ -826,6 +826,9 @@ reversed."
|
||||
(if ans (setq address ans))))))
|
||||
address))
|
||||
|
||||
(declare-function viper-register-to-point "viper-cmd"
|
||||
(char &optional enforce-buffer))
|
||||
|
||||
;; Returns an address as a point
|
||||
(defun viper-get-ex-address-subr (old-address dot)
|
||||
(let ((address nil))
|
||||
@ -960,7 +963,7 @@ reversed."
|
||||
(while (re-search-forward "%\\|#" nil t)
|
||||
(let ((data (match-data))
|
||||
(char (buffer-substring (match-beginning 0) (match-end 0))))
|
||||
(if (viper-looking-back (concat "\\\\" char))
|
||||
(if (looking-back (concat "\\\\" char))
|
||||
(replace-match char)
|
||||
(store-match-data data)
|
||||
(if (string= char "%")
|
||||
@ -986,7 +989,7 @@ reversed."
|
||||
(get-buffer-create viper-ex-work-buf-name))
|
||||
(skip-chars-forward " \t")
|
||||
(if (looking-at "!")
|
||||
(if (and (not (viper-looking-back "[ \t]"))
|
||||
(if (and (not (looking-back "[ \t]"))
|
||||
;; read doesn't have a corresponding :r! form, so ! is
|
||||
;; immediately interpreted as a shell command.
|
||||
(not (string= ex-token "read")))
|
||||
@ -1063,7 +1066,7 @@ reversed."
|
||||
(cond ((ex-cmd-accepts-multiple-files-p ex-token) (exit-minibuffer))
|
||||
;; apparently the argument to an Ex command is
|
||||
;; supposed to be a shell command
|
||||
((viper-looking-back "^[ \t]*!.*")
|
||||
((looking-back "^[ \t]*!.*")
|
||||
(setq ex-cmdfile t)
|
||||
(insert " "))
|
||||
(t
|
||||
@ -1202,6 +1205,8 @@ reversed."
|
||||
(forward-line 1))
|
||||
(insert (current-kill 0))))
|
||||
|
||||
(declare-function viper-append-to-register "viper-cmd" (reg start end))
|
||||
|
||||
;; Ex delete command
|
||||
(defun ex-delete ()
|
||||
(viper-default-ex-addresses)
|
||||
@ -1238,6 +1243,7 @@ reversed."
|
||||
(kill-region (point) (mark t))))))
|
||||
|
||||
|
||||
(declare-function viper-change-state-to-vi "viper-cmd" ())
|
||||
|
||||
;; Ex edit command
|
||||
;; In Viper, `e' and `e!' behave identically. In both cases, the user is
|
||||
@ -1308,6 +1314,8 @@ reversed."
|
||||
))
|
||||
|
||||
|
||||
(declare-function viper-backward-char-carefully "viper-cmd" (&optional arg))
|
||||
|
||||
;; Ex global command
|
||||
;; This is executed in response to:
|
||||
;; :global "pattern" ex-command
|
||||
@ -1416,6 +1424,8 @@ reversed."
|
||||
(goto-char (1- point))
|
||||
(beginning-of-line)))
|
||||
|
||||
(declare-function viper-forward-char-carefully "viper-cmd" (&optional arg))
|
||||
|
||||
(defun ex-line-subr (com beg end)
|
||||
(cond ((string= com "join")
|
||||
(goto-char (min beg end))
|
||||
@ -1566,6 +1576,9 @@ reversed."
|
||||
(message "Autosaving all buffers that need to be saved...")
|
||||
(do-auto-save t))
|
||||
|
||||
(declare-function viper-Put-back "viper-cmd" (arg))
|
||||
(declare-function viper-put-back "viper-cmd" (arg))
|
||||
|
||||
;; Ex put
|
||||
(defun ex-put ()
|
||||
(let ((point (if (null ex-addresses) (point) (car ex-addresses))))
|
||||
@ -1589,6 +1602,8 @@ reversed."
|
||||
(kill-buffer (current-buffer))))
|
||||
|
||||
|
||||
(declare-function viper-add-newline-at-eob-if-necessary "viper-cmd" ())
|
||||
|
||||
;; Ex read command
|
||||
;; ex-read doesn't support wildcards, because file completion is a better
|
||||
;; mechanism. We also don't support # and % (except in :r <shell-command>
|
||||
@ -1975,6 +1990,8 @@ Please contact your system administrator. "
|
||||
(beginning-of-line)
|
||||
(if opt-c (message "done"))))
|
||||
|
||||
(declare-function viper-change-state-to-emacs "viper-cmd" ())
|
||||
|
||||
;; Ex tag command
|
||||
(defun ex-tag ()
|
||||
(let (tag)
|
||||
|
@ -31,13 +31,8 @@
|
||||
(defvar viper-custom-file-name)
|
||||
(defvar viper-current-state)
|
||||
(defvar viper-fast-keyseq-timeout)
|
||||
|
||||
;; loading happens only in non-interactive compilation
|
||||
;; in order to spare non-viperized emacs from being viperized
|
||||
(if noninteractive
|
||||
(eval-when-compile
|
||||
(require 'viper-cmd)
|
||||
))
|
||||
(require 'viper-mous)
|
||||
(require 'viper-ex)
|
||||
;; end pacifier
|
||||
|
||||
(require 'viper-util)
|
||||
@ -83,6 +78,8 @@ a key is a symbol, e.g., `a', `\\1', `f2', etc., or a list, e.g.,
|
||||
|
||||
;;; Code
|
||||
|
||||
(declare-function viper-change-state-to-insert "viper-cmd" ())
|
||||
|
||||
;; Ex map command
|
||||
(defun ex-map ()
|
||||
(let ((mod-char "")
|
||||
@ -277,6 +274,8 @@ a key is a symbol, e.g., `a', `\\1', `f2', etc., or a list, e.g.,
|
||||
))
|
||||
|
||||
|
||||
(declare-function viper-change-state-to-vi "viper-cmd" ())
|
||||
|
||||
;; Terminate a Vi kbd macro.
|
||||
;; optional argument IGNORE, if t, indicates that we are dealing with an
|
||||
;; existing macro that needs to be registered, but there is no need to
|
||||
|
@ -35,15 +35,8 @@
|
||||
(defvar viper-s-string)
|
||||
(defvar viper-re-search)
|
||||
|
||||
;; loading happens only in non-interactive compilation
|
||||
;; in order to spare non-viperized emacs from being viperized
|
||||
(if noninteractive
|
||||
(eval-when-compile
|
||||
(require 'viper-cmd)
|
||||
))
|
||||
;; end pacifier
|
||||
|
||||
(require 'viper-util)
|
||||
;; end pacifier
|
||||
|
||||
|
||||
(defgroup viper-mouse nil
|
||||
@ -140,6 +133,10 @@ considered related."
|
||||
(posn-point (event-start click))))
|
||||
|
||||
|
||||
|
||||
(declare-function viper-backward-char-carefully "viper-cmd" (&optional arg))
|
||||
(declare-function viper-forward-char-carefully "viper-cmd" (&optional arg))
|
||||
|
||||
(defun viper-surrounding-word (count click-count)
|
||||
"Returns word surrounding point according to a heuristic.
|
||||
COUNT indicates how many regions to return.
|
||||
@ -335,6 +332,8 @@ See `viper-surrounding-word' for the definition of a word in this case."
|
||||
viper-current-click-count
|
||||
0))))
|
||||
|
||||
(declare-function viper-forward-word "viper-cmd" (arg))
|
||||
(declare-function viper-adjust-window "viper-cmd" ())
|
||||
|
||||
(defun viper-mouse-click-search-word (click arg)
|
||||
"Find the word clicked or double-clicked on. Word may be in another window.
|
||||
|
Loading…
Reference in New Issue
Block a user