]> git.eshelyaron.com Git - emacs.git/commitdiff
2006-08-25 Michael Kifer <kifer@cs.stonybrook.edu>
authorMichael Kifer <kifer@cs.stonybrook.edu>
Fri, 25 Aug 2006 16:06:57 +0000 (16:06 +0000)
committerMichael Kifer <kifer@cs.stonybrook.edu>
Fri, 25 Aug 2006 16:06:57 +0000 (16:06 +0000)
* viper.el (viper-set-hooks): use frame bindings for
viper-vi-state-cursor-color.
(viper-non-hook-settings): don't set default
mode-line-buffer-identification.

* viper-util.el (viper-set-cursor-color-according-to-state): new
function.
(viper-set-cursor-color-according-to-state,
viper-get-saved-cursor-color-in-replace-mode,
viper-get-saved-cursor-color-in-insert-mode): make conditional on
viper-emacs-state-cursor-color.

* viper-cmd.el (viper-envelop-ESC-key): bug fix.
(viper-undo): use point if undo-beg-posn is nil.
(viper-insert-state-post-command-sentinel,viper-change-state-to-emacs,
viper-after-change-undo-hook): don't use
viper-emacs-state-cursor-color by default.
(viper-undo): more sensible positioning after undo.

* viper-ex.el (ex-splice-args-in-1-letr-cmd): got rid of caddr.
(viper-emacs-state-cursor-color): default to nil, since this feature
doesn't work well yet.

* ediff-mult.el (ediff-intersect-directories,
ediff-get-directory-files-under-revision, ediff-dir-diff-copy-file):
always expand filenames.

lisp/ChangeLog
lisp/ediff-mult.el
lisp/emulation/viper-cmd.el
lisp/emulation/viper-ex.el
lisp/emulation/viper-init.el
lisp/emulation/viper-util.el
lisp/emulation/viper.el

index 554274a2544d88286b1f3db20dbc2410fd91e7c7..ffaf73d86d195dd720459169968d630584660fc6 100644 (file)
@@ -1,3 +1,32 @@
+2006-08-25  Michael Kifer  <kifer@cs.stonybrook.edu>
+       
+       * viper.el (viper-set-hooks): use frame bindings for
+       viper-vi-state-cursor-color.
+       (viper-non-hook-settings): don't set default
+       mode-line-buffer-identification.
+       
+       * viper-util.el (viper-set-cursor-color-according-to-state): new
+       function.
+       (viper-set-cursor-color-according-to-state,
+       viper-get-saved-cursor-color-in-replace-mode,
+       viper-get-saved-cursor-color-in-insert-mode): make conditional on
+       viper-emacs-state-cursor-color.
+       
+       * viper-cmd.el (viper-envelop-ESC-key): bug fix.
+       (viper-undo): use point if undo-beg-posn is nil.
+       (viper-insert-state-post-command-sentinel,viper-change-state-to-emacs,
+       viper-after-change-undo-hook): don't use
+       viper-emacs-state-cursor-color by default.
+       (viper-undo): more sensible positioning after undo.
+       
+       * viper-ex.el (ex-splice-args-in-1-letr-cmd): got rid of caddr.
+       (viper-emacs-state-cursor-color): default to nil, since this feature
+       doesn't work well yet.
+       
+       * ediff-mult.el (ediff-intersect-directories,
+       ediff-get-directory-files-under-revision, ediff-dir-diff-copy-file):
+       always expand filenames.
+       
 2006-08-24  Chong Yidong  <cyd@stupidchicken.com>
 
        * emacs-lisp/timer.el (timer-set-idle-time, run-with-idle-timer):
index 71859a5d4c5611eaea2e2f7eeb9b6163ca07319a..b33ad7c1859569dd9c626101fbd632e73f4da0c5 100644 (file)
@@ -648,8 +648,8 @@ behavior."
           (mapcar
            (lambda (elt)
              (ediff-make-new-meta-list-element
-              (concat auxdir1 elt)
-              (concat auxdir2 elt)
+              (expand-file-name (concat auxdir1 elt))
+              (expand-file-name (concat auxdir2 elt))
               (if lis3
                   (progn
                     ;; The following is done because: In merging with
@@ -660,7 +660,7 @@ behavior."
                     ;; the second case, we insert nil.
                     (setq elt (ediff-add-slash-if-directory auxdir3 elt))
                     (if (file-exists-p (concat auxdir3 elt))
-                        (concat auxdir3 elt))))))
+                        (expand-file-name (concat auxdir3 elt)))))))
            common)))
     ;; return result
     (cons common-part difflist)
@@ -716,7 +716,7 @@ behavior."
                                      auxdir1 nil nil
                                      merge-autostore-dir nil)
      (mapcar (lambda (elt) (ediff-make-new-meta-list-element
-                           (concat auxdir1 elt) nil nil))
+                           (expand-file-name (concat auxdir1 elt)) nil nil))
             common))
     ))
 
