+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):
(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
;; 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)
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))
))
;; 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)
))
(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)
(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)
;; 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."
(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))
(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
;; 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))) ))
))
(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)
(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)))
(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
(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
;; 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)
(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))))
;; 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