diff lisp/emulation/viper-util.el @ 72516:aba79a1f03ed

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.
author Michael Kifer <kifer@cs.stonybrook.edu>
date Fri, 25 Aug 2006 16:06:57 +0000
parents 4033086b16b6
children 7a3f13e2dd57 694bbb62a75d 6823a91487f2
line wrap: on
line diff
--- a/lisp/emulation/viper-util.el	Fri Aug 25 10:05:50 2006 +0000
+++ b/lisp/emulation/viper-util.el	Fri Aug 25 16:06:57 2006 +0000
@@ -137,10 +137,10 @@
    (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
    ))
 
@@ -152,18 +152,31 @@
 
 
 ;; 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)
@@ -191,7 +204,7 @@
     (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)))
 
@@ -201,7 +214,7 @@
     (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)))