@@ -1338,7 +1338,10 @@ Useful commands:
        ;; update ediff-meta-list by direct modification
        (nconc meta-list
               (list (ediff-make-new-meta-list-element
-                     otherfile1 otherfile2 otherfile3)))
+                     (expand-file-name otherfile1)
+                     (expand-file-name otherfile2)
+                     (if otherfile3
+                         (expand-file-name otherfile3)))))
       )
     (ediff-update-meta-buffer meta-buf 'must-redraw)
   ))
index 0dce3b94ff0525704571e618f27276c26763e214..af757a2a55c6b1e18d2c5922c5b518869aa50a51 100644 (file)
@@ -46,6 +46,8 @@
 (defvar mark-even-if-inactive)
 (defvar init-message)
 (defvar initial)
+(defvar undo-beg-posn)
+(defvar undo-end-posn)
 
 ;; loading happens only in non-interactive compilation
 ;; in order to spare non-viperized emacs from being viperized
            (viper-save-cursor-color 'before-insert-mode))
        ;; set insert mode cursor color
        (viper-change-cursor-color viper-insert-state-cursor-color)))
-  (if (eq viper-current-state 'emacs-state)
+  (if (and viper-emacs-state-cursor-color (eq viper-current-state 'emacs-state))
       (let ((has-saved-cursor-color-in-emacs-mode
             (stringp (viper-get-saved-cursor-color-in-emacs-mode))))
        (or has-saved-cursor-color-in-emacs-mode
       (viper-set-replace-overlay (point-min) (point-min)))
   (viper-hide-replace-overlay)
 
-  (let ((has-saved-cursor-color-in-emacs-mode
-        (stringp (viper-get-saved-cursor-color-in-emacs-mode))))
-    (or has-saved-cursor-color-in-emacs-mode
-       (string= (viper-get-cursor-color) viper-emacs-state-cursor-color)
-       (viper-save-cursor-color 'before-emacs-mode))
-    (viper-change-cursor-color viper-emacs-state-cursor-color))
+  (if viper-emacs-state-cursor-color
+      (let ((has-saved-cursor-color-in-emacs-mode
+            (stringp (viper-get-saved-cursor-color-in-emacs-mode))))
+       (or has-saved-cursor-color-in-emacs-mode
+           (string= (viper-get-cursor-color) viper-emacs-state-cursor-color)
+           (viper-save-cursor-color 'before-emacs-mode))
+       (viper-change-cursor-color viper-emacs-state-cursor-color)))
 
   (viper-change-state 'emacs-state)
 
@@ -1030,10 +1033,13 @@ as a Meta key and any number of multiple escapes is allowed."
        (inhibit-quit t))
     (if (viper-ESC-event-p event)
        (progn
-         ;; Emacs 22.50.8 introduced a bug, which makes even a single ESC into
-         ;; a fast keyseq. To guard against this, we added a check if there
-         ;; are other events as well
-         (if (and (viper-fast-keysequence-p) unread-command-events)
+         ;; Some versions of Emacs (eg., 22.50.8 have a bug, which makes even
+         ;; a single ESC into ;; a fast keyseq. To guard against this, we
+         ;; added a check if there are other events as well. Keep the next
+         ;; line for the next time the bug reappears, so that will remember to
+         ;; report it.
+         ;;(if (and (viper-fast-keysequence-p) unread-command-events)
+         (if (viper-fast-keysequence-p) ;; for Emacsen without the above bug
              (progn
                (let (minor-mode-map-alist emulation-mode-map-alists)
                  (viper-set-unread-command-events event)
@@ -1744,12 +1750,14 @@ invokes the command before that, etc."
 
 ;; Hook used in viper-undo
 (defun viper-after-change-undo-hook (beg end len)
-  (setq undo-beg-posn beg
-       undo-end-posn (or end beg))
-  ;; some other hooks may be changing various text properties in
-  ;; the buffer in response to 'undo'; so remove this hook to avoid
-  ;; its repeated invocation
-  (remove-hook 'viper-undo-functions 'viper-after-change-undo-hook 'local))
+  (if undo-in-progress
+      (setq undo-beg-posn beg
+           undo-end-posn (or end beg))
+    ;; some other hooks may be changing various text properties in
+    ;; the buffer in response to 'undo'; so remove this hook to avoid
+    ;; its repeated invocation
+    (remove-hook 'viper-undo-functions 'viper-after-change-undo-hook 'local)
+  ))
 
 (defun viper-undo ()
   "Undo previous change."
@@ -1764,25 +1772,29 @@ invokes the command before that, etc."
 
     (undo-start)
     (undo-more 2)
-    (setq undo-beg-posn (or undo-beg-posn before-undo-pt)
-         undo-end-posn (or undo-end-posn undo-beg-posn))
+    ;;(setq undo-beg-posn (or undo-beg-posn (point))
+    ;;    undo-end-posn (or undo-end-posn (point)))
+    ;;(setq undo-beg-posn (or undo-beg-posn before-undo-pt)
+    ;;      undo-end-posn (or undo-end-posn undo-beg-posn))
 
-    (goto-char undo-beg-posn)
-    (sit-for 0)
-    (if (and viper-keep-point-on-undo
-            (pos-visible-in-window-p before-undo-pt))
+    (if (and undo-beg-posn undo-end-posn)
        (progn
-         (push-mark (point-marker) t)
-         (viper-sit-for-short 300)
-         (goto-char undo-end-posn)
-         (viper-sit-for-short 300)
-         (if (and (> (viper-chars-in-region undo-beg-posn before-undo-pt) 1)
-                  (> (viper-chars-in-region undo-end-posn before-undo-pt) 1))
-             (goto-char before-undo-pt)
-           (goto-char undo-beg-posn)))
-      (push-mark before-undo-pt t))
+         (goto-char undo-beg-posn)
+         (sit-for 0)
+         (if (and viper-keep-point-on-undo
+                  (pos-visible-in-window-p before-undo-pt))
+             (progn
+               (push-mark (point-marker) t)
+               (viper-sit-for-short 300)
+               (goto-char undo-end-posn)
+               (viper-sit-for-short 300)
+               (if (pos-visible-in-window-p undo-beg-posn)
+                   (goto-char before-undo-pt)
+                 (goto-char undo-beg-posn)))
+           (push-mark before-undo-pt t))
+         ))
+
     (if (and (eolp) (not (bolp))) (backward-char 1))
-    ;;(if (not modified) (set-buffer-modified-p t))
     )
   (setq this-command 'viper-undo))
 
@@ -3952,7 +3964,8 @@ Null string will repeat previous search."
   (let ((val (viper-p-val arg))
        (com (viper-getcom arg))
        debug-on-error)
-    (if (null viper-s-string) (error viper-NoPrevSearch))
+    (if (or (null viper-s-string) (string= viper-s-string ""))
+       (error viper-NoPrevSearch))
     (viper-search viper-s-string viper-s-forward arg)
     (if com
        (progn
index e2824246fad2d3763245d3ab2f88aae6e5a1ad77..f9f080345826e2e748915395b1950c6b9fcced92 100644 (file)
 
 ;; If this is a one-letter magic command, splice in args.
 (defun ex-splice-args-in-1-letr-cmd (key list)
-  (let ((onelet (ex-cmd-is-one-letter (assoc (substring key 0 1) list))))
-    (if onelet
+  (let ((oneletter (ex-cmd-is-one-letter (assoc (substring key 0 1) list))))
+    (if oneletter
        (list key
-             (append (cadr onelet)
+             (append (cadr oneletter)
                      (if (< 1 (length key)) (list (substring key 1))))
-             (caddr onelet)))
+             (car (cdr (cdr oneletter))) ))
        ))
 
 
index 80938b0282a4ef17920b1099909dd2dda2328be8..465f6e5cfb870ba50e989bc4fe0dd90a408c6f64 100644 (file)
@@ -434,7 +434,10 @@ delete the text being replaced, as in standard Vi."
 (if (fboundp 'make-variable-frame-local)
     (make-variable-frame-local 'viper-insert-state-cursor-color))
 
-(defcustom viper-emacs-state-cursor-color "Magenta"
+;; viper-emacs-state-cursor-color doesn't work well. Causes cursor colors to be
+;; confused in some cases. So, this var is nulled for now.
+;; (defcustom viper-emacs-state-cursor-color "Magenta"
+(defcustom viper-emacs-state-cursor-color nil
   "Cursor color when Viper is in emacs state."
   :type 'string
   :group 'viper)
index 252088a476d06714d18824ad44da4a29813a9eca..fe179be9cd13830538f507214ec6d447e7842ddd 100644 (file)
    (x-display-color-p)  ; emacs
    ))
 
-(defsubst viper-get-cursor-color ()
+(defun viper-get-cursor-color (&optional frame)
   (viper-cond-compile-for-xemacs-or-emacs
    (color-instance-name
-    (frame-property (selected-frame) 'cursor-color)) ; xemacs
+    (frame-property (or frame (selected-frame)) 'cursor-color)) ; xemacs
    (cdr (assoc 'cursor-color (frame-parameters))) ; emacs
    ))
 
 
 
 ;; cursor colors
-(defun viper-change-cursor-color (new-color)
+(defun viper-change-cursor-color (new-color &optional frame)
   (if (and (viper-window-display-p)  (viper-color-display-p)
           (stringp new-color) (viper-color-defined-p new-color)
           (not (string= new-color (viper-get-cursor-color))))
       (viper-cond-compile-for-xemacs-or-emacs
        (set-frame-property
-       (selected-frame) 'cursor-color (make-color-instance new-color))
+       (or frame (selected-frame))
+       'cursor-color (make-color-instance new-color))
        (modify-frame-parameters
-       (selected-frame) (list (cons 'cursor-color new-color)))
+       (or frame (selected-frame))
+       (list (cons 'cursor-color new-color)))
        )
     ))
 
+(defun viper-set-cursor-color-according-to-state (&optional frame)
+  (cond ((eq viper-current-state 'replace-state)
+        (viper-change-cursor-color viper-replace-state-cursor-color frame))
+       ((and (eq viper-current-state 'emacs-state)
+             viper-emacs-state-cursor-color)
+        (viper-change-cursor-color viper-emacs-state-cursor-color frame))
+       ((eq viper-current-state 'insert-state)
+        (viper-change-cursor-color viper-insert-state-cursor-color frame))
+       (t
+        (viper-change-cursor-color viper-vi-state-cursor-color frame))))
+
 ;; By default, saves current frame cursor color in the
 ;; viper-saved-cursor-color-in-replace-mode property of viper-replace-overlay
 (defun viper-save-cursor-color (before-which-mode)
     (if viper-emacs-p 'frame-parameter 'frame-property)
     (selected-frame)
     'viper-saved-cursor-color-in-replace-mode)
-   (if (eq viper-current-state 'emacs-mode)
+   (if (and (eq viper-current-state 'emacs-mode) viper-emacs-state-cursor-color)
        viper-emacs-state-cursor-color
      viper-vi-state-cursor-color)))
 
     (if viper-emacs-p 'frame-parameter 'frame-property)
     (selected-frame)
     'viper-saved-cursor-color-in-insert-mode)
-   (if (eq viper-current-state 'emacs-mode)
+   (if (and (eq viper-current-state 'emacs-mode) viper-emacs-state-cursor-color)
        viper-emacs-state-cursor-color
      viper-vi-state-cursor-color)))
 
index 8f858526da3fa3da9f19f8747b04fc676bdf8f3a..0ba7bdd041a3fd09e734367cb5ab66d6af2330e9 100644 (file)
@@ -534,10 +534,6 @@ If Viper is enabled, turn it off.  Otherwise, turn it on."
 (defun viper-mode ()
   "Turn on Viper emulation of Vi in Emacs. See Info node `(viper)Viper'."
   (interactive)
-  (if (null viper-vi-state-cursor-color)
-      (modify-frame-parameters
-       (selected-frame)
-       (list (cons 'viper-vi-state-cursor-color (viper-get-cursor-color)))))
   (if (not noninteractive)
       (progn
        ;; if the user requested viper-mode explicitly
@@ -618,7 +614,8 @@ This startup message appears whenever you load Viper, unless you type `y' now."
 
        (or (memq major-mode viper-emacs-state-mode-list) ; don't switch to Vi
            (memq major-mode viper-insert-state-mode-list) ; don't switch
-           (viper-change-state-to-vi)))))
+           (viper-change-state-to-vi))
+       )))
 
 
 ;; Apply a little heuristic to invoke vi state on major-modes
@@ -862,8 +859,11 @@ It also can't undo some Viper settings."
   ;; info about the display and windows until emacs initialization is complete
   ;; So do it via the window-setup-hook
   (add-hook 'window-setup-hook
-           '(lambda ()
-              (setq viper-vi-state-cursor-color (viper-get-cursor-color))))
+           '(lambda ()
+              (modify-frame-parameters
+               (selected-frame)
+               (list (cons 'viper-vi-state-cursor-color
+                           (viper-get-cursor-color))))))
 
   ;; Tell vc-diff to put *vc* in Vi mode
   (if (featurep 'vc)
@@ -903,7 +903,6 @@ It also can't undo some Viper settings."
 
   (defadvice set-cursor-color (after viper-set-cursor-color-ad activate)
     "Change cursor color in VI state."
-    ;;(setq viper-vi-state-cursor-color (ad-get-arg 0))
     (modify-frame-parameters
        (selected-frame)
        (list (cons 'viper-vi-state-cursor-color (ad-get-arg 0))))
@@ -1008,8 +1007,8 @@ It also can't undo some Viper settings."
 ;; these are primarily advices and Vi-ish variable settings
 (defun viper-non-hook-settings ()
 
-  ;; Viper changes the default mode-line-buffer-identification
-  (setq-default mode-line-buffer-identification '(" %b"))
+  ;;;; Viper changes the default mode-line-buffer-identification
+  ;;(setq-default mode-line-buffer-identification '(" %b"))
 
   ;; setup emacs-supported vi-style feel
   (setq next-line-add-newlines nil