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):
"///" '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)
"%%%" '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))))
"///" '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)
;; 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 ()
(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))
(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
(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)
(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)))
(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))))
(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)
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*"
)))
+(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
(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
(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))
(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 "%")
(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")))
(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
(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)
(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
))
+(declare-function viper-backward-char-carefully "viper-cmd" (&optional arg))
+
;; Ex global command
;; This is executed in response to:
;; :global "pattern" ex-command
(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))
(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))))
(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>
(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)