(concat "`" (viper-array-to-string keys) "'")
(viper-abbreviate-string
(if (featurep 'xemacs)
- (replace-in-string ; xemacs
- (cond ((characterp text) (char-to-string text))
- ((stringp text) text)
- (t ""))
- "\n" "^J")
- text ; emacs
- )
+ (replace-in-string ; xemacs
+ (cond ((characterp text) (char-to-string text))
+ ((stringp text) text)
+ (t ""))
+ "\n" "^J")
+ text ; emacs
+ )
max-text-len
" inserting `" "'" " ......."))
))
(key-binding (setq key (read-key-sequence nil))))
(cond ((eq cmd 'self-insert-command)
(if (featurep 'xemacs)
- (insert (events-to-keys key)) ; xemacs
- (insert key) ; emacs
- ))
+ (insert (events-to-keys key)) ; xemacs
+ (insert key) ; emacs
+ ))
((memq cmd '(exit-minibuffer viper-exit-minibuffer))
nil)
(t (command-execute cmd)))
;; (which is called from viper-search-forward/backward/next). If the value of
;; viper-search-scroll-threshold is negative - don't scroll.
(defun viper-adjust-window ()
- (let ((win-height (if (featurep 'xemacs) (window-displayed-height)
+ (let ((win-height (if (featurep 'xemacs)
+ (window-displayed-height)
(1- (window-height)))) ; adjust for modeline
(pt (point))
at-top-p at-bottom-p
;; in order to spare non-viperized emacs from being viperized
(if noninteractive
(eval-when-compile
- (let ((load-path (cons (expand-file-name ".") load-path)))
- (or (featurep 'viper-cmd)
- (load "viper-cmd.el" nil t 'nosuffix))
- )))
+ (require 'viper-cmd)
+ ))
;; end pacifier
(require 'viper-util)
(let ((lis (vector event))
next-event)
(while (and (viper-fast-keysequence-p)
- (viper-keyseq-is-a-possible-macro lis macro-alist))
- (setq next-event (viper-read-key))
- ;;(setq next-event (viper-read-event))
+ (viper-keyseq-is-a-possible-macro lis macro-alist))
+ ;; Seems that viper-read-event is more robust here. We need to be able to
+ ;; place these events on unread-command-events list. If we use
+ ;; viper-read-key then events will be converted to keys, and sometimes
+ ;; (e.g., (control \[)) those keys differ from the corresponding events.
+ ;; So, do not use (setq next-event (viper-read-key))
+ (setq next-event (viper-read-event))
(or (viper-mouse-event-p next-event)
(setq lis (vconcat lis (vector next-event)))))
lis))
(if (featurep 'emacs) 'frame-parameter 'frame-property)
(selected-frame)
'viper-saved-cursor-color-in-replace-mode)
- (let ((ecolor (viper-frame-value viper-emacs-state-cursor-color)))
- (or (and (eq viper-current-state 'emacs-mode)
- ecolor)
- (viper-frame-value viper-vi-state-cursor-color)))))
+ (or (and (eq viper-current-state 'emacs-mode)
+ (viper-frame-value viper-emacs-state-cursor-color))
+ (viper-frame-value viper-vi-state-cursor-color))))
(defsubst viper-get-saved-cursor-color-in-insert-mode ()
(or
(if (featurep 'emacs) 'frame-parameter 'frame-property)
(selected-frame)
'viper-saved-cursor-color-in-insert-mode)
- (let ((ecolor (viper-frame-value viper-emacs-state-cursor-color)))
- (or (and (eq viper-current-state 'emacs-mode)
- ecolor)
- (viper-frame-value viper-vi-state-cursor-color)))))
+ (or (and (eq viper-current-state 'emacs-mode)
+ (viper-frame-value viper-emacs-state-cursor-color))
+ (viper-frame-value viper-vi-state-cursor-color))))
(defsubst viper-get-saved-cursor-color-in-emacs-mode ()
(or
;; This function lets function-key-map convert key sequences into logical
;; keys. This does a better job than viper-read-event when it comes to kbd
;; macros, since it enables certain macros to be shared between X and TTY modes
-;; by correctly mapping key sequences for Left/Right/... (one an ascii
+;; by correctly mapping key sequences for Left/Right/... (on an ascii
;; terminal) into logical keys left, right, etc.
(defun viper-read-key ()
(let ((overriding-local-map viper-overriding-map)
(defun viper-key-press-events-to-chars (events)
(mapconcat (if (featurep 'xemacs)
- (lambda (elt) (char-to-string (event-to-character elt))) ; xemacs
- 'char-to-string ; emacs
- )
+ (lambda (elt) (char-to-string (event-to-character elt))) ; xemacs
+ 'char-to-string ; emacs
+ )
events
""))
))
(viper-set-expert-level 'dont-change-unless)))
- (if (eq major-mode 'viper-mode)
- (setq major-mode 'fundamental-mode))
-
(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))
- )))
+ ))
+
+ (if (eq major-mode 'viper-mode)
+ (setq major-mode 'fundamental-mode))
+ )
;; Apply a little heuristic to invoke vi state on major-modes
(append '("" viper-mode-string) (cdr global-mode-string))))
(if (featurep 'xemacs)
- ;; XEmacs
- (defadvice describe-key (before viper-describe-key-ad protect activate)
- "Force to read key via `viper-read-key-sequence'."
- (interactive (list (viper-read-key-sequence "Describe key: "))))
- ;; Emacs
- (defadvice describe-key (before viper-describe-key-ad protect activate)
- "Force to read key via `viper-read-key-sequence'."
- (interactive (let (key)
- (setq key (viper-read-key-sequence
- "Describe key (or click or menu item): "))
- (list key
- (prefix-numeric-value current-prefix-arg)
- ;; If KEY is a down-event, read also the
- ;; corresponding up-event.
- (and (vectorp key)
- (let ((last-idx (1- (length key))))
- (and (eventp (aref key last-idx))
- (memq 'down (event-modifiers
- (aref key last-idx)))))
- (or (and (eventp (aref key 0))
- (memq 'down (event-modifiers
- (aref key 0)))
- ;; For the C-down-mouse-2 popup menu,
- ;; there is no subsequent up-event
- (= (length key) 1))
- (and (> (length key) 1)
- (eventp (aref key 1))
- (memq 'down (event-modifiers (aref key 1)))))
- (read-event))))))
- ) ; (if (featurep 'xemacs)
-
+ ;; XEmacs
+ (defadvice describe-key (before viper-describe-key-ad protect activate)
+ "Force to read key via `viper-read-key-sequence'."
+ (interactive (list (viper-read-key-sequence "Describe key: "))))
+ ;; Emacs
+ (defadvice describe-key (before viper-describe-key-ad protect activate)
+ "Force to read key via `viper-read-key-sequence'."
+ (interactive (let (key)
+ (setq key (viper-read-key-sequence
+ "Describe key (or click or menu item): "))
+ (list key
+ (prefix-numeric-value current-prefix-arg)
+ ;; If KEY is a down-event, read also the
+ ;; corresponding up-event.
+ (and (vectorp key)
+ (let ((last-idx (1- (length key))))
+ (and (eventp (aref key last-idx))
+ (memq 'down (event-modifiers
+ (aref key last-idx)))))
+ (or (and (eventp (aref key 0))
+ (memq 'down (event-modifiers
+ (aref key 0)))
+ ;; For the C-down-mouse-2 popup menu,
+ ;; there is no subsequent up-event
+ (= (length key) 1))
+ (and (> (length key) 1)
+ (eventp (aref key 1))
+ (memq 'down (event-modifiers (aref key 1)))))
+ (read-event))))))
+ ) ; (if (featurep 'xemacs)
+
(if (featurep 'xemacs)
- ;; XEmacs
- (defadvice describe-key-briefly
- (before viper-describe-key-briefly-ad protect activate)
- "Force to read key via `viper-read-key-sequence'."
- (interactive (list (viper-read-key-sequence "Describe key briefly: "))))
- ;; Emacs
- (defadvice describe-key-briefly
- (before viper-describe-key-briefly-ad protect activate)
- "Force to read key via `viper-read-key-sequence'."
- (interactive (let (key)
- (setq key (viper-read-key-sequence
- "Describe key (or click or menu item): "))
- ;; If KEY is a down-event, read and discard the
- ;; corresponding up-event.
- (and (vectorp key)
- (let ((last-idx (1- (length key))))
- (and (eventp (aref key last-idx))
- (memq 'down (event-modifiers (aref key last-idx)))))
- (read-event))
- (list key
- (if current-prefix-arg
- (prefix-numeric-value current-prefix-arg))
- 1))))
- ) ; (if (featurep 'xemacs)
-
+ ;; XEmacs
+ (defadvice describe-key-briefly
+ (before viper-describe-key-briefly-ad protect activate)
+ "Force to read key via `viper-read-key-sequence'."
+ (interactive (list (viper-read-key-sequence "Describe key briefly: "))))
+ ;; Emacs
+ (defadvice describe-key-briefly
+ (before viper-describe-key-briefly-ad protect activate)
+ "Force to read key via `viper-read-key-sequence'."
+ (interactive (let (key)
+ (setq key (viper-read-key-sequence
+ "Describe key (or click or menu item): "))
+ ;; If KEY is a down-event, read and discard the
+ ;; corresponding up-event.
+ (and (vectorp key)
+ (let ((last-idx (1- (length key))))
+ (and (eventp (aref key last-idx))
+ (memq 'down (event-modifiers (aref key last-idx)))))
+ (read-event))
+ (list key
+ (if current-prefix-arg
+ (prefix-numeric-value current-prefix-arg))
+ 1))))
+ ) ; (if (featurep 'xemacs)
+
(defadvice find-file (before viper-add-suffix-advice activate)
"Use `read-file-name' for reading arguments."
(interactive (cons (read-file-name "Find file: " nil default-directory)