aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Kifer2006-06-18 17:08:24 +0000
committerMichael Kifer2006-06-18 17:08:24 +0000
commitec6aebe8337fdd6dc218609a3ff86ccc0232fb4a (patch)
treecbcaecf8692fb0ba1bcb4dbeeac96d471b1ba2be
parent9e363b8991ea4c52e18b59d0679689cd6a1c0d1b (diff)
downloademacs-ec6aebe8337fdd6dc218609a3ff86ccc0232fb4a.tar.gz
emacs-ec6aebe8337fdd6dc218609a3ff86ccc0232fb4a.zip
2006-06-18 Michael Kifer <kifer@cs.stonybrook.edu>
* viper-cmd.el (viper-special-read-and-insert-char): use read-key-sequence. (viper-after-change-undo-hook): enhancements. (viper-after-change-undo-hook): new hook. (viper-undo): use viper-after-change-undo-hook. (viper-add-newline-at-eob-if-necessary): widen before making changes. (viper-next-line-at-bol): If point is on a widget or a button, simulate clicking on that widget/button. * viper.el (viper-mode): allow for a separate cursor color in Emacs state. * ediff-diff (ediff-test-patch-utility): catch errors. (ediff-actual-diff-options, ediff-actual-diff3-options): new variables. (ediff-set-actual-diff-options): new function. (ediff-reset-diff-options, ediff-toggle-ignore-case): use ediff-set-actual-diff-options. (ediff-extract-diffs): catch errors. (ediff-whitespace): add nonbreakable space. (ediff-same-file-contents): catch errors. * ediff-mult.el (ediff-collect-custom-diffs): save coding-system-for-read. * ediff-vers.el (ediff-keep-tmp-versions): new var. (ediff-vc-internal, ediff-vc-merge-internal): use ediff-delete-version-file. (ediff-delete-version-file): new function. * ediff-wind.el (ediff-control-frame-parameters): set frame fringes. * ediff.el (ediff-directories, ediff-directory-revisions, ediff-merge-directories, ediff-merge-directories-with-ancestor, ediff-directories-internal, ediff-merge-directory-revisions, ediff-merge-directory-revisions-with-ancestor, ediff-directories3): use read-directory-name.
-rw-r--r--lisp/ChangeLog39
-rw-r--r--lisp/ediff-diff.el74
-rw-r--r--lisp/ediff-mult.el36
-rw-r--r--lisp/ediff-vers.el26
-rw-r--r--lisp/ediff-wind.el2
-rw-r--r--lisp/ediff.el80
-rw-r--r--lisp/emulation/viper-cmd.el90
-rw-r--r--lisp/emulation/viper-util.el4
-rw-r--r--lisp/emulation/viper.el6
9 files changed, 233 insertions, 124 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index a6a72978852..9fd0500b825 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,42 @@
12006-06-18 Michael Kifer <kifer@cs.stonybrook.edu>
2
3 * viper-cmd.el (viper-special-read-and-insert-char): use
4 read-key-sequence.
5 (viper-after-change-undo-hook): enhancements.
6 (viper-after-change-undo-hook): new hook.
7 (viper-undo): use viper-after-change-undo-hook.
8 (viper-add-newline-at-eob-if-necessary): widen before making changes.
9 (viper-next-line-at-bol): If point is on a widget or a button, simulate
10 clicking on that widget/button.
11
12 * viper.el (viper-mode): allow for a separate cursor color in Emacs
13 state.
14
15 * ediff-diff (ediff-test-patch-utility): catch errors.
16 (ediff-actual-diff-options, ediff-actual-diff3-options): new variables.
17 (ediff-set-actual-diff-options): new function.
18 (ediff-reset-diff-options, ediff-toggle-ignore-case):
19 use ediff-set-actual-diff-options.
20 (ediff-extract-diffs): catch errors.
21 (ediff-whitespace): add nonbreakable space.
22 (ediff-same-file-contents): catch errors.
23
24 * ediff-mult.el (ediff-collect-custom-diffs): save
25 coding-system-for-read.
26
27 * ediff-vers.el (ediff-keep-tmp-versions): new var.
28 (ediff-vc-internal, ediff-vc-merge-internal): use
29 ediff-delete-version-file.
30 (ediff-delete-version-file): new function.
31
32 * ediff-wind.el (ediff-control-frame-parameters): set frame fringes.
33
34 * ediff.el (ediff-directories, ediff-directory-revisions,
35 ediff-merge-directories, ediff-merge-directories-with-ancestor,
36 ediff-directories-internal, ediff-merge-directory-revisions,
37 ediff-merge-directory-revisions-with-ancestor,
38 ediff-directories3): use read-directory-name.
39
12006-06-18 Ralf Angeli <angeli@caeruleus.net> 402006-06-18 Ralf Angeli <angeli@caeruleus.net>
2 41
3 * textmodes/tex-mode.el (tex-font-lock-match-suscript): Remove 42 * textmodes/tex-mode.el (tex-font-lock-match-suscript): Remove
diff --git a/lisp/ediff-diff.el b/lisp/ediff-diff.el
index 7746954292d..e3675064010 100644
--- a/lisp/ediff-diff.el
+++ b/lisp/ediff-diff.el
@@ -65,10 +65,11 @@ Must produce output compatible with Unix's diff3 program."
65;; The following functions needed for setting diff/diff3 options 65;; The following functions needed for setting diff/diff3 options
66;; test if diff supports the --binary option 66;; test if diff supports the --binary option
67(defsubst ediff-test-utility (diff-util option &optional files) 67(defsubst ediff-test-utility (diff-util option &optional files)
68 (condition-case () 68 (condition-case nil
69 (eq 0 (apply 'call-process 69 (eq 0 (apply 'call-process
70 (append (list diff-util nil nil nil option) files))) 70 (append (list diff-util nil nil nil option) files)))
71 (file-error nil))) 71 (error (format "Cannot execute program %S." diff-util)))
72 )
72 73
73(defun ediff-diff-mandatory-option (diff-util) 74(defun ediff-diff-mandatory-option (diff-util)
74 (let ((file (if (boundp 'null-device) null-device "/dev/null"))) 75 (let ((file (if (boundp 'null-device) null-device "/dev/null")))
@@ -77,13 +78,17 @@ Must produce output compatible with Unix's diff3 program."
77 ((and (string= diff-util ediff-diff-program) 78 ((and (string= diff-util ediff-diff-program)
78 (ediff-test-utility 79 (ediff-test-utility
79 ediff-diff-program "--binary" (list file file))) 80 ediff-diff-program "--binary" (list file file)))
80 "--binary") 81 "--binary ")
81 ((and (string= diff-util ediff-diff3-program) 82 ((and (string= diff-util ediff-diff3-program)
82 (ediff-test-utility 83 (ediff-test-utility
83 ediff-diff3-program "--binary" (list file file file))) 84 ediff-diff3-program "--binary" (list file file file)))
84 "--binary") 85 "--binary ")
85 (t "")))) 86 (t ""))))
86 87
88
89;; must be before ediff-reset-diff-options to avoid compiler errors
90(fset 'ediff-set-actual-diff-options '(lambda () nil))
91
87;; make sure that mandatory options are added even if the user changes 92;; make sure that mandatory options are added even if the user changes
88;; ediff-diff-options or ediff-diff3-options in the customization widget 93;; ediff-diff-options or ediff-diff3-options in the customization widget
89(defun ediff-reset-diff-options (symb val) 94(defun ediff-reset-diff-options (symb val)
@@ -91,12 +96,9 @@ Must produce output compatible with Unix's diff3 program."
91 (if (eq symb 'ediff-diff-options) 96 (if (eq symb 'ediff-diff-options)
92 ediff-diff-program 97 ediff-diff-program
93 ediff-diff3-program)) 98 ediff-diff3-program))
94 (mandatory-option (ediff-diff-mandatory-option diff-program)) 99 (mandatory-option (ediff-diff-mandatory-option diff-program)))
95 (spacer (if (string-equal mandatory-option "") "" " "))) 100 (set symb (concat mandatory-option val))
96 (set symb 101 (ediff-set-actual-diff-options)
97 (if (string-match mandatory-option val)
98 val
99 (concat mandatory-option spacer val)))
100 )) 102 ))
101 103
102 104
@@ -155,7 +157,7 @@ GNU diff3 doesn't have such an option."
155 :group 'ediff-diff) 157 :group 'ediff-diff)
156 158
157;; the actual options used in comparison 159;; the actual options used in comparison
158(ediff-defvar-local ediff-actual-diff-options "" "") 160(ediff-defvar-local ediff-actual-diff-options ediff-diff-options "")
159 161
160(defcustom ediff-custom-diff-program ediff-diff-program 162(defcustom ediff-custom-diff-program ediff-diff-program
161 "*Program to use for generating custom diff output for saving it in a file. 163 "*Program to use for generating custom diff output for saving it in a file.
@@ -178,7 +180,7 @@ This output is not used by Ediff internally."
178 :group 'ediff-diff) 180 :group 'ediff-diff)
179 181
180;; the actual options used in comparison 182;; the actual options used in comparison
181(ediff-defvar-local ediff-actual-diff3-options "" "") 183(ediff-defvar-local ediff-actual-diff3-options ediff-diff3-options "")
182 184
183(defcustom ediff-diff3-ok-lines-regexp 185(defcustom ediff-diff3-ok-lines-regexp
184 "^\\([1-3]:\\|====\\| \\|.*Warning *:\\|.*No newline\\|.*missing newline\\|^\C-m$\\)" 186 "^\\([1-3]:\\|====\\| \\|.*Warning *:\\|.*No newline\\|.*missing newline\\|^\C-m$\\)"
@@ -1272,7 +1274,9 @@ delimiter regions"))
1272 ;; Similarly for Windows-* 1274 ;; Similarly for Windows-*
1273 ;; In DOS, must synchronize because DOS doesn't have 1275 ;; In DOS, must synchronize because DOS doesn't have
1274 ;; asynchronous processes. 1276 ;; asynchronous processes.
1275 (apply 'call-process program nil buffer nil args) 1277 (condition-case nil
1278 (apply 'call-process program nil buffer nil args)
1279 (error (format "Cannot execute program %S." program)))
1276 ;; On other systems, do it asynchronously. 1280 ;; On other systems, do it asynchronously.
1277 (setq proc (get-buffer-process buffer)) 1281 (setq proc (get-buffer-process buffer))
1278 (if proc (kill-process proc)) 1282 (if proc (kill-process proc))
@@ -1328,7 +1332,8 @@ delimiter regions"))
1328Used for splitting difference regions into individual words.") 1332Used for splitting difference regions into individual words.")
1329(make-variable-buffer-local 'ediff-forward-word-function) 1333(make-variable-buffer-local 'ediff-forward-word-function)
1330 1334
1331(defvar ediff-whitespace " \n\t\f" 1335;; \240 is unicode symbol for nonbreakable whitespace
1336(defvar ediff-whitespace " \n\t\f\r\240"
1332 "*Characters constituting white space. 1337 "*Characters constituting white space.
1333These characters are ignored when differing regions are split into words.") 1338These characters are ignored when differing regions are split into words.")
1334(make-variable-buffer-local 'ediff-whitespace) 1339(make-variable-buffer-local 'ediff-whitespace)
@@ -1442,11 +1447,13 @@ arguments to `skip-chars-forward'."
1442 "Return t if files F1 and F2 have identical contents." 1447 "Return t if files F1 and F2 have identical contents."
1443 (if (and (not (file-directory-p f1)) 1448 (if (and (not (file-directory-p f1))
1444 (not (file-directory-p f2))) 1449 (not (file-directory-p f2)))
1445 (let ((res 1450 (condition-case nil
1446 (apply 'call-process ediff-cmp-program nil nil nil 1451 (let ((res
1447 (append ediff-cmp-options (list f1 f2))))) 1452 (apply 'call-process ediff-cmp-program nil nil nil
1448 (and (numberp res) (eq res 0)))) 1453 (append ediff-cmp-options (list f1 f2)))))
1449 ) 1454 (and (numberp res) (eq res 0)))
1455 (error (format "Cannot execute program %S." ediff-cmp-program)))
1456 ))
1450 1457
1451 1458
1452(defun ediff-same-contents (d1 d2 &optional filter-re) 1459(defun ediff-same-contents (d1 d2 &optional filter-re)
@@ -1521,21 +1528,30 @@ affects only files whose names match the expression."
1521 (setq file-list-list (cdr file-list-list))) 1528 (setq file-list-list (cdr file-list-list)))
1522 (reverse result))) 1529 (reverse result)))
1523 1530
1531
1532(defun ediff-set-actual-diff-options ()
1533 (if ediff-ignore-case
1534 (setq ediff-actual-diff-options
1535 (concat ediff-diff-options " " ediff-ignore-case-option)
1536 ediff-actual-diff3-options
1537 (concat ediff-diff3-options " " ediff-ignore-case-option3))
1538 (setq ediff-actual-diff-options ediff-diff-options
1539 ediff-actual-diff3-options ediff-diff3-options)
1540 )
1541 (setq-default ediff-actual-diff-options ediff-actual-diff-options
1542 ediff-actual-diff3-options ediff-actual-diff3-options)
1543 )
1544
1545
1524;; Ignore case handling - some ideas from drew.adams@@oracle.com 1546;; Ignore case handling - some ideas from drew.adams@@oracle.com
1525(defun ediff-toggle-ignore-case () 1547(defun ediff-toggle-ignore-case ()
1526 (interactive) 1548 (interactive)
1527 (ediff-barf-if-not-control-buffer) 1549 (ediff-barf-if-not-control-buffer)
1528 (setq ediff-ignore-case (not ediff-ignore-case)) 1550 (setq ediff-ignore-case (not ediff-ignore-case))
1529 (cond (ediff-ignore-case 1551 (ediff-set-actual-diff-options)
1530 (setq ediff-actual-diff-options 1552 (if ediff-ignore-case
1531 (concat ediff-diff-options " " ediff-ignore-case-option) 1553 (message "Ignoring regions that differ only in case")
1532 ediff-actual-diff3-options 1554 (message "Ignoring case differences turned OFF"))
1533 (concat ediff-diff3-options " " ediff-ignore-case-option3))
1534 (message "Ignoring regions that differ only in case"))
1535 (t
1536 (setq ediff-actual-diff-options ediff-diff-options
1537 ediff-actual-diff3-options ediff-diff3-options)
1538 (message "Ignoring case differences turned OFF")))
1539 (cond (ediff-merge-job 1555 (cond (ediff-merge-job
1540 (message "Ignoring letter case is too dangerous in merge jobs")) 1556 (message "Ignoring letter case is too dangerous in merge jobs"))
1541 ((and ediff-diff3-job (string= ediff-ignore-case-option3 "")) 1557 ((and ediff-diff3-job (string= ediff-ignore-case-option3 ""))
diff --git a/lisp/ediff-mult.el b/lisp/ediff-mult.el
index 0bbd3298c7a..71859a5d4c5 100644
--- a/lisp/ediff-mult.el
+++ b/lisp/ediff-mult.el
@@ -1656,22 +1656,26 @@ This operation is defined only for `ediff-directories' and
1656multifile patches. For `ediff-directory-revisions', we insist that 1656multifile patches. For `ediff-directory-revisions', we insist that
1657all marked sessions must be active." 1657all marked sessions must be active."
1658 (interactive) 1658 (interactive)
1659 (or (ediff-buffer-live-p ediff-meta-diff-buffer) 1659 (let ((coding-system-for-read ediff-coding-system-for-read))
1660 (setq ediff-meta-diff-buffer 1660 (or (ediff-buffer-live-p ediff-meta-diff-buffer)
1661 (get-buffer-create 1661 (setq ediff-meta-diff-buffer
1662 (ediff-unique-buffer-name "*Ediff Multifile Diffs" "*")))) 1662 (get-buffer-create
1663 (ediff-with-current-buffer ediff-meta-diff-buffer 1663 (ediff-unique-buffer-name "*Ediff Multifile Diffs" "*"))))
1664 (setq buffer-read-only nil) 1664 (ediff-with-current-buffer ediff-meta-diff-buffer
1665 (erase-buffer)) 1665 (setq buffer-read-only nil)
1666 (if (> (ediff-operate-on-marked-sessions 'ediff-append-custom-diff) 0) 1666 (erase-buffer))
1667 ;; did something 1667 (if (> (ediff-operate-on-marked-sessions 'ediff-append-custom-diff) 0)
1668 (progn 1668 ;; did something
1669 (display-buffer ediff-meta-diff-buffer 'not-this-window) 1669 (progn
1670 (ediff-with-current-buffer ediff-meta-diff-buffer 1670 (display-buffer ediff-meta-diff-buffer 'not-this-window)
1671 (set-buffer-modified-p nil) 1671 (ediff-with-current-buffer ediff-meta-diff-buffer
1672 (setq buffer-read-only t))) 1672 (set-buffer-modified-p nil)
1673 (beep) 1673 (setq buffer-read-only t))
1674 (message "No marked sessions found"))) 1674 (if (fboundp 'diff-mode)
1675 (with-current-buffer ediff-meta-diff-buffer
1676 (diff-mode))))
1677 (beep)
1678 (message "No marked sessions found"))))
1675 1679
1676(defun ediff-meta-show-patch () 1680(defun ediff-meta-show-patch ()
1677 "Show the multi-file patch associated with this group session." 1681 "Show the multi-file patch associated with this group session."
diff --git a/lisp/ediff-vers.el b/lisp/ediff-vers.el
index 3e8b1c37572..4cd1492a1c7 100644
--- a/lisp/ediff-vers.el
+++ b/lisp/ediff-vers.el
@@ -52,6 +52,13 @@
52 ))) 52 )))
53;; end pacifier 53;; end pacifier
54 54
55(defcustom ediff-keep-tmp-versions nil
56 "*If t, do not delete temporary previous versions for the files on which
57comparison or merge operations are being performed."
58 :type 'boolean
59 :group 'ediff-vers
60 )
61
55;; VC.el support 62;; VC.el support
56 63
57(defun ediff-vc-latest-version (file) 64(defun ediff-vc-latest-version (file)
@@ -87,8 +94,8 @@
87 file2 (buffer-file-name))) 94 file2 (buffer-file-name)))
88 (setq startup-hooks 95 (setq startup-hooks
89 (cons `(lambda () 96 (cons `(lambda ()
90 (delete-file ,file1) 97 (ediff-delete-version-file ,file1)
91 (or ,(string= rev2 "") (delete-file ,file2))) 98 (or ,(string= rev2 "") (ediff-delete-version-file ,file2)))
92 startup-hooks))) 99 startup-hooks)))
93 (ediff-buffers 100 (ediff-buffers
94 rev1buf rev2buf 101 rev1buf rev2buf
@@ -199,12 +206,12 @@
199 (setq startup-hooks 206 (setq startup-hooks
200 (cons 207 (cons
201 `(lambda () 208 `(lambda ()
202 (delete-file ,(buffer-file-name buf1)) 209 (ediff-delete-version-file ,(buffer-file-name buf1))
203 (or ,(string= rev2 "") 210 (or ,(string= rev2 "")
204 (delete-file ,(buffer-file-name buf2))) 211 (ediff-delete-version-file ,(buffer-file-name buf2)))
205 (or ,(string= ancestor-rev "") 212 (or ,(string= ancestor-rev "")
206 ,(not ancestor-rev) 213 ,(not ancestor-rev)
207 (delete-file ,(buffer-file-name ancestor-buf))) 214 (ediff-delete-version-file ,(buffer-file-name ancestor-buf)))
208 ) 215 )
209 startup-hooks))) 216 startup-hooks)))
210 (if ancestor-rev 217 (if ancestor-rev
@@ -305,8 +312,13 @@
305 (find-file-noselect (cvs-fileinfo->full-name fileinfo))) 312 (find-file-noselect (cvs-fileinfo->full-name fileinfo)))
306 nil ; startup-hooks 313 nil ; startup-hooks
307 'ediff-revisions))) 314 'ediff-revisions)))
308 (if (stringp tmp-file) (delete-file tmp-file)) 315 (if (stringp tmp-file) (ediff-delete-version-file tmp-file))
309 (if (stringp ancestor-file) (delete-file ancestor-file)))) 316 (if (stringp ancestor-file) (ediff-delete-version-file ancestor-file))))
317
318
319;; delete version file on exit unless ediff-keep-tmp-versions is true
320(defun ediff-delete-version-file (file)
321 (or ediff-keep-tmp-versions (delete-file file)))
310 322
311 323
312(provide 'ediff-vers) 324(provide 'ediff-vers)
diff --git a/lisp/ediff-wind.el b/lisp/ediff-wind.el
index 28369f9f6bd..c0786b9cc43 100644
--- a/lisp/ediff-wind.el
+++ b/lisp/ediff-wind.el
@@ -158,6 +158,8 @@ In this case, Ediff will use those frames to display these buffers."
158 '(scrollbar-height . 0) ; XEmacs only 158 '(scrollbar-height . 0) ; XEmacs only
159 '(menu-bar-lines . 0) ; Emacs only 159 '(menu-bar-lines . 0) ; Emacs only
160 '(tool-bar-lines . 0) ; Emacs 21+ only 160 '(tool-bar-lines . 0) ; Emacs 21+ only
161 '(left-fringe . 0)
162 '(right-fringe . 0)
161 ;; don't lower but auto-raise 163 ;; don't lower but auto-raise
162 '(auto-lower . nil) 164 '(auto-lower . nil)
163 '(auto-raise . t) 165 '(auto-raise . t)
diff --git a/lisp/ediff.el b/lisp/ediff.el
index 14f634f0cd2..3e0be86b18b 100644
--- a/lisp/ediff.el
+++ b/lisp/ediff.el
@@ -500,12 +500,13 @@ expression; only file names that match the regexp are considered."
500 (let ((dir-A (ediff-get-default-directory-name)) 500 (let ((dir-A (ediff-get-default-directory-name))
501 (default-regexp (eval ediff-default-filtering-regexp)) 501 (default-regexp (eval ediff-default-filtering-regexp))
502 f) 502 f)
503 (list (setq f (ediff-read-file-name "Directory A to compare:" dir-A nil)) 503 (list (setq f (read-directory-name
504 (ediff-read-file-name "Directory B to compare:" 504 "Directory A to compare:" dir-A nil 'must-match))
505 (if ediff-use-last-dir 505 (read-directory-name "Directory B to compare:"
506 ediff-last-dir-B 506 (if ediff-use-last-dir
507 (ediff-strip-last-dir f)) 507 ediff-last-dir-B
508 nil) 508 (ediff-strip-last-dir f))
509 nil 'must-match)
509 (read-string 510 (read-string
510 (if (stringp default-regexp) 511 (if (stringp default-regexp)
511 (format "Filter through regular expression (default %s): " 512 (format "Filter through regular expression (default %s): "
@@ -532,8 +533,8 @@ names. Only the files that are under revision control are taken into account."
532 (let ((dir-A (ediff-get-default-directory-name)) 533 (let ((dir-A (ediff-get-default-directory-name))
533 (default-regexp (eval ediff-default-filtering-regexp)) 534 (default-regexp (eval ediff-default-filtering-regexp))
534 ) 535 )
535 (list (ediff-read-file-name 536 (list (read-directory-name
536 "Directory to compare with revision:" dir-A nil) 537 "Directory to compare with revision:" dir-A nil 'must-match)
537 (read-string 538 (read-string
538 (if (stringp default-regexp) 539 (if (stringp default-regexp)
539 (format "Filter through regular expression (default %s): " 540 (format "Filter through regular expression (default %s): "
@@ -561,17 +562,17 @@ regular expression; only file names that match the regexp are considered."
561 (let ((dir-A (ediff-get-default-directory-name)) 562 (let ((dir-A (ediff-get-default-directory-name))
562 (default-regexp (eval ediff-default-filtering-regexp)) 563 (default-regexp (eval ediff-default-filtering-regexp))
563 f) 564 f)
564 (list (setq f (ediff-read-file-name "Directory A to compare:" dir-A nil)) 565 (list (setq f (read-directory-name "Directory A to compare:" dir-A nil))
565 (setq f (ediff-read-file-name "Directory B to compare:" 566 (setq f (read-directory-name "Directory B to compare:"
566 (if ediff-use-last-dir 567 (if ediff-use-last-dir
567 ediff-last-dir-B 568 ediff-last-dir-B
568 (ediff-strip-last-dir f)) 569 (ediff-strip-last-dir f))
569 nil)) 570 nil 'must-match))
570 (ediff-read-file-name "Directory C to compare:" 571 (read-directory-name "Directory C to compare:"
571 (if ediff-use-last-dir 572 (if ediff-use-last-dir
572 ediff-last-dir-C 573 ediff-last-dir-C
573 (ediff-strip-last-dir f)) 574 (ediff-strip-last-dir f))
574 nil) 575 nil 'must-match)
575 (read-string 576 (read-string
576 (if (stringp default-regexp) 577 (if (stringp default-regexp)
577 (format "Filter through regular expression (default %s): " 578 (format "Filter through regular expression (default %s): "
@@ -597,12 +598,13 @@ expression; only file names that match the regexp are considered."
597 (let ((dir-A (ediff-get-default-directory-name)) 598 (let ((dir-A (ediff-get-default-directory-name))
598 (default-regexp (eval ediff-default-filtering-regexp)) 599 (default-regexp (eval ediff-default-filtering-regexp))
599 f) 600 f)
600 (list (setq f (ediff-read-file-name "Directory A to merge:" dir-A nil)) 601 (list (setq f (read-directory-name "Directory A to merge:"
601 (ediff-read-file-name "Directory B to merge:" 602 dir-A nil 'must-match))
602 (if ediff-use-last-dir 603 (read-directory-name "Directory B to merge:"
603 ediff-last-dir-B 604 (if ediff-use-last-dir
604 (ediff-strip-last-dir f)) 605 ediff-last-dir-B
605 nil) 606 (ediff-strip-last-dir f))
607 nil 'must-match)
606 (read-string 608 (read-string
607 (if (stringp default-regexp) 609 (if (stringp default-regexp)
608 (format "Filter through regular expression (default %s): " 610 (format "Filter through regular expression (default %s): "
@@ -633,17 +635,17 @@ only file names that match the regexp are considered."
633 (let ((dir-A (ediff-get-default-directory-name)) 635 (let ((dir-A (ediff-get-default-directory-name))
634 (default-regexp (eval ediff-default-filtering-regexp)) 636 (default-regexp (eval ediff-default-filtering-regexp))
635 f) 637 f)
636 (list (setq f (ediff-read-file-name "Directory A to merge:" dir-A nil)) 638 (list (setq f (read-directory-name "Directory A to merge:" dir-A nil))
637 (setq f (ediff-read-file-name "Directory B to merge:" 639 (setq f (read-directory-name "Directory B to merge:"
638 (if ediff-use-last-dir 640 (if ediff-use-last-dir
639 ediff-last-dir-B 641 ediff-last-dir-B
640 (ediff-strip-last-dir f)) 642 (ediff-strip-last-dir f))
641 nil)) 643 nil 'must-match))
642 (ediff-read-file-name "Ancestor directory:" 644 (read-directory-name "Ancestor directory:"
643 (if ediff-use-last-dir 645 (if ediff-use-last-dir
644 ediff-last-dir-C 646 ediff-last-dir-C
645 (ediff-strip-last-dir f)) 647 (ediff-strip-last-dir f))
646 nil) 648 nil 'must-match)
647 (read-string 649 (read-string
648 (if (stringp default-regexp) 650 (if (stringp default-regexp)
649 (format "Filter through regular expression (default %s): " 651 (format "Filter through regular expression (default %s): "
@@ -669,8 +671,8 @@ names. Only the files that are under revision control are taken into account."
669 (let ((dir-A (ediff-get-default-directory-name)) 671 (let ((dir-A (ediff-get-default-directory-name))
670 (default-regexp (eval ediff-default-filtering-regexp)) 672 (default-regexp (eval ediff-default-filtering-regexp))
671 ) 673 )
672 (list (ediff-read-file-name 674 (list (read-directory-name
673 "Directory to merge with revisions:" dir-A nil) 675 "Directory to merge with revisions:" dir-A nil 'must-match)
674 (read-string 676 (read-string
675 (if (stringp default-regexp) 677 (if (stringp default-regexp)
676 (format "Filter through regular expression (default %s): " 678 (format "Filter through regular expression (default %s): "
@@ -699,8 +701,9 @@ names. Only the files that are under revision control are taken into account."
699 (let ((dir-A (ediff-get-default-directory-name)) 701 (let ((dir-A (ediff-get-default-directory-name))
700 (default-regexp (eval ediff-default-filtering-regexp)) 702 (default-regexp (eval ediff-default-filtering-regexp))
701 ) 703 )
702 (list (ediff-read-file-name 704 (list (read-directory-name
703 "Directory to merge with revisions and ancestors:" dir-A nil) 705 "Directory to merge with revisions and ancestors:"
706 dir-A nil 'must-match)
704 (read-string 707 (read-string
705 (if (stringp default-regexp) 708 (if (stringp default-regexp)
706 (format "Filter through regular expression (default %s): " 709 (format "Filter through regular expression (default %s): "
@@ -733,11 +736,6 @@ names. Only the files that are under revision control are taken into account."
733(defun ediff-directories-internal (dir1 dir2 dir3 regexp action jobname 736(defun ediff-directories-internal (dir1 dir2 dir3 regexp action jobname
734 &optional startup-hooks 737 &optional startup-hooks
735 merge-autostore-dir) 738 merge-autostore-dir)
736 ;; ediff-read-file-name is set to attach a previously entered file name if
737 ;; the currently entered file is a directory. This code takes care of that.
738 (setq dir1 (if (file-directory-p dir1) dir1 (file-name-directory dir1))
739 dir2 (if (file-directory-p dir2) dir2 (file-name-directory dir2)))
740
741 (if (stringp dir3) 739 (if (stringp dir3)
742 (setq dir3 (if (file-directory-p dir3) dir3 (file-name-directory dir3)))) 740 (setq dir3 (if (file-directory-p dir3) dir3 (file-name-directory dir3))))
743 741
@@ -763,7 +761,7 @@ names. Only the files that are under revision control are taken into account."
763 (ediff-merge-metajob jobname) 761 (ediff-merge-metajob jobname)
764 (not merge-autostore-dir)) 762 (not merge-autostore-dir))
765 (setq merge-autostore-dir 763 (setq merge-autostore-dir
766 (read-file-name "Save merged files in directory: " 764 (read-directory-name "Save merged files in directory: "
767 (if ediff-use-last-dir 765 (if ediff-use-last-dir
768 ediff-last-merge-autostore-dir 766 ediff-last-merge-autostore-dir
769 (ediff-strip-last-dir dir1)) 767 (ediff-strip-last-dir dir1))
@@ -823,7 +821,7 @@ names. Only the files that are under revision control are taken into account."
823 (ediff-merge-metajob jobname) 821 (ediff-merge-metajob jobname)
824 (not merge-autostore-dir)) 822 (not merge-autostore-dir))
825 (setq merge-autostore-dir 823 (setq merge-autostore-dir
826 (read-file-name "Save merged files in directory: " 824 (read-directory-name "Save merged files in directory: "
827 (if ediff-use-last-dir 825 (if ediff-use-last-dir
828 ediff-last-merge-autostore-dir 826 ediff-last-merge-autostore-dir
829 (ediff-strip-last-dir dir1)) 827 (ediff-strip-last-dir dir1))
diff --git a/lisp/emulation/viper-cmd.el b/lisp/emulation/viper-cmd.el
index 645f4f26eaf..0dce3b94ff0 100644
--- a/lisp/emulation/viper-cmd.el
+++ b/lisp/emulation/viper-cmd.el
@@ -887,12 +887,15 @@ Vi's prefix argument will be used. Otherwise, the prefix argument passed to
887 (setq ch (aref (read-key-sequence nil) 0))) 887 (setq ch (aref (read-key-sequence nil) 0)))
888 (insert ch)) 888 (insert ch))
889 (t 889 (t
890 (setq ch (read-char-exclusive)) 890 ;;(setq ch (read-char-exclusive))
891 (setq ch (aref (read-key-sequence nil) 0))
891 ;; replace ^M with the newline 892 ;; replace ^M with the newline
892 (if (eq ch ?\C-m) (setq ch ?\n)) 893 (if (eq ch ?\C-m) (setq ch ?\n))
893 ;; Make sure ^V and ^Q work as quotation chars 894 ;; Make sure ^V and ^Q work as quotation chars
894 (if (memq ch '(?\C-v ?\C-q)) 895 (if (memq ch '(?\C-v ?\C-q))
895 (setq ch (read-char-exclusive))) 896 ;;(setq ch (read-char-exclusive))
897 (setq ch (aref (read-key-sequence nil) 0))
898 )
896 (insert ch)) 899 (insert ch))
897 ) 900 )
898 (setq last-command-event 901 (setq last-command-event
@@ -1730,20 +1733,34 @@ invokes the command before that, etc."
1730 1733
1731;; undoing 1734;; undoing
1732 1735
1736;; hook used inside undo
1737(defvar viper-undo-functions nil)
1738
1739;; Runs viper-before-change-functions inside before-change-functions
1740(defun viper-undo-sentinel (beg end length)
1741 (run-hook-with-args 'viper-undo-functions beg end length))
1742
1743(add-hook 'after-change-functions 'viper-undo-sentinel)
1744
1745;; Hook used in viper-undo
1746(defun viper-after-change-undo-hook (beg end len)
1747 (setq undo-beg-posn beg
1748 undo-end-posn (or end beg))
1749 ;; some other hooks may be changing various text properties in
1750 ;; the buffer in response to 'undo'; so remove this hook to avoid
1751 ;; its repeated invocation
1752 (remove-hook 'viper-undo-functions 'viper-after-change-undo-hook 'local))
1753
1733(defun viper-undo () 1754(defun viper-undo ()
1734 "Undo previous change." 1755 "Undo previous change."
1735 (interactive) 1756 (interactive)
1736 (message "undo!") 1757 (message "undo!")
1737 (let ((modified (buffer-modified-p)) 1758 (let ((modified (buffer-modified-p))
1738 (before-undo-pt (point-marker)) 1759 (before-undo-pt (point-marker))
1739 (after-change-functions after-change-functions)
1740 undo-beg-posn undo-end-posn) 1760 undo-beg-posn undo-end-posn)
1741 1761
1742 ;; no need to remove this hook, since this var has scope inside a let. 1762 ;; the viper-after-change-undo-hook removes itself after the 1st invocation
1743 (add-hook 'after-change-functions 1763 (add-hook 'viper-undo-functions 'viper-after-change-undo-hook nil 'local)
1744 '(lambda (beg end len)
1745 (setq undo-beg-posn beg
1746 undo-end-posn (or end beg))))
1747 1764
1748 (undo-start) 1765 (undo-start)
1749 (undo-more 2) 1766 (undo-more 2)
@@ -1765,7 +1782,8 @@ invokes the command before that, etc."
1765 (goto-char undo-beg-posn))) 1782 (goto-char undo-beg-posn)))
1766 (push-mark before-undo-pt t)) 1783 (push-mark before-undo-pt t))
1767 (if (and (eolp) (not (bolp))) (backward-char 1)) 1784 (if (and (eolp) (not (bolp))) (backward-char 1))
1768 (if (not modified) (set-buffer-modified-p t))) 1785 ;;(if (not modified) (set-buffer-modified-p t))
1786 )
1769 (setq this-command 'viper-undo)) 1787 (setq this-command 'viper-undo))
1770 1788
1771;; Continue undoing previous changes. 1789;; Continue undoing previous changes.
@@ -1813,7 +1831,7 @@ invokes the command before that, etc."
1813 (setq viper-undo-needs-adjustment t))))) 1831 (setq viper-undo-needs-adjustment t)))))
1814 1832
1815 1833
1816 1834;;; Viper's destructive Command ring utilities
1817 1835
1818(defun viper-display-current-destructive-command () 1836(defun viper-display-current-destructive-command ()
1819 (let ((text (nth 4 viper-d-com)) 1837 (let ((text (nth 4 viper-d-com))
@@ -1927,12 +1945,15 @@ Undo previous insertion and inserts new."
1927 (end-of-line) 1945 (end-of-line)
1928 ;; make sure all lines end with newline, unless in the minibuffer or 1946 ;; make sure all lines end with newline, unless in the minibuffer or
1929 ;; when requested otherwise (require-final-newline is nil) 1947 ;; when requested otherwise (require-final-newline is nil)
1930 (if (and (eobp) 1948 (save-restriction
1931 (not (bolp)) 1949 (widen)
1932 require-final-newline 1950 (if (and (eobp)
1933 (not (viper-is-in-minibuffer)) 1951 (not (bolp))
1934 (not buffer-read-only)) 1952 require-final-newline
1935 (insert "\n")))) 1953 (not (viper-is-in-minibuffer))
1954 (not buffer-read-only))
1955 (insert "\n")))
1956 ))
1936 1957
1937(defun viper-yank-defun () 1958(defun viper-yank-defun ()
1938 (mark-defun) 1959 (mark-defun)
@@ -3045,19 +3066,34 @@ On reaching beginning of line, stop and signal error."
3045 (setq this-command 'next-line) 3066 (setq this-command 'next-line)
3046 (if com (viper-execute-com 'viper-next-line val com)))) 3067 (if com (viper-execute-com 'viper-next-line val com))))
3047 3068
3069
3048(defun viper-next-line-at-bol (arg) 3070(defun viper-next-line-at-bol (arg)
3049 "Next line at beginning of line." 3071 "Next line at beginning of line.
3072If point is on a widget or a button, simulate clicking on that widget/button."
3050 (interactive "P") 3073 (interactive "P")
3051 (viper-leave-region-active) 3074 (let* ((field (get-char-property (point) 'field))
3052 (save-excursion 3075 (button (get-char-property (point) 'button))
3053 (end-of-line) 3076 (doc (get-char-property (point) 'widget-doc))
3054 (if (eobp) (error "Last line in buffer"))) 3077 (widget (or field button doc)))
3055 (let ((val (viper-p-val arg)) 3078 (if (and widget
3056 (com (viper-getCom arg))) 3079 (if (symbolp widget)
3057 (if com (viper-move-marker-locally 'viper-com-point (point))) 3080 (get widget 'widget-type)
3058 (forward-line val) 3081 (and (consp widget)
3059 (back-to-indentation) 3082 (get (widget-type widget) 'widget-type))))
3060 (if com (viper-execute-com 'viper-next-line-at-bol val com)))) 3083 (widget-button-press (point))
3084 (if (button-at (point))
3085 (push-button)
3086 ;; not a widget or a button
3087 (viper-leave-region-active)
3088 (save-excursion
3089 (end-of-line)
3090 (if (eobp) (error "Last line in buffer")))
3091 (let ((val (viper-p-val arg))
3092 (com (viper-getCom arg)))
3093 (if com (viper-move-marker-locally 'viper-com-point (point)))
3094 (forward-line val)
3095 (back-to-indentation)
3096 (if com (viper-execute-com 'viper-next-line-at-bol val com)))))))
3061 3097
3062 3098
3063(defun viper-previous-line (arg) 3099(defun viper-previous-line (arg)
diff --git a/lisp/emulation/viper-util.el b/lisp/emulation/viper-util.el
index c7fe792b5f2..252088a476d 100644
--- a/lisp/emulation/viper-util.el
+++ b/lisp/emulation/viper-util.el
@@ -139,8 +139,8 @@
139 139
140(defsubst viper-get-cursor-color () 140(defsubst viper-get-cursor-color ()
141 (viper-cond-compile-for-xemacs-or-emacs 141 (viper-cond-compile-for-xemacs-or-emacs
142 ;; xemacs 142 (color-instance-name
143 (color-instance-name (frame-property (selected-frame) 'cursor-color)) 143 (frame-property (selected-frame) 'cursor-color)) ; xemacs
144 (cdr (assoc 'cursor-color (frame-parameters))) ; emacs 144 (cdr (assoc 'cursor-color (frame-parameters))) ; emacs
145 )) 145 ))
146 146
diff --git a/lisp/emulation/viper.el b/lisp/emulation/viper.el
index fc55d291550..8f858526da3 100644
--- a/lisp/emulation/viper.el
+++ b/lisp/emulation/viper.el
@@ -534,6 +534,10 @@ If Viper is enabled, turn it off. Otherwise, turn it on."
534(defun viper-mode () 534(defun viper-mode ()
535 "Turn on Viper emulation of Vi in Emacs. See Info node `(viper)Viper'." 535 "Turn on Viper emulation of Vi in Emacs. See Info node `(viper)Viper'."
536 (interactive) 536 (interactive)
537 (if (null viper-vi-state-cursor-color)
538 (modify-frame-parameters
539 (selected-frame)
540 (list (cons 'viper-vi-state-cursor-color (viper-get-cursor-color)))))
537 (if (not noninteractive) 541 (if (not noninteractive)
538 (progn 542 (progn
539 ;; if the user requested viper-mode explicitly 543 ;; if the user requested viper-mode explicitly
@@ -545,8 +549,6 @@ If Viper is enabled, turn it off. Otherwise, turn it on."
545 (if viper-first-time ; Important check. Prevents mix-up of startup 549 (if viper-first-time ; Important check. Prevents mix-up of startup
546 (progn ; and expert-level msgs when viper-mode recurses 550 (progn ; and expert-level msgs when viper-mode recurses
547 (setq viper-first-time nil) 551 (setq viper-first-time nil)
548 (setq viper-vi-state-cursor-color
549 (viper-get-cursor-color))
550 (if (not viper-inhibit-startup-message) 552 (if (not viper-inhibit-startup-message)
551 (save-window-excursion 553 (save-window-excursion
552 (setq viper-inhibit-startup-message t) 554 (setq viper-inhibit-startup-message t)