aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorMichael Kifer2001-07-21 05:28:24 +0000
committerMichael Kifer2001-07-21 05:28:24 +0000
commit4960e7572aba4d10ef5f49b4dc27f3cc4a4a7af5 (patch)
tree88083e3fa4569e9e18dad3994d3e7d8809a9c33c /lisp
parent0582471880ed96258caccd64e4d8bcf3028c610d (diff)
downloademacs-4960e7572aba4d10ef5f49b4dc27f3cc4a4a7af5.tar.gz
emacs-4960e7572aba4d10ef5f49b4dc27f3cc4a4a7af5.zip
* viper-ex.el (ex-token-list,ex-cmd-execute): Revamped, courtesy
of Scott Bronson. (ex-cmd-assoc,ex-compile,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-get-ex-address-subr): convert registers to char data type. * viper-util.el (viper-int-to-char,viper-char-equal): new functions. (viper-memq-char): use viper-int-to-char. (viper-file-checked-in-p): use vc-locking-user, if vc doesn't have vc-locking-state. (viper-read-key): use viper-read-key-sequence. * viper.el (viper-major-mode-modifier-list): added inferior-emacs-lisp-mode. (this-major-mode-requires-vi-state): new function that uses simple heuristics to decide if vi state is appropriate. (set-viper-state-in-major-mode): use this-major-mode-requires-vi-state. (viper-non-hook-settings): don't advise read-key-sequence. (viper-read-key-sequence): new function that replaces the previously used advice to read-key-sequence. * viper-cmd.el (viper-test-com-defun,viper-exec-change, viper-exec-Change,viper-execute-com,viper-insert,viper-append, viper-Append,viper-Insert,viper-open-line,viper-Open-line, viper-open-line-at-point,viper-substitute,viper-overwrite, viper-replace-char-subr,viper-forward-word,viper-forward-Word): got rid of the negative character hack. (viper-escape-to-state,viper-replace-state-exit-cmd): use viper-read-key-sequence. (viper-envelop-ESC-key): no need for ad-get-orig-definition. (viper-minibuffer-standard-hook,viper-read-string-with-history): don't override existing minibuffer-setup-hook. (viper-mark-point,viper-goto-mark-subr,viper-brac-function): convert registers to char data type. (viper-autoindent): use viper-indent-line. * viper-keym.el: use viper-exec-key-in-emacs. * viper.texi: Added credits, new commands, like :make. * ediff-util.el: Copyright years. (ediff-choose-syntax-table): New function. (ediff-setup): Use ediff-choose-syntax-table. (ediff-file-checked-out-p,ediff-file-checked-in-p): check if vc-state is available. (ediff-make-temp-file): use ediff-coding-system-for-write. * ediff-init.el (ediff-with-syntax-table): New macro, uses with-syntax-table. (ediff-coding-system-for-read): from ediff-diff.el (ediff-coding-system-for-write): new variable. (ediff-highest-priority): fixed the bug having to do with disappearing overlays. (ediff-file-remote-p): use file-remote-p, if available. (ediff-listable-file): new function. (ediff-file-attributes): use ediff-listable-file. * ediff-mult.el (ediff-meta-insert-file-info1): use ediff-listable-file. * ediff-ptch.el (ediff-prompt-for-patch-file): use ediff-coding-system-for-read. (ediff-patch-file-internal): use ediff-coding-system-for-write. * ediff-diff.el (ediff-coding-system-for-read): moved to ediff-init.el. (ediff-match-diff3-line,ediff-get-diff3-group): improved pattern. * ediff.el: Date of last update, copyright years. * ediff-wind (ediff-setup-control-frame): Nill->nil. * ediff.texi: added clarifications, acknowledgements.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/ChangeLog75
-rw-r--r--lisp/ediff-diff.el13
-rw-r--r--lisp/ediff-init.el65
-rw-r--r--lisp/ediff-mult.el2
-rw-r--r--lisp/ediff-ptch.el9
-rw-r--r--lisp/ediff-util.el21
-rw-r--r--lisp/ediff.el4
-rw-r--r--lisp/emulation/viper-cmd.el183
-rw-r--r--lisp/emulation/viper-ex.el40
-rw-r--r--lisp/emulation/viper-keym.el4
-rw-r--r--lisp/emulation/viper-util.el29
-rw-r--r--lisp/emulation/viper.el76
12 files changed, 342 insertions, 179 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 2f14c6eedeb..55ad54cfcdd 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,78 @@
12001-07-21 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 (ediff-file-checked-out-p,ediff-file-checked-in-p): check if
7 vc-state is available.
8 (ediff-make-temp-file): use ediff-coding-system-for-write.
9
10 * ediff-init.el (ediff-with-syntax-table): New macro, uses
11 with-syntax-table.
12 (ediff-coding-system-for-read): from ediff-diff.el
13 (ediff-coding-system-for-write): new variable.
14 (ediff-highest-priority): fixed the bug having to do with disappearing
15 overlays.
16 (ediff-file-remote-p): use file-remote-p, if available.
17 (ediff-listable-file): new function.
18 (ediff-file-attributes): use ediff-listable-file.
19
20 * ediff-mult.el (ediff-meta-insert-file-info1): use
21 ediff-listable-file.
22
23 * ediff-ptch.el (ediff-prompt-for-patch-file): use
24 ediff-coding-system-for-read.
25 (ediff-patch-file-internal): use ediff-coding-system-for-write.
26
27 * ediff-diff.el (ediff-coding-system-for-read): moved to ediff-init.el.
28 (ediff-match-diff3-line,ediff-get-diff3-group): improved pattern.
29
30 * ediff.el: Date of last update, copyright years.
31
32 * ediff-wind (ediff-setup-control-frame): Nill->nil.
33
34 * viper-ex.el (ex-token-list,ex-cmd-execute): Revamped, courtesy
35 of Scott Bronson.
36 (ex-cmd-assoc,ex-compile,ex-cmd-one-letr): New functions.
37 (viper-check-sub,viper-get-ex-command,viper-execute-ex-command):
38 Deleted functions.
39 (viper-get-ex-com-subr,viper-ex,ex-mark): Changed to use the new
40 ex-token-list.
41 (viper-get-ex-address-subr): convert registers to char data type.
42
43 * viper-util.el (viper-int-to-char,viper-char-equal): new
44 functions.
45 (viper-memq-char): use viper-int-to-char.
46 (viper-file-checked-in-p): use vc-locking-user, if vc doesn't have
47 vc-locking-state.
48 (viper-read-key): use viper-read-key-sequence.
49
50 * viper.el (viper-major-mode-modifier-list): added
51 inferior-emacs-lisp-mode.
52 (this-major-mode-requires-vi-state): new function that uses simple
53 heuristics to decide if vi state is appropriate.
54 (set-viper-state-in-major-mode): use this-major-mode-requires-vi-state.
55 (viper-non-hook-settings): don't advise read-key-sequence.
56 (viper-read-key-sequence): new function that replaces the
57 previously used advice to read-key-sequence.
58
59 * viper-cmd.el (viper-test-com-defun,viper-exec-change,
60 viper-exec-Change,viper-execute-com,viper-insert,viper-append,
61 viper-Append,viper-Insert,viper-open-line,viper-Open-line,
62 viper-open-line-at-point,viper-substitute,viper-overwrite,
63 viper-replace-char-subr,viper-forward-word,viper-forward-Word):
64 got rid of the negative character hack.
65 (viper-escape-to-state,viper-replace-state-exit-cmd):
66 use viper-read-key-sequence.
67 (viper-envelop-ESC-key): no need for ad-get-orig-definition.
68 (viper-minibuffer-standard-hook,viper-read-string-with-history):
69 don't override existing minibuffer-setup-hook.
70 (viper-mark-point,viper-goto-mark-subr,viper-brac-function):
71 convert registers to char data type.
72 (viper-autoindent): use viper-indent-line.
73
74 * viper-keym.el: use viper-exec-key-in-emacs.
75
12001-07-20 Stefan Monnier <monnier@cs.yale.edu> 762001-07-20 Stefan Monnier <monnier@cs.yale.edu>
2 77
3 * server.el (server-visit-files): Fix variable name typo. 78 * server.el (server-visit-files): Fix variable name typo.
diff --git a/lisp/ediff-diff.el b/lisp/ediff-diff.el
index f2b2687c0c5..128737c4df3 100644
--- a/lisp/ediff-diff.el
+++ b/lisp/ediff-diff.el
@@ -57,15 +57,6 @@ Must produce output compatible with Unix's diff3 program."
57 :type 'string 57 :type 'string
58 :group 'ediff-diff) 58 :group 'ediff-diff)
59 59
60(defcustom ediff-coding-system-for-read 'raw-text
61 "*The coding system for read to use when running the diff program as a subprocess.
62In most cases, the default will do. However, under certain circumstances in
63Windows NT/98/95 you might need to use something like 'raw-text-dos here.
64So, if the output that your diff program sends to Emacs contains extra ^M's,
65you might need to experiment here, if the default or 'raw-text-dos doesn't
66work."
67 :type 'symbol
68 :group 'ediff-diff)
69 60
70;; The following functions must precede all defcustom-defined variables. 61;; The following functions must precede all defcustom-defined variables.
71 62
@@ -153,7 +144,7 @@ This output is not used by Ediff internally."
153 144
154;;; Support for diff3 145;;; Support for diff3
155 146
156(defvar ediff-match-diff3-line "^====\\(.?\\)$" 147(defvar ediff-match-diff3-line "^====\\(.?\\)\C-m?$"
157 "Pattern to match lines produced by diff3 that describe differences.") 148 "Pattern to match lines produced by diff3 that describe differences.")
158(defcustom ediff-diff3-options "" 149(defcustom ediff-diff3-options ""
159 "*Options to pass to `ediff-diff3-program'." 150 "*Options to pass to `ediff-diff3-program'."
@@ -918,7 +909,7 @@ delimiter regions"))
918 ;; can produce the groups in the order 1, 2, 3 or 1, 3, 2. 909 ;; can produce the groups in the order 1, 2, 3 or 1, 3, 2.
919 (save-excursion 910 (save-excursion
920 (re-search-forward 911 (re-search-forward
921 (concat "^" file ":\\([0-9]+\\)\\(,\\([0-9]+\\)\\)?\\([ac]\\)$")) 912 (concat "^" file ":\\([0-9]+\\)\\(,\\([0-9]+\\)\\)?\\([ac]\\)\C-m?$"))
922 (beginning-of-line 2) 913 (beginning-of-line 2)
923 ;; treatment depends on whether it is an "a" group or a "c" group 914 ;; treatment depends on whether it is an "a" group or a "c" group
924 (if (string-equal (buffer-substring (match-beginning 4) (match-end 4)) "c") 915 (if (string-equal (buffer-substring (match-beginning 4) (match-end 4)) "c")
diff --git a/lisp/ediff-init.el b/lisp/ediff-init.el
index 4594445a89f..fa8e0e9b794 100644
--- a/lisp/ediff-init.el
+++ b/lisp/ediff-init.el
@@ -1,4 +1,4 @@
1;;; ediff-init.el --- macros, variables, and defsubsts used by Ediff 1;;; ediff-init.el --- Macros, variables, and defsubsts used by Ediff
2 2
3;; Copyright (C) 1994, 1995, 1996, 1997, 2000 Free Software Foundation, Inc. 3;; Copyright (C) 1994, 1995, 1996, 1997, 2000 Free Software Foundation, Inc.
4 4
@@ -714,6 +714,22 @@ appropriate symbol: `rcs', `pcl-cvs', or `generic-sc' if you so desire."
714 :type 'symbol 714 :type 'symbol
715 :group 'ediff) 715 :group 'ediff)
716 716
717(defcustom ediff-coding-system-for-read 'raw-text
718 "*The coding system for read to use when running the diff program as a subprocess.
719In most cases, the default will do. However, under certain circumstances in
720Windows NT/98/95 you might need to use something like 'raw-text-dos here.
721So, if the output that your diff program sends to Emacs contains extra ^M's,
722you might need to experiment here, if the default or 'raw-text-dos doesn't
723work."
724 :type 'symbol
725 :group 'ediff)
726
727(defcustom ediff-coding-system-for-write 'no-conversion
728 "*The coding system for write to use when writing out difference regions
729to temp files when Ediff needs to find fine differences."
730 :type 'symbol
731 :group 'ediff)
732
717 733
718(if ediff-xemacs-p 734(if ediff-xemacs-p
719 (progn 735 (progn
@@ -1174,7 +1190,7 @@ this variable represents.")
1174(ediff-defvar-local ediff-current-diff-overlay-Ancestor nil 1190(ediff-defvar-local ediff-current-diff-overlay-Ancestor nil
1175 "Overlay for the current difference region in the ancestor buffer.") 1191 "Overlay for the current difference region in the ancestor buffer.")
1176 1192
1177;; Compute priority of ediff overlay. 1193;; Compute priority of a current ediff overlay.
1178(defun ediff-highest-priority (start end buffer) 1194(defun ediff-highest-priority (start end buffer)
1179 (let ((pos (max 1 (1- start))) 1195 (let ((pos (max 1 (1- start)))
1180 ovr-list) 1196 ovr-list)
@@ -1184,13 +1200,21 @@ this variable represents.")
1184 (while (< pos (min (point-max) (1+ end))) 1200 (while (< pos (min (point-max) (1+ end)))
1185 (setq ovr-list (append (overlays-at pos) ovr-list)) 1201 (setq ovr-list (append (overlays-at pos) ovr-list))
1186 (setq pos (next-overlay-change pos))) 1202 (setq pos (next-overlay-change pos)))
1187 (1+ (apply '+ 1203 (+ 1 ediff-shadow-overlay-priority
1188 (mapcar (lambda (ovr) 1204 (apply 'max
1189 (if ovr 1205 (mapcar
1190 (or (ediff-overlay-get ovr 'priority) 0) 1206 (lambda (ovr)
1191 0)) 1207 (if (and ovr
1192 ovr-list) 1208 ;; exclude ediff overlays from priority
1193 )) 1209 ;; calculation, or else priority will keep
1210 ;; increasing
1211 (null (ediff-overlay-get ovr 'ediff))
1212 (null (ediff-overlay-get ovr 'ediff-diff-num)))
1213 ;; use the overlay priority or 0
1214 (or (ediff-overlay-get ovr 'priority) 0)
1215 0))
1216 ovr-list)
1217 ))
1194 )))) 1218 ))))
1195 1219
1196 1220
@@ -1281,14 +1305,16 @@ This default should work without changes."
1281 1305
1282;;; In-line functions 1306;;; In-line functions
1283 1307
1284(or (fboundp 'ediff-file-remote-p) ; user supplied his own function: use it 1308;; If file-remote-p is defined (as in XEmacs, use it. Otherwise, check
1285 (defun ediff-file-remote-p (file-name) 1309;; if find-file-name-handler is defined for 'file-local-copy
1310(defun ediff-file-remote-p (file-name)
1311 (or (and (fboundp 'file-remote-p) (file-remote-p file-name))
1286 (find-file-name-handler file-name 'file-local-copy))) 1312 (find-file-name-handler file-name 'file-local-copy)))
1287;;; (or (and (featurep 'efs-auto) (efs-ftp-path file-name)) 1313
1288;;; (and (featurep 'tramp) (tramp-tramp-file-p file-name)) 1314;; File for which we can get attributes, such as size or date
1289;;; (and (fboundp 'file-remote-p) (file-remote-p file-name)) 1315(defun ediff-listable-file (file-name)
1290;;; ;; Can happen only in Emacs, since XEmacs has file-remote-p 1316 (let ((handler (find-file-name-handler file-name 'file-local-copy)))
1291;;; (and (require 'ange-ftp) (ange-ftp-ftp-name file-name))))) 1317 (or (null handler) (eq handler 'dired-handler-fn))))
1292 1318
1293 1319
1294(defsubst ediff-frame-unsplittable-p (frame) 1320(defsubst ediff-frame-unsplittable-p (frame)
@@ -1740,9 +1766,10 @@ Unless optional argument INPLACE is non-nil, return a new string."
1740 (apply 'message string args))) 1766 (apply 'message string args)))
1741 1767
1742(defun ediff-file-attributes (filename attr-number) 1768(defun ediff-file-attributes (filename attr-number)
1743 (if (ediff-file-remote-p filename) 1769 (if (ediff-listable-file filename)
1744 -1 1770 (nth attr-number (file-attributes filename))
1745 (nth attr-number (file-attributes filename)))) 1771 -1)
1772 )
1746 1773
1747(defsubst ediff-file-size (filename) 1774(defsubst ediff-file-size (filename)
1748 (ediff-file-attributes filename 7)) 1775 (ediff-file-attributes filename 7))
diff --git a/lisp/ediff-mult.el b/lisp/ediff-mult.el
index 206ef40351b..7115a2671f8 100644
--- a/lisp/ediff-mult.el
+++ b/lisp/ediff-mult.el
@@ -970,7 +970,7 @@ behavior."
970 500)) 970 500))
971 file-modtime file-size) 971 file-modtime file-size)
972 (cond ((not (stringp fname)) (setq file-size -2)) ; file doesn't exits 972 (cond ((not (stringp fname)) (setq file-size -2)) ; file doesn't exits
973 ((not (ediff-file-remote-p fname)) 973 ((ediff-listable-file fname)
974 (if (file-exists-p fname) 974 (if (file-exists-p fname)
975 ;; set real size and modtime 975 ;; set real size and modtime
976 (setq file-size (ediff-file-size fname) 976 (setq file-size (ediff-file-size fname)
diff --git a/lisp/ediff-ptch.el b/lisp/ediff-ptch.el
index 6cbd9bb70c6..95d93ed5899 100644
--- a/lisp/ediff-ptch.el
+++ b/lisp/ediff-ptch.el
@@ -408,7 +408,8 @@ are two possible targets for this patch. However, these files do not exist."
408(defun ediff-prompt-for-patch-file () 408(defun ediff-prompt-for-patch-file ()
409 (let ((dir (cond (ediff-patch-default-directory) ; try patch default dir 409 (let ((dir (cond (ediff-patch-default-directory) ; try patch default dir
410 (ediff-use-last-dir ediff-last-dir-patch) 410 (ediff-use-last-dir ediff-last-dir-patch)
411 (t default-directory)))) 411 (t default-directory)))
412 (coding-system-for-read ediff-coding-system-for-read))
412 (find-file-noselect 413 (find-file-noselect
413 (read-file-name 414 (read-file-name
414 (format "Patch is in file:%s " 415 (format "Patch is in file:%s "
@@ -445,7 +446,7 @@ are two possible targets for this patch. However, these files do not exist."
445 (goto-char (point-min)) 446 (goto-char (point-min))
446 (and (re-search-forward ediff-context-diff-label-regexp nil t) 447 (and (re-search-forward ediff-context-diff-label-regexp nil t)
447 (current-buffer))))) 448 (current-buffer)))))
448 (t (other-buffer (current-buffer) 'visible-ok))) 449 (t (ediff-other-buffer (current-buffer))))
449 'must-match))) 450 'must-match)))
450 451
451 452
@@ -576,6 +577,10 @@ optional argument, then use it."
576 ;; file for the purpose of patching. 577 ;; file for the purpose of patching.
577 (true-source-filename source-filename) 578 (true-source-filename source-filename)
578 (target-filename source-filename) 579 (target-filename source-filename)
580 ;; this ensures that the patch process gets patch buffer in the
581 ;; encoding that Emacs thinks is right for that type of text
582 (coding-system-for-write
583 (if (boundp 'buffer-file-coding-system) buffer-file-coding-system))
579 target-buf buf-to-patch file-name-magic-p 584 target-buf buf-to-patch file-name-magic-p
580 patch-return-code ctl-buf backup-style aux-wind) 585 patch-return-code ctl-buf backup-style aux-wind)
581 586
diff --git a/lisp/ediff-util.el b/lisp/ediff-util.el
index 2eabfa9fc86..8d0f7395149 100644
--- a/lisp/ediff-util.el
+++ b/lisp/ediff-util.el
@@ -1101,15 +1101,24 @@ of the current buffer."
1101(defsubst ediff-file-checked-out-p (file) 1101(defsubst ediff-file-checked-out-p (file)
1102 (or (not (featurep 'vc-hooks)) 1102 (or (not (featurep 'vc-hooks))
1103 (and (vc-backend file) 1103 (and (vc-backend file)
1104 (or (memq (vc-state file) '(edited needs-merge)) 1104 (if (fboundp 'vc-state)
1105 (stringp (vc-state file)))))) 1105 (or (memq (vc-state file) '(edited needs-merge))
1106 (stringp (vc-state file)))
1107 ;; XEmacs has no vc-state
1108 (vc-locking-user file))
1109 )))
1106 1110
1107(defsubst ediff-file-checked-in-p (file) 1111(defsubst ediff-file-checked-in-p (file)
1108 (and (featurep 'vc-hooks) 1112 (and (featurep 'vc-hooks)
1109 ;; CVS files are considered not checked in 1113 ;; CVS files are considered not checked in
1110 (not (memq (vc-backend file) '(nil CVS))) 1114 (not (memq (vc-backend file) '(nil CVS)))
1111 (not (memq (vc-state file) '(edited needs-merge))) 1115 (if (fboundp 'vc-state)
1112 (not (stringp (vc-state file))))) 1116 (progn
1117 (not (memq (vc-state file) '(edited needs-merge)))
1118 (not (stringp (vc-state file))))
1119 ;; XEmacs has no vc-state
1120 (not (vc-locking-user file)))
1121 ))
1113 1122
1114(defun ediff-file-compressed-p (file) 1123(defun ediff-file-compressed-p (file)
1115 (condition-case nil 1124 (condition-case nil
@@ -2971,7 +2980,7 @@ Hit \\[ediff-recenter] to reset the windows afterward."
2971(defun ediff-make-temp-file (buff &optional prefix given-file start end) 2980(defun ediff-make-temp-file (buff &optional prefix given-file start end)
2972 (let* ((p (ediff-convert-standard-filename (or prefix "ediff"))) 2981 (let* ((p (ediff-convert-standard-filename (or prefix "ediff")))
2973 (short-p p) 2982 (short-p p)
2974 (coding-system-for-write 'no-conversion) 2983 (coding-system-for-write ediff-coding-system-for-write)
2975 f short-f) 2984 f short-f)
2976 (if (and (fboundp 'msdos-long-file-names) 2985 (if (and (fboundp 'msdos-long-file-names)
2977 (not (msdos-long-file-names)) 2986 (not (msdos-long-file-names))
@@ -3464,7 +3473,7 @@ Ediff Control Panel to restore highlighting."
3464 ;; never detach 3473 ;; never detach
3465 (ediff-overlay-put 3474 (ediff-overlay-put
3466 overl (if ediff-emacs-p 'evaporate 'detachable) nil) 3475 overl (if ediff-emacs-p 'evaporate 'detachable) nil)
3467 ;; make vip-minibuffer-overlay open-ended 3476 ;; make overlay open-ended
3468 ;; In emacs, it is made open ended at creation time 3477 ;; In emacs, it is made open ended at creation time
3469 (if ediff-xemacs-p 3478 (if ediff-xemacs-p
3470 (progn 3479 (progn
diff --git a/lisp/ediff.el b/lisp/ediff.el
index d824128e4d0..a170d4b1a99 100644
--- a/lisp/ediff.el
+++ b/lisp/ediff.el
@@ -6,8 +6,8 @@
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.76" "The current version of Ediff")
10(defconst ediff-date "March 5, 2001" "Date of last update") 10(defconst ediff-date "July 18, 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-cmd.el b/lisp/emulation/viper-cmd.el
index 9033ac7ce02..d4574779412 100644
--- a/lisp/emulation/viper-cmd.el
+++ b/lisp/emulation/viper-cmd.el
@@ -74,18 +74,15 @@
74;; given symbol foo, foo-p is the test function, foos is the set of 74;; given symbol foo, foo-p is the test function, foos is the set of
75;; Viper command keys 75;; Viper command keys
76;; (macroexpand '(viper-test-com-defun foo)) 76;; (macroexpand '(viper-test-com-defun foo))
77;; (defun foo-p (com) (consp (memq (if (< com 0) (- com) com) foos))) 77;; (defun foo-p (com) (consp (memq com foos)))
78 78
79(defmacro viper-test-com-defun (name) 79(defmacro viper-test-com-defun (name)
80 (let* ((snm (symbol-name name)) 80 (let* ((snm (symbol-name name))
81 (nm-p (intern (concat snm "-p"))) 81 (nm-p (intern (concat snm "-p")))
82 (nms (intern (concat snm "s")))) 82 (nms (intern (concat snm "s"))))
83 `(defun ,nm-p (com) 83 `(defun ,nm-p (com)
84 (consp (viper-memq-char 84 (consp (viper-memq-char com ,nms)
85 (if (and (viper-characterp com) (< com 0)) 85 ))))
86 (- com) com)
87 ,nms)
88 ))))
89 86
90;; Variables for defining VI commands 87;; Variables for defining VI commands
91 88
@@ -725,10 +722,8 @@ Vi's prefix argument will be used. Otherwise, the prefix argument passed to
725 viper-emacs-kbd-minor-mode) 722 viper-emacs-kbd-minor-mode)
726 (unwind-protect 723 (unwind-protect
727 (progn 724 (progn
728 (setq com (key-binding (setq key 725 (setq com
729 (if viper-xemacs-p 726 (key-binding (setq key (viper-read-key-sequence nil))))
730 (read-key-sequence nil)
731 (read-key-sequence nil t)))))
732 ;; In case of binding indirection--chase definitions. 727 ;; In case of binding indirection--chase definitions.
733 ;; Have to do it here because we execute this command under 728 ;; Have to do it here because we execute this command under
734 ;; different keymaps, so command-execute may not do the 729 ;; different keymaps, so command-execute may not do the
@@ -797,6 +792,12 @@ Similar to viper-escape-to-emacs, but accepts forms rather than keystrokes."
797 (viper-set-mode-vars-for viper-current-state) 792 (viper-set-mode-vars-for viper-current-state)
798 result)) 793 result))
799 794
795;; This executes the last kbd event in emacs mode. Is used when we want to
796;; interpret certain keys directly in emacs (as, for example, in comint mode).
797(defun viper-exec-key-in-emacs (arg)
798 (interactive "P")
799 (viper-escape-to-emacs arg last-command-event))
800
800 801
801;; This is needed because minor modes sometimes override essential Viper 802;; This is needed because minor modes sometimes override essential Viper
802;; bindings. By letting Viper know which files these modes are in, it will 803;; bindings. By letting Viper know which files these modes are in, it will
@@ -878,9 +879,7 @@ as a Meta key and any number of multiple escapes is allowed."
878 (progn 879 (progn
879 (let (minor-mode-map-alist) 880 (let (minor-mode-map-alist)
880 (viper-set-unread-command-events event) 881 (viper-set-unread-command-events event)
881 (setq keyseq 882 (setq keyseq (read-key-sequence nil 'continue-echo))
882 (funcall
883 (ad-get-orig-definition 'read-key-sequence) nil))
884 ) ; let 883 ) ; let
885 ;; If keyseq translates into something that still has ESC 884 ;; If keyseq translates into something that still has ESC
886 ;; at the beginning, separate ESC from the rest of the seq. 885 ;; at the beginning, separate ESC from the rest of the seq.
@@ -933,8 +932,7 @@ as a Meta key and any number of multiple escapes is allowed."
933 ;; this is escape event with nothing after it 932 ;; this is escape event with nothing after it
934 ;; put in unread-command-event and then re-read 933 ;; put in unread-command-event and then re-read
935 (viper-set-unread-command-events event) 934 (viper-set-unread-command-events event)
936 (setq keyseq 935 (setq keyseq (read-key-sequence nil))
937 (funcall (ad-get-orig-definition 'read-key-sequence) nil))
938 )) 936 ))
939 ;; not an escape event 937 ;; not an escape event
940 (setq keyseq (vector event))) 938 (setq keyseq (vector event)))
@@ -1121,7 +1119,8 @@ as a Meta key and any number of multiple escapes is allowed."
1121 ;; execute apropriate region command. 1119 ;; execute apropriate region command.
1122 (let ((char (car com)) (com (cdr com))) 1120 (let ((char (car com)) (com (cdr com)))
1123 (setq prefix-arg (cons value com)) 1121 (setq prefix-arg (cons value com))
1124 (if (viper= char ?r) (viper-region prefix-arg) 1122 (if (viper= char ?r)
1123 (viper-region prefix-arg)
1125 (viper-Region prefix-arg)) 1124 (viper-Region prefix-arg))
1126 ;; reset prefix-arg 1125 ;; reset prefix-arg
1127 (setq prefix-arg nil)) 1126 (setq prefix-arg nil))
@@ -1249,9 +1248,10 @@ as a Meta key and any number of multiple escapes is allowed."
1249 (exchange-point-and-mark)) 1248 (exchange-point-and-mark))
1250 (if (eq (preceding-char) ?\n) 1249 (if (eq (preceding-char) ?\n)
1251 (viper-backward-char-carefully)) ; give back the newline 1250 (viper-backward-char-carefully)) ; give back the newline
1252 (if (viper= com ?c) 1251 (if (eq viper-intermediate-command 'viper-repeat)
1253 (viper-change (mark t) (point)) 1252 (viper-change-subr (mark t) (point))
1254 (viper-change-subr (mark t) (point)))) 1253 (viper-change (mark t) (point))
1254 ))
1255 1255
1256;; this is invoked by viper-substitute-line 1256;; this is invoked by viper-substitute-line
1257(defun viper-exec-Change (m-com com) 1257(defun viper-exec-Change (m-com com)
@@ -1271,9 +1271,10 @@ as a Meta key and any number of multiple escapes is allowed."
1271 (setq viper-use-register nil))) 1271 (setq viper-use-register nil)))
1272 (delete-region (mark t) (point))) 1272 (delete-region (mark t) (point)))
1273 (open-line 1) 1273 (open-line 1)
1274 (if (viper= com ?C) 1274 (if (eq viper-intermediate-command 'viper-repeat)
1275 (viper-change-state-to-insert) 1275 (viper-yank-last-insertion)
1276 (viper-yank-last-insertion))) 1276 (viper-change-state-to-insert)
1277 ))
1277 1278
1278(defun viper-exec-delete (m-com com) 1279(defun viper-exec-delete (m-com com)
1279 (or (and (markerp viper-com-point) (marker-position viper-com-point)) 1280 (or (and (markerp viper-com-point) (marker-position viper-com-point))
@@ -1455,15 +1456,13 @@ as a Meta key and any number of multiple escapes is allowed."
1455 ;; this is the special command `#' 1456 ;; this is the special command `#'
1456 (if (> com 128) 1457 (if (> com 128)
1457 (viper-special-prefix-com (- com 128)) 1458 (viper-special-prefix-com (- com 128))
1458 (let ((fn (aref viper-exec-array (if (< com 0) (- com) com)))) 1459 (let ((fn (aref viper-exec-array com)))
1459 (if (null fn) 1460 (if (null fn)
1460 (error "%c: %s" com viper-InvalidViCommand) 1461 (error "%c: %s" com viper-InvalidViCommand)
1461 (funcall fn m-com com)))) 1462 (funcall fn m-com com))))
1462 (if (viper-dotable-command-p com) 1463 (if (viper-dotable-command-p com)
1463 (viper-set-destructive-command 1464 (viper-set-destructive-command
1464 (list m-com val 1465 (list m-com val com reg nil nil)))
1465 (if (viper-memq-char com (list ?c ?C ?!)) (- com) com)
1466 reg nil nil)))
1467 )) 1466 ))
1468 1467
1469 1468
@@ -1889,8 +1888,7 @@ Undo previous insertion and inserts new."
1889 (if (fboundp 'minibuffer-prompt-end) 1888 (if (fboundp 'minibuffer-prompt-end)
1890 (delete-region (minibuffer-prompt-end) (point-max)) 1889 (delete-region (minibuffer-prompt-end) (point-max))
1891 (erase-buffer)) 1890 (erase-buffer))
1892 (insert initial))) 1891 (insert initial))))
1893 (viper-minibuffer-setup-sentinel))
1894 1892
1895(defsubst viper-minibuffer-real-start () 1893(defsubst viper-minibuffer-real-start ()
1896 (if (fboundp 'minibuffer-prompt-end) 1894 (if (fboundp 'minibuffer-prompt-end)
@@ -1994,7 +1992,16 @@ problems."
1994 ;; KEYMAP is used, if given, instead of minibuffer-local-map. 1992 ;; KEYMAP is used, if given, instead of minibuffer-local-map.
1995 ;; INIT-MESSAGE is the message temporarily displayed after entering the 1993 ;; INIT-MESSAGE is the message temporarily displayed after entering the
1996 ;; minibuffer. 1994 ;; minibuffer.
1997 (let ((minibuffer-setup-hook 'viper-minibuffer-standard-hook) 1995 (let ((minibuffer-setup-hook
1996 ;; stolen from add-hook
1997 (let ((old
1998 (if (boundp 'minibuffer-setup-hook)
1999 minibuffer-setup-hook
2000 nil)))
2001 (cons
2002 'viper-minibuffer-standard-hook
2003 (if (or (not (listp old)) (eq (car old) 'lambda))
2004 (list old) old))))
1998 (val "") 2005 (val "")
1999 (padding "") 2006 (padding "")
2000 temp-msg) 2007 temp-msg)
@@ -2059,7 +2066,7 @@ problems."
2059 (let ((val (viper-p-val arg)) 2066 (let ((val (viper-p-val arg))
2060 (com (viper-getcom arg))) 2067 (com (viper-getcom arg)))
2061 (viper-set-destructive-command (list 'viper-insert val ?r nil nil nil)) 2068 (viper-set-destructive-command (list 'viper-insert val ?r nil nil nil))
2062 (if com 2069 (if (eq viper-intermediate-command 'viper-repeat)
2063 (viper-loop val (viper-yank-last-insertion)) 2070 (viper-loop val (viper-yank-last-insertion))
2064 (viper-change-state-to-insert)))) 2071 (viper-change-state-to-insert))))
2065 2072
@@ -2071,7 +2078,7 @@ problems."
2071 (com (viper-getcom arg))) 2078 (com (viper-getcom arg)))
2072 (viper-set-destructive-command (list 'viper-append val ?r nil nil nil)) 2079 (viper-set-destructive-command (list 'viper-append val ?r nil nil nil))
2073 (if (not (eolp)) (forward-char)) 2080 (if (not (eolp)) (forward-char))
2074 (if (viper= com ?r) 2081 (if (eq viper-intermediate-command 'viper-repeat)
2075 (viper-loop val (viper-yank-last-insertion)) 2082 (viper-loop val (viper-yank-last-insertion))
2076 (viper-change-state-to-insert)))) 2083 (viper-change-state-to-insert))))
2077 2084
@@ -2083,7 +2090,7 @@ problems."
2083 (com (viper-getcom arg))) 2090 (com (viper-getcom arg)))
2084 (viper-set-destructive-command (list 'viper-Append val ?r nil nil nil)) 2091 (viper-set-destructive-command (list 'viper-Append val ?r nil nil nil))
2085 (end-of-line) 2092 (end-of-line)
2086 (if (viper= com ?r) 2093 (if (eq viper-intermediate-command 'viper-repeat)
2087 (viper-loop val (viper-yank-last-insertion)) 2094 (viper-loop val (viper-yank-last-insertion))
2088 (viper-change-state-to-insert)))) 2095 (viper-change-state-to-insert))))
2089 2096
@@ -2095,7 +2102,7 @@ problems."
2095 (com (viper-getcom arg))) 2102 (com (viper-getcom arg)))
2096 (viper-set-destructive-command (list 'viper-Insert val ?r nil nil nil)) 2103 (viper-set-destructive-command (list 'viper-Insert val ?r nil nil nil))
2097 (back-to-indentation) 2104 (back-to-indentation)
2098 (if (viper= com ?r) 2105 (if (eq viper-intermediate-command 'viper-repeat)
2099 (viper-loop val (viper-yank-last-insertion)) 2106 (viper-loop val (viper-yank-last-insertion))
2100 (viper-change-state-to-insert)))) 2107 (viper-change-state-to-insert))))
2101 2108
@@ -2107,26 +2114,15 @@ problems."
2107 (com (viper-getcom arg))) 2114 (com (viper-getcom arg)))
2108 (viper-set-destructive-command (list 'viper-open-line val ?r nil nil nil)) 2115 (viper-set-destructive-command (list 'viper-open-line val ?r nil nil nil))
2109 (let ((col (current-indentation))) 2116 (let ((col (current-indentation)))
2110 (if (viper= com ?r) 2117 (if (eq viper-intermediate-command 'viper-repeat)
2111 (viper-loop val 2118 (viper-loop val
2112 (end-of-line) 2119 (end-of-line)
2113 (newline 1) 2120 (newline 1)
2114 (if viper-auto-indent 2121 (viper-indent-line col)
2115 (progn
2116 (setq viper-cted t)
2117 (if viper-electric-mode
2118 (indent-according-to-mode)
2119 (indent-to col))
2120 ))
2121 (viper-yank-last-insertion)) 2122 (viper-yank-last-insertion))
2122 (end-of-line) 2123 (end-of-line)
2123 (newline 1) 2124 (newline 1)
2124 (if viper-auto-indent 2125 (viper-indent-line col)
2125 (progn
2126 (setq viper-cted t)
2127 (if viper-electric-mode
2128 (indent-according-to-mode)
2129 (indent-to col))))
2130 (viper-change-state-to-insert))))) 2126 (viper-change-state-to-insert)))))
2131 2127
2132(defun viper-Open-line (arg) 2128(defun viper-Open-line (arg)
@@ -2137,27 +2133,15 @@ problems."
2137 (com (viper-getcom arg))) 2133 (com (viper-getcom arg)))
2138 (viper-set-destructive-command (list 'viper-Open-line val ?r nil nil nil)) 2134 (viper-set-destructive-command (list 'viper-Open-line val ?r nil nil nil))
2139 (let ((col (current-indentation))) 2135 (let ((col (current-indentation)))
2140 (if (viper= com ?r) 2136 (if (eq viper-intermediate-command 'viper-repeat)
2141 (viper-loop val 2137 (viper-loop val
2142 (beginning-of-line) 2138 (beginning-of-line)
2143 (open-line 1) 2139 (open-line 1)
2144 (if viper-auto-indent 2140 (viper-indent-line col)
2145 (progn
2146 (setq viper-cted t)
2147 (if viper-electric-mode
2148 (indent-according-to-mode)
2149 (indent-to col))
2150 ))
2151 (viper-yank-last-insertion)) 2141 (viper-yank-last-insertion))
2152 (beginning-of-line) 2142 (beginning-of-line)
2153 (open-line 1) 2143 (open-line 1)
2154 (if viper-auto-indent 2144 (viper-indent-line col)
2155 (progn
2156 (setq viper-cted t)
2157 (if viper-electric-mode
2158 (indent-according-to-mode)
2159 (indent-to col))
2160 ))
2161 (viper-change-state-to-insert))))) 2145 (viper-change-state-to-insert)))))
2162 2146
2163(defun viper-open-line-at-point (arg) 2147(defun viper-open-line-at-point (arg)
@@ -2168,13 +2152,14 @@ problems."
2168 (com (viper-getcom arg))) 2152 (com (viper-getcom arg)))
2169 (viper-set-destructive-command 2153 (viper-set-destructive-command
2170 (list 'viper-open-line-at-point val ?r nil nil nil)) 2154 (list 'viper-open-line-at-point val ?r nil nil nil))
2171 (if (viper= com ?r) 2155 (if (eq viper-intermediate-command 'viper-repeat)
2172 (viper-loop val 2156 (viper-loop val
2173 (open-line 1) 2157 (open-line 1)
2174 (viper-yank-last-insertion)) 2158 (viper-yank-last-insertion))
2175 (open-line 1) 2159 (open-line 1)
2176 (viper-change-state-to-insert)))) 2160 (viper-change-state-to-insert))))
2177 2161
2162;; bound to s
2178(defun viper-substitute (arg) 2163(defun viper-substitute (arg)
2179 "Substitute characters." 2164 "Substitute characters."
2180 (interactive "P") 2165 (interactive "P")
@@ -2182,9 +2167,10 @@ problems."
2182 (com (viper-getcom arg))) 2167 (com (viper-getcom arg)))
2183 (push-mark nil t) 2168 (push-mark nil t)
2184 (forward-char val) 2169 (forward-char val)
2185 (if (viper= com ?r) 2170 (if (eq viper-intermediate-command 'viper-repeat)
2186 (viper-change-subr (mark t) (point)) 2171 (viper-change-subr (mark t) (point))
2187 (viper-change (mark t) (point))) 2172 (viper-change (mark t) (point)))
2173 ;; com is set to ?r when we repeat this comand with dot
2188 (viper-set-destructive-command (list 'viper-substitute val ?r nil nil nil)) 2174 (viper-set-destructive-command (list 'viper-substitute val ?r nil nil nil))
2189 )) 2175 ))
2190 2176
@@ -2356,7 +2342,7 @@ These keys are ESC, RET, and LineFeed"
2356 (if (eq this-command 'viper-intercept-ESC-key) 2342 (if (eq this-command 'viper-intercept-ESC-key)
2357 (setq com 'viper-exit-insert-state) 2343 (setq com 'viper-exit-insert-state)
2358 (viper-set-unread-command-events last-input-char) 2344 (viper-set-unread-command-events last-input-char)
2359 (setq com (key-binding (read-key-sequence nil)))) 2345 (setq com (key-binding (viper-read-key-sequence nil))))
2360 2346
2361 (condition-case conds 2347 (condition-case conds
2362 (command-execute com) 2348 (command-execute com)
@@ -2405,11 +2391,11 @@ These keys are ESC, RET, and LineFeed"
2405 (let ((val (viper-p-val arg)) 2391 (let ((val (viper-p-val arg))
2406 (com (viper-getcom arg)) (len)) 2392 (com (viper-getcom arg)) (len))
2407 (viper-set-destructive-command (list 'viper-overwrite val ?r nil nil nil)) 2393 (viper-set-destructive-command (list 'viper-overwrite val ?r nil nil nil))
2408 (if com 2394 (if (eq viper-intermediate-command 'viper-repeat)
2409 (progn 2395 (progn
2410 ;; Viper saves inserted text in viper-last-insertion 2396 ;; Viper saves inserted text in viper-last-insertion
2411 (setq len (length viper-last-insertion)) 2397 (setq len (length viper-last-insertion))
2412 (delete-char len) 2398 (delete-char (min len (- (point-max) (point) 1)))
2413 (viper-loop val (viper-yank-last-insertion))) 2399 (viper-loop val (viper-yank-last-insertion)))
2414 (setq last-command 'viper-overwrite) 2400 (setq last-command 'viper-overwrite)
2415 (viper-set-complex-command-for-undo) 2401 (viper-set-complex-command-for-undo)
@@ -2476,7 +2462,7 @@ These keys are ESC, RET, and LineFeed"
2476 2462
2477(defun viper-replace-char-subr (com arg) 2463(defun viper-replace-char-subr (com arg)
2478 (let (char) 2464 (let (char)
2479 (setq char (if (viper= com ?r) 2465 (setq char (if (eq viper-intermediate-command 'viper-repeat)
2480 viper-d-char 2466 viper-d-char
2481 (read-char))) 2467 (read-char)))
2482 (let (inhibit-quit) ; preserve consistency of undo-list and iso-accents 2468 (let (inhibit-quit) ; preserve consistency of undo-list and iso-accents
@@ -2694,15 +2680,17 @@ On reaching beginning of line, stop and signal error."
2694 (com (viper-getcom arg))) 2680 (com (viper-getcom arg)))
2695 (if com (viper-move-marker-locally 'viper-com-point (point))) 2681 (if com (viper-move-marker-locally 'viper-com-point (point)))
2696 (viper-forward-word-kernel val) 2682 (viper-forward-word-kernel val)
2697 (if com (progn 2683 (if com
2698 (cond ((viper-memq-char com (list ?c (- ?c))) 2684 (progn
2699 (viper-separator-skipback-special 'twice viper-com-point)) 2685 (cond ((viper-char-equal com ?c)
2700 ;; Yank words including the whitespace, but not newline 2686 (viper-separator-skipback-special 'twice viper-com-point))
2701 ((viper-memq-char com (list ?y (- ?y))) 2687 ;; Yank words including the whitespace, but not newline
2702 (viper-separator-skipback-special nil viper-com-point)) 2688 ((viper-char-equal com ?y)
2703 ((viper-dotable-command-p com) 2689 (viper-separator-skipback-special nil viper-com-point))
2704 (viper-separator-skipback-special nil viper-com-point))) 2690 ((viper-dotable-command-p com)
2705 (viper-execute-com 'viper-forward-word val com))))) 2691 (viper-separator-skipback-special nil viper-com-point)))
2692 (viper-execute-com 'viper-forward-word val com)))
2693 ))
2706 2694
2707 2695
2708(defun viper-forward-Word (arg) 2696(defun viper-forward-Word (arg)
@@ -2716,10 +2704,10 @@ On reaching beginning of line, stop and signal error."
2716 (viper-skip-nonseparators 'forward) 2704 (viper-skip-nonseparators 'forward)
2717 (viper-skip-separators t)) 2705 (viper-skip-separators t))
2718 (if com (progn 2706 (if com (progn
2719 (cond ((viper-memq-char com (list ?c (- ?c))) 2707 (cond ((viper-char-equal com ?c)
2720 (viper-separator-skipback-special 'twice viper-com-point)) 2708 (viper-separator-skipback-special 'twice viper-com-point))
2721 ;; Yank words including the whitespace, but not newline 2709 ;; Yank words including the whitespace, but not newline
2722 ((viper-memq-char com (list ?y (- ?y))) 2710 ((viper-char-equal com ?y)
2723 (viper-separator-skipback-special nil viper-com-point)) 2711 (viper-separator-skipback-special nil viper-com-point))
2724 ((viper-dotable-command-p com) 2712 ((viper-dotable-command-p com)
2725 (viper-separator-skipback-special nil viper-com-point))) 2713 (viper-separator-skipback-special nil viper-com-point)))
@@ -4234,7 +4222,7 @@ and regexp replace."
4234 (interactive) 4222 (interactive)
4235 (let ((char (read-char))) 4223 (let ((char (read-char)))
4236 (cond ((and (<= ?a char) (<= char ?z)) 4224 (cond ((and (<= ?a char) (<= char ?z))
4237 (point-to-register (1+ (- char ?a)))) 4225 (point-to-register (viper-int-to-char (1+ (- char ?a)))))
4238 ((viper= char ?<) (viper-mark-beginning-of-buffer)) 4226 ((viper= char ?<) (viper-mark-beginning-of-buffer))
4239 ((viper= char ?>) (viper-mark-end-of-buffer)) 4227 ((viper= char ?>) (viper-mark-end-of-buffer))
4240 ((viper= char ?.) (viper-set-mark-if-necessary)) 4228 ((viper= char ?.) (viper-set-mark-if-necessary))
@@ -4304,7 +4292,7 @@ One can use `` and '' to temporarily jump 1 step back."
4304 (backward-char 1))) 4292 (backward-char 1)))
4305 (cond ((viper-valid-register char '(letter)) 4293 (cond ((viper-valid-register char '(letter))
4306 (let* ((buff (current-buffer)) 4294 (let* ((buff (current-buffer))
4307 (reg (1+ (- char ?a))) 4295 (reg (viper-int-to-char (1+ (- char ?a))))
4308 (text-marker (get-register reg))) 4296 (text-marker (get-register reg)))
4309 ;; If marker points to file that had markers set (and those markers 4297 ;; If marker points to file that had markers set (and those markers
4310 ;; were saved (as e.g., in session.el), then restore those markers 4298 ;; were saved (as e.g., in session.el), then restore those markers
@@ -4410,6 +4398,19 @@ One can use `` and '' to temporarily jump 1 step back."
4410 (if (or (bolp) (viper-looking-back "[^ \t]")) 4398 (if (or (bolp) (viper-looking-back "[^ \t]"))
4411 (setq viper-cted nil))))) 4399 (setq viper-cted nil)))))
4412 4400
4401;; do smart indent
4402(defun viper-indent-line (col)
4403 (if viper-auto-indent
4404 (progn
4405 (setq viper-cted t)
4406 (if (and viper-electric-mode
4407 (not (memq major-mode '(fundamental-mode
4408 text-mode
4409 paragraph-indent-text-mode))))
4410 (indent-according-to-mode)
4411 (indent-to col)))))
4412
4413
4413(defun viper-autoindent () 4414(defun viper-autoindent ()
4414 "Auto Indentation, Vi-style." 4415 "Auto Indentation, Vi-style."
4415 (interactive) 4416 (interactive)
@@ -4427,17 +4428,7 @@ One can use `` and '' to temporarily jump 1 step back."
4427 ;; use \n instead of newline, or else <Return> will move the insert point 4428 ;; use \n instead of newline, or else <Return> will move the insert point
4428 ;;(newline 1) 4429 ;;(newline 1)
4429 (insert "\n") 4430 (insert "\n")
4430 (if viper-auto-indent 4431 (viper-indent-line viper-current-indent)
4431 (progn
4432 (setq viper-cted t)
4433 (if (and viper-electric-mode
4434 (not
4435 (memq major-mode '(fundamental-mode
4436 text-mode
4437 paragraph-indent-text-mode ))))
4438 (indent-according-to-mode)
4439 (indent-to viper-current-indent))
4440 ))
4441 )) 4432 ))
4442 4433
4443 4434
@@ -4469,7 +4460,7 @@ One can use `` and '' to temporarily jump 1 step back."
4469 ((viper= ?\] reg) 4460 ((viper= ?\] reg)
4470 (viper-heading-end arg)) 4461 (viper-heading-end arg))
4471 ((viper-valid-register reg '(letter)) 4462 ((viper-valid-register reg '(letter))
4472 (let* ((val (get-register (1+ (- reg ?a)))) 4463 (let* ((val (get-register (viper-int-to-char (1+ (- reg ?a)))))
4473 (buf (if (not (markerp val)) 4464 (buf (if (not (markerp val))
4474 (error viper-EmptyTextmarker reg) 4465 (error viper-EmptyTextmarker reg)
4475 (marker-buffer val))) 4466 (marker-buffer val)))
@@ -4699,17 +4690,17 @@ Please, specify your level now: ")
4699 (if (and enforce-buffer 4690 (if (and enforce-buffer
4700 (not (equal (current-buffer) (marker-buffer val)))) 4691 (not (equal (current-buffer) (marker-buffer val))))
4701 (error (concat viper-EmptyTextmarker " in this buffer") 4692 (error (concat viper-EmptyTextmarker " in this buffer")
4702 (1- (+ char ?a)))) 4693 (viper-int-to-char (1- (+ char ?a)))))
4703 (pop-to-buffer (marker-buffer val)) 4694 (pop-to-buffer (marker-buffer val))
4704 (goto-char val)) 4695 (goto-char val))
4705 ((and (consp val) (eq (car val) 'file)) 4696 ((and (consp val) (eq (car val) 'file))
4706 (find-file (cdr val))) 4697 (find-file (cdr val)))
4707 (t 4698 (t
4708 (error viper-EmptyTextmarker (1- (+ char ?a))))))) 4699 (error viper-EmptyTextmarker (viper-int-to-char (1- (+ char ?a))))))))
4709 4700
4710 4701
4711(defun viper-save-kill-buffer () 4702(defun viper-save-kill-buffer ()
4712 "Save then kill current buffer. " 4703 "Save then kill current buffer."
4713 (interactive) 4704 (interactive)
4714 (if (< viper-expert-level 2) 4705 (if (< viper-expert-level 2)
4715 (save-buffers-kill-emacs) 4706 (save-buffers-kill-emacs)
diff --git a/lisp/emulation/viper-ex.el b/lisp/emulation/viper-ex.el
index 3b01dd05241..398e5a937c6 100644
--- a/lisp/emulation/viper-ex.el
+++ b/lisp/emulation/viper-ex.el
@@ -122,6 +122,7 @@
122 ("k" (ex-mark) one-letter) 122 ("k" (ex-mark) one-letter)
123 ("kmark" (ex-mark)) 123 ("kmark" (ex-mark))
124 ("m" "move") 124 ("m" "move")
125 ("make" (ex-compile))
125 ; old viper doesn't specify a default for "ma" so leave it undefined 126 ; old viper doesn't specify a default for "ma" so leave it undefined
126 ("map" (ex-map)) 127 ("map" (ex-map))
127 ("mark" (ex-mark)) 128 ("mark" (ex-mark))
@@ -215,7 +216,7 @@
215;; If there is no appropriate key (no match or duplicate matches) return nil 216;; If there is no appropriate key (no match or duplicate matches) return nil
216(defun ex-cmd-assoc (key list) 217(defun ex-cmd-assoc (key list)
217 (let ((entry (try-completion key list)) 218 (let ((entry (try-completion key list))
218 result onelet) 219 result)
219 (setq result (cond 220 (setq result (cond
220 ((eq entry t) (assoc key list)) 221 ((eq entry t) (assoc key list))
221 ((stringp entry) (or (ex-splice-args-in-1-letr-cmd key list) 222 ((stringp entry) (or (ex-splice-args-in-1-letr-cmd key list)
@@ -320,6 +321,11 @@ Don't put `-c' here, as it is added automatically."
320 :type '(choice (const nil) string) 321 :type '(choice (const nil) string)
321 :group 'viper-ex) 322 :group 'viper-ex)
322 323
324(defcustom ex-compile-command "make"
325 "The comand to run when the user types :make."
326 :type 'string
327 :group 'viper-ex)
328
323(defcustom viper-glob-function 329(defcustom viper-glob-function
324 (cond (ex-unix-type-shell 'viper-glob-unix-files) 330 (cond (ex-unix-type-shell 'viper-glob-unix-files)
325 ((eq system-type 'emx) 'viper-glob-mswindows-files) ; OS/2 331 ((eq system-type 'emx) 'viper-glob-mswindows-files) ; OS/2
@@ -643,7 +649,7 @@ reversed."
643 'viper-ex-history 649 'viper-ex-history
644 ;; no default when working on region 650 ;; no default when working on region
645 (if initial-str 651 (if initial-str
646 "none" 652 nil
647 (car viper-ex-history)) 653 (car viper-ex-history))
648 map 654 map
649 (if initial-str 655 (if initial-str
@@ -855,8 +861,9 @@ reversed."
855 (save-excursion 861 (save-excursion
856 (if (null ex-token) 862 (if (null ex-token)
857 (exchange-point-and-mark) 863 (exchange-point-and-mark)
858 (goto-char (viper-register-to-point 864 (goto-char
859 (1+ (- ex-token ?a)) 'enforce-buffer))) 865 (viper-register-to-point
866 (viper-int-to-char (1+ (- ex-token ?a))) 'enforce-buffer)))
860 (setq address (point-marker))))) 867 (setq address (point-marker)))))
861 address)) 868 address))
862 869
@@ -1454,7 +1461,7 @@ reversed."
1454 (error "`%s' requires a following letter" ex-token)))) 1461 (error "`%s' requires a following letter" ex-token))))
1455 (save-excursion 1462 (save-excursion
1456 (goto-char (car ex-addresses)) 1463 (goto-char (car ex-addresses))
1457 (point-to-register (1+ (- char ?a)))))) 1464 (point-to-register (viper-int-to-char (1+ (- char ?a)))))))
1458 1465
1459 1466
1460 1467
@@ -2159,6 +2166,29 @@ Please contact your system administrator. "
2159 (shell-command-on-region (point) (mark t) command t)) 2166 (shell-command-on-region (point) (mark t) command t))
2160 (goto-char beg))))) 2167 (goto-char beg)))))
2161 2168
2169(defun ex-compile ()
2170 "Reads args from the command line, then runs make with the args.
2171If no args are given, then it runs the last compile command.
2172Type 'mak ' (including the space) to run make with no args."
2173 (let (args)
2174 (save-window-excursion
2175 (setq viper-ex-work-buf (get-buffer-create viper-ex-work-buf-name))
2176 (set-buffer viper-ex-work-buf)
2177 (setq args (buffer-substring (point) (point-max)))
2178 (end-of-line))
2179 ;; Remove the newline that may (will?) be at the end of the args
2180 (if (string= "\n" (substring args (1- (length args))))
2181 (setq args (substring args 0 (1- (length args)))))
2182 ;; Run last command if no args given, else construct a new command.
2183 (setq args
2184 (if (string= "" args)
2185 (if (boundp 'compile-command)
2186 compile-command
2187 ex-compile-command)
2188 (concat ex-compile-command " " args)))
2189 (compile args)
2190 ))
2191
2162;; Print line number 2192;; Print line number
2163(defun ex-line-no () 2193(defun ex-line-no ()
2164 (message "%d" 2194 (message "%d"
diff --git a/lisp/emulation/viper-keym.el b/lisp/emulation/viper-keym.el
index 2df1b388755..73155a05798 100644
--- a/lisp/emulation/viper-keym.el
+++ b/lisp/emulation/viper-keym.el
@@ -445,8 +445,8 @@ Useful in some modes, such as Gnus, MH, etc.")
445 445
446(defvar viper-comint-mode-modifier-map (make-sparse-keymap) 446(defvar viper-comint-mode-modifier-map (make-sparse-keymap)
447 "This map modifies comint mode.") 447 "This map modifies comint mode.")
448(define-key viper-comint-mode-modifier-map "\C-m" 'comint-send-input) 448(define-key viper-comint-mode-modifier-map "\C-m" 'viper-exec-key-in-emacs)
449(define-key viper-comint-mode-modifier-map "\C-d" 'comint-delchar-or-maybe-eof) 449(define-key viper-comint-mode-modifier-map "\C-d" 'viper-exec-key-in-emacs)
450 450
451(defvar viper-dired-modifier-map (make-sparse-keymap) 451(defvar viper-dired-modifier-map (make-sparse-keymap)
452 "This map modifies Dired behavior.") 452 "This map modifies Dired behavior.")
diff --git a/lisp/emulation/viper-util.el b/lisp/emulation/viper-util.el
index a27f20b626f..cacd8debd46 100644
--- a/lisp/emulation/viper-util.el
+++ b/lisp/emulation/viper-util.el
@@ -1,4 +1,4 @@
1;;; viper-util.el --- utilities used by viper.el 1;;; viper-util.el --- Utilities used by viper.el
2 2
3;; Copyright (C) 1994, 1995, 1996, 1997 Free Software Foundation, Inc. 3;; Copyright (C) 1994, 1995, 1996, 1997 Free Software Foundation, Inc.
4 4
@@ -103,16 +103,26 @@
103 (symbol-function 103 (symbol-function
104 (if viper-xemacs-p 'characterp 'integerp))) 104 (if viper-xemacs-p 'characterp 'integerp)))
105 105
106(fset 'viper-int-to-char
107 (symbol-function
108 (if viper-xemacs-p 'int-to-char 'identity)))
109
106;; CHAR is supposed to be a char or an integer (positive or negative) 110;; CHAR is supposed to be a char or an integer (positive or negative)
107;; LIST is a list of chars, nil, and negative numbers 111;; LIST is a list of chars, nil, and negative numbers
108;; Check if CHAR is a member by trying to convert into integers, if necessary. 112;; Check if CHAR is a member by trying to convert in characters, if necessary.
109;; Introduced for compatibility with XEmacs, where integers are not the same as 113;; Introduced for compatibility with XEmacs, where integers are not the same as
110;; chars. 114;; chars.
111(defun viper-memq-char (char list) 115(defun viper-memq-char (char list)
112 (cond (viper-emacs-p (memq char list)) 116 (cond ((and (integerp char) (>= char 0))
113 ((and (integerp char) (>= char 0)) (memq (int-to-char char) list)) 117 (memq (viper-int-to-char char) list))
114 ((memq char list)))) 118 ((memq char list))))
115 119
120;; Check if char-or-int and char are the same as characters
121(defun viper-char-equal (char-or-int char)
122 (cond ((and (integerp char-or-int) (>= char-or-int 0))
123 (= (viper-int-to-char char-or-int) char))
124 ((eq char-or-int char))))
125
116;; Like =, but accommodates null and also is t for eq-objects 126;; Like =, but accommodates null and also is t for eq-objects
117(defun viper= (char char1) 127(defun viper= (char char1)
118 (cond ((eq char char1) t) 128 (cond ((eq char char1) t)
@@ -683,8 +693,13 @@
683 (and (featurep 'vc-hooks) 693 (and (featurep 'vc-hooks)
684 ;; CVS files are considered not checked in 694 ;; CVS files are considered not checked in
685 (not (memq (vc-backend file) '(nil CVS))) 695 (not (memq (vc-backend file) '(nil CVS)))
686 (not (memq (vc-state file) '(edited needs-merge))) 696 (if (fboundp 'vc-state)
687 (not (stringp (vc-state file))))) 697 (progn
698 (not (memq (vc-state file) '(edited needs-merge)))
699 (not (stringp (vc-state file))))
700 ;; XEmacs has no vc-state
701 (not (vc-locking-user file)))
702 ))
688 703
689;; checkout if visited file is checked in 704;; checkout if visited file is checked in
690(defun viper-maybe-checkout (buf) 705(defun viper-maybe-checkout (buf)
@@ -926,7 +941,7 @@
926 help-char key) 941 help-char key)
927 (use-global-map viper-overriding-map) 942 (use-global-map viper-overriding-map)
928 (unwind-protect 943 (unwind-protect
929 (setq key (elt (read-key-sequence nil) 0)) 944 (setq key (elt (viper-read-key-sequence nil) 0))
930 (use-global-map global-map)) 945 (use-global-map global-map))
931 key)) 946 key))
932 947
diff --git a/lisp/emulation/viper.el b/lisp/emulation/viper.el
index 792bb1578b0..277ae0c408e 100644
--- a/lisp/emulation/viper.el
+++ b/lisp/emulation/viper.el
@@ -1,4 +1,4 @@
1;;; viper.el --- a full-featured Vi emulator for GNU Emacs and XEmacs, 1;;; viper.el --- A full-featured Vi emulator for GNU Emacs and XEmacs,
2;; a VI Plan for Emacs Rescue, 2;; a VI Plan for Emacs Rescue,
3;; and a venomous VI PERil. 3;; and a venomous VI PERil.
4;; Viper Is also a Package for Emacs Rebels. 4;; Viper Is also a Package for Emacs Rebels.
@@ -8,7 +8,7 @@
8 8
9;; Copyright (C) 1994, 95, 96, 97, 98, 99, 2000, 01 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.10 of March 3, 2001" 11(defconst viper-version "3.11 of July 18, 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.
@@ -401,6 +401,7 @@ widget."
401 401
402 completion-list-mode 402 completion-list-mode
403 diff-mode 403 diff-mode
404 idl-mode
404 405
405 perl-mode 406 perl-mode
406 cperl-mode 407 cperl-mode
@@ -446,6 +447,7 @@ unless it is coming up in a wrong Viper state."
446(defcustom viper-insert-state-mode-list 447(defcustom viper-insert-state-mode-list
447 '(internal-ange-ftp-mode 448 '(internal-ange-ftp-mode
448 comint-mode 449 comint-mode
450 inferior-emacs-lisp-mode
449 eshell-mode 451 eshell-mode
450 shell-mode) 452 shell-mode)
451 "*A list of major modes that should come up in Vi Insert state." 453 "*A list of major modes that should come up in Vi Insert state."
@@ -462,11 +464,14 @@ unless it is coming up in a wrong Viper state."
462 (nth 0 triple) (nth 1 triple) (eval (nth 2 triple)))) 464 (nth 0 triple) (nth 1 triple) (eval (nth 2 triple))))
463 viper-major-mode-modifier-list)) 465 viper-major-mode-modifier-list))
464 466
467;; We change standard bindings in some major mode, making them slightly
468;; different than in "normal" vi/insert/emacs states
465(defcustom viper-major-mode-modifier-list 469(defcustom viper-major-mode-modifier-list
466 '((help-mode emacs-state viper-slash-and-colon-map) 470 '((help-mode emacs-state viper-slash-and-colon-map)
467 (comint-mode insert-state viper-comint-mode-modifier-map) 471 (comint-mode insert-state viper-comint-mode-modifier-map)
468 (comint-mode vi-state viper-comint-mode-modifier-map) 472 (comint-mode vi-state viper-comint-mode-modifier-map)
469 (shell-mode insert-state viper-comint-mode-modifier-map) 473 (shell-mode insert-state viper-comint-mode-modifier-map)
474 (inferior-emacs-lisp-mode insert-state viper-comint-mode-modifier-map)
470 (shell-mode vi-state viper-comint-mode-modifier-map) 475 (shell-mode vi-state viper-comint-mode-modifier-map)
471 (ange-ftp-shell-mode insert-state viper-comint-mode-modifier-map) 476 (ange-ftp-shell-mode insert-state viper-comint-mode-modifier-map)
472 (ange-ftp-shell-mode vi-state viper-comint-mode-modifier-map) 477 (ange-ftp-shell-mode vi-state viper-comint-mode-modifier-map)
@@ -595,11 +600,23 @@ This startup message appears whenever you load Viper, unless you type `y' now."
595 600
596 (if viper-xemacs-p 601 (if viper-xemacs-p
597 (make-variable-buffer-local 'bar-cursor)) 602 (make-variable-buffer-local 'bar-cursor))
603 (if (eq major-mode 'viper-mode)
604 (setq major-mode 'fundamental-mode))
598 605
599 (or (memq major-mode viper-emacs-state-mode-list) ; don't switch to Vi 606 (or (memq major-mode viper-emacs-state-mode-list) ; don't switch to Vi
600 (memq major-mode viper-insert-state-mode-list) ; don't switch 607 (memq major-mode viper-insert-state-mode-list) ; don't switch
601 (viper-change-state-to-vi))))) 608 (viper-change-state-to-vi)))))
602 609
610
611;; Apply a little heuristic to invoke vi state on major-modes
612;; that are not listed in viper-vi-state-mode-list
613(defun this-major-mode-requires-vi-state (mode)
614 (cond ((memq mode viper-vi-state-mode-list) t)
615 ((memq mode viper-emacs-state-mode-list) nil)
616 ((memq mode viper-insert-state-mode-list) nil)
617 (t (and (eq (key-binding "a") 'self-insert-command)
618 (eq (key-binding " ") 'self-insert-command)))))
619
603 620
604;; This hook designed to enable Vi-style editing in comint-based modes." 621;; This hook designed to enable Vi-style editing in comint-based modes."
605(defun viper-comint-mode-hook () 622(defun viper-comint-mode-hook ()
@@ -760,7 +777,7 @@ remains buffer-local."
760 (lambda (buf) 777 (lambda (buf)
761 (if (viper-buffer-live-p buf) 778 (if (viper-buffer-live-p buf)
762 (with-current-buffer buf 779 (with-current-buffer buf
763 (cond ((and (memq major-mode viper-vi-state-mode-list) 780 (cond ((and (this-major-mode-requires-vi-state major-mode)
764 (eq viper-current-state 'emacs-state)) 781 (eq viper-current-state 'emacs-state))
765 (viper-mode)) 782 (viper-mode))
766 ((memq major-mode viper-emacs-state-mode-list) 783 ((memq major-mode viper-emacs-state-mode-list)
@@ -798,6 +815,8 @@ remains buffer-local."
798 ;; However, this has the effect that if the user didn't specify the 815 ;; However, this has the effect that if the user didn't specify the
799 ;; default mode, new buffers that fall back on the default will come up 816 ;; default mode, new buffers that fall back on the default will come up
800 ;; in Fundamental Mode and Vi state. 817 ;; in Fundamental Mode and Vi state.
818 ;; When viper-mode is executed in such a case, it will set the major mode
819 ;; back to fundamental-mode.
801 (if (eq default-major-mode 'fundamental-mode) 820 (if (eq default-major-mode 'fundamental-mode)
802 (setq default-major-mode 'viper-mode)) 821 (setq default-major-mode 'viper-mode))
803 822
@@ -956,36 +975,16 @@ remains buffer-local."
956 (setq global-mode-string 975 (setq global-mode-string
957 (append '("" viper-mode-string) (cdr global-mode-string)))) 976 (append '("" viper-mode-string) (cdr global-mode-string))))
958 977
959 (defadvice read-key-sequence (around viper-read-keyseq-ad activate)
960 "Harness to work for Viper. This advice is harmless---don't worry!"
961 (let (inhibit-quit event keyseq)
962 (setq keyseq ad-do-it)
963 (setq event (if viper-xemacs-p
964 (elt keyseq 0) ; XEmacs returns vector of events
965 (elt (listify-key-sequence keyseq) 0)))
966 (if (viper-ESC-event-p event)
967 (let (unread-command-events)
968 (viper-set-unread-command-events keyseq)
969 (if (viper-fast-keysequence-p)
970 (let ((viper-vi-global-user-minor-mode nil)
971 (viper-vi-local-user-minor-mode nil)
972 (viper-replace-minor-mode nil) ; actually unnecessary
973 (viper-insert-global-user-minor-mode nil)
974 (viper-insert-local-user-minor-mode nil))
975 (setq keyseq ad-do-it))
976 (setq keyseq ad-do-it))))
977 keyseq))
978
979 (defadvice describe-key (before viper-read-keyseq-ad protect activate) 978 (defadvice describe-key (before viper-read-keyseq-ad protect activate)
980 "Force to read key via `read-key-sequence'." 979 "Force to read key via `viper-read-key-sequence'."
981 (interactive (list (viper-events-to-keys 980 (interactive (list (viper-events-to-keys
982 (read-key-sequence "Describe key: "))))) 981 (viper-read-key-sequence "Describe key: ")))))
983 982
984 (defadvice describe-key-briefly 983 (defadvice describe-key-briefly
985 (before viper-read-keyseq-ad protect activate) 984 (before viper-read-keyseq-ad protect activate)
986 "Force to read key via `read-key-sequence'." 985 "Force to read key via `viper-read-key-sequence'."
987 (interactive (list (viper-events-to-keys 986 (interactive (list (viper-events-to-keys
988 (read-key-sequence "Describe key briefly: "))))) 987 (viper-read-key-sequence "Describe key briefly: ")))))
989 988
990 989
991 (defadvice find-file (before viper-add-suffix-advice activate) 990 (defadvice find-file (before viper-add-suffix-advice activate)
@@ -1056,6 +1055,27 @@ remains buffer-local."
1056 1055
1057 ) ; end viper-non-hook-settings 1056 ) ; end viper-non-hook-settings
1058 1057
1058;; Viperized read-key-sequence
1059(defun viper-read-key-sequence (prompt &optional continue-echo)
1060 (let (inhibit-quit event keyseq)
1061 (setq keyseq (read-key-sequence prompt continue-echo))
1062 (setq event (if viper-xemacs-p
1063 (elt keyseq 0) ; XEmacs returns vector of events
1064 (elt (listify-key-sequence keyseq) 0)))
1065 (if (viper-ESC-event-p event)
1066 (let (unread-command-events)
1067 (viper-set-unread-command-events keyseq)
1068 (if (viper-fast-keysequence-p)
1069 (let ((viper-vi-global-user-minor-mode nil)
1070 (viper-vi-local-user-minor-mode nil)
1071 (viper-replace-minor-mode nil) ; actually unnecessary
1072 (viper-insert-global-user-minor-mode nil)
1073 (viper-insert-local-user-minor-mode nil))
1074 (setq keyseq (read-key-sequence prompt continue-echo)))
1075 (setq keyseq (read-key-sequence prompt continue-echo)))))
1076 keyseq))
1077
1078
1059 1079
1060;; Ask only if this-command/last-command are nil, i.e., when loading 1080;; Ask only if this-command/last-command are nil, i.e., when loading
1061(cond ((and (eq viper-mode 'ask) (null this-command) (null last-command)) 1081(cond ((and (eq viper-mode 'ask) (null this-command) (null last-command))
@@ -1259,7 +1279,7 @@ These two lines must come in the order given.
1259 (setq-default minor-mode-map-alist minor-mode-map-alist) 1279 (setq-default minor-mode-map-alist minor-mode-map-alist)
1260 )) 1280 ))
1261 1281
1262(if (and viper-mode (memq major-mode viper-vi-state-mode-list)) 1282(if (and viper-mode (this-major-mode-requires-vi-state major-mode))
1263 (viper-mode)) 1283 (viper-mode))
1264 1284
1265(if viper-mode 1285(if viper-mode