aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Kifer1996-12-28 02:53:04 +0000
committerMichael Kifer1996-12-28 02:53:04 +0000
commitbf5d92c5e3c9eccf0adbf150c70bc4e656c7aa01 (patch)
tree710e2d34c85a2982384a996efb2ccffb6d523843
parent469b44cbf1916dc9502d4356e8fce0081809f585 (diff)
downloademacs-bf5d92c5e3c9eccf0adbf150c70bc4e656c7aa01.tar.gz
emacs-bf5d92c5e3c9eccf0adbf150c70bc4e656c7aa01.zip
*** empty log message ***
-rw-r--r--lisp/ediff-hook.el33
-rw-r--r--lisp/ediff-init.el19
-rw-r--r--lisp/ediff-mult.el13
-rw-r--r--lisp/ediff-ptch.el24
-rw-r--r--lisp/ediff-util.el180
-rw-r--r--lisp/ediff-wind.el10
-rw-r--r--lisp/ediff.el4
-rw-r--r--lisp/emulation/viper-keym.el1
-rw-r--r--lisp/emulation/viper-mous.el6
-rw-r--r--lisp/emulation/viper-util.el8
-rw-r--r--lisp/emulation/viper.el228
11 files changed, 414 insertions, 112 deletions
diff --git a/lisp/ediff-hook.el b/lisp/ediff-hook.el
index 0b9dc1fb61c..25c5afc1d8b 100644
--- a/lisp/ediff-hook.el
+++ b/lisp/ediff-hook.el
@@ -38,9 +38,24 @@
38(defvar epatch-menu) 38(defvar epatch-menu)
39;; end pacifier 39;; end pacifier
40 40
41
41(defun ediff-xemacs-init-menus () 42(defun ediff-xemacs-init-menus ()
42 (if (featurep 'menubar) 43 (if (featurep 'menubar)
43 (progn 44 (progn
45 (add-menu-button
46 '("Tools")
47 ["Use separate frame for Ediff control buffer"
48 ediff-toggle-multiframe
49 :style toggle
50 :selected (eq ediff-window-setup-function 'ediff-setup-windows-multiframe)]
51 "00-Browser...")
52 (add-menu-button
53 '("Tools")
54 ["Use a toolbar with Ediff control buffer"
55 ediff-menu-toggle-use-toolbar
56 :style toggle
57 :selected (ediff-use-toolbar-p)]
58 "00-Browser...")
44 (add-submenu 59 (add-submenu
45 '("Tools") ediff-menu "OO-Browser...") 60 '("Tools") ediff-menu "OO-Browser...")
46 (add-submenu 61 (add-submenu
@@ -128,6 +143,9 @@
128 ;; define ediff-menu 143 ;; define ediff-menu
129 (define-key menu-bar-ediff-menu [ediff-doc] 144 (define-key menu-bar-ediff-menu [ediff-doc]
130 '("Ediff Manual..." . ediff-documentation)) 145 '("Ediff Manual..." . ediff-documentation))
146 (define-key menu-bar-ediff-menu [emultiframe]
147 '("Toggle separate control buffer frame..."
148 . ediff-toggle-multiframe))
131 (define-key menu-bar-ediff-menu [eregistry] 149 (define-key menu-bar-ediff-menu [eregistry]
132 '("List Ediff Sessions..." . ediff-show-registry)) 150 '("List Ediff Sessions..." . ediff-show-registry))
133 (define-key menu-bar-ediff-menu [separator-ediff-manual] '("--")) 151 (define-key menu-bar-ediff-menu [separator-ediff-manual] '("--"))
@@ -165,6 +183,9 @@
165 ;; define merge menu 183 ;; define merge menu
166 (define-key menu-bar-ediff-merge-menu [ediff-doc2] 184 (define-key menu-bar-ediff-merge-menu [ediff-doc2]
167 '("Ediff Manual..." . ediff-documentation)) 185 '("Ediff Manual..." . ediff-documentation))
186 (define-key menu-bar-ediff-merge-menu [emultiframe2]
187 '("Toggle separate control buffer frame..."
188 . ediff-toggle-multiframe))
168 (define-key menu-bar-ediff-merge-menu [eregistry2] 189 (define-key menu-bar-ediff-merge-menu [eregistry2]
169 '("List Ediff Sessions..." . ediff-show-registry)) 190 '("List Ediff Sessions..." . ediff-show-registry))
170 (define-key 191 (define-key
@@ -204,6 +225,9 @@
204 ;; define epatch menu 225 ;; define epatch menu
205 (define-key menu-bar-epatch-menu [ediff-doc3] 226 (define-key menu-bar-epatch-menu [ediff-doc3]
206 '("Ediff Manual..." . ediff-documentation)) 227 '("Ediff Manual..." . ediff-documentation))
228 (define-key menu-bar-epatch-menu [emultiframe3]
229 '("Toggle separate control buffer frame..."
230 . ediff-toggle-multiframe))
207 (define-key menu-bar-epatch-menu [eregistry3] 231 (define-key menu-bar-epatch-menu [eregistry3]
208 '("List Ediff Sessions..." . ediff-show-registry)) 232 '("List Ediff Sessions..." . ediff-show-registry))
209 (define-key menu-bar-epatch-menu [separator-epatch] '("--")) 233 (define-key menu-bar-epatch-menu [separator-epatch] '("--"))
@@ -310,6 +334,15 @@
310 "ediff" 334 "ediff"
311 "Show Ediff's version and last modification date." 335 "Show Ediff's version and last modification date."
312 t) 336 t)
337 (autoload 'ediff-toggle-multiframe
338 "ediff-util"
339 "Toggle the use of separate frame for Ediff control buffer."
340 t)
341 (if (string-match "XEmacs" emacs-version)
342 (autoload 'ediff-toggle-use-toolbar
343 "ediff-tbar"
344 "Toggle the use of Ediff toolbar."
345 t))
313 ) ; if purify-flag 346 ) ; if purify-flag
314 347
315 348
diff --git a/lisp/ediff-init.el b/lisp/ediff-init.el
index f6aa724ee44..3da02d7242a 100644
--- a/lisp/ediff-init.el
+++ b/lisp/ediff-init.el
@@ -62,7 +62,7 @@ that Ediff doesn't know about.")
62 (ediff-force-faces) 62 (ediff-force-faces)
63 (ediff-emacs-p (memq (ediff-device-type) '(pc))) 63 (ediff-emacs-p (memq (ediff-device-type) '(pc)))
64 (ediff-xemacs-p (memq (ediff-device-type) '(tty pc))))) 64 (ediff-xemacs-p (memq (ediff-device-type) '(tty pc)))))
65 65
66 66
67;; Defines SYMBOL as an advertised local variable. 67;; Defines SYMBOL as an advertised local variable.
68;; Performs a defvar, then executes `make-variable-buffer-local' on 68;; Performs a defvar, then executes `make-variable-buffer-local' on
@@ -302,13 +302,18 @@ that Ediff doesn't know about.")
302 (memq (or metajob ediff-metajob-name) 302 (memq (or metajob ediff-metajob-name)
303 '(ediff-directories3 ediff-filegroups3))) 303 '(ediff-directories3 ediff-filegroups3)))
304 304
305(defsubst ediff-barf-if-not-control-buffer (&optional meta-buf) 305;; with no argument, checks if we are in ediff-control-buffer
306 (or (eq (if meta-buf ediff-meta-buffer ediff-control-buffer) 306;; with argument, checks if we are in ediff-meta-buffer
307 (current-buffer)) 307(defun ediff-in-control-buffer-p (&optional meta-buf-p)
308 (and (boundp 'ediff-control-buffer)
309 (eq (if meta-buf-p ediff-meta-buffer ediff-control-buffer)
310 (current-buffer))))
311
312(defsubst ediff-barf-if-not-control-buffer (&optional meta-buf-p)
313 (or (ediff-in-control-buffer-p meta-buf-p)
308 (error "%S: This command runs in Ediff Control Buffer only!" 314 (error "%S: This command runs in Ediff Control Buffer only!"
309 this-command))) 315 this-command)))
310 316
311
312;; Hook variables 317;; Hook variables
313 318
314(defvar ediff-before-setup-windows-hook nil 319(defvar ediff-before-setup-windows-hook nil
@@ -588,7 +593,6 @@ appropriate symbol: `rcs', `pcl-cvs', or `generic-sc' if you so desire.")
588 (fset 'ediff-delete-overlay (symbol-function 'delete-extent))) 593 (fset 'ediff-delete-overlay (symbol-function 'delete-extent)))
589 (fset 'ediff-read-event (symbol-function 'read-event)) 594 (fset 'ediff-read-event (symbol-function 'read-event))
590 (fset 'ediff-overlayp (symbol-function 'overlayp)) 595 (fset 'ediff-overlayp (symbol-function 'overlayp))
591 (fset 'ediff-overlayp (symbol-function 'overlayp))
592 (fset 'ediff-make-overlay (symbol-function 'make-overlay)) 596 (fset 'ediff-make-overlay (symbol-function 'make-overlay))
593 (fset 'ediff-delete-overlay (symbol-function 'delete-overlay))) 597 (fset 'ediff-delete-overlay (symbol-function 'delete-overlay)))
594 598
@@ -831,7 +835,8 @@ appropriate symbol: `rcs', `pcl-cvs', or `generic-sc' if you so desire.")
831 (ediff-hide-face 'ediff-current-diff-face-Ancestor) 835 (ediff-hide-face 'ediff-current-diff-face-Ancestor)
832 (or (face-differs-from-default-p 'ediff-current-diff-face-Ancestor) 836 (or (face-differs-from-default-p 'ediff-current-diff-face-Ancestor)
833 (copy-face 837 (copy-face
834 'ediff-current-diff-face-C 'ediff-current-diff-face-Ancestor)))) 838 'ediff-current-diff-face-C 'ediff-current-diff-face-Ancestor))
839 'ediff-current-diff-face-Ancestor))
835 "Face for highlighting the selected difference in the ancestor buffer.") 840 "Face for highlighting the selected difference in the ancestor buffer.")
836 841
837(defvar ediff-fine-diff-pixmap "gray3" 842(defvar ediff-fine-diff-pixmap "gray3"
diff --git a/lisp/ediff-mult.el b/lisp/ediff-mult.el
index 2a88f9dc036..2920e250e86 100644
--- a/lisp/ediff-mult.el
+++ b/lisp/ediff-mult.el
@@ -161,6 +161,11 @@ ediff-directories, is run.")
161 "*Hooks run just after the registry buffer is shown.") 161 "*Hooks run just after the registry buffer is shown.")
162(defvar ediff-show-session-group-hook nil 162(defvar ediff-show-session-group-hook nil
163 "*Hooks run just after a session group buffer is shown.") 163 "*Hooks run just after a session group buffer is shown.")
164(defvar ediff-meta-buffer-keymap-setup-hook nil
165 "*Hooks run just after setting up the ediff-meta-buffer-map.
166This keymap controls key bindings in the meta buffer and is a local variable.
167This means that you can set different bindings for different kinds of meta
168buffers.")
164 169
165;; buffer holding the multi-file patch. local to the meta buffer 170;; buffer holding the multi-file patch. local to the meta buffer
166(ediff-defvar-local ediff-meta-patchbufer nil "") 171(ediff-defvar-local ediff-meta-patchbufer nil "")
@@ -230,7 +235,9 @@ ediff-directories, is run.")
230 (define-key ediff-meta-buffer-map [mouse-2] ediff-meta-action-function) 235 (define-key ediff-meta-buffer-map [mouse-2] ediff-meta-action-function)
231 (define-key ediff-meta-buffer-map [button2] ediff-meta-action-function)) 236 (define-key ediff-meta-buffer-map [button2] ediff-meta-action-function))
232 237
233 (use-local-map ediff-meta-buffer-map)) 238 (use-local-map ediff-meta-buffer-map)
239 ;; modify ediff-meta-buffer-map here
240 (run-hooks 'ediff-meta-buffer-keymap-setup-hook))
234 241
235(defun ediff-meta-mode () 242(defun ediff-meta-mode ()
236 "This mode controls all operations on Ediff session groups. 243 "This mode controls all operations on Ediff session groups.
@@ -1275,6 +1282,7 @@ all marked sessions must be active."
1275 (setq ediff-merge-store-file 1282 (setq ediff-merge-store-file
1276 (, (concat 1283 (, (concat
1277 merge-autostore-dir 1284 merge-autostore-dir
1285 "mrg_"
1278 (file-name-nondirectory file1)))) 1286 (file-name-nondirectory file1))))
1279 ;; make ediff-startup pass 1287 ;; make ediff-startup pass
1280 ;; ediff-control-buffer back to the meta 1288 ;; ediff-control-buffer back to the meta
@@ -1291,6 +1299,7 @@ all marked sessions must be active."
1291 (setq ediff-merge-store-file 1299 (setq ediff-merge-store-file
1292 (, (concat 1300 (, (concat
1293 merge-autostore-dir 1301 merge-autostore-dir
1302 "mrg_"
1294 (file-name-nondirectory file1)))) 1303 (file-name-nondirectory file1))))
1295 ;; make ediff-startup pass 1304 ;; make ediff-startup pass
1296 ;; ediff-control-buffer back to the meta 1305 ;; ediff-control-buffer back to the meta
@@ -1306,6 +1315,7 @@ all marked sessions must be active."
1306 (setq ediff-merge-store-file 1315 (setq ediff-merge-store-file
1307 (, (concat 1316 (, (concat
1308 merge-autostore-dir 1317 merge-autostore-dir
1318 "mrg_"
1309 (file-name-nondirectory file1)))) 1319 (file-name-nondirectory file1))))
1310 ;; make ediff-startup pass 1320 ;; make ediff-startup pass
1311 ;; ediff-control-buffer back to the meta 1321 ;; ediff-control-buffer back to the meta
@@ -1320,6 +1330,7 @@ all marked sessions must be active."
1320 (setq ediff-merge-store-file 1330 (setq ediff-merge-store-file
1321 (, (concat 1331 (, (concat
1322 merge-autostore-dir 1332 merge-autostore-dir
1333 "mrg_"
1323 (file-name-nondirectory file1)))) 1334 (file-name-nondirectory file1))))
1324 (setq ediff-meta-buffer (, (current-buffer))) 1335 (setq ediff-meta-buffer (, (current-buffer)))
1325 ;; this arranges that ediff-startup will pass 1336 ;; this arranges that ediff-startup will pass
diff --git a/lisp/ediff-ptch.el b/lisp/ediff-ptch.el
index 960eb6fda93..309316d721e 100644
--- a/lisp/ediff-ptch.el
+++ b/lisp/ediff-ptch.el
@@ -462,10 +462,9 @@ Else, read patch file into a new buffer."
462 (setq file-name-magic-p (not (equal (file-truename true-source-filename) 462 (setq file-name-magic-p (not (equal (file-truename true-source-filename)
463 (file-truename source-filename)))) 463 (file-truename source-filename))))
464 464
465 ;; Checkout orig file, if necessary, so that the patched file could be 465 ;; Checkout orig file, if necessary, so that the patched file
466 ;; checked back in. 466 ;; could be checked back in.
467 (if (ediff-file-checked-in-p (buffer-file-name buf-to-patch)) 467 (ediff-maybe-checkout buf-to-patch)
468 (ediff-toggle-read-only buf-to-patch))
469 468
470 (ediff-eval-in-buffer patch-diagnostics 469 (ediff-eval-in-buffer patch-diagnostics
471 (insert-buffer patch-buf) 470 (insert-buffer patch-buf)
@@ -506,23 +505,28 @@ Else, read patch file into a new buffer."
506Patch has failed OR the backup version of the patched file was not created by 505Patch has failed OR the backup version of the patched file was not created by
507the patch program. 506the patch program.
508 507
509A possible reason is that the values of the variables 508One reason may be that the values of the variables
510 509
511ediff-patch-options = %S 510 ediff-patch-options = %S
512ediff-backup-extension = %S 511 ediff-backup-extension = %S
513ediff-backup-specs = %S 512 ediff-backup-specs = %S
514 513
515are not appropriate for the program specified in the variable 514are not appropriate for the program specified in the variable
516 515
517ediff-patch-program = %S 516 ediff-patch-program = %S
517
518Another reason could be that the %S program doesn't understand
519the format of the patch file you used.
518 520
519See Ediff on-line manual for more details on these variables. 521See Ediff on-line manual for more details on these variables.
520\(Or use a GNU-compatible patch program and stay out of trouble.\) 522\(Or use a GNU-compatible patch program and stay out of trouble.\)
521 523
522Type any key to continue... " 524Type any key to continue...
525"
523 ediff-patch-options 526 ediff-patch-options
524 ediff-backup-extension 527 ediff-backup-extension
525 ediff-backup-specs 528 ediff-backup-specs
529 ediff-patch-program
526 ediff-patch-program))) 530 ediff-patch-program)))
527 (beep 1) 531 (beep 1)
528 (if (setq aux-wind (get-buffer-window ediff-msg-buffer)) 532 (if (setq aux-wind (get-buffer-window ediff-msg-buffer))
diff --git a/lisp/ediff-util.el b/lisp/ediff-util.el
index f248135b5bf..0a625aa14df 100644
--- a/lisp/ediff-util.el
+++ b/lisp/ediff-util.el
@@ -23,10 +23,6 @@
23 23
24;;; Code: 24;;; Code:
25 25
26(require 'ediff-init)
27(require 'ediff-help)
28(require 'ediff-mult)
29
30;; Pacify compiler and avoid the need in checking for boundp 26;; Pacify compiler and avoid the need in checking for boundp
31(defvar ediff-patch-diagnostics nil) 27(defvar ediff-patch-diagnostics nil)
32(defvar ediff-patchbufer nil) 28(defvar ediff-patchbufer nil)
@@ -37,6 +33,17 @@
37 (load-file "ediff-help.el")))) 33 (load-file "ediff-help.el"))))
38;; end pacifier 34;; end pacifier
39 35
36(require 'ediff-init)
37(require 'ediff-help)
38(require 'ediff-mult)
39
40;;(if ediff-xemacs-p
41;; (require 'ediff-tbar)
42;; (defun ediff-use-toolbar-p () nil))
43;;
44;; for the time being
45(defun ediff-use-toolbar-p () nil)
46
40 47
41;;; Functions 48;;; Functions
42 49
@@ -489,6 +496,8 @@ to invocation.")
489 ediff-split-window-function 496 ediff-split-window-function
490 (ediff-multiframe-setup-p) 497 (ediff-multiframe-setup-p)
491 ediff-wide-display-p)) 498 ediff-wide-display-p))
499 (if (not (ediff-multiframe-setup-p))
500 (ediff-make-bottom-toolbar)) ; checks if toolbar is requested
492 (goto-char (point-min)) 501 (goto-char (point-min))
493 (skip-chars-forward ediff-whitespace))) 502 (skip-chars-forward ediff-whitespace)))
494 503
@@ -954,12 +963,13 @@ of the current buffer."
954 (setq toggle-ro-cmd 'toggle-read-only) 963 (setq toggle-ro-cmd 'toggle-read-only)
955 (beep 1) (beep 1) 964 (beep 1) (beep 1)
956 (message 965 (message
957 "Boy, this is risky! Better don't change this file...") 966 "Boy, this is risky! Don't modify this file...")
958 (sit-for 3)))) ; let the user see the warning 967 (sit-for 3)))) ; let the user see the warning
959 (if (and toggle-ro-cmd 968 (if (and toggle-ro-cmd
960 (string-match "toggle-read-only" (symbol-name toggle-ro-cmd))) 969 (string-match "toggle-read-only" (symbol-name toggle-ro-cmd)))
961 (save-excursion 970 (save-excursion
962 (save-window-excursion 971 (save-window-excursion
972 (select-window (ediff-get-visible-buffer-window buf))
963 (command-execute toggle-ro-cmd))) 973 (command-execute toggle-ro-cmd)))
964 (error "Don't know how to toggle read-only in buffer %S" buf)) 974 (error "Don't know how to toggle read-only in buffer %S" buf))
965 975
@@ -972,33 +982,51 @@ of the current buffer."
972 (message "Warning: file %s is read-only" 982 (message "Warning: file %s is read-only"
973 (ediff-abbreviate-file-name file) (beep 1))) 983 (ediff-abbreviate-file-name file) (beep 1)))
974 )))) 984 ))))
975
976 985
977;; This is a simple-minded check for whether a file is under version control 986;; checkout if visited file is checked in
978;; and is checked out. 987(defun ediff-maybe-checkout (buf)
988 (let ((file (buffer-file-name buf))
989 (checkout-function (key-binding "\C-x\C-q")))
990 (if (and (ediff-file-checked-in-p file)
991 (or (beep 1) t)
992 (y-or-n-p
993 (format
994 "File %s is under version control. Check it out? "
995 (ediff-abbreviate-file-name file))))
996 (ediff-eval-in-buffer buf
997 (command-execute checkout-function)))))
998
999
1000;; This is a simple-minded check for whether a file is under version control.
979;; If file,v exists but file doesn't, this file is considered to be not checked 1001;; If file,v exists but file doesn't, this file is considered to be not checked
980;; in and not checked out for the purpose of patching (since patch won't be 1002;; in and not checked out for the purpose of patching (since patch won't be
981;; able to read such a file anyway). 1003;; able to read such a file anyway).
982;; FILE is a string representing file name 1004;; FILE is a string representing file name
983(defun ediff-file-checked-out-p (file) 1005(defun ediff-file-under-version-control (file)
984 (and (stringp file) 1006 (let* ((filedir (file-name-directory file))
985 (file-exists-p file) 1007 (file-nondir (file-name-nondirectory file))
986 (file-writable-p file) 1008 (trial (concat file-nondir ",v"))
987 (or 1009 (full-trial (concat filedir trial))
988 (file-exists-p (concat file ",v")) 1010 (full-rcs-trial (concat filedir "RCS/" trial)))
989 (file-exists-p (concat (file-name-directory file) 1011 (and (stringp file)
990 "RCS/" 1012 (file-exists-p file)
991 (file-name-nondirectory file) 1013 (or
992 ",v"))) 1014 (and
1015 (file-exists-p full-trial)
1016 ;; in FAT FS, `file,v' and `file' may turn out to be the same!
1017 ;; don't be fooled by this!
1018 (not (equal (file-attributes file)
1019 (file-attributes full-trial))))
1020 ;; check if a version is in RCS/ directory
1021 (file-exists-p full-rcs-trial)))
993 )) 1022 ))
1023
1024(defun ediff-file-checked-out-p (file)
1025 (and (ediff-file-under-version-control file)
1026 (file-writable-p file)))
994(defun ediff-file-checked-in-p (file) 1027(defun ediff-file-checked-in-p (file)
995 (and (stringp file) 1028 (and (ediff-file-under-version-control file)
996 (file-exists-p file) 1029 (not (file-writable-p file))))
997 (not (file-writable-p file))
998 (or
999 (file-exists-p (concat file ",v"))
1000 (file-exists-p (concat "RCS/" file ",v")))
1001 ))
1002 1030
1003(defun ediff-swap-buffers () 1031(defun ediff-swap-buffers ()
1004 "Rotate the display of buffers A, B, and C." 1032 "Rotate the display of buffers A, B, and C."
@@ -1132,21 +1160,56 @@ This is especially useful when comparing buffers side-by-side."
1132 (setq ediff-window-B nil) ; force update of window config 1160 (setq ediff-window-B nil) ; force update of window config
1133 (ediff-recenter 'no-rehighlight))))) 1161 (ediff-recenter 'no-rehighlight)))))
1134 1162
1163;;;###autoload
1135(defun ediff-toggle-multiframe () 1164(defun ediff-toggle-multiframe ()
1136 "Switch from the multiframe display to single-frame display and back. 1165 "Switch from the multiframe display to single-frame display and back.
1137For a permanent change, set the variable `ediff-window-setup-function', 1166For a permanent change, set the variable `ediff-window-setup-function',
1138which see." 1167which see."
1139 (interactive) 1168 (interactive)
1140 (ediff-barf-if-not-control-buffer) 1169 (let (set-func)
1141 (or (ediff-window-display-p) 1170 (or (ediff-window-display-p)
1142 (error "%sEmacs is not running as a window application" 1171 (error "%sEmacs is not running as a window application"
1143 (if ediff-emacs-p "" "X"))) 1172 (if ediff-emacs-p "" "X")))
1173
1174 (setq set-func (if (ediff-in-control-buffer-p) 'setq 'setq-default))
1175
1144 (cond ((eq ediff-window-setup-function 'ediff-setup-windows-multiframe) 1176 (cond ((eq ediff-window-setup-function 'ediff-setup-windows-multiframe)
1145 (setq ediff-window-setup-function 'ediff-setup-windows-plain)) 1177 (eval
1178 (list
1179 set-func
1180 'ediff-window-setup-function ''ediff-setup-windows-plain)))
1146 ((eq ediff-window-setup-function 'ediff-setup-windows-plain) 1181 ((eq ediff-window-setup-function 'ediff-setup-windows-plain)
1147 (setq ediff-window-setup-function 'ediff-setup-windows-multiframe))) 1182 (if (ediff-in-control-buffer-p)
1148 (setq ediff-window-B nil) 1183 (ediff-kill-bottom-toolbar))
1149 (ediff-recenter 'no-rehighlight)) 1184 (eval
1185 (list
1186 set-func
1187 'ediff-window-setup-function ''ediff-setup-windows-multiframe))))
1188 (if (ediff-in-control-buffer-p)
1189 (progn
1190 (setq ediff-window-B nil)
1191 (ediff-recenter 'no-rehighlight)))))
1192
1193;; if was using toolbar, kill it
1194(defun ediff-kill-bottom-toolbar ()
1195 ;; Using ctl-buffer or ediff-control-window for LOCALE does not
1196 ;; work properly in XEmacs 19.14: we have to use
1197 ;;(selected-frame).
1198 ;; The problem with this is that any previous bottom-toolbar
1199 ;; will not re-appear after our cleanup here. Is there a way
1200 ;; to do "push" and "pop" toolbars ? --marcpa
1201 (if (ediff-use-toolbar-p)
1202 (progn
1203 (set-specifier bottom-toolbar (list (selected-frame) nil))
1204 (set-specifier bottom-toolbar-visible-p (list (selected-frame) nil)))))
1205
1206;; if wants to use toolbar, make it
1207(defun ediff-make-bottom-toolbar ()
1208 (if (ediff-use-toolbar-p)
1209 (progn
1210 (set-specifier bottom-toolbar (list (selected-frame) ediff-toolbar))
1211 (set-specifier bottom-toolbar-visible-p (list (selected-frame) t))
1212 (set-specifier bottom-toolbar-height (list (selected-frame) 34)))))
1150 1213
1151;; Merging 1214;; Merging
1152 1215
@@ -2262,6 +2325,10 @@ temporarily reverses the meaning of this variable."
2262 2325
2263 (if (and (ediff-window-display-p) (frame-live-p ctl-frame)) 2326 (if (and (ediff-window-display-p) (frame-live-p ctl-frame))
2264 (delete-frame ctl-frame)) 2327 (delete-frame ctl-frame))
2328 ;; Hide bottom toolbar. --marcpa
2329 (if (not (ediff-multiframe-setup-p))
2330 (ediff-kill-bottom-toolbar))
2331
2265 (ediff-kill-buffer-carefully ctl-buf) 2332 (ediff-kill-buffer-carefully ctl-buf)
2266 2333
2267 (delete-other-windows) 2334 (delete-other-windows)
@@ -2343,8 +2410,9 @@ only if this merge job is part of a group, i.e., was invoked from within
2343 (read-file-name "Save the result of the merge in: ")) 2410 (read-file-name "Save the result of the merge in: "))
2344 (ediff-write-merge-buffer-then-kill 2411 (ediff-write-merge-buffer-then-kill
2345 ediff-buffer-C merge-store-file)) 2412 ediff-buffer-C merge-store-file))
2346 ((ediff-eval-in-buffer ediff-meta-buffer 2413 ((and (ediff-buffer-live-p ediff-meta-buffer)
2347 (ediff-merge-metajob)) 2414 (ediff-eval-in-buffer ediff-meta-buffer
2415 (ediff-merge-metajob)))
2348 ;; This case shouldn't occur, as the parent metajob must pass on 2416 ;; This case shouldn't occur, as the parent metajob must pass on
2349 ;; a file name, ediff-merge-store-file, where to save the result 2417 ;; a file name, ediff-merge-store-file, where to save the result
2350 ;; of the merge. 2418 ;; of the merge.
@@ -2837,6 +2905,8 @@ Ediff Control Panel to restore highlighting."
2837 (interactive) 2905 (interactive)
2838 (let ((answer "") 2906 (let ((answer "")
2839 (possibilities (list ?A ?B ?C)) 2907 (possibilities (list ?A ?B ?C))
2908 (zmacs-regions t)
2909 quit-now
2840 begA begB endA endB bufA bufB) 2910 begA begB endA endB bufA bufB)
2841 2911
2842 (cond ((ediff-merge-job) 2912 (cond ((ediff-merge-job)
@@ -2849,7 +2919,7 @@ Ediff Control Panel to restore highlighting."
2849 nil) 2919 nil)
2850 ((equal answer "")) 2920 ((equal answer ""))
2851 (t (beep 1) 2921 (t (beep 1)
2852 (message "Valid answers are A or B") 2922 (message "Valid values are A or B")
2853 (sit-for 2) 2923 (sit-for 2)
2854 t)) 2924 t))
2855 (let ((cursor-in-echo-area t)) 2925 (let ((cursor-in-echo-area t))
@@ -2866,7 +2936,7 @@ Ediff Control Panel to restore highlighting."
2866 ((equal answer "")) 2936 ((equal answer ""))
2867 (t (beep 1) 2937 (t (beep 1)
2868 (message 2938 (message
2869 "Valid answers are %s" 2939 "Valid values are %s"
2870 (mapconcat 'char-to-string possibilities " or ")) 2940 (mapconcat 'char-to-string possibilities " or "))
2871 (sit-for 2) 2941 (sit-for 2)
2872 t)) 2942 t))
@@ -2884,7 +2954,7 @@ Ediff Control Panel to restore highlighting."
2884 ((equal answer "")) 2954 ((equal answer ""))
2885 (t (beep 1) 2955 (t (beep 1)
2886 (message 2956 (message
2887 "Valid answers are %s" 2957 "Valid values are %s"
2888 (mapconcat 'char-to-string possibilities " or ")) 2958 (mapconcat 'char-to-string possibilities " or "))
2889 (sit-for 2) 2959 (sit-for 2)
2890 t)) 2960 t))
@@ -2897,6 +2967,8 @@ Ediff Control Panel to restore highlighting."
2897 bufB ediff-buffer-B))) 2967 bufB ediff-buffer-B)))
2898 2968
2899 (ediff-eval-in-buffer bufA 2969 (ediff-eval-in-buffer bufA
2970 (or (mark t)
2971 (error "You forgot to specify a region in buffer %s" (buffer-name)))
2900 (setq begA (region-beginning) 2972 (setq begA (region-beginning)
2901 endA (region-end)) 2973 endA (region-end))
2902 (goto-char begA) 2974 (goto-char begA)
@@ -2907,6 +2979,8 @@ Ediff Control Panel to restore highlighting."
2907 (or (eobp) (forward-char)) ; include the newline char 2979 (or (eobp) (forward-char)) ; include the newline char
2908 (setq endA (point))) 2980 (setq endA (point)))
2909 (ediff-eval-in-buffer bufB 2981 (ediff-eval-in-buffer bufB
2982 (or (mark t)
2983 (error "You forgot to specify a region in buffer %s" (buffer-name)))
2910 (setq begB (region-beginning) 2984 (setq begB (region-beginning)
2911 endB (region-end)) 2985 endB (region-end))
2912 (goto-char begB) 2986 (goto-char begB)
@@ -2921,6 +2995,32 @@ Ediff Control Panel to restore highlighting."
2921 ediff-current-difference 'unselect-only) 2995 ediff-current-difference 'unselect-only)
2922 (ediff-paint-background-regions 'unhighlight) 2996 (ediff-paint-background-regions 'unhighlight)
2923 2997
2998 (ediff-eval-in-buffer bufA
2999 (goto-char begA)
3000 (set-mark endA)
3001 (narrow-to-region begA endA)
3002 ;; (ediff-activate-mark)
3003 )
3004 ;; (sit-for 0)
3005 (ediff-eval-in-buffer bufB
3006 (goto-char begB)
3007 (set-mark endB)
3008 (narrow-to-region begB endB)
3009 ;; (ediff-activate-mark)
3010 )
3011 ;; (sit-for 0)
3012
3013 (or (y-or-n-p
3014 "Please check the selected regions. Continue? ")
3015 (setq quit-now t))
3016
3017 (ediff-eval-in-buffer bufA
3018 (widen))
3019 (ediff-eval-in-buffer bufB
3020 (widen))
3021 (if quit-now
3022 (error "Thank you. Come back another day..."))
3023
2924 (ediff-regions-internal 3024 (ediff-regions-internal
2925 bufA begA endA bufB begB endB 3025 bufA begA endA bufB begB endB
2926 nil ; startup hook 3026 nil ; startup hook
@@ -2930,26 +3030,20 @@ Ediff Control Panel to restore highlighting."
2930 3030
2931 3031
2932 3032
2933;; will simplify it in due time, when emacs acquires before/after strings
2934(defun ediff-remove-flags-from-buffer (buffer overlay) 3033(defun ediff-remove-flags-from-buffer (buffer overlay)
2935 (ediff-eval-in-buffer buffer 3034 (ediff-eval-in-buffer buffer
2936 (let ((inhibit-read-only t)) 3035 (let ((inhibit-read-only t))
2937 (if ediff-xemacs-p 3036 (if ediff-xemacs-p
2938 (ediff-overlay-put overlay 'begin-glyph nil) 3037 (ediff-overlay-put overlay 'begin-glyph nil)
2939 ;; before-string is not yet implemented in emacs.
2940 ;; when it will be, I will be able to delete much of the rest of
2941 ;; this function
2942 (ediff-overlay-put overlay 'before-string nil)) 3038 (ediff-overlay-put overlay 'before-string nil))
2943 3039
2944 (if ediff-xemacs-p 3040 (if ediff-xemacs-p
2945 (ediff-overlay-put overlay 'end-glyph nil) 3041 (ediff-overlay-put overlay 'end-glyph nil)
2946 ;; after-string is not yet implemented in emacs.
2947 (ediff-overlay-put overlay 'after-string nil)) 3042 (ediff-overlay-put overlay 'after-string nil))
2948 ))) 3043 )))
2949 3044
2950 3045
2951 3046
2952;; will simplify it in due time, when emacs acquires before/after strings
2953(defun ediff-place-flags-in-buffer (buf-type buffer ctl-buffer diff) 3047(defun ediff-place-flags-in-buffer (buf-type buffer ctl-buffer diff)
2954 (ediff-eval-in-buffer buffer 3048 (ediff-eval-in-buffer buffer
2955 (ediff-place-flags-in-buffer1 buf-type ctl-buffer diff))) 3049 (ediff-place-flags-in-buffer1 buf-type ctl-buffer diff)))
@@ -3266,6 +3360,10 @@ Mail anyway? (y or n) ")
3266 (if ediff-xemacs-p 3360 (if ediff-xemacs-p
3267 (zmacs-deactivate-region) 3361 (zmacs-deactivate-region)
3268 (deactivate-mark))) 3362 (deactivate-mark)))
3363(defun ediff-activate-mark ()
3364 (if ediff-emacs-p
3365 (setq mark-active t)
3366 (zmacs-activate-region)))
3269 3367
3270(cond ((fboundp 'nuke-selective-display) 3368(cond ((fboundp 'nuke-selective-display)
3271 ;; XEmacs 19.12 has nuke-selective-display 3369 ;; XEmacs 19.12 has nuke-selective-display
diff --git a/lisp/ediff-wind.el b/lisp/ediff-wind.el
index 58cae39a191..8edde2995df 100644
--- a/lisp/ediff-wind.el
+++ b/lisp/ediff-wind.el
@@ -24,6 +24,9 @@
24;;; Code: 24;;; Code:
25 25
26(require 'ediff-init) 26(require 'ediff-init)
27(if ediff-xemacs-p
28 (require 'ediff-tbar)
29 (defun ediff-compute-toolbar-width () 0))
27 30
28;; Compiler pacifier 31;; Compiler pacifier
29(defvar icon-title-format) 32(defvar icon-title-format)
@@ -853,7 +856,8 @@ into icons, regardless of the window manager.")
853 ;; 1 more line for the modeline 856 ;; 1 more line for the modeline
854 (setq lines (1+ (count-lines (point-min) (point-max))) 857 (setq lines (1+ (count-lines (point-min) (point-max)))
855 fheight lines 858 fheight lines
856 fwidth (+ (ediff-help-message-line-length) 1) 859 fwidth (max (+ (ediff-help-message-line-length) 2)
860 (ediff-compute-toolbar-width))
857 adjusted-parameters (append (list 861 adjusted-parameters (append (list
858 ;; possibly change surrogate minibuffer 862 ;; possibly change surrogate minibuffer
859 (cons 'minibuffer 863 (cons 'minibuffer
@@ -876,9 +880,6 @@ into icons, regardless of the window manager.")
876 (set-specifier bottom-toolbar-height (list ctl-frame 0)) 880 (set-specifier bottom-toolbar-height (list ctl-frame 0))
877 (set-specifier left-toolbar-width (list ctl-frame 0)) 881 (set-specifier left-toolbar-width (list ctl-frame 0))
878 (set-specifier right-toolbar-width (list ctl-frame 0)) 882 (set-specifier right-toolbar-width (list ctl-frame 0))
879 ;; XEmacs needed a redisplay, as it had trouble setting
880 ;; height correctly otherwise.
881 ;;(sit-for 0)
882 )) 883 ))
883 884
884 ;; Under OS/2 (emx) we have to call modify frame parameters twice, in order 885 ;; Under OS/2 (emx) we have to call modify frame parameters twice, in order
@@ -893,6 +894,7 @@ into icons, regardless of the window manager.")
893 894
894 (modify-frame-parameters ctl-frame adjusted-parameters) 895 (modify-frame-parameters ctl-frame adjusted-parameters)
895 (make-frame-visible ctl-frame) 896 (make-frame-visible ctl-frame)
897 (ediff-make-bottom-toolbar) ; no effect if the toolbar is not requested
896 898
897 ;; This works around a bug in 19.25 and earlier. There, if frame gets 899 ;; This works around a bug in 19.25 and earlier. There, if frame gets
898 ;; iconified, the current buffer changes to that of the frame that 900 ;; iconified, the current buffer changes to that of the frame that
diff --git a/lisp/ediff.el b/lisp/ediff.el
index be9c1d143d4..9c4c8cec3e5 100644
--- a/lisp/ediff.el
+++ b/lisp/ediff.el
@@ -566,7 +566,7 @@ can be used to filter out certain file names."
566The second argument, REGEXP, is a regular expression that filters the file 566The second argument, REGEXP, is a regular expression that filters the file
567names. Only the files that are under revision control are taken into account." 567names. Only the files that are under revision control are taken into account."
568 (interactive 568 (interactive
569 (let* ((dir-A (ediff-get-default-directory-name))) 569 (let ((dir-A (ediff-get-default-directory-name)))
570 (list (ediff-read-file-name 570 (list (ediff-read-file-name
571 "Directory to merge with revisions:" dir-A nil) 571 "Directory to merge with revisions:" dir-A nil)
572 (read-string "Filter through regular expression: " 572 (read-string "Filter through regular expression: "
@@ -585,7 +585,7 @@ names. Only the files that are under revision control are taken into account."
585The second argument, REGEXP, is a regular expression that filters the file 585The second argument, REGEXP, is a regular expression that filters the file
586names. Only the files that are under revision control are taken into account." 586names. Only the files that are under revision control are taken into account."
587 (interactive 587 (interactive
588 (let* ((dir-A (ediff-get-default-directory-name))) 588 (let ((dir-A (ediff-get-default-directory-name)))
589 (list (ediff-read-file-name 589 (list (ediff-read-file-name
590 "Directory to merge with revisions and ancestors:" dir-A nil) 590 "Directory to merge with revisions and ancestors:" dir-A nil)
591 (read-string "Filter through regular expression: " 591 (read-string "Filter through regular expression: "
diff --git a/lisp/emulation/viper-keym.el b/lisp/emulation/viper-keym.el
index 75890aae5eb..f9c09514d79 100644
--- a/lisp/emulation/viper-keym.el
+++ b/lisp/emulation/viper-keym.el
@@ -398,6 +398,7 @@ Useful in some modes, such as Gnus, MH, etc.")
398(defvar vip-dired-modifier-map (make-sparse-keymap) 398(defvar vip-dired-modifier-map (make-sparse-keymap)
399 "This map modifies Dired behavior.") 399 "This map modifies Dired behavior.")
400(define-key vip-dired-modifier-map ":" 'vip-ex) 400(define-key vip-dired-modifier-map ":" 'vip-ex)
401(define-key vip-dired-modifier-map "/" 'vip-search-forward)
401 402
402 403
403 404
diff --git a/lisp/emulation/viper-mous.el b/lisp/emulation/viper-mous.el
index 16e20aabda8..73cef2eef85 100644
--- a/lisp/emulation/viper-mous.el
+++ b/lisp/emulation/viper-mous.el
@@ -354,8 +354,10 @@ this command."
354 vip-mouse-click-search-limit nil))) 354 vip-mouse-click-search-limit nil)))
355 (goto-char (match-beginning 0)) 355 (goto-char (match-beginning 0))
356 (message "Searching for: %s" vip-s-string) 356 (message "Searching for: %s" vip-s-string)
357 (if (<= arg 1) 357 (if (<= arg 1) ; found the right occurrence of the pattern
358 (vip-flash-search-pattern)) 358 (progn
359 (vip-adjust-window)
360 (vip-flash-search-pattern)))
359 ) 361 )
360 (error (beep 1) 362 (error (beep 1)
361 (if (or (not (string= click-word previous-search-string)) 363 (if (or (not (string= click-word previous-search-string))
diff --git a/lisp/emulation/viper-util.el b/lisp/emulation/viper-util.el
index 70daa478bae..059e840d3a4 100644
--- a/lisp/emulation/viper-util.el
+++ b/lisp/emulation/viper-util.el
@@ -249,9 +249,12 @@ that Viper doesn't know about.")
249 (not (string= color vip-replace-overlay-cursor-color))) 249 (not (string= color vip-replace-overlay-cursor-color)))
250 (vip-overlay-put vip-replace-overlay 'vip-cursor-color color))))) 250 (vip-overlay-put vip-replace-overlay 'vip-cursor-color color)))))
251 251
252(defsubst vip-restore-cursor-color () 252;; restore cursor color from replace overlay
253(defsubst vip-restore-cursor-color-after-replace ()
253 (vip-change-cursor-color 254 (vip-change-cursor-color
254 (vip-overlay-get vip-replace-overlay 'vip-cursor-color))) 255 (vip-overlay-get vip-replace-overlay 'vip-cursor-color)))
256(defsubst vip-restore-cursor-color-after-insert ()
257 (vip-change-cursor-color vip-saved-cursor-color))
255 258
256 259
257;; Check the current version against the major and minor version numbers 260;; Check the current version against the major and minor version numbers
@@ -789,7 +792,8 @@ to write a custom function, similar to `vip-ex-nontrivial-find-file-unix'."
789 792
790(defsubst vip-hide-replace-overlay () 793(defsubst vip-hide-replace-overlay ()
791 (vip-set-replace-overlay-glyphs nil nil) 794 (vip-set-replace-overlay-glyphs nil nil)
792 (vip-restore-cursor-color) 795 (vip-restore-cursor-color-after-replace)
796 (vip-restore-cursor-color-after-insert)
793 (if (vip-has-face-support-p) 797 (if (vip-has-face-support-p)
794 (vip-overlay-put vip-replace-overlay 'face nil))) 798 (vip-overlay-put vip-replace-overlay 'face nil)))
795 799
diff --git a/lisp/emulation/viper.el b/lisp/emulation/viper.el
index f3ede946449..592f15021ac 100644
--- a/lisp/emulation/viper.el
+++ b/lisp/emulation/viper.el
@@ -479,7 +479,11 @@ it better fits your working style.")
479 479
480(defvar vip-replace-overlay-cursor-color "Red" 480(defvar vip-replace-overlay-cursor-color "Red"
481 "*Cursor color to use in Replace state") 481 "*Cursor color to use in Replace state")
482 482(defvar vip-insert-state-cursor-color nil
483 "Cursor color for Viper insert state.")
484(put 'vip-insert-state-cursor-color 'permanent-local t)
485;; place to save cursor colow when switching to insert mode
486(vip-deflocalvar vip-saved-cursor-color nil "")
483 487
484(vip-deflocalvar vip-replace-overlay nil "") 488(vip-deflocalvar vip-replace-overlay nil "")
485(put 'vip-replace-overlay 'permanent-local t) 489(put 'vip-replace-overlay 'permanent-local t)
@@ -698,10 +702,14 @@ to a new place after repeating previous Vi command.")
698(defvar vip-s-forward nil) 702(defvar vip-s-forward nil)
699 703
700(defconst vip-case-fold-search nil 704(defconst vip-case-fold-search nil
701 "*If t, search ignores cases.") 705 "*If not nil, search ignores cases.")
702 706
703(defconst vip-re-search t 707(defconst vip-re-search t
704 "*If t, search is reg-exp search, otherwise vanilla search.") 708 "*If not nil, search is reg-exp search, otherwise vanilla search.")
709
710(defvar vip-adjust-window-after-search t
711 "*If not nil, pull the window up or down, depending on the direction of the
712search, if search ends up near the bottom or near the top of the window.")
705 713
706(defconst vip-re-query-replace t 714(defconst vip-re-query-replace t
707 "*If t then do regexp replace, if nil then do string replace.") 715 "*If t then do regexp replace, if nil then do string replace.")
@@ -983,6 +991,14 @@ Should be set in `~/.vip' file.")
983 vip-insert-point 991 vip-insert-point
984 (>= (point) vip-insert-point)) 992 (>= (point) vip-insert-point))
985 (setq vip-last-posn-while-in-insert-state (point-marker))) 993 (setq vip-last-posn-while-in-insert-state (point-marker)))
994 (if (eq vip-current-state 'insert-state)
995 (progn
996 (or (stringp vip-saved-cursor-color)
997 (string= (vip-get-cursor-color) vip-insert-state-cursor-color)
998 (setq vip-saved-cursor-color (vip-get-cursor-color)))
999 (if (stringp vip-saved-cursor-color)
1000 (vip-change-cursor-color vip-insert-state-cursor-color))
1001 ))
986 (if (and (eq this-command 'dabbrev-expand) 1002 (if (and (eq this-command 'dabbrev-expand)
987 (integerp vip-pre-command-point) 1003 (integerp vip-pre-command-point)
988 (> vip-insert-point vip-pre-command-point)) 1004 (> vip-insert-point vip-pre-command-point))
@@ -990,6 +1006,11 @@ Should be set in `~/.vip' file.")
990 ) 1006 )
991 1007
992(defsubst vip-insert-state-pre-command-sentinel () 1008(defsubst vip-insert-state-pre-command-sentinel ()
1009 (or (memq this-command '(self-insert-command))
1010 (memq (vip-event-key last-command-event)
1011 '(up down left right (meta f) (meta b)
1012 (control n) (control p) (control f) (control b)))
1013 (vip-restore-cursor-color-after-insert))
993 (if (and (eq this-command 'dabbrev-expand) 1014 (if (and (eq this-command 'dabbrev-expand)
994 (markerp vip-insert-point) 1015 (markerp vip-insert-point)
995 (marker-position vip-insert-point)) 1016 (marker-position vip-insert-point))
@@ -1005,7 +1026,7 @@ Should be set in `~/.vip' file.")
1005 (if (and (<= (vip-replace-start) (point)) 1026 (if (and (<= (vip-replace-start) (point))
1006 (<= (point) (vip-replace-end))) 1027 (<= (point) (vip-replace-end)))
1007 (vip-change-cursor-color vip-replace-overlay-cursor-color) 1028 (vip-change-cursor-color vip-replace-overlay-cursor-color)
1008 (vip-restore-cursor-color) 1029 (vip-restore-cursor-color-after-replace)
1009 )) 1030 ))
1010 1031
1011;; to speed up, don't change cursor color before self-insert 1032;; to speed up, don't change cursor color before self-insert
@@ -1015,7 +1036,7 @@ Should be set in `~/.vip' file.")
1015 (memq (vip-event-key last-command-event) 1036 (memq (vip-event-key last-command-event)
1016 '(up down left right (meta f) (meta b) 1037 '(up down left right (meta f) (meta b)
1017 (control n) (control p) (control f) (control b))) 1038 (control n) (control p) (control f) (control b)))
1018 (vip-restore-cursor-color))) 1039 (vip-restore-cursor-color-after-replace)))
1019 1040
1020(defun vip-replace-state-post-command-sentinel () 1041(defun vip-replace-state-post-command-sentinel ()
1021 ;; Restoring cursor color is needed despite 1042 ;; Restoring cursor color is needed despite
@@ -1029,7 +1050,7 @@ Should be set in `~/.vip' file.")
1029 ;; cursor color or, if they terminate replace mode, the color will be changed 1050 ;; cursor color or, if they terminate replace mode, the color will be changed
1030 ;; in vip-finish-change 1051 ;; in vip-finish-change
1031 (or (memq this-command '(self-insert-command)) 1052 (or (memq this-command '(self-insert-command))
1032 (vip-restore-cursor-color)) 1053 (vip-restore-cursor-color-after-replace))
1033 (cond 1054 (cond
1034 ((eq vip-current-state 'replace-state) 1055 ((eq vip-current-state 'replace-state)
1035 ;; delete characters to compensate for inserted chars. 1056 ;; delete characters to compensate for inserted chars.
@@ -1148,18 +1169,18 @@ Should be set in `~/.vip' file.")
1148 1169
1149 (if vip-want-ctl-h-help 1170 (if vip-want-ctl-h-help
1150 (progn 1171 (progn
1151 (define-key vip-insert-basic-map "\C-h" 'help-command) 1172 (define-key vip-insert-basic-map [(control h)] 'help-command)
1152 (define-key vip-replace-map "\C-h" 'help-command)) 1173 (define-key vip-replace-map [(control h)] 'help-command))
1153 (define-key vip-insert-basic-map 1174 (define-key vip-insert-basic-map
1154 "\C-h" 'vip-del-backward-char-in-insert) 1175 [(control h)] 'vip-del-backward-char-in-insert)
1155 (define-key vip-replace-map 1176 (define-key vip-replace-map
1156 "\C-h" 'vip-del-backward-char-in-replace))) 1177 [(control h)] 'vip-del-backward-char-in-replace)))
1157 1178
1158 (t 1179 (t ; Vi state
1159 (setq vip-vi-diehard-minor-mode (not vip-want-emacs-keys-in-vi)) 1180 (setq vip-vi-diehard-minor-mode (not vip-want-emacs-keys-in-vi))
1160 (if vip-want-ctl-h-help 1181 (if vip-want-ctl-h-help
1161 (define-key vip-vi-basic-map "\C-h" 'help-command) 1182 (define-key vip-vi-basic-map [(control h)] 'help-command)
1162 (define-key vip-vi-basic-map "\C-h" 'vip-backward-char))) 1183 (define-key vip-vi-basic-map [(control h)] 'vip-backward-char)))
1163 )) 1184 ))
1164 1185
1165 1186
@@ -1429,6 +1450,8 @@ This startup message appears whenever you load Viper, unless you type `y' now."
1429 ;; keys `,',^ in Vi state, as they will do accents instead of Vi actions. 1450 ;; keys `,',^ in Vi state, as they will do accents instead of Vi actions.
1430 (if (and (boundp 'iso-accents-mode) iso-accents-mode) 1451 (if (and (boundp 'iso-accents-mode) iso-accents-mode)
1431 (iso-accents-mode -1)) 1452 (iso-accents-mode -1))
1453
1454 (vip-restore-cursor-color-after-insert)
1432 1455
1433 ;; Protection against user errors in hooks 1456 ;; Protection against user errors in hooks
1434 (condition-case conds 1457 (condition-case conds
@@ -1443,6 +1466,14 @@ This startup message appears whenever you load Viper, unless you type `y' now."
1443 (if (and vip-automatic-iso-accents (fboundp 'iso-accents-mode)) 1466 (if (and vip-automatic-iso-accents (fboundp 'iso-accents-mode))
1444 (iso-accents-mode 1)) ; turn iso accents on 1467 (iso-accents-mode 1)) ; turn iso accents on
1445 1468
1469 (or (stringp vip-saved-cursor-color)
1470 (string= (vip-get-cursor-color) vip-insert-state-cursor-color)
1471 (setq vip-saved-cursor-color (vip-get-cursor-color)))
1472 ;; Commented out, because if vip-change-state-to-insert is executed
1473 ;; non-interactively then the old cursor color may get lost. Same old Emacs
1474 ;; bug related to local variables?
1475;;;(if (stringp vip-saved-cursor-color)
1476;;; (vip-change-cursor-color vip-insert-state-cursor-color))
1446 ;; Protection against user errors in hooks 1477 ;; Protection against user errors in hooks
1447 (condition-case conds 1478 (condition-case conds
1448 (run-hooks 'vip-insert-state-hook) 1479 (run-hooks 'vip-insert-state-hook)
@@ -2546,20 +2577,23 @@ Undo previous insertion and inserts new."
2546;; Tells whether BEG is on the same line as END. 2577;; Tells whether BEG is on the same line as END.
2547;; If one of the args is nil, it'll return nil. 2578;; If one of the args is nil, it'll return nil.
2548(defun vip-same-line (beg end) 2579(defun vip-same-line (beg end)
2549 (let ((selective-display nil)) 2580 (let ((selective-display nil)
2550 (cond ((and beg end) 2581 (incr 0)
2551 ;; This 'if' is needed because Emacs treats the next empty line 2582 temp)
2552 ;; as part of the previous line. 2583 (if (and beg end (> beg end))
2553 (if (or (> beg (point-max)) (> end (point-max))) ; out of range 2584 (setq temp beg
2554 () 2585 beg end
2555 (if (and (> end beg) (= (vip-line-pos 'start) end)) 2586 end temp))
2556 (setq end (min (1+ end) (point-max)))) 2587 (if (and beg end)
2557 (if (and (> beg end) (= (vip-line-pos 'start) beg)) 2588 (cond ((or (> beg (point-max)) (> end (point-max))) ; out of range
2558 (setq beg (min (1+ beg) (point-max)))) 2589 nil)
2559 (<= (count-lines beg end) 1) )) 2590 (t
2560 2591 ;; This 'if' is needed because Emacs treats the next empty line
2561 (t nil)) 2592 ;; as part of the previous line.
2562 )) 2593 (if (= (vip-line-pos 'start) end)
2594 (setq incr 1))
2595 (<= (+ incr (count-lines beg end)) 1))))
2596 ))
2563 2597
2564 2598
2565;; Check if the string ends with a newline. 2599;; Check if the string ends with a newline.
@@ -3024,7 +3058,7 @@ Undo previous insertion and inserts new."
3024 'vip-replace-state-post-command-sentinel) 3058 'vip-replace-state-post-command-sentinel)
3025 (vip-remove-hook 3059 (vip-remove-hook
3026 'vip-pre-command-hooks 'vip-replace-state-pre-command-sentinel) 3060 'vip-pre-command-hooks 'vip-replace-state-pre-command-sentinel)
3027 (vip-restore-cursor-color) 3061 (vip-restore-cursor-color-after-replace)
3028 (setq vip-sitting-in-replace nil) ; just in case we'll need to know it 3062 (setq vip-sitting-in-replace nil) ; just in case we'll need to know it
3029 (save-excursion 3063 (save-excursion
3030 (if (and 3064 (if (and
@@ -3840,6 +3874,32 @@ controlled by the sign of prefix numeric value."
3840 (interactive "p") 3874 (interactive "p")
3841 (recenter (- (window-height) (1+ arg)))) 3875 (recenter (- (window-height) (1+ arg))))
3842 3876
3877;; If vip-adjust-window-after-search is t, scroll up or down 1/4 of window
3878;; height, depending on whether we are at the bottom or at the top of the
3879;; window. This function is called by vip-search (which is called from
3880;; vip-search-forward/backward/next)
3881(defun vip-adjust-window ()
3882 (let ((win-height (if vip-emacs-p
3883 (1- (window-height)) ; adjust for modeline
3884 (window-displayed-height)))
3885 (pt (point))
3886 at-top-p at-bottom-p
3887 min-scroll direction)
3888 (save-excursion
3889 (move-to-window-line 0) ; top
3890 (setq at-top-p (<= (count-lines pt (point)) 2))
3891 (move-to-window-line -1) ; bottom
3892 (setq at-bottom-p (<= (count-lines pt (point)) 2))
3893 )
3894 (cond (at-top-p (setq min-scroll 1
3895 direction 1))
3896 (at-bottom-p (setq min-scroll 2
3897 direction -1)))
3898 (if (and vip-adjust-window-after-search min-scroll)
3899 (recenter
3900 (* (max min-scroll (/ win-height 7)) direction)))
3901 ))
3902
3843 3903
3844;; paren match 3904;; paren match
3845;; must correct this to only match ( to ) etc. On the other hand 3905;; must correct this to only match ( to ) etc. On the other hand
@@ -4091,6 +4151,62 @@ the Emacs binding of `/'."
4091 (setq msg "Search style remains unchanged"))) 4151 (setq msg "Search style remains unchanged")))
4092 (prin1 msg t))) 4152 (prin1 msg t)))
4093 4153
4154(defun vip-set-vi-search-style-macros (unset)
4155 "Set the macros for toggling the search style in Viper's vi-state.
4156The macro that toggles case sensitivity is bound to `//', and the one that
4157toggles regexp search is bound to `///'.
4158With a prefix argument, this function unsets the macros. "
4159 (interactive "P")
4160 (or noninteractive
4161 (if (not unset)
4162 (progn
4163 ;; toggle case sensitivity in search
4164 (vip-record-kbd-macro
4165 "//" 'vi-state
4166 [1 (meta x) v i p - t o g g l e - s e a r c h - s t y l e return]
4167 't)
4168 ;; toggle regexp/vanila search
4169 (vip-record-kbd-macro
4170 "///" 'vi-state
4171 [2 (meta x) v i p - t o g g l e - s e a r c h - s t y l e return]
4172 't)
4173 (if (interactive-p)
4174 (message
4175 "// and /// now toggle case-sensitivity and regexp search.")))
4176 (vip-unrecord-kbd-macro "//" 'vi-state)
4177 (sit-for 2)
4178 (vip-unrecord-kbd-macro "///" 'vi-state))))
4179
4180(defun vip-set-emacs-search-style-macros (unset &optional arg-majormode)
4181 "Set the macros for toggling the search style in Viper's emacs-state.
4182The macro that toggles case sensitivity is bound to `//', and the one that
4183toggles regexp search is bound to `///'.
4184With a prefix argument, this function unsets the macros.
4185If the optional prefix argument is non-nil and specifies a valid major mode,
4186this sets the macros only in the macros in that major mode. Otherwise,
4187the macros are set in the current major mode.
4188\(When unsetting the macros, the second argument has no effect.\)"
4189 (interactive "P")
4190 (or noninteractive
4191 (if (not unset)
4192 (progn
4193 ;; toggle case sensitivity in search
4194 (vip-record-kbd-macro
4195 "//" 'emacs-state
4196 [1 (meta x) v i p - t o g g l e - s e a r c h - s t y l e return]
4197 (or arg-majormode major-mode))
4198 ;; toggle regexp/vanila search
4199 (vip-record-kbd-macro
4200 "///" 'emacs-state
4201 [2 (meta x) v i p - t o g g l e - s e a r c h - s t y l e return]
4202 (or arg-majormode major-mode))
4203 (if (interactive-p)
4204 (message
4205 "// and /// now toggle case-sensitivity and regexp search.")))
4206 (vip-unrecord-kbd-macro "//" 'emacs-state)
4207 (sit-for 2)
4208 (vip-unrecord-kbd-macro "///" 'emacs-state))))
4209
4094 4210
4095(defun vip-search-forward (arg) 4211(defun vip-search-forward (arg)
4096 "Search a string forward. 4212 "Search a string forward.
@@ -4159,9 +4275,6 @@ Null string will repeat previous search."
4159 (re-search-backward string)) 4275 (re-search-backward string))
4160 (search-forward string nil nil val) 4276 (search-forward string nil nil val)
4161 (search-backward string)) 4277 (search-backward string))
4162 ;; don't wait and don't flash in macros
4163 (or executing-kbd-macro
4164 (vip-flash-search-pattern))
4165 (if (not (equal start-point (point))) 4278 (if (not (equal start-point (point)))
4166 (push-mark start-point t))) 4279 (push-mark start-point t)))
4167 (search-failed 4280 (search-failed
@@ -4186,9 +4299,6 @@ Null string will repeat previous search."
4186 (if vip-re-search 4299 (if vip-re-search
4187 (re-search-backward string nil nil val) 4300 (re-search-backward string nil nil val)
4188 (search-backward string nil nil val)) 4301 (search-backward string nil nil val))
4189 ;; don't wait and don't flash in macros
4190 (or executing-kbd-macro
4191 (vip-flash-search-pattern))
4192 (if (not (equal start-point (point))) 4302 (if (not (equal start-point (point)))
4193 (push-mark start-point t))) 4303 (push-mark start-point t)))
4194 (search-failed 4304 (search-failed
@@ -4206,7 +4316,14 @@ Null string will repeat previous search."
4206 (error "`%s': %s not found" 4316 (error "`%s': %s not found"
4207 string 4317 string
4208 (if vip-re-search "Pattern" "String")) 4318 (if vip-re-search "Pattern" "String"))
4209 ))))))) 4319 ))))
4320 ;; pull up or down if at top/bottom of window
4321 (vip-adjust-window)
4322 ;; highlight the result of search
4323 ;; don't wait and don't highlight in macros
4324 (or executing-kbd-macro
4325 (vip-flash-search-pattern))
4326 )))
4210 4327
4211(defun vip-search-next (arg) 4328(defun vip-search-next (arg)
4212 "Repeat previous search." 4329 "Repeat previous search."
@@ -4412,6 +4529,7 @@ To turn this feature off, set this variable to nil.")
4412 (setq vip-use-register nil) 4529 (setq vip-use-register nil)
4413 (if (vip-end-with-a-newline-p text) 4530 (if (vip-end-with-a-newline-p text)
4414 (progn 4531 (progn
4532 (end-of-line)
4415 (if (eobp) 4533 (if (eobp)
4416 (insert "\n") 4534 (insert "\n")
4417 (forward-line 1)) 4535 (forward-line 1))
@@ -5507,6 +5625,11 @@ Mail anyway (y or n)? ")
5507 5625
5508 (defvar fortran-mode-hook) 5626 (defvar fortran-mode-hook)
5509 (add-hook 'fortran-mode-hook 'vip-mode) 5627 (add-hook 'fortran-mode-hook 'vip-mode)
5628
5629 (defvar basic-mode-hook)
5630 (add-hook 'basic-mode-hook 'vip-mode)
5631 (defvar bat-mode-hook)
5632 (add-hook 'bat-mode-hook 'vip-mode)
5510 5633
5511 (defvar text-mode-hook) 5634 (defvar text-mode-hook)
5512 (add-hook 'text-mode-hook 'viper-mode) 5635 (add-hook 'text-mode-hook 'viper-mode)
@@ -5567,6 +5690,21 @@ Mail anyway (y or n)? ")
5567 'comint-mode 'insert-state vip-comint-mode-modifier-map) 5690 'comint-mode 'insert-state vip-comint-mode-modifier-map)
5568 (vip-modify-major-mode 5691 (vip-modify-major-mode
5569 'comint-mode 'vi-state vip-comint-mode-modifier-map) 5692 'comint-mode 'vi-state vip-comint-mode-modifier-map)
5693 (vip-modify-major-mode
5694 'shell-mode 'insert-state vip-comint-mode-modifier-map)
5695 (vip-modify-major-mode
5696 'shell-mode 'vi-state vip-comint-mode-modifier-map)
5697 ;; ange-ftp in XEmacs
5698 (vip-modify-major-mode
5699 'ange-ftp-shell-mode 'insert-state vip-comint-mode-modifier-map)
5700 (vip-modify-major-mode
5701 'ange-ftp-shell-mode 'vi-state vip-comint-mode-modifier-map)
5702 ;; ange-ftp in Emacs
5703 (vip-modify-major-mode
5704 'internal-ange-ftp-mode 'insert-state vip-comint-mode-modifier-map)
5705 (vip-modify-major-mode
5706 'internal-ange-ftp-mode 'vi-state vip-comint-mode-modifier-map)
5707 ;; set hook
5570 (add-hook 'comint-mode-hook 'vip-comint-mode-hook) 5708 (add-hook 'comint-mode-hook 'vip-comint-mode-hook)
5571 5709
5572 ;; Shell scripts 5710 ;; Shell scripts
@@ -5577,18 +5715,26 @@ Mail anyway (y or n)? ")
5577 5715
5578 ;; Dired 5716 ;; Dired
5579 (vip-modify-major-mode 'dired-mode 'emacs-state vip-dired-modifier-map) 5717 (vip-modify-major-mode 'dired-mode 'emacs-state vip-dired-modifier-map)
5718 (vip-set-emacs-search-style-macros nil 'dired-mode)
5580 (add-hook 'dired-mode-hook 'vip-change-state-to-emacs) 5719 (add-hook 'dired-mode-hook 'vip-change-state-to-emacs)
5581 5720
5721 ;; Tar
5722 (vip-modify-major-mode 'tar-mode 'emacs-state vip-slash-and-colon-map)
5723 (vip-set-emacs-search-style-macros nil 'tar-mode)
5724
5582 ;; MH-E 5725 ;; MH-E
5583 (vip-modify-major-mode 'mh-folder-mode 'emacs-state vip-slash-and-colon-map) 5726 (vip-modify-major-mode 'mh-folder-mode 'emacs-state vip-slash-and-colon-map)
5727 (vip-set-emacs-search-style-macros nil 'mh-folder-mode)
5584 ;; changing state to emacs is needed so the preceding will take hold 5728 ;; changing state to emacs is needed so the preceding will take hold
5585 (add-hook 'mh-folder-mode-hook 'vip-change-state-to-emacs) 5729 (add-hook 'mh-folder-mode-hook 'vip-change-state-to-emacs)
5586 (add-hook 'mh-show-mode-hook 'viper-mode) 5730 (add-hook 'mh-show-mode-hook 'viper-mode)
5587 5731
5588 ;; Gnus 5732 ;; Gnus
5589 (vip-modify-major-mode 'gnus-group-mode 'emacs-state vip-slash-and-colon-map) 5733 (vip-modify-major-mode 'gnus-group-mode 'emacs-state vip-slash-and-colon-map)
5734 (vip-set-emacs-search-style-macros nil 'gnus-group-mode)
5590 (vip-modify-major-mode 5735 (vip-modify-major-mode
5591 'gnus-summary-mode 'emacs-state vip-slash-and-colon-map) 5736 'gnus-summary-mode 'emacs-state vip-slash-and-colon-map)
5737 (vip-set-emacs-search-style-macros nil 'gnus-summary-mode)
5592 ;; changing state to emacs is needed so the preceding will take hold 5738 ;; changing state to emacs is needed so the preceding will take hold
5593 (add-hook 'gnus-group-mode-hook 'vip-change-state-to-emacs) 5739 (add-hook 'gnus-group-mode-hook 'vip-change-state-to-emacs)
5594 (add-hook 'gnus-summary-mode-hook 'vip-change-state-to-emacs) 5740 (add-hook 'gnus-summary-mode-hook 'vip-change-state-to-emacs)
@@ -5596,6 +5742,7 @@ Mail anyway (y or n)? ")
5596 5742
5597 ;; Info 5743 ;; Info
5598 (vip-modify-major-mode 'Info-mode 'emacs-state vip-slash-and-colon-map) 5744 (vip-modify-major-mode 'Info-mode 'emacs-state vip-slash-and-colon-map)
5745 (vip-set-emacs-search-style-macros nil 'Info-mode)
5599 ;; Switching to emacs is needed so the above will take hold 5746 ;; Switching to emacs is needed so the above will take hold
5600 (defadvice Info-mode (after vip-Info-ad activate) 5747 (defadvice Info-mode (after vip-Info-ad activate)
5601 "Switch to emacs mode." 5748 "Switch to emacs mode."
@@ -5604,6 +5751,7 @@ Mail anyway (y or n)? ")
5604 ;; Buffer menu 5751 ;; Buffer menu
5605 (vip-modify-major-mode 5752 (vip-modify-major-mode
5606 'Buffer-menu-mode 'emacs-state vip-slash-and-colon-map) 5753 'Buffer-menu-mode 'emacs-state vip-slash-and-colon-map)
5754 (vip-set-emacs-search-style-macros nil 'Buffer-menu-mode)
5607 ;; Switching to emacs is needed so the above will take hold 5755 ;; Switching to emacs is needed so the above will take hold
5608 (defadvice Buffer-menu-mode (after vip-Buffer-menu-ad activate) 5756 (defadvice Buffer-menu-mode (after vip-Buffer-menu-ad activate)
5609 "Switch to emacs mode." 5757 "Switch to emacs mode."
@@ -5652,14 +5800,8 @@ Mail anyway (y or n)? ")
5652 (vector vip-repeat-from-history-key '\2) 'vi-state 5800 (vector vip-repeat-from-history-key '\2) 'vi-state
5653 [(meta x) v i p - r e p e a t - f r o m - h i s t o r y return] 't) 5801 [(meta x) v i p - r e p e a t - f r o m - h i s t o r y return] 't)
5654 5802
5655;; toggle case sensitivity in search 5803;; set the toggle case sensitivity and regexp search macros
5656(vip-record-kbd-macro 5804(vip-set-vi-search-style-macros nil)
5657 "//" 'vi-state
5658 [1 (meta x) v i p - t o g g l e - s e a r c h - s t y l e return] 't)
5659;; toggle regexp/vanila search
5660(vip-record-kbd-macro
5661 "///" 'vi-state
5662 [2 (meta x) v i p - t o g g l e - s e a r c h - s t y l e return] 't)
5663 5805
5664 5806
5665;; ~/.vip is loaded if it exists 5807;; ~/.vip is loaded if it exists