aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Kifer2001-03-17 18:59:39 +0000
committerMichael Kifer2001-03-17 18:59:39 +0000
commit4986c2c6c8b786409fb44f740b2e358736145313 (patch)
treea159e994a7ca65985c2e7b03f56ff0e3472071f6
parent42b7180c96b3855e62720491ba55e432ca470356 (diff)
downloademacs-4986c2c6c8b786409fb44f740b2e358736145313.tar.gz
emacs-4986c2c6c8b786409fb44f740b2e358736145313.zip
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.
-rw-r--r--lisp/ChangeLog25
-rw-r--r--lisp/ediff-diff.el27
-rw-r--r--lisp/ediff-init.el23
-rw-r--r--lisp/ediff-util.el25
-rw-r--r--lisp/ediff-wind.el2
-rw-r--r--lisp/ediff.el4
-rw-r--r--lisp/emulation/viper-ex.el420
-rw-r--r--lisp/emulation/viper-util.el2
-rw-r--r--lisp/emulation/viper.el7
-rw-r--r--man/ChangeLog4
-rw-r--r--man/viper.texi1
11 files changed, 298 insertions, 242 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index c5c679c7098..1514d34ad49 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,28 @@
12001-03-17 Michael Kifer <kifer@cs.sunysb.edu>
2
3 * ediff-util.el: Copyright years.
4 (ediff-choose-syntax-table): New function.
5 (ediff-setup): Use ediff-choose-syntax-table.
6
7 * ediff-init.el (ediff-with-syntax-table): New macro, uses
8 with-syntax-table.
9
10 * ediff.el: Date of last update, copyright years.
11
12 * ediff-wind (ediff-setup-control-frame): Nill->nil.
13
14 * viper-ex.el (ex-token-list,ex-cmd-execute): Revamped, courtesy
15 of Scott Bronson.
16 (ex-cmd-assoc,ex-cmd-one-letr): New functions.
17 (viper-check-sub,viper-get-ex-command,viper-execute-ex-command):
18 Deleted functions.
19 (viper-get-ex-com-subr,viper-ex,ex-mark): Changed to use the new
20 ex-token-list.
21
22 * viper-util.el: Spaces, indentation.
23
24 * viper.el: Changed version, modification time.
25
12001-03-16 John Wiegley <johnw@gnu.org> 262001-03-16 John Wiegley <johnw@gnu.org>
2 27
3 * (timeclock-workday-remaining): Check whether `discrep' is 28 * (timeclock-workday-remaining): Check whether `discrep' is
diff --git a/lisp/ediff-diff.el b/lisp/ediff-diff.el
index 3bf2277d6be..79b8b539de9 100644
--- a/lisp/ediff-diff.el
+++ b/lisp/ediff-diff.el
@@ -1256,11 +1256,15 @@ arguments to `skip-chars-forward'."
1256 1256
1257 1257
1258(defun ediff-wordify (beg end in-buffer out-buffer &optional control-buf) 1258(defun ediff-wordify (beg end in-buffer out-buffer &optional control-buf)
1259 (let (inbuf-syntax-tbl sv-point string) 1259 (let (inbuf-syntax-tbl sv-point diff-string)
1260 (save-excursion 1260 (save-excursion
1261 (set-buffer in-buffer) 1261 (set-buffer in-buffer)
1262 (setq inbuf-syntax-tbl (syntax-table)) 1262 (setq inbuf-syntax-tbl
1263 (setq string (buffer-substring-no-properties beg end)) 1263 (if control-buf
1264 (ediff-with-current-buffer control-buf
1265 ediff-syntax-table)
1266 (syntax-table)))
1267 (setq diff-string (buffer-substring-no-properties beg end))
1264 1268
1265 (set-buffer out-buffer) 1269 (set-buffer out-buffer)
1266 ;; Make sure that temp buff syntax table is the same a the original buf 1270 ;; Make sure that temp buff syntax table is the same a the original buf
@@ -1268,18 +1272,18 @@ arguments to `skip-chars-forward'."
1268 ;; ediff-forward-word depends on the syntax classes of characters. 1272 ;; ediff-forward-word depends on the syntax classes of characters.
1269 (set-syntax-table inbuf-syntax-tbl) 1273 (set-syntax-table inbuf-syntax-tbl)
1270 (erase-buffer) 1274 (erase-buffer)
1271 (insert string) 1275 (insert diff-string)
1272 (goto-char (point-min)) 1276 (goto-char (point-min))
1273 (skip-chars-forward ediff-whitespace) 1277 (skip-chars-forward ediff-whitespace)
1274 (delete-region (point-min) (point)) 1278 (delete-region (point-min) (point))
1275 1279
1276 (while (not (eobp)) 1280 (while (not (eobp))
1277 ;; eval incontrol buf to let user create local versions for 1281 ;; eval in control buf to let user create local versions for
1278 ;; different invocations 1282 ;; different invocations
1279 (if control-buf 1283 (if control-buf
1280 (funcall 1284 (funcall
1281 (ediff-with-current-buffer 1285 (ediff-with-current-buffer control-buf
1282 control-buf ediff-forward-word-function)) 1286 ediff-forward-word-function))
1283 (funcall ediff-forward-word-function)) 1287 (funcall ediff-forward-word-function))
1284 (setq sv-point (point)) 1288 (setq sv-point (point))
1285 (skip-chars-forward ediff-whitespace) 1289 (skip-chars-forward ediff-whitespace)
@@ -1300,16 +1304,17 @@ arguments to `skip-chars-forward'."
1300 1304
1301 1305
1302;; goto word #n starting at current position in buffer `buf' 1306;; goto word #n starting at current position in buffer `buf'
1303;; For ediff, a word is either a string of a-z,A-Z, incl `-' and `_'; 1307;; For ediff, a word is determined by ediff-forward-word-function
1304;; or a string of other non-blanks. A blank is a \n\t\f
1305;; If `flag' is non-nil, goto the end of the n-th word. 1308;; If `flag' is non-nil, goto the end of the n-th word.
1306(defun ediff-goto-word (n buf &optional flag) 1309(defun ediff-goto-word (n buf &optional flag)
1307 ;; remember val ediff-forward-word-function has in ctl buf 1310 ;; remember val ediff-forward-word-function has in ctl buf
1308 (let ((fwd-word-fun ediff-forward-word-function)) 1311 (let ((fwd-word-fun ediff-forward-word-function)
1312 (syntax-tbl ediff-syntax-table))
1309 (ediff-with-current-buffer buf 1313 (ediff-with-current-buffer buf
1310 (skip-chars-forward ediff-whitespace) 1314 (skip-chars-forward ediff-whitespace)
1311 (while (> n 1) 1315 (while (> n 1)
1312 (funcall fwd-word-fun) 1316 (ediff-with-syntax-table syntax-tbl
1317 (funcall fwd-word-fun))
1313 (skip-chars-forward ediff-whitespace) 1318 (skip-chars-forward ediff-whitespace)
1314 (setq n (1- n))) 1319 (setq n (1- n)))
1315 (if (and flag (> n 0)) 1320 (if (and flag (> n 0))
diff --git a/lisp/ediff-init.el b/lisp/ediff-init.el
index f984ac2fa30..da6ac26a738 100644
--- a/lisp/ediff-init.el
+++ b/lisp/ediff-init.el
@@ -519,6 +519,11 @@ See the documentation string of `ediff-focus-on-regexp-matches' for details.")
519;; where some buffer-objects may be missing. 519;; where some buffer-objects may be missing.
520(ediff-defvar-local ediff-killed-diffs-alist nil "") 520(ediff-defvar-local ediff-killed-diffs-alist nil "")
521 521
522;; Syntax table to use in ediff-forward-word-function
523;; This is chosen by a heuristic. The important thing is for all buffers to
524;; have the same syntax table. Which is not too important.
525(ediff-defvar-local ediff-syntax-table nil "")
526
522 527
523;; Highlighting 528;; Highlighting
524(defcustom ediff-before-flag-bol (if ediff-xemacs-p (make-glyph "->>") "->>") 529(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."
1749 fname)) 1754 fname))
1750 1755
1751 1756
1757(if (fboundp 'with-syntax-table)
1758 (fset 'ediff-with-syntax-table 'with-syntax-table)
1759 ;; stolen from subr.el in emacs 21
1760 (defmacro ediff-with-syntax-table (table &rest body)
1761 (let ((old-table (make-symbol "table"))
1762 (old-buffer (make-symbol "buffer")))
1763 `(let ((,old-table (syntax-table))
1764 (,old-buffer (current-buffer)))
1765 (unwind-protect
1766 (progn
1767 (set-syntax-table (copy-syntax-table ,table))
1768 ,@body)
1769 (save-current-buffer
1770 (set-buffer ,old-buffer)
1771 (set-syntax-table ,old-table)))))))
1772
1773
1774
1752;;; Local Variables: 1775;;; Local Variables:
1753;;; eval: (put 'ediff-defvar-local 'lisp-indent-hook 'defun) 1776;;; eval: (put 'ediff-defvar-local 'lisp-indent-hook 'defun)
1754;;; eval: (put 'ediff-with-current-buffer 'lisp-indent-hook 1) 1777;;; eval: (put 'ediff-with-current-buffer 'lisp-indent-hook 1)
diff --git a/lisp/ediff-util.el b/lisp/ediff-util.el
index dff95ce4cb8..c26162715c7 100644
--- a/lisp/ediff-util.el
+++ b/lisp/ediff-util.el
@@ -1,6 +1,6 @@
1;;; ediff-util.el --- the core commands and utilities of ediff 1;;; ediff-util.el --- the core commands and utilities of ediff
2 2
3;; Copyright (C) 1994, 1995, 1996, 1997, 2001 Free Software Foundation, Inc. 3;; Copyright (C) 1994, 95, 96, 97, 98, 99, 2000, 01 Free Software Foundation, Inc.
4 4
5;; Author: Michael Kifer <kifer@cs.sunysb.edu> 5;; Author: Michael Kifer <kifer@cs.sunysb.edu>
6 6
@@ -354,6 +354,8 @@ to invocation.")
354 ediff-buffer-B buffer-B 354 ediff-buffer-B buffer-B
355 ediff-buffer-C buffer-C 355 ediff-buffer-C buffer-C
356 ediff-control-buffer control-buffer) 356 ediff-control-buffer control-buffer)
357
358 (ediff-choose-syntax-table)
357 359
358 (setq ediff-control-buffer-suffix 360 (setq ediff-control-buffer-suffix
359 (if (string-match "<[0-9]*>" control-buffer-name) 361 (if (string-match "<[0-9]*>" control-buffer-name)
@@ -3692,7 +3694,26 @@ Mail anyway? (y or n) ")
3692 (ediff-with-current-buffer ctl-buf 3694 (ediff-with-current-buffer ctl-buf
3693 (ediff-recenter 'no-rehighlight)))) 3695 (ediff-recenter 'no-rehighlight))))
3694 )) 3696 ))
3695 3697
3698
3699;; Find an appropriate syntax table for everyone to use
3700;; If buffer B is not fundamental or text mode, use its syntax table
3701;; Otherwise, use buffer B's.
3702;; The syntax mode is used in ediff-forward-word-function
3703;; The important thing is that every buffer should use the same syntax table
3704;; during the refinement operation
3705(defun ediff-choose-syntax-table ()
3706 (setq ediff-syntax-table
3707 (ediff-with-current-buffer ediff-buffer-A
3708 (if (not (memq major-mode
3709 '(fundamental-mode text-mode indented-text-mode)))
3710 (syntax-table))))
3711 (if (not ediff-syntax-table)
3712 (setq ediff-syntax-table
3713 (ediff-with-current-buffer ediff-buffer-B
3714 (syntax-table))))
3715 )
3716
3696 3717
3697(defun ediff-deactivate-mark () 3718(defun ediff-deactivate-mark ()
3698 (if ediff-xemacs-p 3719 (if ediff-xemacs-p
diff --git a/lisp/ediff-wind.el b/lisp/ediff-wind.el
index 46d56595511..d987cecbe16 100644
--- a/lisp/ediff-wind.el
+++ b/lisp/ediff-wind.el
@@ -905,7 +905,7 @@ into icons, regardless of the window manager."
905 (make-frame ediff-control-frame-parameters)) 905 (make-frame ediff-control-frame-parameters))
906 ediff-control-frame ctl-frame) 906 ediff-control-frame ctl-frame)
907 ;; protect against undefined face-attribute 907 ;; protect against undefined face-attribute
908 (condition-case nill 908 (condition-case nil
909 (when (and ediff-emacs-p (face-attribute 'mode-line :box)) 909 (when (and ediff-emacs-p (face-attribute 'mode-line :box))
910 (set-face-attribute 'mode-line ctl-frame :box nil)) 910 (set-face-attribute 'mode-line ctl-frame :box nil))
911 (error)) 911 (error))
diff --git a/lisp/ediff.el b/lisp/ediff.el
index 5fd8e67ff25..d824128e4d0 100644
--- a/lisp/ediff.el
+++ b/lisp/ediff.el
@@ -1,13 +1,13 @@
1;;; ediff.el --- a comprehensive visual interface to diff & patch 1;;; ediff.el --- a comprehensive visual interface to diff & patch
2 2
3;; Copyright (C) 1994, 95, 96, 97, 98, 99, 2000 Free Software Foundation, Inc. 3;; Copyright (C) 1994, 95, 96, 97, 98, 99, 2000, 01 Free Software Foundation, Inc.
4 4
5;; Author: Michael Kifer <kifer@cs.sunysb.edu> 5;; Author: Michael Kifer <kifer@cs.sunysb.edu>
6;; Created: February 2, 1994 6;; Created: February 2, 1994
7;; Keywords: comparing, merging, patching, tools, unix 7;; Keywords: comparing, merging, patching, tools, unix
8 8
9(defconst ediff-version "2.75" "The current version of Ediff") 9(defconst ediff-version "2.75" "The current version of Ediff")
10(defconst ediff-date "January 19, 2001" "Date of last update") 10(defconst ediff-date "March 5, 2001" "Date of last update")
11 11
12 12
13;; This file is part of GNU Emacs. 13;; This file is part of GNU Emacs.
diff --git a/lisp/emulation/viper-ex.el b/lisp/emulation/viper-ex.el
index 9a7439a6309..047ac5f9c18 100644
--- a/lisp/emulation/viper-ex.el
+++ b/lisp/emulation/viper-ex.el
@@ -66,19 +66,168 @@
66(defconst viper-ex-tmp-buf-name " *ex-tmp*") 66(defconst viper-ex-tmp-buf-name " *ex-tmp*")
67 67
68 68
69;;; Variable completion in :set command 69;;; ex-commands...
70 70
71;; The list of Ex commands. Used for completing command names. 71(defun ex-cmd-obsolete (name)
72(defconst ex-token-alist 72 (error "`%s': Obsolete command, not supported by Viper" name))
73 '(("!") ("=") (">") ("&") ("~") 73
74 ("yank") ("xit") ("WWrite") ("Write") ("write") ("wq") ("visual") 74(defun ex-cmd-not-yet (name)
75 ("version") ("vglobal") ("unmap") ("undo") ("tag") ("transfer") ("suspend") 75 (error "`%s': Command not implemented in Viper" name))
76 ("substitute") ("submitReport") ("stop") ("sr") ("source") ("shell") 76
77 ("set") ("rewind") ("recover") ("read") ("quit") ("pwd") 77;; alist entries: name (in any order), command, cont(??)
78 ("put") ("preserve") ("PreviousRelatedFile") ("RelatedFile") 78;; If command is a string, then that is an alias to the real command
79 ("next") ("Next") ("move") ("mark") ("map") ("kmark") ("join") 79;; to execute (for instance, ":m" -> ":move").
80 ("help") ("goto") ("global") ("file") ("edit") ("delete") ("customize") 80;; command attributes:
81 ("copy") ("chdir") ("cd") ("Buffer") ("buffer") ("args")) ) 81;; is-mashed: the command's args may be jammed right up against the command
82;; one-letter: this is a one-letter token. Any text appearing after
83;; the name gets appended as an argument for the command
84;; i.e. ":kabc" gets turned into (ex-mark "abc")
85(defconst ex-token-alist '(
86 ("!" (ex-command))
87 ("&" (ex-substitute t))
88 ("=" (ex-line-no))
89 (">" (ex-line "right"))
90 ("<" (ex-line "left"))
91 ("Buffer" (if ex-cycle-other-window
92 (viper-switch-to-buffer)
93 (viper-switch-to-buffer-other-window)))
94 ("Next" (ex-next (not ex-cycle-other-window)))
95 ("PreviousRelatedFile" (ex-next-related-buffer -1))
96 ("RelatedFile" (ex-next-related-buffer 1))
97 ("W" "Write")
98 ("WWrite" (save-some-buffers t))
99 ("Write" (save-some-buffers))
100 ("a" "append")
101 ("args" (ex-args))
102 ("buffer" (if ex-cycle-other-window
103 (viper-switch-to-buffer-other-window)
104 (viper-switch-to-buffer)))
105 ("c" "change")
106 ;; ch should be "change" but maintain old viper compatibility
107 ("ch" "chdir")
108 ("cd" (ex-cd))
109 ("chdir" (ex-cd))
110 ("copy" (ex-copy nil))
111 ("customize" (customize-group "viper"))
112 ("delete" (ex-delete))
113 ("edit" (ex-edit))
114 ("file" (viper-info-on-file))
115 ("g" "global")
116 ("global" (ex-global nil) is-mashed)
117 ("goto" (ex-goto))
118 ("help" (ex-help))
119 ("join" (ex-line "join"))
120 ("k" (ex-mark) one-letter)
121 ("kmark" (ex-mark))
122 ("m" "move")
123 ; old viper doesn't specify a default for "ma" so leave it undefined
124 ("map" (ex-map))
125 ("mark" (ex-mark))
126 ("move" (ex-copy t))
127 ("next" (ex-next ex-cycle-other-window))
128 ("p" "print")
129 ("preserve" (ex-preserve))
130 ("put" (ex-put))
131 ("pwd" (ex-pwd))
132 ("quit" (ex-quit))
133 ("r" "read")
134 ("re" "read")
135 ("read" (ex-read))
136 ("recover" (ex-recover))
137 ("rewind" (ex-rewind))
138 ("s" "substitute")
139 ("su" "substitute")
140 ("sub" "substitute")
141 ("set" (ex-set))
142 ("shell" (ex-shell))
143 ("source" (ex-source))
144 ("stop" (suspend-emacs))
145 ("sr" (ex-substitute t t))
146 ("submitReport" (viper-submit-report))
147 ("substitute" (ex-substitute) is-mashed)
148 ("suspend" (suspend-emacs))
149 ("t" "transfer")
150 ("tag" (ex-tag))
151 ("transfer" (ex-copy nil))
152 ("u" "undo")
153 ("un" "undo")
154 ("undo" (viper-undo))
155 ("unmap" (ex-unmap))
156 ("v" "vglobal")
157 ("version" (viper-version))
158 ("vglobal" (ex-global t) is-mashed)
159 ("visual" (ex-edit))
160 ("w" "write")
161 ("wq" (ex-write t))
162 ("write" (ex-write nil))
163 ("xit" (ex-write t))
164 ("yank" (ex-yank))
165 ("~" (ex-substitute t t))
166
167 ("append" (ex-cmd-obsolete "append"))
168 ("change" (ex-cmd-obsolete "change"))
169 ("insert" (ex-cmd-obsolete "insert"))
170 ("open" (ex-cmd-obsolete "open"))
171
172 ("list" (ex-cmd-not-yet "list"))
173 ("print" (ex-cmd-not-yet "print"))
174 ("z" (ex-cmd-not-yet "z"))
175 ("#" (ex-cmd-not-yet "#"))
176
177 ("abbreviate" (error "`%s': Vi abbreviations are obsolete. Use the more powerful Emacs abbrevs" ex-token))
178 ("unabbreviate" (error "`%s': Vi abbreviations are obsolete. Use the more powerful Emacs abbrevs" ex-token))
179 ))
180
181;; No code should touch anything in the alist entry! (other than the name,
182;; "car entry", of course) This way, changing this data structure
183;; requires changing only the following ex-cmd functions...
184
185;; Returns cmd if the command may be jammed right up against its
186;; arguments, nil if there must be a space.
187;; examples of mashable commands: g// g!// v// s// sno// sm//
188(defun ex-cmd-is-mashed-with-args (cmd)
189 (if (eq 'is-mashed (car (nthcdr 2 cmd))) cmd))
190
191;; Returns true if this is a one-letter command that may be followed
192;; by anything, no whitespace needed. This is a special-case for ":k".
193(defun ex-cmd-is-one-letter (cmd)
194 (if (eq 'one-letter (car (nthcdr 2 cmd))) cmd))
195
196;; Executes the function associated with the command
197(defun ex-cmd-execute (cmd)
198 (eval (cadr cmd)))
199
200;; If this is a one-letter magic command, splice in args.
201(defun ex-splice-args-in-1-letr-cmd (key list)
202 (let ((onelet (ex-cmd-is-one-letter (assoc (substring key 0 1) list))))
203 (if onelet
204 (list key
205 (append (cadr onelet)
206 (if (< 1 (length key)) (list (substring key 1))))
207 (caddr onelet)))
208 ))
209
210
211;; Returns the alist entry for the appropriate key.
212;; Tries to complete the key before using it in the alist.
213;; If there is no appropriate key (no match or duplicate matches) return nil
214(defun ex-cmd-assoc (key list)
215 (let ((entry (try-completion key list))
216 result onelet)
217 (setq result (cond
218 ((eq entry t) (assoc key list))
219 ((stringp entry) (or (ex-splice-args-in-1-letr-cmd key list)
220 (assoc entry list)))
221 ((eq entry nil) (ex-splice-args-in-1-letr-cmd key list))
222 (t nil)
223 ))
224 ;; If we end up with an alias, look up the alias...
225 (if (stringp (cadr result))
226 (setq result (ex-cmd-assoc (cadr result) list)))
227 ;; and return the corresponding alist entry
228 result
229 ))
230
82 231
83;; A-list of Ex variables that can be set using the :set command. 232;; A-list of Ex variables that can be set using the :set command.
84(defconst ex-variable-alist 233(defconst ex-variable-alist
@@ -233,104 +382,17 @@ reversed."
233(defvar viper-last-ex-prompt "") 382(defvar viper-last-ex-prompt "")
234 383
235 384
236;;; Code
237
238;; Check if ex-token is an initial segment of STR
239(defun viper-check-sub (str)
240 (let ((length (length ex-token)))
241 (if (and (<= length (length str))
242 (string= ex-token (substring str 0 length)))
243 (setq ex-token str)
244 (setq ex-token-type 'non-command))))
245
246;; Get a complete ex command 385;; Get a complete ex command
247(defun viper-get-ex-com-subr () 386(defun viper-get-ex-com-subr ()
248 (let (case-fold-search) 387 (let (cmd case-fold-search)
249 (set-mark (point)) 388 (set-mark (point))
250 (re-search-forward "[a-zA-Z][a-zA-Z]*") 389 (re-search-forward "[a-zA-Z][a-zA-Z]*")
251 (setq ex-token-type 'command) 390 (setq ex-token-type 'command)
252 (setq ex-token (buffer-substring (point) (mark t))) 391 (setq ex-token (buffer-substring (point) (mark t)))
253 (exchange-point-and-mark) 392 (setq cmd (ex-cmd-assoc ex-token ex-token-alist))
254 (cond ((looking-at "a") 393 (if cmd
255 (cond ((looking-at "ab") (viper-check-sub "abbreviate")) 394 (setq ex-token (car cmd))
256 ((looking-at "ar") (viper-check-sub "args")) 395 (setq ex-token-type 'non-command))
257 (t (viper-check-sub "append"))))
258 ((looking-at "h") (viper-check-sub "help"))
259 ((looking-at "c")
260 (cond ((looking-at "cd") (viper-check-sub "cd"))
261 ((looking-at "ch") (viper-check-sub "chdir"))
262 ((looking-at "co") (viper-check-sub "copy"))
263 ((looking-at "cu") (viper-check-sub "customize"))
264 (t (viper-check-sub "change"))))
265 ((looking-at "d") (viper-check-sub "delete"))
266 ((looking-at "b") (viper-check-sub "buffer"))
267 ((looking-at "B") (viper-check-sub "Buffer"))
268 ((looking-at "e")
269 (if (looking-at "ex") (viper-check-sub "ex")
270 (viper-check-sub "edit")))
271 ((looking-at "f") (viper-check-sub "file"))
272 ((looking-at "g") (viper-check-sub "global"))
273 ((looking-at "i") (viper-check-sub "insert"))
274 ((looking-at "j") (viper-check-sub "join"))
275 ((looking-at "l") (viper-check-sub "list"))
276 ((looking-at "m")
277 (cond ((looking-at "map") (viper-check-sub "map"))
278 ((looking-at "mar") (viper-check-sub "mark"))
279 (t (viper-check-sub "move"))))
280 ((looking-at "k[a-z][^a-z]")
281 (setq ex-token "kmark")
282 (forward-char 1)
283 (exchange-point-and-mark)) ; this is canceled out by another
284 ; exchange-point-and-mark at the end
285 ((looking-at "k") (viper-check-sub "kmark"))
286 ((looking-at "n") (if (looking-at "nu")
287 (viper-check-sub "number")
288 (viper-check-sub "next")))
289 ((looking-at "N") (viper-check-sub "Next"))
290 ((looking-at "o") (viper-check-sub "open"))
291 ((looking-at "p")
292 (cond ((looking-at "pre") (viper-check-sub "preserve"))
293 ((looking-at "pu") (viper-check-sub "put"))
294 ((looking-at "pw") (viper-check-sub "pwd"))
295 (t (viper-check-sub "print"))))
296 ((looking-at "P") (viper-check-sub "PreviousRelatedFile"))
297 ((looking-at "R") (viper-check-sub "RelatedFile"))
298 ((looking-at "q") (viper-check-sub "quit"))
299 ((looking-at "r")
300 (cond ((looking-at "rec") (viper-check-sub "recover"))
301 ((looking-at "rew") (viper-check-sub "rewind"))
302 (t (viper-check-sub "read"))))
303 ((looking-at "s")
304 (cond ((looking-at "se") (viper-check-sub "set"))
305 ((looking-at "sh") (viper-check-sub "shell"))
306 ((looking-at "so") (viper-check-sub "source"))
307 ((looking-at "sr") (viper-check-sub "sr"))
308 ((looking-at "st") (viper-check-sub "stop"))
309 ((looking-at "sus") (viper-check-sub "suspend"))
310 ((looking-at "subm") (viper-check-sub "submitReport"))
311 (t (viper-check-sub "substitute"))))
312 ((looking-at "t")
313 (if (looking-at "ta") (viper-check-sub "tag")
314 (viper-check-sub "transfer")))
315 ((looking-at "u")
316 (cond ((looking-at "una") (viper-check-sub "unabbreviate"))
317 ((looking-at "unm") (viper-check-sub "unmap"))
318 (t (viper-check-sub "undo"))))
319 ((looking-at "v")
320 (cond ((looking-at "ve") (viper-check-sub "version"))
321 ((looking-at "vi") (viper-check-sub "visual"))
322 (t (viper-check-sub "vglobal"))))
323 ((looking-at "w")
324 (if (looking-at "wq") (viper-check-sub "wq")
325 (viper-check-sub "write")))
326 ((looking-at "W")
327 (if (looking-at "WW")
328 (viper-check-sub "WWrite")
329 (viper-check-sub "Write")))
330 ((looking-at "x") (viper-check-sub "xit"))
331 ((looking-at "y") (viper-check-sub "yank"))
332 ((looking-at "z") (viper-check-sub "z")))
333 (exchange-point-and-mark)
334 )) 396 ))
335 397
336;; Get an ex-token which is either an address or a command. 398;; Get an ex-token which is either an address or a command.
@@ -597,28 +659,28 @@ reversed."
597 (viper-get-ex-token) 659 (viper-get-ex-token)
598 (cond ((memq ex-token-type '(command end-mark)) 660 (cond ((memq ex-token-type '(command end-mark))
599 (if address (setq ex-addresses (cons address ex-addresses))) 661 (if address (setq ex-addresses (cons address ex-addresses)))
600 (cond ((string= ex-token "global") 662 (viper-deactivate-mark)
601 (ex-global nil) 663 (let ((cmd (ex-cmd-assoc ex-token ex-token-alist)))
602 (setq cont nil)) 664 (if (null cmd)
603 ((string= ex-token "vglobal") 665 (error "`%s': %s" ex-token viper-BadExCommand))
604 (ex-global t) 666 (ex-cmd-execute cmd)
605 (setq cont nil)) 667 (if (or (ex-cmd-is-mashed-with-args cmd)
606 (t 668 (ex-cmd-is-one-letter cmd))
607 (viper-execute-ex-command) 669 (setq cont nil)
608 (save-excursion 670 (save-excursion
609 (save-window-excursion 671 (save-window-excursion
610 (setq viper-ex-work-buf 672 (setq viper-ex-work-buf
611 (get-buffer-create viper-ex-work-buf-name)) 673 (get-buffer-create viper-ex-work-buf-name))
612 (set-buffer viper-ex-work-buf) 674 (set-buffer viper-ex-work-buf)
613 (skip-chars-forward " \t") 675 (skip-chars-forward " \t")
614 (cond ((looking-at "|") 676 (cond ((looking-at "|")
615 (forward-char 1)) 677 (forward-char 1))
616 ((looking-at "\n") 678 ((looking-at "\n")
617 (setq cont nil)) 679 (setq cont nil))
618 (t (error 680 (t (error
619 "`%s': %s" ex-token viper-SpuriousText))) 681 "`%s': %s" ex-token viper-SpuriousText)))
620 ))) 682 )))
621 )) 683 ))
622 ((eq ex-token-type 'non-command) 684 ((eq ex-token-type 'non-command)
623 (error "`%s': %s" ex-token viper-BadExCommand)) 685 (error "`%s': %s" ex-token viper-BadExCommand))
624 ((eq ex-token-type 'whole) 686 ((eq ex-token-type 'whole)
@@ -701,22 +763,6 @@ reversed."
701 (setq ex-token nil)) 763 (setq ex-token nil))
702 c))) 764 c)))
703 765
704;; get an ex command
705(defun viper-get-ex-command ()
706 (save-window-excursion
707 (setq viper-ex-work-buf (get-buffer-create viper-ex-work-buf-name))
708 (set-buffer viper-ex-work-buf)
709 (if (looking-at "/") (forward-char 1))
710 (skip-chars-forward " \t")
711 (cond ((looking-at "[a-z]")
712 (viper-get-ex-com-subr)
713 (if (eq ex-token-type 'non-command)
714 (error "`%s': %s" ex-token viper-BadExCommand)))
715 ((looking-at "[!=><&~]")
716 (setq ex-token (char-to-string (following-char)))
717 (forward-char 1))
718 (t (error viper-BadExCommand)))))
719
720;; Get an Ex option g or c 766;; Get an Ex option g or c
721(defun viper-get-ex-opt-gc (c) 767(defun viper-get-ex-opt-gc (c)
722 (save-window-excursion 768 (save-window-excursion
@@ -1067,83 +1113,6 @@ reversed."
1067 (concat viper-last-ex-prompt " !"))))) 1113 (concat viper-last-ex-prompt " !")))))
1068 (substring str (or beg 0) end))) 1114 (substring str (or beg 0) end)))
1069 1115
1070;; Execute ex command using the value of addresses
1071(defun viper-execute-ex-command ()
1072 (viper-deactivate-mark)
1073 (cond ((string= ex-token "args") (ex-args))
1074 ((string= ex-token "copy") (ex-copy nil))
1075 ((string= ex-token "cd") (ex-cd))
1076 ((string= ex-token "customize") (customize-group "viper"))
1077 ((string= ex-token "chdir") (ex-cd))
1078 ((string= ex-token "delete") (ex-delete))
1079 ((string= ex-token "edit") (ex-edit))
1080 ((string= ex-token "file") (viper-info-on-file))
1081 ((string= ex-token "goto") (ex-goto))
1082 ((string= ex-token "help") (ex-help))
1083 ((string= ex-token "join") (ex-line "join"))
1084 ((string= ex-token "kmark") (ex-mark))
1085 ((string= ex-token "mark") (ex-mark))
1086 ((string= ex-token "map") (ex-map))
1087 ((string= ex-token "move") (ex-copy t))
1088 ((string= ex-token "next") (ex-next ex-cycle-other-window))
1089 ((string= ex-token "Next") (ex-next (not ex-cycle-other-window)))
1090 ((string= ex-token "RelatedFile") (ex-next-related-buffer 1))
1091 ((string= ex-token "put") (ex-put))
1092 ((string= ex-token "pwd") (ex-pwd))
1093 ((string= ex-token "preserve") (ex-preserve))
1094 ((string= ex-token "PreviousRelatedFile") (ex-next-related-buffer -1))
1095 ((string= ex-token "quit") (ex-quit))
1096 ((string= ex-token "read") (ex-read))
1097 ((string= ex-token "recover") (ex-recover))
1098 ((string= ex-token "rewind") (ex-rewind))
1099 ((string= ex-token "submitReport") (viper-submit-report))
1100 ((string= ex-token "set") (ex-set))
1101 ((string= ex-token "shell") (ex-shell))
1102 ((string= ex-token "source") (ex-source))
1103 ((string= ex-token "sr") (ex-substitute t t))
1104 ((string= ex-token "substitute") (ex-substitute))
1105 ((string= ex-token "suspend") (suspend-emacs))
1106 ((string= ex-token "stop") (suspend-emacs))
1107 ((string= ex-token "transfer") (ex-copy nil))
1108 ((string= ex-token "buffer") (if ex-cycle-other-window
1109 (viper-switch-to-buffer-other-window)
1110 (viper-switch-to-buffer)))
1111 ((string= ex-token "Buffer") (if ex-cycle-other-window
1112 (viper-switch-to-buffer)
1113 (viper-switch-to-buffer-other-window)))
1114 ((string= ex-token "tag") (ex-tag))
1115 ((string= ex-token "undo") (viper-undo))
1116 ((string= ex-token "unmap") (ex-unmap))
1117 ((string= ex-token "version") (viper-version))
1118 ((string= ex-token "visual") (ex-edit))
1119 ((string= ex-token "write") (ex-write nil))
1120 ((string= ex-token "Write") (save-some-buffers))
1121 ((string= ex-token "wq") (ex-write t))
1122 ((string= ex-token "WWrite") (save-some-buffers t)) ; don't ask
1123 ((string= ex-token "xit") (ex-write t))
1124 ((string= ex-token "yank") (ex-yank))
1125 ((string= ex-token "!") (ex-command))
1126 ((string= ex-token "=") (ex-line-no))
1127 ((string= ex-token ">") (ex-line "right"))
1128 ((string= ex-token "<") (ex-line "left"))
1129 ((string= ex-token "&") (ex-substitute t))
1130 ((string= ex-token "~") (ex-substitute t t))
1131 ((or (string= ex-token "append")
1132 (string= ex-token "change")
1133 (string= ex-token "insert")
1134 (string= ex-token "open"))
1135 (error "`%s': Obsolete command, not supported by Viper" ex-token))
1136 ((or (string= ex-token "abbreviate")
1137 (string= ex-token "unabbreviate"))
1138 (error
1139 "`%s': Vi abbrevs are obsolete. Use the more powerful Emacs abbrevs"
1140 ex-token))
1141 ((or (string= ex-token "list")
1142 (string= ex-token "print")
1143 (string= ex-token "z")
1144 (string= ex-token "#"))
1145 (error "`%s': Command not implemented in Viper" ex-token))
1146 (t (error "`%s': %s" ex-token viper-BadExCommand))))
1147 1116
1148(defun viper-undisplayed-files () 1117(defun viper-undisplayed-files ()
1149 (mapcar 1118 (mapcar
@@ -1457,11 +1426,18 @@ reversed."
1457 1426
1458 1427
1459;; Ex mark command 1428;; Ex mark command
1460(defun ex-mark () 1429;; Sets the mark to the current point.
1430;; If name is omitted, get the name straight from the work buffer."
1431(defun ex-mark (&optional name)
1461 (let (char) 1432 (let (char)
1462 (if (null ex-addresses) 1433 (if (null ex-addresses)
1463 (setq ex-addresses 1434 (setq ex-addresses
1464 (cons (point) nil))) 1435 (cons (point) nil)))
1436 (if name
1437 (if (eq 1 (length name))
1438 (setq char (string-to-char name))
1439 (error "`%s': Spurious text \"%s\" after mark name."
1440 name (substring name 1) viper-SpuriousText))
1465 (save-window-excursion 1441 (save-window-excursion
1466 (setq viper-ex-work-buf (get-buffer-create viper-ex-work-buf-name)) 1442 (setq viper-ex-work-buf (get-buffer-create viper-ex-work-buf-name))
1467 (set-buffer viper-ex-work-buf) 1443 (set-buffer viper-ex-work-buf)
@@ -1473,7 +1449,7 @@ reversed."
1473 (skip-chars-forward " \t") 1449 (skip-chars-forward " \t")
1474 (if (not (looking-at "[\n|]")) 1450 (if (not (looking-at "[\n|]"))
1475 (error "`%s': %s" ex-token viper-SpuriousText))) 1451 (error "`%s': %s" ex-token viper-SpuriousText)))
1476 (error "`%s' requires a following letter" ex-token))) 1452 (error "`%s' requires a following letter" ex-token))))
1477 (save-excursion 1453 (save-excursion
1478 (goto-char (car ex-addresses)) 1454 (goto-char (car ex-addresses))
1479 (point-to-register (1+ (- char ?a)))))) 1455 (point-to-register (1+ (- char ?a))))))
diff --git a/lisp/emulation/viper-util.el b/lisp/emulation/viper-util.el
index 51f0efc6266..6956d0098e8 100644
--- a/lisp/emulation/viper-util.el
+++ b/lisp/emulation/viper-util.el
@@ -334,7 +334,6 @@
334(defun viper-append-filter-alist (lis1 lis2) 334(defun viper-append-filter-alist (lis1 lis2)
335 (let ((temp lis1) 335 (let ((temp lis1)
336 elt) 336 elt)
337
338 ;;filter-append the second list 337 ;;filter-append the second list
339 (while temp 338 (while temp
340 ;; delete all occurrences 339 ;; delete all occurrences
@@ -344,6 +343,7 @@
344 343
345 (nconc lis1 lis2))) 344 (nconc lis1 lis2)))
346 345
346
347 347
348;;; Support for :e, :r, :w file globbing 348;;; Support for :e, :r, :w file globbing
349 349
diff --git a/lisp/emulation/viper.el b/lisp/emulation/viper.el
index 63dd5006577..9e8efaf8b0d 100644
--- a/lisp/emulation/viper.el
+++ b/lisp/emulation/viper.el
@@ -6,9 +6,9 @@
6;; Keywords: emulations 6;; Keywords: emulations
7;; Author: Michael Kifer <kifer@cs.sunysb.edu> 7;; Author: Michael Kifer <kifer@cs.sunysb.edu>
8 8
9;; Copyright (C) 1994, 95, 96, 97, 98, 99, 2000 Free Software Foundation, Inc. 9;; Copyright (C) 1994, 95, 96, 97, 98, 99, 2000, 01 Free Software Foundation, Inc.
10 10
11(defconst viper-version "3.09 of January 19, 2001" 11(defconst viper-version "3.10 of March 3, 2001"
12 "The current version of Viper") 12 "The current version of Viper")
13 13
14;; This file is part of GNU Emacs. 14;; This file is part of GNU Emacs.
@@ -402,7 +402,8 @@ widget."
402 completion-list-mode 402 completion-list-mode
403 diff-mode 403 diff-mode
404 404
405 perl-mode cperl-mode 405 perl-mode
406 cperl-mode
406 javascript-mode 407 javascript-mode
407 tcl-mode 408 tcl-mode
408 python-mode 409 python-mode
diff --git a/man/ChangeLog b/man/ChangeLog
index 3da209ba8dd..e564fbd6d8f 100644
--- a/man/ChangeLog
+++ b/man/ChangeLog
@@ -1,3 +1,7 @@
12001-03-17 Michael Kifer <kifer@cs.sunysb.edu>
2
3 * viper.texi: Added credits.
4
12001-03-13 Thien-Thi Nguyen <ttn@gnu.org> 52001-03-13 Thien-Thi Nguyen <ttn@gnu.org>
2 6
3 * programs.texi: Update hideshow key bindings. 7 * programs.texi: Update hideshow key bindings.
diff --git a/man/viper.texi b/man/viper.texi
index c4c4158ac7f..20ca01c5576 100644
--- a/man/viper.texi
+++ b/man/viper.texi
@@ -4425,6 +4425,7 @@ aaronl@@vitelus.com (Aaron Lehmann),
4425ahg@@panix.com (Al Gelders), 4425ahg@@panix.com (Al Gelders),
4426amade@@diagram.fr (Paul-Bernard Amade), 4426amade@@diagram.fr (Paul-Bernard Amade),
4427ascott@@fws214.intel.com (Andy Scott), 4427ascott@@fws214.intel.com (Andy Scott),
4428bronson@@trestle.com (Scott Bronson),
4428cook@@biostat.wisc.edu (Tom Cook), 4429cook@@biostat.wisc.edu (Tom Cook),
4429csdayton@@midway.uchicago.edu (Soren Dayton), 4430csdayton@@midway.uchicago.edu (Soren Dayton),
4430dave@@hellgate.utah.edu, 4431dave@@hellgate.utah.edu,