]> git.eshelyaron.com Git - emacs.git/commitdiff
2001-03-17 Michael Kifer <kifer@cs.sunysb.edu>
authorMichael Kifer <kifer@cs.stonybrook.edu>
Sat, 17 Mar 2001 18:59:39 +0000 (18:59 +0000)
committerMichael Kifer <kifer@cs.stonybrook.edu>
Sat, 17 Mar 2001 18:59:39 +0000 (18:59 +0000)
* ediff-util.el: Copyright years.
(ediff-choose-syntax-table): New function.
(ediff-setup): Use ediff-choose-syntax-table.

* ediff-init.el (ediff-with-syntax-table): New macro, uses
with-syntax-table.

* ediff.el: Date of last update, copyright years.

* ediff-wind (ediff-setup-control-frame): Nill->nil.

* viper-ex.el (ex-token-list,ex-cmd-execute): Revamped, courtesy
of Scott Bronson.
(ex-cmd-assoc,ex-cmd-one-letr): New functions.
(viper-check-sub,viper-get-ex-command,viper-execute-ex-command):
Deleted functions.
(viper-get-ex-com-subr,viper-ex,ex-mark): Changed to use the new
ex-token-list.

* viper-util.el: Spaces, indentation.

* viper.el: Changed version, modification time.

lisp/ChangeLog
lisp/ediff-diff.el
lisp/ediff-init.el
lisp/ediff-util.el
lisp/ediff-wind.el
lisp/ediff.el
lisp/emulation/viper-ex.el
lisp/emulation/viper-util.el
lisp/emulation/viper.el
man/ChangeLog
man/viper.texi

