emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] /srv/bzr/emacs/trunk r112664: Small viper clean-up


From: Glenn Morris
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r112664: Small viper clean-up
Date: Tue, 21 May 2013 20:21:30 -0700
User-agent: Bazaar (2.6b2)

------------------------------------------------------------
revno: 112664
committer: Glenn Morris <address@hidden>
branch nick: trunk
timestamp: Tue 2013-05-21 20:21:30 -0700
message:
  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.
modified:
  lisp/ChangeLog
  lisp/emulation/viper-cmd.el
  lisp/emulation/viper-ex.el
  lisp/emulation/viper-macs.el
  lisp/emulation/viper-mous.el
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2013-05-22 03:17:22 +0000
+++ b/lisp/ChangeLog    2013-05-22 03:21:30 +0000
@@ -1,5 +1,24 @@
 2013-05-22  Glenn Morris  <address@hidden>
 
+       * 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):

=== modified file 'lisp/emulation/viper-cmd.el'
--- a/lisp/emulation/viper-cmd.el       2013-03-12 02:08:21 +0000
+++ b/lisp/emulation/viper-cmd.el       2013-05-22 03:21:30 +0000
@@ -3781,9 +3781,9 @@
               "///" '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 @@
             "%%%" '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 @@
             "///" '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 @@
 
 ;; 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 @@
   (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 @@
        (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

=== modified file 'lisp/emulation/viper-ex.el'
--- a/lisp/emulation/viper-ex.el        2013-01-01 09:11:05 +0000
+++ b/lisp/emulation/viper-ex.el        2013-05-22 03:21:30 +0000
@@ -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 @@
               (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 @@
               (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 @@
       (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 @@
            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 @@
       )))
 
 
+(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 @@
                    (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 @@
                 (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 @@
       (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 @@
                                  (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 @@
   (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 @@
       (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 @@
        (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 @@
     ))
 
 
+(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 @@
     (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 @@
   (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 @@
     (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 @@
     (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)

=== modified file 'lisp/emulation/viper-macs.el'
--- a/lisp/emulation/viper-macs.el      2013-01-01 09:11:05 +0000
+++ b/lisp/emulation/viper-macs.el      2013-05-22 03:21:30 +0000
@@ -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 @@
 
 ;;; Code
 
+(declare-function viper-change-state-to-insert "viper-cmd" ())
+
 ;; Ex map command
 (defun ex-map ()
   (let ((mod-char "")
@@ -277,6 +274,8 @@
     ))
 
 
+(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

=== modified file 'lisp/emulation/viper-mous.el'
--- a/lisp/emulation/viper-mous.el      2013-01-01 09:11:05 +0000
+++ b/lisp/emulation/viper-mous.el      2013-05-22 03:21:30 +0000
@@ -35,16 +35,9 @@
 (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)
-      ))
+(require 'viper-util)
 ;; end pacifier
 
-(require 'viper-util)
-
 
 (defgroup viper-mouse nil
   "Support for Viper special mouse-bound commands."
@@ -140,6 +133,10 @@
     (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 @@
          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.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]