index c5c679c709830ec8c3634d2718af484c0c10e8c3..1514d34ad493609846702619c9ac133353a04561 100644 (file)
@@ -1,3 +1,28 @@
+2001-03-17  Michael Kifer  <kifer@cs.sunysb.edu>
+       
+       * ediff-util.el: Copyright years.
+       (ediff-choose-syntax-table): New function.
+       (ediff-setup): Use ediff-choose-syntax-table.
+       
+       * ediff-init.el (ediff-with-syntax-table): New macro, uses
+       with-syntax-table.
+       
+       * ediff.el: Date of last update, copyright years.
+       
+       * ediff-wind (ediff-setup-control-frame): Nill->nil.
+       
+       * viper-ex.el (ex-token-list,ex-cmd-execute): Revamped, courtesy
+       of Scott Bronson.
+       (ex-cmd-assoc,ex-cmd-one-letr): New functions.
+       (viper-check-sub,viper-get-ex-command,viper-execute-ex-command):
+       Deleted functions.
+       (viper-get-ex-com-subr,viper-ex,ex-mark): Changed to use the new
+       ex-token-list.
+       
+       * viper-util.el: Spaces, indentation.
+       
+       * viper.el: Changed version, modification time.
+       
 2001-03-16  John Wiegley  <johnw@gnu.org>
        
        * (timeclock-workday-remaining): Check whether `discrep' is
index 3bf2277d6be7c0990e86debb365fb118cd6a28e5..79b8b539de94655d926209e28ac4a0bc9e346c57 100644 (file)
@@ -1256,11 +1256,15 @@ arguments to `skip-chars-forward'."
 
 
 (defun ediff-wordify (beg end in-buffer out-buffer &optional control-buf)
-  (let (inbuf-syntax-tbl sv-point string)
+  (let (inbuf-syntax-tbl sv-point diff-string)
     (save-excursion
      (set-buffer in-buffer)
-     (setq inbuf-syntax-tbl (syntax-table))
-     (setq string (buffer-substring-no-properties beg end))
+     (setq inbuf-syntax-tbl
+          (if control-buf
+              (ediff-with-current-buffer control-buf
+                ediff-syntax-table)
+            (syntax-table)))
+     (setq diff-string (buffer-substring-no-properties beg end))
 
      (set-buffer out-buffer)
      ;; Make sure that temp buff syntax table is the same a the original buf
@@ -1268,18 +1272,18 @@ arguments to `skip-chars-forward'."
      ;; ediff-forward-word depends on the syntax classes of characters.
      (set-syntax-table inbuf-syntax-tbl)
      (erase-buffer)
-     (insert string)
+     (insert diff-string)
      (goto-char (point-min))
      (skip-chars-forward ediff-whitespace)
      (delete-region (point-min) (point))
      
      (while (not (eobp))
-       ;; eval incontrol buf to let user create local versions for
+       ;; eval in control buf to let user create local versions for
        ;; different invocations
        (if control-buf
           (funcall 
-           (ediff-with-current-buffer 
-               control-buf ediff-forward-word-function))
+           (ediff-with-current-buffer control-buf
+             ediff-forward-word-function))
         (funcall ediff-forward-word-function))
        (setq sv-point (point))
        (skip-chars-forward ediff-whitespace)
@@ -1300,16 +1304,17 @@ arguments to `skip-chars-forward'."
 
 
 ;; goto word #n starting at current position in buffer `buf'
-;; For ediff, a word is either a string of a-z,A-Z, incl `-' and `_';
-;; or a string of other non-blanks. A blank is a \n\t\f
+;; For ediff, a word is determined by ediff-forward-word-function
 ;; If `flag' is non-nil, goto the end of the n-th word.
 (defun ediff-goto-word (n buf &optional flag)
   ;; remember val ediff-forward-word-function has in ctl buf
-  (let ((fwd-word-fun ediff-forward-word-function))
+  (let ((fwd-word-fun ediff-forward-word-function)
+       (syntax-tbl ediff-syntax-table))
     (ediff-with-current-buffer buf
       (skip-chars-forward ediff-whitespace)
       (while (> n 1)
-       (funcall fwd-word-fun)
+       (ediff-with-syntax-table syntax-tbl
+           (funcall fwd-word-fun))
        (skip-chars-forward ediff-whitespace)
        (setq n (1- n)))
       (if (and flag (> n 0))
index f984ac2fa30bd8f8c72285b7bf05056a570e2bc7..da6ac26a738f3abbd11e6964571fd14c9a1c009d 100644 (file)
@@ -519,6 +519,11 @@ See the documentation string of `ediff-focus-on-regexp-matches' for details.")
 ;; where some buffer-objects may be missing.
 (ediff-defvar-local ediff-killed-diffs-alist nil "")
 
+;; Syntax table to use in ediff-forward-word-function
+;; This is chosen by a heuristic. The important thing is for all buffers to
+;; have the same syntax table. Which is not too important.
+(ediff-defvar-local ediff-syntax-table nil "")
+
 
 ;; Highlighting
 (defcustom ediff-before-flag-bol (if ediff-xemacs-p (make-glyph "->>") "->>")
@@ -1749,6 +1754,24 @@ Unless optional argument INPLACE is non-nil, return a new string."
     fname))
 
 
+(if (fboundp 'with-syntax-table)
+    (fset 'ediff-with-syntax-table 'with-syntax-table)
+  ;; stolen from subr.el in emacs 21
+  (defmacro ediff-with-syntax-table (table &rest body)
+    (let ((old-table (make-symbol "table"))
+         (old-buffer (make-symbol "buffer")))
+      `(let ((,old-table (syntax-table))
+            (,old-buffer (current-buffer)))
+        (unwind-protect
+            (progn
+              (set-syntax-table (copy-syntax-table ,table))
+              ,@body)
+          (save-current-buffer
+            (set-buffer ,old-buffer)
+            (set-syntax-table ,old-table)))))))
+
+
+
 ;;; Local Variables:
 ;;; eval: (put 'ediff-defvar-local 'lisp-indent-hook 'defun)
 ;;; eval: (put 'ediff-with-current-buffer 'lisp-indent-hook 1)
index dff95ce4cb8322d5cfecbddf7b8057480d6be1c4..c26162715c7988ec73ce42a94e99c8d9c2aa6082 100644 (file)
@@ -1,6 +1,6 @@
 ;;; ediff-util.el --- the core commands and utilities of ediff
 
-;; Copyright (C) 1994, 1995, 1996, 1997, 2001 Free Software Foundation, Inc.
+;; Copyright (C) 1994, 95, 96, 97, 98, 99, 2000, 01 Free Software Foundation, Inc.
 
 ;; Author: Michael Kifer <kifer@cs.sunysb.edu>
 
@@ -354,6 +354,8 @@ to invocation.")
            ediff-buffer-B buffer-B
            ediff-buffer-C buffer-C
            ediff-control-buffer control-buffer)
+
+      (ediff-choose-syntax-table)
           
       (setq ediff-control-buffer-suffix
            (if (string-match "<[0-9]*>" control-buffer-name)
@@ -3692,7 +3694,26 @@ Mail anyway? (y or n) ")
          (ediff-with-current-buffer ctl-buf
            (ediff-recenter 'no-rehighlight))))
     ))
-                            
+
+
+;; Find an appropriate syntax table for everyone to use
+;; If buffer B is not fundamental or text mode, use its syntax table
+;; Otherwise, use buffer B's.
+;; The syntax mode is used in ediff-forward-word-function
+;; The important thing is that every buffer should use the same syntax table
+;; during the refinement operation
+(defun ediff-choose-syntax-table ()
+  (setq ediff-syntax-table
+       (ediff-with-current-buffer ediff-buffer-A
+         (if (not (memq major-mode 
+                        '(fundamental-mode text-mode indented-text-mode)))
+             (syntax-table))))
+  (if (not ediff-syntax-table)
+      (setq ediff-syntax-table 
+           (ediff-with-current-buffer ediff-buffer-B
+             (syntax-table))))
+  )
+
        
 (defun ediff-deactivate-mark ()
   (if ediff-xemacs-p
index 46d56595511680e7b8bd29f9b7e85639fd1d69d9..d987cecbe16742d87d09dedc898d6fbe164373eb 100644 (file)
@@ -905,7 +905,7 @@ into icons, regardless of the window manager."
                        (make-frame ediff-control-frame-parameters))
            ediff-control-frame ctl-frame)
       ;; protect against undefined face-attribute
-      (condition-case nill
+      (condition-case nil
          (when (and ediff-emacs-p (face-attribute 'mode-line :box))
            (set-face-attribute 'mode-line ctl-frame :box nil))
        (error))
index 5fd8e67ff255ec780fe2ce6f41152bd88d286ac1..d824128e4d069da8bd06e738877e6af1afa311ad 100644 (file)
@@ -1,13 +1,13 @@
 ;;; ediff.el --- a comprehensive visual interface to diff & patch
 
-;; Copyright (C) 1994, 95, 96, 97, 98, 99, 2000 Free Software Foundation, Inc.
+;; Copyright (C) 1994, 95, 96, 97, 98, 99, 2000, 01 Free Software Foundation, Inc.
 
 ;; Author: Michael Kifer <kifer@cs.sunysb.edu>
 ;; Created: February 2, 1994
 ;; Keywords: comparing, merging, patching, tools, unix
 
 (defconst ediff-version "2.75" "The current version of Ediff")
-(defconst ediff-date "January 19, 2001" "Date of last update")  
+(defconst ediff-date "March 5, 2001" "Date of last update")  
 
 
 ;; This file is part of GNU Emacs.
index 9a7439a6309f355124ec7956536ac14f2581984d..047ac5f9c18c25ff62884855244eef9899bc7d53 100644 (file)
 (defconst viper-ex-tmp-buf-name " *ex-tmp*")
 
 
-;;; Variable completion in :set command
-  
-;; The list of Ex commands.  Used for completing command names.
-(defconst ex-token-alist
-  '(("!") ("=") (">") ("&") ("~")
-    ("yank") ("xit") ("WWrite") ("Write") ("write") ("wq") ("visual") 
-    ("version") ("vglobal") ("unmap") ("undo") ("tag") ("transfer") ("suspend")
-    ("substitute") ("submitReport") ("stop")  ("sr") ("source") ("shell")
-    ("set") ("rewind") ("recover") ("read") ("quit") ("pwd")
-    ("put") ("preserve") ("PreviousRelatedFile") ("RelatedFile")
-    ("next") ("Next") ("move") ("mark") ("map") ("kmark") ("join")
-    ("help") ("goto") ("global") ("file") ("edit") ("delete") ("customize")
-    ("copy") ("chdir") ("cd") ("Buffer") ("buffer") ("args"))  )
+;;; ex-commands...
+
+(defun ex-cmd-obsolete (name)
+  (error "`%s': Obsolete command, not supported by Viper" name))
+
+(defun ex-cmd-not-yet (name)
+  (error "`%s': Command not implemented in Viper" name))
+
+;; alist entries: name (in any order), command, cont(??)
+;; If command is a string, then that is an alias to the real command
+;; to execute (for instance, ":m" -> ":move").
+;; command attributes:
+;;   is-mashed: the command's args may be jammed right up against the command
+;;   one-letter: this is a one-letter token.  Any text appearing after
+;;                  the name gets appended as an argument for the command
+;;               i.e. ":kabc" gets turned into (ex-mark "abc")
+(defconst ex-token-alist '(
+       ("!"                    (ex-command))
+       ("&"                    (ex-substitute t))
+       ("="                    (ex-line-no))
+       (">"                    (ex-line "right"))
+       ("<"                    (ex-line "left"))
+       ("Buffer"               (if ex-cycle-other-window
+                                   (viper-switch-to-buffer)
+                                 (viper-switch-to-buffer-other-window)))
+       ("Next"                 (ex-next (not ex-cycle-other-window)))
+       ("PreviousRelatedFile"  (ex-next-related-buffer -1))
+       ("RelatedFile"          (ex-next-related-buffer 1))
+       ("W"                    "Write")
+       ("WWrite"               (save-some-buffers t))
+       ("Write"                (save-some-buffers))
+       ("a"                    "append")
+       ("args"                 (ex-args))
+       ("buffer"               (if ex-cycle-other-window
+                                   (viper-switch-to-buffer-other-window)
+                                 (viper-switch-to-buffer)))
+       ("c"                    "change")
+       ;; ch should be "change" but maintain old viper compatibility
+       ("ch"                   "chdir")
+       ("cd"                   (ex-cd))
+       ("chdir"                (ex-cd))
+       ("copy"                 (ex-copy nil))
+       ("customize"            (customize-group "viper"))
+       ("delete"               (ex-delete))
+       ("edit"                 (ex-edit))
+       ("file"                 (viper-info-on-file))
+       ("g"                    "global")
+       ("global"               (ex-global nil) is-mashed)
+       ("goto"                 (ex-goto))
+       ("help"                 (ex-help))
+       ("join"                 (ex-line "join"))
+       ("k"                    (ex-mark) one-letter)
+       ("kmark"                (ex-mark))
+       ("m"                    "move")
+       ; old viper doesn't specify a default for "ma" so leave it undefined
+       ("map"                  (ex-map))
+       ("mark"                 (ex-mark))
+       ("move"                 (ex-copy t))
+       ("next"                 (ex-next ex-cycle-other-window))
+       ("p"                    "print")
+       ("preserve"             (ex-preserve))
+       ("put"                  (ex-put))
+       ("pwd"                  (ex-pwd))
+       ("quit"                 (ex-quit))
+       ("r"                    "read")
+       ("re"                   "read")
+       ("read"                 (ex-read))
+       ("recover"              (ex-recover))
+       ("rewind"               (ex-rewind))
+       ("s"                    "substitute")
+       ("su"                   "substitute")
+       ("sub"                  "substitute")
+       ("set"                  (ex-set))
+       ("shell"                (ex-shell))
+       ("source"               (ex-source))
+       ("stop"                 (suspend-emacs)) 
+       ("sr"                   (ex-substitute t t))
+       ("submitReport"         (viper-submit-report))
+       ("substitute"           (ex-substitute) is-mashed)
+       ("suspend"              (suspend-emacs))
+       ("t"                    "transfer")
+       ("tag"                  (ex-tag))
+       ("transfer"             (ex-copy nil))
+       ("u"                    "undo")
+       ("un"                   "undo")
+       ("undo"                 (viper-undo))
+       ("unmap"                (ex-unmap))
+       ("v"                    "vglobal")
+       ("version"              (viper-version))
+       ("vglobal"              (ex-global t) is-mashed)
+       ("visual"               (ex-edit)) 
+       ("w"                    "write")
+       ("wq"                   (ex-write t))
+       ("write"                (ex-write nil))
+       ("xit"                  (ex-write t))
+       ("yank"                 (ex-yank))
+       ("~"                    (ex-substitute t t))
+
+       ("append"               (ex-cmd-obsolete "append"))
+       ("change"               (ex-cmd-obsolete "change"))
+       ("insert"               (ex-cmd-obsolete "insert"))
+       ("open"                 (ex-cmd-obsolete "open"))
+
+       ("list"                 (ex-cmd-not-yet "list"))
+       ("print"                (ex-cmd-not-yet "print"))
+       ("z"                    (ex-cmd-not-yet "z"))
+       ("#"                    (ex-cmd-not-yet "#"))
+
+       ("abbreviate"           (error "`%s': Vi abbreviations are obsolete.  Use the more powerful Emacs abbrevs" ex-token))
+       ("unabbreviate"         (error "`%s': Vi abbreviations are obsolete.  Use the more powerful Emacs abbrevs" ex-token))
+       ))
+
+;; No code should touch anything in the alist entry!  (other than the name,
+;; "car entry", of course)   This way, changing this data structure
+;; requires changing only the following ex-cmd functions...
+
+;; Returns cmd if the command may be jammed right up against its
+;; arguments, nil if there must be a space.
+;; examples of mashable commands: g// g!// v// s// sno// sm//
+(defun ex-cmd-is-mashed-with-args (cmd)
+  (if (eq 'is-mashed (car (nthcdr 2 cmd))) cmd))
+
+;; Returns true if this is a one-letter command that may be followed
+;; by anything, no whitespace needed.  This is a special-case for ":k".
+(defun ex-cmd-is-one-letter (cmd)
+  (if (eq 'one-letter (car (nthcdr 2 cmd))) cmd))
+
+;; Executes the function associated with the command
+(defun ex-cmd-execute (cmd)
+  (eval (cadr cmd)))
+
+;; If this is a one-letter magic command, splice in args.
+(defun ex-splice-args-in-1-letr-cmd (key list)
+  (let ((onelet (ex-cmd-is-one-letter (assoc (substring key 0 1) list))))
+    (if onelet
+       (list key
+             (append (cadr onelet)
+                     (if (< 1 (length key)) (list (substring key 1))))
+             (caddr onelet)))
+       ))
+
+
+;; Returns the alist entry for the appropriate key.
+;; Tries to complete the key before using it in the alist.
+;; If there is no appropriate key (no match or duplicate matches) return nil
+(defun ex-cmd-assoc (key list)
+  (let ((entry (try-completion key list))
+       result onelet)
+    (setq result (cond
+                 ((eq entry t)     (assoc key list))
+                 ((stringp entry)  (or (ex-splice-args-in-1-letr-cmd key list)
+                                       (assoc entry list)))
+                 ((eq entry nil)   (ex-splice-args-in-1-letr-cmd key list))
+                 (t nil)
+                 ))
+    ;; If we end up with an alias, look up the alias...
+    (if (stringp (cadr result))
+       (setq result (ex-cmd-assoc (cadr result) list)))
+    ;; and return the corresponding alist entry
+    result
+    ))
+
 
 ;; A-list of Ex variables that can be set using the :set command.
 (defconst ex-variable-alist 
@@ -233,104 +382,17 @@ reversed."
 (defvar viper-last-ex-prompt "")
 
 
-;;; Code
-  
-;; Check if ex-token is an initial segment of STR
-(defun viper-check-sub (str)
-  (let ((length (length ex-token)))
-    (if (and (<= length (length str))
-            (string= ex-token (substring str 0 length)))
-       (setq ex-token str)
-      (setq ex-token-type 'non-command))))
-
 ;; Get a complete ex command
 (defun viper-get-ex-com-subr ()
-  (let (case-fold-search)
+  (let (cmd case-fold-search)
     (set-mark (point))
     (re-search-forward "[a-zA-Z][a-zA-Z]*")
     (setq ex-token-type 'command)
     (setq ex-token (buffer-substring (point) (mark t)))
-    (exchange-point-and-mark)
-    (cond ((looking-at "a")
-          (cond ((looking-at "ab") (viper-check-sub "abbreviate"))
-                ((looking-at "ar") (viper-check-sub "args"))
-                (t (viper-check-sub "append"))))
-         ((looking-at "h") (viper-check-sub "help"))
-         ((looking-at "c")
-          (cond ((looking-at "cd") (viper-check-sub "cd"))
-                ((looking-at "ch") (viper-check-sub "chdir"))
-                ((looking-at "co") (viper-check-sub "copy"))
-                ((looking-at "cu") (viper-check-sub "customize"))
-                (t (viper-check-sub "change"))))
-         ((looking-at "d") (viper-check-sub "delete"))
-         ((looking-at "b") (viper-check-sub "buffer"))
-         ((looking-at "B") (viper-check-sub "Buffer"))
-         ((looking-at "e")
-          (if (looking-at "ex") (viper-check-sub "ex")
-            (viper-check-sub "edit")))
-         ((looking-at "f") (viper-check-sub "file"))
-         ((looking-at "g") (viper-check-sub "global"))
-         ((looking-at "i") (viper-check-sub "insert"))
-         ((looking-at "j") (viper-check-sub "join"))
-         ((looking-at "l") (viper-check-sub "list"))
-         ((looking-at "m")
-          (cond ((looking-at "map") (viper-check-sub "map"))
-                ((looking-at "mar") (viper-check-sub "mark"))
-                (t (viper-check-sub "move"))))
-         ((looking-at "k[a-z][^a-z]")
-          (setq ex-token "kmark")
-          (forward-char 1)
-          (exchange-point-and-mark))   ; this is canceled out by another
-                                       ; exchange-point-and-mark at the end
-         ((looking-at "k") (viper-check-sub "kmark"))
-         ((looking-at "n") (if (looking-at "nu")
-                               (viper-check-sub "number")
-                             (viper-check-sub "next")))
-         ((looking-at "N") (viper-check-sub "Next"))
-         ((looking-at "o") (viper-check-sub "open"))
-         ((looking-at "p")
-          (cond ((looking-at "pre") (viper-check-sub "preserve"))
-                ((looking-at "pu") (viper-check-sub "put"))
-                ((looking-at "pw") (viper-check-sub "pwd"))
-                (t (viper-check-sub "print"))))
-         ((looking-at "P") (viper-check-sub "PreviousRelatedFile"))
-         ((looking-at "R") (viper-check-sub "RelatedFile"))
-         ((looking-at "q") (viper-check-sub "quit"))
-         ((looking-at "r")
-          (cond ((looking-at "rec") (viper-check-sub "recover"))
-                ((looking-at "rew") (viper-check-sub "rewind"))
-                (t (viper-check-sub "read"))))
-         ((looking-at "s")
-          (cond ((looking-at "se") (viper-check-sub "set"))
-                ((looking-at "sh") (viper-check-sub "shell"))
-                ((looking-at "so") (viper-check-sub "source"))
-                ((looking-at "sr") (viper-check-sub "sr"))
-                ((looking-at "st") (viper-check-sub "stop"))
-                ((looking-at "sus") (viper-check-sub "suspend"))
-                ((looking-at "subm") (viper-check-sub "submitReport"))
-                (t (viper-check-sub "substitute"))))
-         ((looking-at "t")
-          (if (looking-at "ta") (viper-check-sub "tag")
-            (viper-check-sub "transfer")))
-         ((looking-at "u")
-          (cond ((looking-at "una") (viper-check-sub "unabbreviate"))
-                ((looking-at "unm") (viper-check-sub "unmap"))
-                (t (viper-check-sub "undo"))))
-         ((looking-at "v")
-          (cond ((looking-at "ve") (viper-check-sub "version"))
-                ((looking-at "vi") (viper-check-sub "visual"))
-                (t (viper-check-sub "vglobal"))))
-         ((looking-at "w")
-          (if (looking-at "wq") (viper-check-sub "wq")
-            (viper-check-sub "write")))
-         ((looking-at "W")
-          (if (looking-at "WW") 
-              (viper-check-sub "WWrite")
-            (viper-check-sub "Write")))
-         ((looking-at "x") (viper-check-sub "xit"))
-         ((looking-at "y") (viper-check-sub "yank"))
-         ((looking-at "z") (viper-check-sub "z")))
-    (exchange-point-and-mark)
+    (setq cmd (ex-cmd-assoc ex-token ex-token-alist))
+    (if cmd
+       (setq ex-token (car cmd))
+      (setq ex-token-type 'non-command))
     ))
 
 ;; Get an ex-token which is either an address or a command.
@@ -597,28 +659,28 @@ reversed."
       (viper-get-ex-token)
       (cond ((memq ex-token-type '(command end-mark))
             (if address (setq ex-addresses (cons address ex-addresses)))
-            (cond ((string= ex-token "global")
-                   (ex-global nil)
-                   (setq cont nil))
-                  ((string= ex-token "vglobal")
-                   (ex-global t)
-                   (setq cont nil))
-                  (t
-                   (viper-execute-ex-command)
-                   (save-excursion
-                     (save-window-excursion
-                       (setq viper-ex-work-buf
-                             (get-buffer-create viper-ex-work-buf-name))
-                       (set-buffer viper-ex-work-buf)
-                       (skip-chars-forward " \t")
-                       (cond ((looking-at "|")
-                              (forward-char 1))
-                             ((looking-at "\n")
-                              (setq cont nil))
-                             (t (error
-                                 "`%s': %s" ex-token viper-SpuriousText)))
-                       )))
-                  ))
+            (viper-deactivate-mark)
+            (let ((cmd (ex-cmd-assoc ex-token ex-token-alist)))
+              (if (null cmd)
+                  (error "`%s': %s" ex-token viper-BadExCommand))
+              (ex-cmd-execute cmd)
+              (if (or (ex-cmd-is-mashed-with-args cmd)
+                      (ex-cmd-is-one-letter cmd))
+                  (setq cont nil)
+                (save-excursion
+                  (save-window-excursion
+                    (setq viper-ex-work-buf
+                          (get-buffer-create viper-ex-work-buf-name))
+                    (set-buffer viper-ex-work-buf)
+                    (skip-chars-forward " \t")
+                    (cond ((looking-at "|")
+                           (forward-char 1))
+                          ((looking-at "\n")
+                           (setq cont nil))
+                          (t (error
+                              "`%s': %s" ex-token viper-SpuriousText)))
+                    )))
+              ))
            ((eq ex-token-type 'non-command)
             (error "`%s': %s" ex-token viper-BadExCommand))
            ((eq ex-token-type 'whole)
@@ -701,22 +763,6 @@ reversed."
        (setq ex-token nil))
       c)))
 
-;; get an ex command
-(defun viper-get-ex-command ()
-  (save-window-excursion
-    (setq viper-ex-work-buf (get-buffer-create viper-ex-work-buf-name)) 
-    (set-buffer viper-ex-work-buf)
-    (if (looking-at "/") (forward-char 1))
-    (skip-chars-forward " \t")
-    (cond ((looking-at "[a-z]")
-          (viper-get-ex-com-subr)
-          (if (eq ex-token-type 'non-command)
-              (error "`%s': %s" ex-token viper-BadExCommand)))
-         ((looking-at "[!=><&~]")
-          (setq ex-token (char-to-string (following-char)))
-          (forward-char 1))
-         (t (error viper-BadExCommand)))))
-
 ;; Get an Ex option g or c
 (defun viper-get-ex-opt-gc (c)
   (save-window-excursion
@@ -1067,83 +1113,6 @@ reversed."
                      (concat viper-last-ex-prompt " !")))))
     (substring str (or beg 0) end)))
 
-;; Execute ex command using the value of addresses
-(defun viper-execute-ex-command ()
-  (viper-deactivate-mark)
-  (cond ((string= ex-token "args") (ex-args))
-       ((string= ex-token "copy") (ex-copy nil))
-       ((string= ex-token "cd") (ex-cd))
-       ((string= ex-token "customize") (customize-group "viper"))
-       ((string= ex-token "chdir") (ex-cd))
-       ((string= ex-token "delete") (ex-delete))
-       ((string= ex-token "edit") (ex-edit))
-       ((string= ex-token "file") (viper-info-on-file))
-       ((string= ex-token "goto") (ex-goto))
-       ((string= ex-token "help") (ex-help))
-       ((string= ex-token "join") (ex-line "join"))
-       ((string= ex-token "kmark") (ex-mark))
-       ((string= ex-token "mark") (ex-mark))
-       ((string= ex-token "map") (ex-map))
-       ((string= ex-token "move") (ex-copy t))
-       ((string= ex-token "next") (ex-next ex-cycle-other-window))
-       ((string= ex-token "Next") (ex-next (not ex-cycle-other-window)))
-       ((string= ex-token "RelatedFile") (ex-next-related-buffer 1))
-       ((string= ex-token "put") (ex-put))
-       ((string= ex-token "pwd") (ex-pwd))
-       ((string= ex-token "preserve") (ex-preserve))
-       ((string= ex-token "PreviousRelatedFile") (ex-next-related-buffer -1))
-       ((string= ex-token "quit") (ex-quit))
-       ((string= ex-token "read") (ex-read))
-       ((string= ex-token "recover") (ex-recover))
-       ((string= ex-token "rewind") (ex-rewind))
-       ((string= ex-token "submitReport") (viper-submit-report))
-       ((string= ex-token "set") (ex-set))
-       ((string= ex-token "shell") (ex-shell))
-       ((string= ex-token "source") (ex-source))
-       ((string= ex-token "sr") (ex-substitute t t))
-       ((string= ex-token "substitute") (ex-substitute))
-       ((string= ex-token "suspend") (suspend-emacs))
-       ((string= ex-token "stop") (suspend-emacs))
-       ((string= ex-token "transfer") (ex-copy nil))
-       ((string= ex-token "buffer") (if ex-cycle-other-window
-                                        (viper-switch-to-buffer-other-window)
-                                      (viper-switch-to-buffer)))
-       ((string= ex-token "Buffer") (if ex-cycle-other-window
-                                        (viper-switch-to-buffer)
-                                      (viper-switch-to-buffer-other-window)))
-       ((string= ex-token "tag") (ex-tag))
-       ((string= ex-token "undo") (viper-undo))
-       ((string= ex-token "unmap") (ex-unmap))
-       ((string= ex-token "version") (viper-version))
-       ((string= ex-token "visual") (ex-edit))
-       ((string= ex-token "write") (ex-write nil))
-       ((string= ex-token "Write") (save-some-buffers))
-       ((string= ex-token "wq") (ex-write t))
-       ((string= ex-token "WWrite") (save-some-buffers t)) ; don't ask
-       ((string= ex-token "xit") (ex-write t))
-       ((string= ex-token "yank") (ex-yank))
-       ((string= ex-token "!") (ex-command))
-       ((string= ex-token "=") (ex-line-no))
-       ((string= ex-token ">") (ex-line "right"))
-       ((string= ex-token "<") (ex-line "left"))
-       ((string= ex-token "&") (ex-substitute t))
-       ((string= ex-token "~") (ex-substitute t t))
-       ((or (string= ex-token "append")
-            (string= ex-token "change")
-            (string= ex-token "insert")
-            (string= ex-token "open"))
-        (error "`%s': Obsolete command, not supported by Viper" ex-token))
-       ((or (string= ex-token "abbreviate")
-            (string= ex-token "unabbreviate"))
-        (error
-         "`%s': Vi abbrevs are obsolete.  Use the more powerful Emacs abbrevs"
-         ex-token))
-       ((or (string= ex-token "list")
-            (string= ex-token "print")
-            (string= ex-token "z")
-            (string= ex-token "#"))
-        (error "`%s': Command not implemented in Viper" ex-token))
-       (t (error "`%s': %s" ex-token viper-BadExCommand))))
 
 (defun viper-undisplayed-files ()
   (mapcar
@@ -1457,11 +1426,18 @@ reversed."
 
 
 ;; Ex mark command
-(defun ex-mark ()
+;; Sets the mark to the current point.
+;; If name is omitted, get the name straight from the work buffer."
+(defun ex-mark (&optional name)
   (let (char)
     (if (null ex-addresses)
        (setq ex-addresses
              (cons (point) nil)))
+    (if name
+       (if (eq 1 (length name))
+           (setq char (string-to-char name))
+         (error "`%s': Spurious text \"%s\" after mark name."
+                name (substring name 1) viper-SpuriousText))
     (save-window-excursion
       (setq viper-ex-work-buf (get-buffer-create viper-ex-work-buf-name)) 
       (set-buffer viper-ex-work-buf)
@@ -1473,7 +1449,7 @@ reversed."
            (skip-chars-forward " \t")
            (if (not (looking-at "[\n|]"))
                (error "`%s': %s" ex-token viper-SpuriousText)))
-       (error "`%s' requires a following letter" ex-token)))
+       (error "`%s' requires a following letter" ex-token))))
     (save-excursion
       (goto-char (car ex-addresses))
       (point-to-register (1+ (- char ?a))))))
index 51f0efc6266e3b16473c85a6f196fb738e2a7192..6956d0098e83c01d9d6983f61e176627349231fc 100644 (file)
 (defun viper-append-filter-alist (lis1 lis2)
   (let ((temp lis1)
        elt)
-  
     ;;filter-append the second list
     (while temp
       ;; delete all occurrences
     
     (nconc lis1 lis2)))
 
+
 \f
 ;;; Support for :e, :r, :w file globbing
 
index 63dd5006577594d76520ca9db25c8cbaa9fc8ba2..9e8efaf8b0d1acba7fefd58a310a3648cfd162b5 100644 (file)
@@ -6,9 +6,9 @@
 ;;  Keywords: emulations
 ;;  Author: Michael Kifer <kifer@cs.sunysb.edu>
 
-;; Copyright (C) 1994, 95, 96, 97, 98, 99, 2000 Free Software Foundation, Inc.
+;; Copyright (C) 1994, 95, 96, 97, 98, 99, 2000, 01 Free Software Foundation, Inc.
 
-(defconst viper-version "3.09 of January 19, 2001"
+(defconst viper-version "3.10 of March 3, 2001"
   "The current version of Viper")
 
 ;; This file is part of GNU Emacs.
@@ -402,7 +402,8 @@ widget."
     completion-list-mode
     diff-mode
     
-    perl-mode cperl-mode
+    perl-mode
+    cperl-mode
     javascript-mode
     tcl-mode
     python-mode
index 3da209ba8ddaea3bc6f77330fa994baa4e40cfac..e564fbd6d8ff4bd460e7a4a040d6b6c3de0810b8 100644 (file)
@@ -1,3 +1,7 @@
+2001-03-17  Michael Kifer  <kifer@cs.sunysb.edu>
+       
+       * viper.texi: Added credits.
+
 2001-03-13  Thien-Thi Nguyen  <ttn@gnu.org>
 
        * programs.texi: Update hideshow key bindings.
index c4c4158ac7f1826e6cfa4bbe97ee66e7dd490288..20ca01c55764a71b240753bd2934bc55ed7b3caf 100644 (file)
@@ -4425,6 +4425,7 @@ aaronl@@vitelus.com (Aaron Lehmann),
 ahg@@panix.com (Al Gelders),
 amade@@diagram.fr (Paul-Bernard Amade),
 ascott@@fws214.intel.com (Andy Scott),
+bronson@@trestle.com (Scott Bronson),
 cook@@biostat.wisc.edu (Tom Cook),
 csdayton@@midway.uchicago.edu (Soren Dayton),
 dave@@hellgate.utah.edu,