mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-15 10:30:25 -08:00
new version
This commit is contained in:
parent
2f3eb3b625
commit
8626cfa223
8 changed files with 2275 additions and 2152 deletions
|
|
@ -1557,8 +1557,12 @@ invokes the command before that, etc."
|
|||
|
||||
(message " `.' runs %s%s"
|
||||
(concat "`" (viper-array-to-string keys) "'")
|
||||
(viper-abbreviate-string text max-text-len
|
||||
" inserting `" "'" " ......."))
|
||||
(viper-abbreviate-string
|
||||
(if viper-xemacs-p
|
||||
(replace-in-string text "\n" "^J")
|
||||
text)
|
||||
max-text-len
|
||||
" inserting `" "'" " ......."))
|
||||
))
|
||||
|
||||
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -27,7 +27,6 @@
|
|||
(defvar mark-even-if-inactive)
|
||||
(defvar viper-version)
|
||||
(defvar viper-expert-level)
|
||||
(defvar vip-expert-level)
|
||||
;; end pacifier
|
||||
|
||||
|
||||
|
|
@ -35,33 +34,32 @@
|
|||
(defun viper-version ()
|
||||
(interactive)
|
||||
(message "Viper version is %s" viper-version))
|
||||
(defalias 'vip-version 'viper-version)
|
||||
|
||||
;; Is it XEmacs?
|
||||
(defconst vip-xemacs-p (string-match "\\(Lucid\\|XEmacs\\)" emacs-version))
|
||||
(defconst viper-xemacs-p (string-match "XEmacs" emacs-version))
|
||||
;; Is it Emacs?
|
||||
(defconst vip-emacs-p (not vip-xemacs-p))
|
||||
(defconst viper-emacs-p (not viper-xemacs-p))
|
||||
;; Tell whether we are running as a window application or on a TTY
|
||||
(defsubst vip-device-type ()
|
||||
(if vip-emacs-p
|
||||
(defsubst viper-device-type ()
|
||||
(if viper-emacs-p
|
||||
window-system
|
||||
(device-type (selected-device))))
|
||||
;; in XEmacs: device-type is tty on tty and stream in batch.
|
||||
(defun vip-window-display-p ()
|
||||
(and (vip-device-type) (not (memq (vip-device-type) '(tty stream pc)))))
|
||||
(defun viper-window-display-p ()
|
||||
(and (viper-device-type) (not (memq (viper-device-type) '(tty stream pc)))))
|
||||
|
||||
(defcustom vip-ms-style-os-p (memq system-type '(ms-dos windows-nt windows-95))
|
||||
(defcustom viper-ms-style-os-p (memq system-type '(ms-dos windows-nt windows-95))
|
||||
"Tells if Emacs is running under an MS-style OS: ms-dos, windows-nt, W95."
|
||||
:type 'boolean
|
||||
:tag "Is it Microsoft-made OS?"
|
||||
:group 'viper)
|
||||
(defcustom vip-vms-os-p (memq system-type '(vax-vms axp-vms))
|
||||
(defcustom viper-vms-os-p (memq system-type '(vax-vms axp-vms))
|
||||
"Tells if Emacs is running under VMS."
|
||||
:type 'boolean
|
||||
:tag "Is it VMS?"
|
||||
:group 'viper)
|
||||
|
||||
(defcustom vip-force-faces nil
|
||||
(defcustom viper-force-faces nil
|
||||
"If t, Viper will think that it is running on a display that supports faces.
|
||||
This is provided as a temporary relief for users of graphics-capable terminals
|
||||
that Viper doesn't know about.
|
||||
|
|
@ -69,189 +67,183 @@ In all likelihood, you don't need to bother with this setting."
|
|||
:type 'boolean
|
||||
:group 'viper)
|
||||
|
||||
(defun vip-has-face-support-p ()
|
||||
(cond ((vip-window-display-p))
|
||||
(vip-force-faces)
|
||||
(vip-emacs-p (memq (vip-device-type) '(pc)))
|
||||
(vip-xemacs-p (memq (vip-device-type) '(tty pc)))))
|
||||
|
||||
(defun vip-convert-standard-file-name (fname)
|
||||
(if vip-emacs-p
|
||||
(convert-standard-filename fname)
|
||||
;; hopefully, XEmacs adds this functionality
|
||||
fname))
|
||||
(defun viper-has-face-support-p ()
|
||||
(cond ((viper-window-display-p))
|
||||
(viper-force-faces)
|
||||
(viper-emacs-p (memq (viper-device-type) '(pc)))
|
||||
(viper-xemacs-p (memq (viper-device-type) '(tty pc)))))
|
||||
|
||||
|
||||
;;; Macros
|
||||
|
||||
(defmacro vip-deflocalvar (var default-value &optional documentation)
|
||||
(defmacro viper-deflocalvar (var default-value &optional documentation)
|
||||
(` (progn
|
||||
(defvar (, var) (, default-value)
|
||||
(, (format "%s\n\(buffer local\)" documentation)))
|
||||
(make-variable-buffer-local '(, var))
|
||||
)))
|
||||
|
||||
(defmacro vip-loop (count body)
|
||||
"(vip-loop COUNT BODY) Execute BODY COUNT times."
|
||||
(defmacro viper-loop (count body)
|
||||
"(viper-loop COUNT BODY) Execute BODY COUNT times."
|
||||
(list 'let (list (list 'count count))
|
||||
(list 'while '(> count 0)
|
||||
body
|
||||
'(setq count (1- count))
|
||||
)))
|
||||
|
||||
(defmacro vip-buffer-live-p (buf)
|
||||
(defmacro viper-buffer-live-p (buf)
|
||||
(` (and (, buf) (get-buffer (, buf)) (buffer-name (get-buffer (, buf))))))
|
||||
|
||||
;; return buffer-specific macro definition, given a full macro definition
|
||||
(defmacro vip-kbd-buf-alist (macro-elt)
|
||||
(defmacro viper-kbd-buf-alist (macro-elt)
|
||||
(` (nth 1 (, macro-elt))))
|
||||
;; get a pair: (curr-buffer . macro-definition)
|
||||
(defmacro vip-kbd-buf-pair (macro-elt)
|
||||
(` (assoc (buffer-name) (vip-kbd-buf-alist (, macro-elt)))))
|
||||
(defmacro viper-kbd-buf-pair (macro-elt)
|
||||
(` (assoc (buffer-name) (viper-kbd-buf-alist (, macro-elt)))))
|
||||
;; get macro definition for current buffer
|
||||
(defmacro vip-kbd-buf-definition (macro-elt)
|
||||
(` (cdr (vip-kbd-buf-pair (, macro-elt)))))
|
||||
(defmacro viper-kbd-buf-definition (macro-elt)
|
||||
(` (cdr (viper-kbd-buf-pair (, macro-elt)))))
|
||||
|
||||
;; return mode-specific macro definitions, given a full macro definition
|
||||
(defmacro vip-kbd-mode-alist (macro-elt)
|
||||
(defmacro viper-kbd-mode-alist (macro-elt)
|
||||
(` (nth 2 (, macro-elt))))
|
||||
;; get a pair: (major-mode . macro-definition)
|
||||
(defmacro vip-kbd-mode-pair (macro-elt)
|
||||
(` (assoc major-mode (vip-kbd-mode-alist (, macro-elt)))))
|
||||
(defmacro viper-kbd-mode-pair (macro-elt)
|
||||
(` (assoc major-mode (viper-kbd-mode-alist (, macro-elt)))))
|
||||
;; get macro definition for the current major mode
|
||||
(defmacro vip-kbd-mode-definition (macro-elt)
|
||||
(` (cdr (vip-kbd-mode-pair (, macro-elt)))))
|
||||
(defmacro viper-kbd-mode-definition (macro-elt)
|
||||
(` (cdr (viper-kbd-mode-pair (, macro-elt)))))
|
||||
|
||||
;; return global macro definition, given a full macro definition
|
||||
(defmacro vip-kbd-global-pair (macro-elt)
|
||||
(defmacro viper-kbd-global-pair (macro-elt)
|
||||
(` (nth 3 (, macro-elt))))
|
||||
;; get global macro definition from an elt of macro-alist
|
||||
(defmacro vip-kbd-global-definition (macro-elt)
|
||||
(` (cdr (vip-kbd-global-pair (, macro-elt)))))
|
||||
(defmacro viper-kbd-global-definition (macro-elt)
|
||||
(` (cdr (viper-kbd-global-pair (, macro-elt)))))
|
||||
|
||||
;; last elt of a sequence
|
||||
(defsubst vip-seq-last-elt (seq)
|
||||
(defsubst viper-seq-last-elt (seq)
|
||||
(elt seq (1- (length seq))))
|
||||
|
||||
|
||||
(defvar vip-minibuffer-overlay-priority 300)
|
||||
(defvar vip-replace-overlay-priority 400)
|
||||
(defvar vip-search-overlay-priority 500)
|
||||
(defvar viper-minibuffer-overlay-priority 300)
|
||||
(defvar viper-replace-overlay-priority 400)
|
||||
(defvar viper-search-overlay-priority 500)
|
||||
|
||||
|
||||
;;; Viper minor modes
|
||||
|
||||
;; Mode for vital things like \e, C-z.
|
||||
(vip-deflocalvar vip-vi-intercept-minor-mode nil)
|
||||
(viper-deflocalvar viper-vi-intercept-minor-mode nil)
|
||||
|
||||
(vip-deflocalvar vip-vi-basic-minor-mode nil
|
||||
(viper-deflocalvar viper-vi-basic-minor-mode nil
|
||||
"Viper's minor mode for Vi bindings.")
|
||||
|
||||
(vip-deflocalvar vip-vi-local-user-minor-mode nil
|
||||
(viper-deflocalvar viper-vi-local-user-minor-mode nil
|
||||
"Auxiliary minor mode for user-defined local bindings in Vi state.")
|
||||
|
||||
(vip-deflocalvar vip-vi-global-user-minor-mode nil
|
||||
(viper-deflocalvar viper-vi-global-user-minor-mode nil
|
||||
"Auxiliary minor mode for user-defined global bindings in Vi state.")
|
||||
|
||||
(vip-deflocalvar vip-vi-state-modifier-minor-mode nil
|
||||
(viper-deflocalvar viper-vi-state-modifier-minor-mode nil
|
||||
"Minor mode used to make major-mode-specific modification to Vi state.")
|
||||
|
||||
(vip-deflocalvar vip-vi-diehard-minor-mode nil
|
||||
(viper-deflocalvar viper-vi-diehard-minor-mode nil
|
||||
"This minor mode is in effect when the user wants Viper to be Vi.")
|
||||
|
||||
(vip-deflocalvar vip-vi-kbd-minor-mode nil
|
||||
(viper-deflocalvar viper-vi-kbd-minor-mode nil
|
||||
"Minor mode for Ex command macros in Vi state.
|
||||
The corresponding keymap stores key bindings of Vi macros defined with
|
||||
the Ex command :map.")
|
||||
|
||||
;; Mode for vital things like \e, C-z.
|
||||
(vip-deflocalvar vip-insert-intercept-minor-mode nil)
|
||||
(viper-deflocalvar viper-insert-intercept-minor-mode nil)
|
||||
|
||||
(vip-deflocalvar vip-insert-basic-minor-mode nil
|
||||
(viper-deflocalvar viper-insert-basic-minor-mode nil
|
||||
"Viper's minor mode for bindings in Insert mode.")
|
||||
|
||||
(vip-deflocalvar vip-insert-local-user-minor-mode nil
|
||||
(viper-deflocalvar viper-insert-local-user-minor-mode nil
|
||||
"Auxiliary minor mode for buffer-local user-defined bindings in Insert state.
|
||||
This is a way to overshadow normal Insert mode bindings locally to certain
|
||||
designated buffers.")
|
||||
|
||||
(vip-deflocalvar vip-insert-global-user-minor-mode nil
|
||||
(viper-deflocalvar viper-insert-global-user-minor-mode nil
|
||||
"Auxiliary minor mode for global user-defined bindings in Insert state.")
|
||||
|
||||
(vip-deflocalvar vip-insert-state-modifier-minor-mode nil
|
||||
(viper-deflocalvar viper-insert-state-modifier-minor-mode nil
|
||||
"Minor mode used to make major-mode-specific modification to Insert state.")
|
||||
|
||||
(vip-deflocalvar vip-insert-diehard-minor-mode nil
|
||||
(viper-deflocalvar viper-insert-diehard-minor-mode nil
|
||||
"Minor mode that simulates Vi very closely.
|
||||
Not recommened, except for the novice user.")
|
||||
|
||||
(vip-deflocalvar vip-insert-kbd-minor-mode nil
|
||||
(viper-deflocalvar viper-insert-kbd-minor-mode nil
|
||||
"Minor mode for Ex command macros Insert state.
|
||||
The corresponding keymap stores key bindings of Vi macros defined with
|
||||
the Ex command :map!.")
|
||||
|
||||
(vip-deflocalvar vip-replace-minor-mode nil
|
||||
(viper-deflocalvar viper-replace-minor-mode nil
|
||||
"Minor mode in effect in replace state (cw, C, and the like commands).")
|
||||
|
||||
;; Mode for vital things like \C-z and \C-x)
|
||||
;; This is t, by default. So, any new buffer will have C-z defined as
|
||||
;; switch to Vi, unless we switched states in this buffer
|
||||
(vip-deflocalvar vip-emacs-intercept-minor-mode t)
|
||||
(viper-deflocalvar viper-emacs-intercept-minor-mode t)
|
||||
|
||||
(vip-deflocalvar vip-emacs-local-user-minor-mode t
|
||||
(viper-deflocalvar viper-emacs-local-user-minor-mode t
|
||||
"Minor mode for local user bindings effective in Emacs state.
|
||||
Users can use it to override Emacs bindings when Viper is in its Emacs
|
||||
state.")
|
||||
|
||||
(vip-deflocalvar vip-emacs-global-user-minor-mode t
|
||||
(viper-deflocalvar viper-emacs-global-user-minor-mode t
|
||||
"Minor mode for global user bindings in effect in Emacs state.
|
||||
Users can use it to override Emacs bindings when Viper is in its Emacs
|
||||
state.")
|
||||
|
||||
(vip-deflocalvar vip-emacs-kbd-minor-mode t
|
||||
(viper-deflocalvar viper-emacs-kbd-minor-mode t
|
||||
"Minor mode for Vi style macros in Emacs state.
|
||||
The corresponding keymap stores key bindings of Vi macros defined with
|
||||
`vip-record-kbd-macro' command. There is no Ex-level command to do this
|
||||
`viper-record-kbd-macro' command. There is no Ex-level command to do this
|
||||
interactively.")
|
||||
|
||||
(vip-deflocalvar vip-emacs-state-modifier-minor-mode t
|
||||
(viper-deflocalvar viper-emacs-state-modifier-minor-mode t
|
||||
"Minor mode used to make major-mode-specific modification to Emacs state.
|
||||
For instance, a Vi purist may want to bind `dd' in Dired mode to a function
|
||||
that deletes a file.")
|
||||
|
||||
(vip-deflocalvar vip-vi-minibuffer-minor-mode nil
|
||||
(viper-deflocalvar viper-vi-minibuffer-minor-mode nil
|
||||
"Minor mode that forces Vi-style when the Minibuffer is in Vi state.")
|
||||
|
||||
(vip-deflocalvar vip-insert-minibuffer-minor-mode nil
|
||||
(viper-deflocalvar viper-insert-minibuffer-minor-mode nil
|
||||
"Minor mode that forces Vi-style when the Minibuffer is in Insert state.")
|
||||
|
||||
|
||||
|
||||
;; Some common error messages
|
||||
|
||||
(defconst vip-SpuriousText "Spurious text after command" "")
|
||||
(defconst vip-BadExCommand "Not an editor command" "")
|
||||
(defconst vip-InvalidCommandArgument "Invalid command argument" "")
|
||||
(defconst vip-NoPrevSearch "No previous search string" "")
|
||||
(defconst vip-EmptyRegister "`%c': Nothing in this register" "")
|
||||
(defconst vip-InvalidRegister "`%c': Invalid register" "")
|
||||
(defconst vip-EmptyTextmarker "`%c': Text marker doesn't point anywhere" "")
|
||||
(defconst vip-InvalidTextmarker "`%c': Invalid text marker" "")
|
||||
(defconst vip-InvalidViCommand "Invalid command" "")
|
||||
(defconst vip-BadAddress "Ill-formed address" "")
|
||||
(defconst vip-FirstAddrExceedsSecond "First address exceeds second" "")
|
||||
(defconst vip-NoFileSpecified "No file specified" "")
|
||||
(defconst viper-SpuriousText "Spurious text after command" "")
|
||||
(defconst viper-BadExCommand "Not an editor command" "")
|
||||
(defconst viper-InvalidCommandArgument "Invalid command argument" "")
|
||||
(defconst viper-NoPrevSearch "No previous search string" "")
|
||||
(defconst viper-EmptyRegister "`%c': Nothing in this register" "")
|
||||
(defconst viper-InvalidRegister "`%c': Invalid register" "")
|
||||
(defconst viper-EmptyTextmarker "`%c': Text marker doesn't point anywhere" "")
|
||||
(defconst viper-InvalidTextmarker "`%c': Invalid text marker" "")
|
||||
(defconst viper-InvalidViCommand "Invalid command" "")
|
||||
(defconst viper-BadAddress "Ill-formed address" "")
|
||||
(defconst viper-FirstAddrExceedsSecond "First address exceeds second" "")
|
||||
(defconst viper-NoFileSpecified "No file specified" "")
|
||||
|
||||
;; Is t until viper-mode executes for the very first time.
|
||||
;; Prevents recursive descend into startup messages.
|
||||
(defvar vip-first-time t)
|
||||
(defvar viper-first-time t)
|
||||
|
||||
(defvar viper-expert-level (if (boundp 'vip-expert-level) vip-expert-level 0)
|
||||
(defvar viper-expert-level (if (boundp 'viper-expert-level) viper-expert-level 0)
|
||||
"User's expert level.
|
||||
The minor mode vip-vi-diehard-minor-mode is in effect when
|
||||
viper-expert-level is 1 or 2 or when vip-want-emacs-keys-in-vi is t.
|
||||
The minor mode vip-insert-diehard-minor-mode is in effect when
|
||||
viper-expert-level is 1 or 2 or if vip-want-emacs-keys-in-insert is t.
|
||||
The minor mode viper-vi-diehard-minor-mode is in effect when
|
||||
viper-expert-level is 1 or 2 or when viper-want-emacs-keys-in-vi is t.
|
||||
The minor mode viper-insert-diehard-minor-mode is in effect when
|
||||
viper-expert-level is 1 or 2 or if viper-want-emacs-keys-in-insert is t.
|
||||
Use `M-x viper-set-expert-level' to change this.")
|
||||
|
||||
;; Max expert level supported by Viper. This is NOT a user option.
|
||||
|
|
@ -261,8 +253,8 @@ Use `M-x viper-set-expert-level' to change this.")
|
|||
|
||||
;;; ISO characters
|
||||
|
||||
(vip-deflocalvar vip-automatic-iso-accents nil "")
|
||||
(defcustom vip-automatic-iso-accents nil
|
||||
(viper-deflocalvar viper-automatic-iso-accents nil "")
|
||||
(defcustom viper-automatic-iso-accents nil
|
||||
"*If non-nil, ISO accents will be turned on in insert/replace emacs states and turned off in vi-state.
|
||||
For some users, this behavior may be too primitive. In this case, use
|
||||
insert/emacs/vi state hooks."
|
||||
|
|
@ -273,15 +265,15 @@ insert/emacs/vi state hooks."
|
|||
;; VI-style Undo
|
||||
|
||||
;; Used to 'undo' complex commands, such as replace and insert commands.
|
||||
(vip-deflocalvar vip-undo-needs-adjustment nil)
|
||||
(put 'vip-undo-needs-adjustment 'permanent-local t)
|
||||
(viper-deflocalvar viper-undo-needs-adjustment nil)
|
||||
(put 'viper-undo-needs-adjustment 'permanent-local t)
|
||||
|
||||
;; A mark that Viper puts on buffer-undo-list. Marks the beginning of a
|
||||
;; complex command that must be undone atomically. If inserted, it is
|
||||
;; erased by vip-change-state-to-vi and vip-repeat.
|
||||
(defconst vip-buffer-undo-list-mark 'viper)
|
||||
;; erased by viper-change-state-to-vi and viper-repeat.
|
||||
(defconst viper-buffer-undo-list-mark 'viper)
|
||||
|
||||
(defcustom vip-keep-point-on-undo nil
|
||||
(defcustom viper-keep-point-on-undo nil
|
||||
"*Non-nil means not to move point while undoing commands.
|
||||
This style is different from Emacs and Vi. Try it to see if
|
||||
it better fits your working style."
|
||||
|
|
@ -291,20 +283,26 @@ it better fits your working style."
|
|||
|
||||
;; Replace mode and changing text
|
||||
|
||||
;; Viper's own after/before change functions, which get vip-add-hook'ed to
|
||||
;; Viper's own after/before change functions, which get viper-add-hook'ed to
|
||||
;; Emacs's
|
||||
(vip-deflocalvar vip-after-change-functions nil "")
|
||||
(vip-deflocalvar vip-before-change-functions nil "")
|
||||
(vip-deflocalvar vip-post-command-hooks nil "")
|
||||
(vip-deflocalvar vip-pre-command-hooks nil "")
|
||||
(viper-deflocalvar viper-after-change-functions nil "")
|
||||
(viper-deflocalvar viper-before-change-functions nil "")
|
||||
(viper-deflocalvar viper-post-command-hooks nil "")
|
||||
(viper-deflocalvar viper-pre-command-hooks nil "")
|
||||
|
||||
;; Can be used to pass global states around for short period of time
|
||||
(vip-deflocalvar vip-intermediate-command nil "")
|
||||
(viper-deflocalvar viper-intermediate-command nil "")
|
||||
|
||||
;; This is used to pass the right Vi command key sequence to
|
||||
;; viper-set-destructive-command whenever (this-command-keys) doesn't give the
|
||||
;; right result. For instance, in commands like c/bla<RET>, (this-command-keys)
|
||||
;; will return ^M, which invoked exit-minibuffer, while we need "c/"
|
||||
(defconst viper-this-command-keys nil)
|
||||
|
||||
;; Indicates that the current destructive command has started in replace mode.
|
||||
(vip-deflocalvar vip-began-as-replace nil "")
|
||||
(viper-deflocalvar viper-began-as-replace nil "")
|
||||
|
||||
(defcustom vip-allow-multiline-replace-regions t
|
||||
(defcustom viper-allow-multiline-replace-regions t
|
||||
"If non-nil, Viper will allow multi-line replace regions.
|
||||
This is an extension to standard Vi.
|
||||
If nil, commands that attempt to replace text spanning multiple lines first
|
||||
|
|
@ -312,114 +310,114 @@ delete the text being replaced, as in standard Vi."
|
|||
:type 'boolean
|
||||
:group 'viper)
|
||||
|
||||
(defcustom vip-replace-overlay-cursor-color "Red"
|
||||
(defcustom viper-replace-overlay-cursor-color "Red"
|
||||
"*Cursor color when Viper is in Replace state."
|
||||
:type 'string
|
||||
:group 'viper)
|
||||
(defcustom vip-insert-state-cursor-color "Green"
|
||||
(defcustom viper-insert-state-cursor-color "Green"
|
||||
"Cursor color when Viper is in insert state."
|
||||
:type 'string
|
||||
:group 'viper)
|
||||
|
||||
;; place to save cursor colow when switching to insert mode
|
||||
(vip-deflocalvar vip-saved-cursor-color nil "")
|
||||
(viper-deflocalvar viper-saved-cursor-color nil "")
|
||||
|
||||
(vip-deflocalvar vip-replace-overlay nil "")
|
||||
(put 'vip-replace-overlay 'permanent-local t)
|
||||
(viper-deflocalvar viper-replace-overlay nil "")
|
||||
(put 'viper-replace-overlay 'permanent-local t)
|
||||
|
||||
(defcustom vip-replace-overlay-pixmap "gray3"
|
||||
(defcustom viper-replace-overlay-pixmap "gray3"
|
||||
"Pixmap to use for search face on non-color displays."
|
||||
:type 'string
|
||||
:group 'viper)
|
||||
(defcustom vip-search-face-pixmap "gray3"
|
||||
(defcustom viper-search-face-pixmap "gray3"
|
||||
"Pixmap to use for search face on non-color displays."
|
||||
:type 'string
|
||||
:group 'viper)
|
||||
|
||||
|
||||
(defcustom vip-replace-region-end-delimiter "$"
|
||||
(defcustom viper-replace-region-end-delimiter "$"
|
||||
"A string marking the end of replacement regions.
|
||||
It is used only with TTYs or if `vip-use-replace-region-delimiters'
|
||||
It is used only with TTYs or if `viper-use-replace-region-delimiters'
|
||||
is non-nil."
|
||||
:type 'string
|
||||
:group 'viper)
|
||||
(defcustom vip-replace-region-start-delimiter ""
|
||||
(defcustom viper-replace-region-start-delimiter ""
|
||||
"A string marking the beginning of replacement regions.
|
||||
It is used only with TTYs or if `vip-use-replace-region-delimiters'
|
||||
It is used only with TTYs or if `viper-use-replace-region-delimiters'
|
||||
is non-nil."
|
||||
:type 'string
|
||||
:group 'viper)
|
||||
(defcustom vip-use-replace-region-delimiters (not (vip-has-face-support-p))
|
||||
"*If non-nil, Viper will always use `vip-replace-region-end-delimiter' and
|
||||
`vip-replace-region-start-delimiter' to delimit replacement regions, even on
|
||||
(defcustom viper-use-replace-region-delimiters (not (viper-has-face-support-p))
|
||||
"*If non-nil, Viper will always use `viper-replace-region-end-delimiter' and
|
||||
`viper-replace-region-start-delimiter' to delimit replacement regions, even on
|
||||
color displays. By default, the delimiters are used only on TTYs."
|
||||
:type 'boolean
|
||||
:group 'viper)
|
||||
|
||||
;; XEmacs requires glyphs
|
||||
(if vip-xemacs-p
|
||||
(if viper-xemacs-p
|
||||
(progn
|
||||
(or (glyphp vip-replace-region-end-delimiter)
|
||||
(setq vip-replace-region-end-delimiter
|
||||
(make-glyph vip-replace-region-end-delimiter)))
|
||||
(or (glyphp vip-replace-region-start-delimiter)
|
||||
(setq vip-replace-region-start-delimiter
|
||||
(make-glyph vip-replace-region-start-delimiter)))
|
||||
(or (glyphp viper-replace-region-end-delimiter)
|
||||
(setq viper-replace-region-end-delimiter
|
||||
(make-glyph viper-replace-region-end-delimiter)))
|
||||
(or (glyphp viper-replace-region-start-delimiter)
|
||||
(setq viper-replace-region-start-delimiter
|
||||
(make-glyph viper-replace-region-start-delimiter)))
|
||||
))
|
||||
|
||||
|
||||
;; These are local marker that must be initialized to nil and moved with
|
||||
;; `vip-move-marker-locally'
|
||||
;; `viper-move-marker-locally'
|
||||
;;
|
||||
;; Remember the last position inside the replace region.
|
||||
(vip-deflocalvar vip-last-posn-in-replace-region nil)
|
||||
(viper-deflocalvar viper-last-posn-in-replace-region nil)
|
||||
;; Remember the last position while inserting
|
||||
(vip-deflocalvar vip-last-posn-while-in-insert-state nil)
|
||||
(put 'vip-last-posn-in-replace-region 'permanent-local t)
|
||||
(put 'vip-last-posn-while-in-insert-state 'permanent-local t)
|
||||
(viper-deflocalvar viper-last-posn-while-in-insert-state nil)
|
||||
(put 'viper-last-posn-in-replace-region 'permanent-local t)
|
||||
(put 'viper-last-posn-while-in-insert-state 'permanent-local t)
|
||||
|
||||
(vip-deflocalvar vip-sitting-in-replace nil "")
|
||||
(put 'vip-sitting-in-replace 'permanent-local t)
|
||||
(viper-deflocalvar viper-sitting-in-replace nil "")
|
||||
(put 'viper-sitting-in-replace 'permanent-local t)
|
||||
|
||||
;; Remember the number of characters that have to be deleted in replace
|
||||
;; mode to compensate for the inserted characters.
|
||||
(vip-deflocalvar vip-replace-chars-to-delete 0 "")
|
||||
(vip-deflocalvar vip-replace-chars-deleted 0 "")
|
||||
(viper-deflocalvar viper-replace-chars-to-delete 0 "")
|
||||
(viper-deflocalvar viper-replace-chars-deleted 0 "")
|
||||
|
||||
;; Insertion ring and command ring
|
||||
(defcustom vip-insertion-ring-size 14
|
||||
(defcustom viper-insertion-ring-size 14
|
||||
"The size of history of inserted text.
|
||||
This is a list where Viper keeps the history of previously inserted pieces of
|
||||
text."
|
||||
:type 'integer
|
||||
:group 'viper)
|
||||
;; The insertion ring.
|
||||
(defvar vip-insertion-ring nil)
|
||||
(defvar viper-insertion-ring nil)
|
||||
;; This is temp insertion ring. Used to do rotation for display purposes.
|
||||
;; When rotation just started, it is initialized to vip-insertion-ring.
|
||||
(defvar vip-temp-insertion-ring nil)
|
||||
(defvar vip-last-inserted-string-from-insertion-ring "")
|
||||
;; When rotation just started, it is initialized to viper-insertion-ring.
|
||||
(defvar viper-temp-insertion-ring nil)
|
||||
(defvar viper-last-inserted-string-from-insertion-ring "")
|
||||
|
||||
(defcustom vip-command-ring-size 14
|
||||
(defcustom viper-command-ring-size 14
|
||||
"The size of history of Vi commands repeatable with dot."
|
||||
:type 'integer
|
||||
:group 'viper)
|
||||
;; The command ring.
|
||||
(defvar vip-command-ring nil)
|
||||
(defvar viper-command-ring nil)
|
||||
;; This is temp command ring. Used to do rotation for display purposes.
|
||||
;; When rotation just started, it is initialized to vip-command-ring.
|
||||
(defvar vip-temp-command-ring nil)
|
||||
;; When rotation just started, it is initialized to viper-command-ring.
|
||||
(defvar viper-temp-command-ring nil)
|
||||
|
||||
;; Fast keyseq and ESC keyseq timeouts
|
||||
(defcustom vip-fast-keyseq-timeout 200
|
||||
(defcustom viper-fast-keyseq-timeout 200
|
||||
"*Key sequence separated by no more than this many milliseconds is viewed as a Vi-style macro, if such a macro is defined.
|
||||
Setting this too high may slow down your typing. Setting this value too low
|
||||
will make it hard to use Vi-stile timeout macros."
|
||||
:type 'integer
|
||||
:group 'viper)
|
||||
|
||||
(defcustom vip-ESC-keyseq-timeout (if (vip-window-display-p)
|
||||
0 vip-fast-keyseq-timeout)
|
||||
(defcustom viper-ESC-keyseq-timeout (if (viper-window-display-p)
|
||||
0 viper-fast-keyseq-timeout)
|
||||
"*Key sequence beginning with ESC and separated by no more than this many milliseconds is considered to be generated by a keyboard function key.
|
||||
Setting this too high may slow down switching from insert to vi state. Setting
|
||||
this value too low will make it impossible to use function keys in insert mode
|
||||
|
|
@ -430,29 +428,29 @@ on a dumb terminal."
|
|||
;; Modes and related variables
|
||||
|
||||
;; Current mode. One of: `emacs-state', `vi-state', `insert-state'
|
||||
(vip-deflocalvar vip-current-state 'emacs-state)
|
||||
(viper-deflocalvar viper-current-state 'emacs-state)
|
||||
|
||||
|
||||
;; Autoindent in insert
|
||||
|
||||
;; Variable that keeps track of whether C-t has been pressed.
|
||||
(vip-deflocalvar vip-cted nil "")
|
||||
(viper-deflocalvar viper-cted nil "")
|
||||
|
||||
;; Preserve the indent value, used by C-d in insert mode.
|
||||
(vip-deflocalvar vip-current-indent 0)
|
||||
(viper-deflocalvar viper-current-indent 0)
|
||||
|
||||
;; Whether to preserve the indent, used by C-d in insert mode.
|
||||
(vip-deflocalvar vip-preserve-indent nil)
|
||||
(viper-deflocalvar viper-preserve-indent nil)
|
||||
|
||||
(vip-deflocalvar vip-auto-indent nil "")
|
||||
(defcustom vip-auto-indent nil
|
||||
(viper-deflocalvar viper-auto-indent nil "")
|
||||
(defcustom viper-auto-indent nil
|
||||
"*Enable autoindent, if t.
|
||||
This is a buffer-local variable."
|
||||
:type 'boolean
|
||||
:group 'viper)
|
||||
|
||||
(vip-deflocalvar vip-electric-mode t "")
|
||||
(defcustom vip-electric-mode t
|
||||
(viper-deflocalvar viper-electric-mode t "")
|
||||
(defcustom viper-electric-mode t
|
||||
"*If t, electrify Viper.
|
||||
Currently, this only electrifies auto-indentation, making it appropriate to the
|
||||
mode of the buffer.
|
||||
|
|
@ -462,14 +460,14 @@ programs and LaTeX documents."
|
|||
:type 'boolean
|
||||
:group 'viper)
|
||||
|
||||
(defcustom vip-shift-width 8
|
||||
(defcustom viper-shift-width 8
|
||||
"*The shiftwidth variable."
|
||||
:type 'integer
|
||||
:group 'viper)
|
||||
|
||||
;; Variables for repeating destructive commands
|
||||
|
||||
(defcustom vip-keep-point-on-repeat t
|
||||
(defcustom viper-keep-point-on-repeat t
|
||||
"*If t, don't move point when repeating previous command.
|
||||
This is useful for doing repeated changes with the '.' key.
|
||||
The user can change this to nil, if she likes when the cursor moves
|
||||
|
|
@ -478,40 +476,40 @@ to a new place after repeating previous Vi command."
|
|||
:group 'viper)
|
||||
|
||||
;; Remember insert point as a marker. This is a local marker that must be
|
||||
;; initialized to nil and moved with `vip-move-marker-locally'.
|
||||
(vip-deflocalvar vip-insert-point nil)
|
||||
(put 'vip-insert-point 'permanent-local t)
|
||||
;; initialized to nil and moved with `viper-move-marker-locally'.
|
||||
(viper-deflocalvar viper-insert-point nil)
|
||||
(put 'viper-insert-point 'permanent-local t)
|
||||
|
||||
;; This remembers the point before dabbrev-expand was called.
|
||||
;; If vip-insert-point turns out to be bigger than that, it is reset
|
||||
;; back to vip-pre-command-point.
|
||||
;; If viper-insert-point turns out to be bigger than that, it is reset
|
||||
;; back to viper-pre-command-point.
|
||||
;; The reason this is needed is because dabbrev-expand (and possibly
|
||||
;; others) may jump to before the insertion point, delete something and
|
||||
;; then reinsert a bigger piece. For instance: bla^blo
|
||||
;; If dabbrev-expand is called after `blo' and ^ undicates vip-insert-point,
|
||||
;; If dabbrev-expand is called after `blo' and ^ undicates viper-insert-point,
|
||||
;; then point jumps to the beginning of `blo'. If expansion is found, `blablo'
|
||||
;; is deleted, and we have |^, where | denotes point. Next, dabbrev-expand
|
||||
;; will insert the expansion, and we get: blablo^
|
||||
;; Whatever we insert next goes before the ^, i.e., before the
|
||||
;; vip-insert-point marker. So, Viper will think that nothing was
|
||||
;; viper-insert-point marker. So, Viper will think that nothing was
|
||||
;; inserted. Remembering the orig position of the marker circumvents the
|
||||
;; problem.
|
||||
;; We don't know of any command, except dabbrev-expand, that has the same
|
||||
;; problem. However, the same trick can be used if such a command is
|
||||
;; discovered later.
|
||||
;;
|
||||
(vip-deflocalvar vip-pre-command-point nil)
|
||||
(put 'vip-pre-command-point 'permanent-local t) ; this is probably an overkill
|
||||
(viper-deflocalvar viper-pre-command-point nil)
|
||||
(put 'viper-pre-command-point 'permanent-local t) ; this is probably an overkill
|
||||
|
||||
;; This is used for saving inserted text.
|
||||
(defvar vip-last-insertion nil)
|
||||
(defvar viper-last-insertion nil)
|
||||
|
||||
;; Remembers the last replaced region.
|
||||
(defvar vip-last-replace-region "")
|
||||
(defvar viper-last-replace-region "")
|
||||
|
||||
;; Remember com point as a marker.
|
||||
;; This is a local marker. Should be moved with `vip-move-marker-locally'
|
||||
(vip-deflocalvar vip-com-point nil)
|
||||
;; This is a local marker. Should be moved with `viper-move-marker-locally'
|
||||
(viper-deflocalvar viper-com-point nil)
|
||||
|
||||
;; If non-nil, the value is a list (M-COM VAL COM REG inserted-text cmd-keys)
|
||||
;; It is used to re-execute last destructive command.
|
||||
|
|
@ -523,53 +521,53 @@ to a new place after repeating previous Vi command."
|
|||
;; INSERTED-TEXT is text inserted by that command (in case of o, c, C, i, r
|
||||
;; commands).
|
||||
;; COMMAND-KEYS are the keys that were typed to invoke the command.
|
||||
(defvar vip-d-com nil)
|
||||
(defvar viper-d-com nil)
|
||||
|
||||
;; The character remembered by the Vi `r' command.
|
||||
(defvar vip-d-char nil)
|
||||
(defvar viper-d-char nil)
|
||||
|
||||
;; Name of register to store deleted or yanked strings
|
||||
(defvar vip-use-register nil)
|
||||
(defvar viper-use-register nil)
|
||||
|
||||
|
||||
|
||||
;; Variables for Moves and Searches
|
||||
|
||||
;; For use by `;' command.
|
||||
(defvar vip-f-char nil)
|
||||
(defvar viper-f-char nil)
|
||||
|
||||
;; For use by `.' command.
|
||||
(defvar vip-F-char nil)
|
||||
(defvar viper-F-char nil)
|
||||
|
||||
;; For use by `;' command.
|
||||
(defvar vip-f-forward nil)
|
||||
(defvar viper-f-forward nil)
|
||||
|
||||
;; For use by `;' command.
|
||||
(defvar vip-f-offset nil)
|
||||
(defvar viper-f-offset nil)
|
||||
|
||||
;; Last search string
|
||||
(defvar vip-s-string "")
|
||||
(defvar viper-s-string "")
|
||||
|
||||
(defcustom vip-quote-string "> "
|
||||
(defcustom viper-quote-string "> "
|
||||
"String inserted at the beginning of quoted region."
|
||||
:type 'string
|
||||
:group 'viper)
|
||||
|
||||
;; If t, search is forward.
|
||||
(defvar vip-s-forward nil)
|
||||
(defvar viper-s-forward nil)
|
||||
|
||||
(defcustom vip-case-fold-search nil
|
||||
(defcustom viper-case-fold-search nil
|
||||
"*If not nil, search ignores cases."
|
||||
:type 'boolean
|
||||
:group 'viper)
|
||||
|
||||
(defcustom vip-re-search t
|
||||
(defcustom viper-re-search t
|
||||
"*If not nil, search is regexp search, otherwise vanilla search."
|
||||
:type 'boolean
|
||||
:tag "Regexp Search"
|
||||
:group 'viper)
|
||||
|
||||
(defcustom vip-search-scroll-threshold 2
|
||||
(defcustom viper-search-scroll-threshold 2
|
||||
"*If search lands within this threshnold from the window top/bottom,
|
||||
the window will be scrolled up or down appropriately, to reveal context.
|
||||
If you want Viper search to behave as usual in Vi, set this variable to a
|
||||
|
|
@ -577,81 +575,81 @@ negative number."
|
|||
:type 'boolean
|
||||
:group 'viper)
|
||||
|
||||
(defcustom vip-re-query-replace t
|
||||
(defcustom viper-re-query-replace t
|
||||
"*If t then do regexp replace, if nil then do string replace."
|
||||
:type 'boolean
|
||||
:tag "Regexp Query Replace"
|
||||
:group 'viper)
|
||||
|
||||
(defcustom vip-re-replace t
|
||||
(defcustom viper-re-replace t
|
||||
"*If t, do regexp replace. nil means do string replace."
|
||||
:type 'boolean
|
||||
:tag "Regexp Replace"
|
||||
:group 'viper)
|
||||
|
||||
(defcustom vip-parse-sexp-ignore-comments t
|
||||
(defcustom viper-parse-sexp-ignore-comments t
|
||||
"*If t, `%' ignores the parentheses that occur inside comments."
|
||||
:type 'boolean
|
||||
:group 'viper)
|
||||
|
||||
(vip-deflocalvar vip-ex-style-motion t "")
|
||||
(defcustom vip-ex-style-motion t
|
||||
(viper-deflocalvar viper-ex-style-motion t "")
|
||||
(defcustom viper-ex-style-motion t
|
||||
"*If t, the commands l,h do not cross lines, etc (Ex-style).
|
||||
If nil, these commands cross line boundaries."
|
||||
:type 'boolean
|
||||
:group 'viper)
|
||||
|
||||
(vip-deflocalvar vip-ex-style-editing-in-insert t "")
|
||||
(defcustom vip-ex-style-editing-in-insert t
|
||||
(viper-deflocalvar viper-ex-style-editing-in-insert t "")
|
||||
(defcustom viper-ex-style-editing-in-insert t
|
||||
"*If t, `Backspace' and `Delete' don't cross line boundaries in insert, etc.
|
||||
Note: this doesn't preclude `Backspace' and `Delete' from deleting characters
|
||||
by moving past the insertion point. This is a feature, not a bug."
|
||||
:type 'boolean
|
||||
:group 'viper)
|
||||
|
||||
(vip-deflocalvar vip-ESC-moves-cursor-back vip-ex-style-editing-in-insert "")
|
||||
(defcustom vip-ESC-moves-cursor-back nil
|
||||
(viper-deflocalvar viper-ESC-moves-cursor-back viper-ex-style-editing-in-insert "")
|
||||
(defcustom viper-ESC-moves-cursor-back nil
|
||||
"*If t, ESC moves cursor back when changing from insert to vi state.
|
||||
If nil, the cursor stays where it was."
|
||||
:type 'boolean
|
||||
:group 'viper)
|
||||
|
||||
(vip-deflocalvar vip-delete-backwards-in-replace nil "")
|
||||
(defcustom vip-delete-backwards-in-replace nil
|
||||
(viper-deflocalvar viper-delete-backwards-in-replace nil "")
|
||||
(defcustom viper-delete-backwards-in-replace nil
|
||||
"*If t, DEL key will delete characters while moving the cursor backwards.
|
||||
If nil, the cursor will move backwards without deleting anything."
|
||||
:type 'boolean
|
||||
:group 'viper)
|
||||
|
||||
(defcustom vip-buffer-search-char nil
|
||||
(defcustom viper-buffer-search-char nil
|
||||
"*Key used for buffer-searching. Must be a character type, e.g., ?g."
|
||||
:type '(choice (const nil) character)
|
||||
:group 'viper)
|
||||
|
||||
(defcustom vip-search-wrap-around-t t
|
||||
(defcustom viper-search-wrap-around-t t
|
||||
"*If t, search wraps around."
|
||||
:type 'boolean
|
||||
:tag "Search Wraps Around"
|
||||
:group 'viper)
|
||||
|
||||
(vip-deflocalvar vip-related-files-and-buffers-ring nil "")
|
||||
(defcustom vip-related-files-and-buffers-ring nil
|
||||
(viper-deflocalvar viper-related-files-and-buffers-ring nil "")
|
||||
(defcustom viper-related-files-and-buffers-ring nil
|
||||
"*List of file and buffer names that are considered to be related to the current buffer.
|
||||
Related buffers can be cycled through via :R and :P commands."
|
||||
:type 'boolean
|
||||
:group 'viper)
|
||||
(put 'vip-related-files-and-buffers-ring 'permanent-local t)
|
||||
(put 'viper-related-files-and-buffers-ring 'permanent-local t)
|
||||
|
||||
;; Used to find out if we are done with searching the current buffer.
|
||||
(vip-deflocalvar vip-local-search-start-marker nil)
|
||||
(viper-deflocalvar viper-local-search-start-marker nil)
|
||||
;; As above, but global
|
||||
(defvar vip-search-start-marker (make-marker))
|
||||
(defvar viper-search-start-marker (make-marker))
|
||||
|
||||
;; the search overlay
|
||||
(vip-deflocalvar vip-search-overlay nil)
|
||||
(viper-deflocalvar viper-search-overlay nil)
|
||||
|
||||
|
||||
(defvar vip-heading-start
|
||||
(defvar viper-heading-start
|
||||
(concat "^\\s-*(\\s-*defun\\s-\\|" ; lisp
|
||||
"^{\\s-*$\\|^[_a-zA-Z][^()]*[()].*{\\s-*$\\|" ; C/C++
|
||||
"^\\s-*class.*{\\|^\\s-*struct.*{\\|^\\s-*enum.*{\\|"
|
||||
|
|
@ -660,7 +658,7 @@ Related buffers can be cycled through via :R and :P commands."
|
|||
"^.+:-") ; prolog
|
||||
"*Regexps for Headings. Used by \[\[ and \]\].")
|
||||
|
||||
(defvar vip-heading-end
|
||||
(defvar viper-heading-end
|
||||
(concat "^}\\|" ; C/C++
|
||||
"^\\\\end{\\|" ; latex
|
||||
"^@end \\|" ; texinfo
|
||||
|
|
@ -675,106 +673,102 @@ Related buffers can be cycled through via :R and :P commands."
|
|||
;; inside the lines.
|
||||
|
||||
;; Remembers position of the last jump done using ``'.
|
||||
(vip-deflocalvar vip-last-jump nil)
|
||||
(viper-deflocalvar viper-last-jump nil)
|
||||
;; Remembers position of the last jump done using `''.
|
||||
(vip-deflocalvar vip-last-jump-ignore 0)
|
||||
(viper-deflocalvar viper-last-jump-ignore 0)
|
||||
|
||||
;; History variables
|
||||
|
||||
;; History of search strings.
|
||||
(defvar vip-search-history (list ""))
|
||||
(defvar viper-search-history (list ""))
|
||||
;; History of query-replace strings used as a source.
|
||||
(defvar vip-replace1-history nil)
|
||||
(defvar viper-replace1-history nil)
|
||||
;; History of query-replace strings used as replacement.
|
||||
(defvar vip-replace2-history nil)
|
||||
(defvar viper-replace2-history nil)
|
||||
;; History of region quoting strings.
|
||||
(defvar vip-quote-region-history (list vip-quote-string))
|
||||
(defvar viper-quote-region-history (list viper-quote-string))
|
||||
;; History of Ex-style commands.
|
||||
(defvar vip-ex-history nil)
|
||||
(defvar viper-ex-history nil)
|
||||
;; History of shell commands.
|
||||
(defvar vip-shell-history nil)
|
||||
(defvar viper-shell-history nil)
|
||||
|
||||
|
||||
;; Last shell command. There are two of these, one for Ex (in viper-ex)
|
||||
;; and one for Vi.
|
||||
|
||||
;; Last shell command executed with ! command.
|
||||
(defvar vip-last-shell-com nil)
|
||||
(defvar viper-last-shell-com nil)
|
||||
|
||||
|
||||
|
||||
;;; Miscellaneous
|
||||
|
||||
(defvar vip-inhibit-startup-message nil
|
||||
(defvar viper-inhibit-startup-message nil
|
||||
"Whether Viper startup message should be inhibited.")
|
||||
|
||||
(defcustom vip-spell-function 'ispell-region
|
||||
(defcustom viper-spell-function 'ispell-region
|
||||
"Spell function used by #s<move> command to spell."
|
||||
:type 'function
|
||||
:group 'viper)
|
||||
|
||||
(defcustom vip-tags-file-name "TAGS"
|
||||
(defcustom viper-tags-file-name "TAGS"
|
||||
"The tags file used by Viper."
|
||||
:type 'string
|
||||
:group 'viper)
|
||||
|
||||
;; Indicates if we are in the middle of executing a command that takes another
|
||||
;; command as an argument, e.g., cw, dw, etc.
|
||||
(defvar vip-inside-command-argument-action nil)
|
||||
|
||||
;; Minibuffer
|
||||
|
||||
(defcustom vip-vi-style-in-minibuffer t
|
||||
(defcustom viper-vi-style-in-minibuffer t
|
||||
"If t, use vi-style editing in minibuffer.
|
||||
Should be set in `~/.vip' file."
|
||||
Should be set in `~/.viper' file."
|
||||
:type 'boolean
|
||||
:group 'viper)
|
||||
|
||||
;; overlay used in the minibuffer to indicate which state it is in
|
||||
(vip-deflocalvar vip-minibuffer-overlay nil)
|
||||
(viper-deflocalvar viper-minibuffer-overlay nil)
|
||||
|
||||
;; Hook, specific to Viper, which is run just *before* exiting the minibuffer.
|
||||
;; Beginning with Emacs 19.26, the standard `minibuffer-exit-hook' is run
|
||||
;; *after* exiting the minibuffer
|
||||
(defvar vip-minibuffer-exit-hook nil)
|
||||
(defvar viper-minibuffer-exit-hook nil)
|
||||
|
||||
|
||||
;; Mode line
|
||||
(defconst vip-vi-state-id "<V> "
|
||||
(defconst viper-vi-state-id "<V> "
|
||||
"Mode line tag identifying the Vi mode of Viper.")
|
||||
(defconst vip-emacs-state-id "<E> "
|
||||
(defconst viper-emacs-state-id "<E> "
|
||||
"Mode line tag identifying the Emacs mode of Viper.")
|
||||
(defconst vip-insert-state-id "<I> "
|
||||
(defconst viper-insert-state-id "<I> "
|
||||
"Mode line tag identifying the Insert mode of Viper.")
|
||||
(defconst vip-replace-state-id "<R> "
|
||||
(defconst viper-replace-state-id "<R> "
|
||||
"Mode line tag identifying the Replace mode of Viper.")
|
||||
|
||||
|
||||
(defcustom vip-vi-state-hook nil
|
||||
(defcustom viper-vi-state-hook nil
|
||||
"*Hooks run just before the switch to Vi mode is completed."
|
||||
:type 'hook
|
||||
:group 'viper)
|
||||
(defcustom vip-insert-state-hook nil
|
||||
(defcustom viper-insert-state-hook nil
|
||||
"*Hooks run just before the switch to Insert mode is completed."
|
||||
:type 'hook
|
||||
:group 'viper)
|
||||
(defcustom vip-replace-state-hook nil
|
||||
(defcustom viper-replace-state-hook nil
|
||||
"*Hooks run just before the switch to Replace mode is completed."
|
||||
:type 'hook
|
||||
:group 'viper)
|
||||
(defcustom vip-emacs-state-hook nil
|
||||
(defcustom viper-emacs-state-hook nil
|
||||
"*Hooks run just before the switch to Emacs mode is completed."
|
||||
:type 'hook
|
||||
:group 'viper)
|
||||
|
||||
(defcustom vip-load-hook nil
|
||||
(defcustom viper-load-hook nil
|
||||
"Hooks run just after loading Viper."
|
||||
:type 'hook
|
||||
:group 'viper)
|
||||
|
||||
|
||||
;;; Local Variables:
|
||||
;;; eval: (put 'vip-deflocalvar 'lisp-indent-hook 'defun)
|
||||
;;; eval: (put 'viper-deflocalvar 'lisp-indent-hook 'defun)
|
||||
;;; End:
|
||||
|
||||
;;; viper-ex.el ends here
|
||||
|
|
|
|||
|
|
@ -25,11 +25,11 @@
|
|||
|
||||
;; compiler pacifier
|
||||
(defvar viper-always)
|
||||
(defvar vip-current-state)
|
||||
(defvar vip-mode-string)
|
||||
(defvar viper-current-state)
|
||||
(defvar viper-mode-string)
|
||||
(defvar viper-expert-level)
|
||||
(defvar vip-ex-style-editing-in-insert)
|
||||
(defvar vip-ex-style-motion)
|
||||
(defvar viper-ex-style-editing-in-insert)
|
||||
(defvar viper-ex-style-motion)
|
||||
|
||||
;; loading happens only in non-interactive compilation
|
||||
;; in order to spare non-viperized emacs from being viperized
|
||||
|
|
@ -46,43 +46,43 @@
|
|||
|
||||
;;; Variables
|
||||
|
||||
(defvar vip-toggle-key "\C-z"
|
||||
(defvar viper-toggle-key "\C-z"
|
||||
"The key used to change states from emacs to Vi and back.
|
||||
In insert mode, this key also functions as Meta.
|
||||
Must be set in .vip file or prior to loading Viper.
|
||||
Must be set in .viper file or prior to loading Viper.
|
||||
This setting cannot be changed interactively.")
|
||||
|
||||
(defvar vip-ESC-key "\e"
|
||||
(defvar viper-ESC-key "\e"
|
||||
"Key used to ESC.
|
||||
Must be set in .vip file or prior to loading Viper.
|
||||
Must be set in .viper file or prior to loading Viper.
|
||||
This setting cannot be changed interactively.")
|
||||
|
||||
;;; Emacs keys in other states.
|
||||
|
||||
(defcustom vip-want-emacs-keys-in-insert t
|
||||
(defcustom viper-want-emacs-keys-in-insert t
|
||||
"*Set to nil if you want complete Vi compatibility in insert mode.
|
||||
Complete compatibility with Vi is not recommended for power use of Viper."
|
||||
:type 'boolean
|
||||
:group 'viper)
|
||||
|
||||
(defcustom vip-want-emacs-keys-in-vi t
|
||||
(defcustom viper-want-emacs-keys-in-vi t
|
||||
"*Set to nil if you want complete Vi compatibility in Vi mode.
|
||||
Full Vi compatibility is not recommended for power use of Viper."
|
||||
:type 'boolean
|
||||
:group 'viper)
|
||||
|
||||
(defcustom vip-no-multiple-ESC t
|
||||
(defcustom viper-no-multiple-ESC t
|
||||
"*If true, multiple ESC in Vi mode will cause bell to ring.
|
||||
This is set to t on a windowing terminal and to 'twice on a dumb
|
||||
terminal (unless the user level is 1, 2, or 5). On a dumb terminal, this
|
||||
enables cursor keys and is generally more convenient, as terminals usually
|
||||
don't have a convenient Meta key.
|
||||
Setting vip-no-multiple-ESC to nil will allow as many multiple ESC,
|
||||
Setting viper-no-multiple-ESC to nil will allow as many multiple ESC,
|
||||
as is allowed by the major mode in effect."
|
||||
:type 'boolean
|
||||
:group 'viper)
|
||||
|
||||
(defcustom vip-want-ctl-h-help nil
|
||||
(defcustom viper-want-ctl-h-help nil
|
||||
"*If t then C-h is bound to help-command in insert mode, if nil then it is
|
||||
bound to delete-backward-char."
|
||||
:type 'boolean
|
||||
|
|
@ -93,76 +93,76 @@ bound to delete-backward-char."
|
|||
|
||||
;; Keymaps for vital things like \e and C-z.
|
||||
;; Not for users
|
||||
(defvar vip-vi-intercept-map (make-sparse-keymap))
|
||||
(defvar vip-insert-intercept-map (make-sparse-keymap))
|
||||
(defvar vip-emacs-intercept-map (make-sparse-keymap))
|
||||
(defvar viper-vi-intercept-map (make-sparse-keymap))
|
||||
(defvar viper-insert-intercept-map (make-sparse-keymap))
|
||||
(defvar viper-emacs-intercept-map (make-sparse-keymap))
|
||||
|
||||
;; keymap used to zap all keymaps other than function-key-map,
|
||||
;; device-function-key-map, etc.
|
||||
(defvar vip-overriding-map (make-sparse-keymap))
|
||||
(defvar viper-overriding-map (make-sparse-keymap))
|
||||
|
||||
(vip-deflocalvar vip-vi-local-user-map (make-sparse-keymap)
|
||||
(viper-deflocalvar viper-vi-local-user-map (make-sparse-keymap)
|
||||
"Keymap for user-defined local bindings.
|
||||
Useful for changing bindings such as ZZ in certain major modes.
|
||||
For instance, in letter-mode, one may want to bind ZZ to
|
||||
mh-send-letter. In a newsreader such as gnus, tin, or rn, ZZ could be bound
|
||||
to save-buffers-kill-emacs then post article, etc.")
|
||||
(put 'vip-vi-local-user-map 'permanent-local t)
|
||||
(put 'viper-vi-local-user-map 'permanent-local t)
|
||||
|
||||
(defvar vip-vi-global-user-map (make-sparse-keymap)
|
||||
(defvar viper-vi-global-user-map (make-sparse-keymap)
|
||||
"Keymap for user-defined global bindings.
|
||||
These bindings are seen in all Viper buffers.")
|
||||
|
||||
(defvar vip-vi-basic-map (make-keymap)
|
||||
(defvar viper-vi-basic-map (make-keymap)
|
||||
"This is the main keymap in effect in Viper's Vi state.
|
||||
This map is global, shared by all buffers.")
|
||||
|
||||
(defvar vip-vi-kbd-map (make-sparse-keymap)
|
||||
(defvar viper-vi-kbd-map (make-sparse-keymap)
|
||||
"This keymap keeps keyboard macros defined via the :map command.")
|
||||
|
||||
(defvar vip-vi-diehard-map (make-sparse-keymap)
|
||||
(defvar viper-vi-diehard-map (make-sparse-keymap)
|
||||
"This keymap is in use when the user asks Viper to simulate Vi very closely.
|
||||
This happens when viper-expert-level is 1 or 2. See viper-set-expert-level.")
|
||||
|
||||
|
||||
(vip-deflocalvar vip-insert-local-user-map (make-sparse-keymap)
|
||||
(viper-deflocalvar viper-insert-local-user-map (make-sparse-keymap)
|
||||
"Auxiliary map for per-buffer user-defined keybindings in Insert state.")
|
||||
(put 'vip-insert-local-user-map 'permanent-local t)
|
||||
(put 'viper-insert-local-user-map 'permanent-local t)
|
||||
|
||||
(defvar vip-insert-global-user-map (make-sparse-keymap)
|
||||
(defvar viper-insert-global-user-map (make-sparse-keymap)
|
||||
"Auxiliary map for global user-defined bindings in Insert state.")
|
||||
|
||||
(defvar vip-insert-basic-map (make-sparse-keymap)
|
||||
(defvar viper-insert-basic-map (make-sparse-keymap)
|
||||
"The basic insert-mode keymap.")
|
||||
|
||||
(defvar vip-insert-diehard-map (make-keymap)
|
||||
(defvar viper-insert-diehard-map (make-keymap)
|
||||
"Map used when user wants vi-style keys in insert mode.
|
||||
Most of the Emacs keys are suppressed. This map overshadows
|
||||
vip-insert-basic-map. Not recommended, except for novice users.")
|
||||
viper-insert-basic-map. Not recommended, except for novice users.")
|
||||
|
||||
(defvar vip-insert-kbd-map (make-sparse-keymap)
|
||||
(defvar viper-insert-kbd-map (make-sparse-keymap)
|
||||
"This keymap keeps VI-style kbd macros for insert mode.")
|
||||
|
||||
(defvar vip-replace-map (make-sparse-keymap)
|
||||
(defvar viper-replace-map (make-sparse-keymap)
|
||||
"Map used in Viper's replace state.")
|
||||
|
||||
(defvar vip-emacs-global-user-map (make-sparse-keymap)
|
||||
(defvar viper-emacs-global-user-map (make-sparse-keymap)
|
||||
"Auxiliary map for global user-defined bindings in Emacs state.")
|
||||
|
||||
(defvar vip-emacs-kbd-map (make-sparse-keymap)
|
||||
(defvar viper-emacs-kbd-map (make-sparse-keymap)
|
||||
"This keymap keeps Vi-style kbd macros for emacs mode.")
|
||||
|
||||
(vip-deflocalvar vip-emacs-local-user-map (make-sparse-keymap)
|
||||
(viper-deflocalvar viper-emacs-local-user-map (make-sparse-keymap)
|
||||
"Auxiliary map for local user-defined bindings in Emacs state.")
|
||||
(put 'vip-emacs-local-user-map 'permanent-local t)
|
||||
(put 'viper-emacs-local-user-map 'permanent-local t)
|
||||
|
||||
;; This keymap should stay empty
|
||||
(defvar vip-empty-keymap (make-sparse-keymap))
|
||||
(defvar viper-empty-keymap (make-sparse-keymap))
|
||||
|
||||
;; This was the main Vi mode in old versions of VIP which may have been
|
||||
;; extensively used by VIP users. We declare it as a global var
|
||||
;; and, after .vip is loaded, we add this keymap to vip-vi-basic-map.
|
||||
(defvar vip-mode-map (make-sparse-keymap))
|
||||
;; and, after .viper is loaded, we add this keymap to viper-vi-basic-map.
|
||||
(defvar viper-mode-map (make-sparse-keymap))
|
||||
|
||||
|
||||
;;; Variables used by minor modes
|
||||
|
|
@ -171,296 +171,296 @@ vip-insert-basic-map. Not recommended, except for novice users.")
|
|||
;; ((major-mode . keymap) (major-mode . keymap) ...)
|
||||
;; Viper uses these keymaps to make user-requested adjustments
|
||||
;; to its Vi state in various major modes.")
|
||||
(defvar vip-vi-state-modifier-alist nil)
|
||||
(defvar viper-vi-state-modifier-alist nil)
|
||||
|
||||
;; Association list of the form
|
||||
;; ((major-mode . keymap) (major-mode . keymap) ...)
|
||||
;; Viper uses these keymaps to make user-requested adjustments
|
||||
;; to its Insert state in various major modes.")
|
||||
(defvar vip-insert-state-modifier-alist nil)
|
||||
(defvar viper-insert-state-modifier-alist nil)
|
||||
|
||||
;; Association list of the form
|
||||
;; ((major-mode . keymap) (major-mode . keymap) ...)
|
||||
;; Viper uses these keymaps to make user-requested adjustments
|
||||
;; to its Emacs state in various major modes.
|
||||
(defvar vip-emacs-state-modifier-alist nil)
|
||||
(defvar viper-emacs-state-modifier-alist nil)
|
||||
|
||||
;; Tells vip-add-local-keys to create a new vip-vi-local-user-map for new
|
||||
;; Tells viper-add-local-keys to create a new viper-vi-local-user-map for new
|
||||
;; buffers. Not a user option.
|
||||
(vip-deflocalvar vip-need-new-vi-local-map t "")
|
||||
(put 'vip-need-new-vi-local-map 'permanent-local t)
|
||||
(viper-deflocalvar viper-need-new-vi-local-map t "")
|
||||
(put 'viper-need-new-vi-local-map 'permanent-local t)
|
||||
|
||||
;; Tells vip-add-local-keys to create a new vip-insert-local-user-map for new
|
||||
;; buffers. Not a user option.
|
||||
(vip-deflocalvar vip-need-new-insert-local-map t "")
|
||||
(put 'vip-need-new-insert-local-map 'permanent-local t)
|
||||
;; Tells viper-add-local-keys to create a new viper-insert-local-user-map for
|
||||
;; new buffers. Not a user option.
|
||||
(viper-deflocalvar viper-need-new-insert-local-map t "")
|
||||
(put 'viper-need-new-insert-local-map 'permanent-local t)
|
||||
|
||||
;; Tells vip-add-local-keys to create a new vip-emacs-local-user-map for new
|
||||
;; buffers. Not a user option.
|
||||
(vip-deflocalvar vip-need-new-emacs-local-map t "")
|
||||
(put 'vip-need-new-emacs-local-map 'permanent-local t)
|
||||
;; Tells viper-add-local-keys to create a new viper-emacs-local-user-map for
|
||||
;; new buffers. Not a user option.
|
||||
(viper-deflocalvar viper-need-new-emacs-local-map t "")
|
||||
(put 'viper-need-new-emacs-local-map 'permanent-local t)
|
||||
|
||||
|
||||
|
||||
;; Insert mode keymap
|
||||
|
||||
;; for novice users, pretend you are the real vi.
|
||||
(define-key vip-insert-diehard-map "\t" 'vip-insert-tab)
|
||||
(define-key vip-insert-diehard-map "\C-a" 'self-insert-command)
|
||||
(define-key vip-insert-diehard-map "\C-b" 'self-insert-command)
|
||||
(define-key vip-insert-diehard-map "\C-c" 'vip-change-state-to-vi)
|
||||
(define-key vip-insert-diehard-map "\C-e" 'self-insert-command)
|
||||
(define-key vip-insert-diehard-map "\C-f" 'self-insert-command)
|
||||
(define-key vip-insert-diehard-map "\C-g" 'self-insert-command)
|
||||
(define-key vip-insert-diehard-map "\C-i" 'self-insert-command)
|
||||
(define-key vip-insert-diehard-map "\C-k" 'self-insert-command)
|
||||
(define-key vip-insert-diehard-map "\C-l" 'self-insert-command)
|
||||
(define-key vip-insert-diehard-map "\C-n" 'self-insert-command)
|
||||
(define-key vip-insert-diehard-map "\C-o" 'self-insert-command)
|
||||
(define-key vip-insert-diehard-map "\C-p" 'self-insert-command)
|
||||
(define-key vip-insert-diehard-map "\C-q" 'self-insert-command)
|
||||
(define-key vip-insert-diehard-map "\C-r" 'self-insert-command)
|
||||
(define-key vip-insert-diehard-map "\C-s" 'self-insert-command)
|
||||
(define-key vip-insert-diehard-map "\C-u" 'vip-erase-line)
|
||||
(define-key vip-insert-diehard-map "\C-x" 'self-insert-command)
|
||||
(define-key vip-insert-diehard-map "\C-y" 'self-insert-command)
|
||||
(define-key vip-insert-diehard-map "\C-z" 'self-insert-command)
|
||||
(define-key vip-insert-diehard-map "\C-]" 'self-insert-command)
|
||||
(define-key vip-insert-diehard-map "\C-_" 'self-insert-command)
|
||||
(define-key viper-insert-diehard-map "\t" 'viper-insert-tab)
|
||||
(define-key viper-insert-diehard-map "\C-a" 'self-insert-command)
|
||||
(define-key viper-insert-diehard-map "\C-b" 'self-insert-command)
|
||||
(define-key viper-insert-diehard-map "\C-c" 'viper-change-state-to-vi)
|
||||
(define-key viper-insert-diehard-map "\C-e" 'self-insert-command)
|
||||
(define-key viper-insert-diehard-map "\C-f" 'self-insert-command)
|
||||
(define-key viper-insert-diehard-map "\C-g" 'self-insert-command)
|
||||
(define-key viper-insert-diehard-map "\C-i" 'self-insert-command)
|
||||
(define-key viper-insert-diehard-map "\C-k" 'self-insert-command)
|
||||
(define-key viper-insert-diehard-map "\C-l" 'self-insert-command)
|
||||
(define-key viper-insert-diehard-map "\C-n" 'self-insert-command)
|
||||
(define-key viper-insert-diehard-map "\C-o" 'self-insert-command)
|
||||
(define-key viper-insert-diehard-map "\C-p" 'self-insert-command)
|
||||
(define-key viper-insert-diehard-map "\C-q" 'self-insert-command)
|
||||
(define-key viper-insert-diehard-map "\C-r" 'self-insert-command)
|
||||
(define-key viper-insert-diehard-map "\C-s" 'self-insert-command)
|
||||
(define-key viper-insert-diehard-map "\C-u" 'viper-erase-line)
|
||||
(define-key viper-insert-diehard-map "\C-x" 'self-insert-command)
|
||||
(define-key viper-insert-diehard-map "\C-y" 'self-insert-command)
|
||||
(define-key viper-insert-diehard-map "\C-z" 'self-insert-command)
|
||||
(define-key viper-insert-diehard-map "\C-]" 'self-insert-command)
|
||||
(define-key viper-insert-diehard-map "\C-_" 'self-insert-command)
|
||||
|
||||
(let ((i ?\ ))
|
||||
(while (<= i ?~)
|
||||
(define-key vip-insert-diehard-map (make-string 1 i) 'self-insert-command)
|
||||
(define-key viper-insert-diehard-map (make-string 1 i) 'self-insert-command)
|
||||
(setq i (1+ i))))
|
||||
|
||||
;; Insert mode map when user wants emacs style
|
||||
(define-key vip-insert-basic-map "\C-d" 'vip-backward-indent)
|
||||
(define-key vip-insert-basic-map "\C-w" 'vip-delete-backward-word)
|
||||
(define-key vip-insert-basic-map "\C-t" 'vip-forward-indent)
|
||||
(define-key vip-insert-basic-map
|
||||
(if vip-xemacs-p [(shift tab)] [S-tab]) 'vip-insert-tab)
|
||||
(define-key vip-insert-basic-map "\C-v" 'quoted-insert)
|
||||
(define-key vip-insert-basic-map "\C-?" 'vip-del-backward-char-in-insert)
|
||||
(define-key vip-insert-basic-map "\C-\\" 'vip-alternate-Meta-key)
|
||||
(define-key vip-insert-basic-map vip-toggle-key 'vip-escape-to-vi)
|
||||
(define-key vip-insert-basic-map "\C-c\M-p"
|
||||
'vip-insert-prev-from-insertion-ring)
|
||||
(define-key vip-insert-basic-map "\C-c\M-n"
|
||||
'vip-insert-next-from-insertion-ring)
|
||||
(define-key viper-insert-basic-map "\C-d" 'viper-backward-indent)
|
||||
(define-key viper-insert-basic-map "\C-w" 'viper-delete-backward-word)
|
||||
(define-key viper-insert-basic-map "\C-t" 'viper-forward-indent)
|
||||
(define-key viper-insert-basic-map
|
||||
(if viper-xemacs-p [(shift tab)] [S-tab]) 'viper-insert-tab)
|
||||
(define-key viper-insert-basic-map "\C-v" 'quoted-insert)
|
||||
(define-key viper-insert-basic-map "\C-?" 'viper-del-backward-char-in-insert)
|
||||
(define-key viper-insert-basic-map "\C-\\" 'viper-alternate-Meta-key)
|
||||
(define-key viper-insert-basic-map viper-toggle-key 'viper-escape-to-vi)
|
||||
(define-key viper-insert-basic-map "\C-c\M-p"
|
||||
'viper-insert-prev-from-insertion-ring)
|
||||
(define-key viper-insert-basic-map "\C-c\M-n"
|
||||
'viper-insert-next-from-insertion-ring)
|
||||
|
||||
|
||||
;; Replace keymap
|
||||
(define-key vip-replace-map "\C-t" 'vip-forward-indent)
|
||||
(define-key vip-replace-map "\C-j" 'vip-replace-state-carriage-return)
|
||||
(define-key vip-replace-map "\C-m" 'vip-replace-state-carriage-return)
|
||||
(define-key vip-replace-map "\C-?" 'vip-del-backward-char-in-replace)
|
||||
(define-key viper-replace-map "\C-t" 'viper-forward-indent)
|
||||
(define-key viper-replace-map "\C-j" 'viper-replace-state-carriage-return)
|
||||
(define-key viper-replace-map "\C-m" 'viper-replace-state-carriage-return)
|
||||
(define-key viper-replace-map "\C-?" 'viper-del-backward-char-in-replace)
|
||||
|
||||
|
||||
|
||||
;; Vi keymaps
|
||||
|
||||
(define-key vip-vi-basic-map "\C-^"
|
||||
(function (lambda () (interactive) (vip-ex "e#"))))
|
||||
(define-key vip-vi-basic-map "\C-b" 'vip-scroll-screen-back)
|
||||
(define-key vip-vi-basic-map "\C-d" 'vip-scroll-up)
|
||||
(define-key vip-vi-basic-map "\C-e" 'vip-scroll-up-one)
|
||||
(define-key vip-vi-basic-map "\C-f" 'vip-scroll-screen)
|
||||
(define-key vip-vi-basic-map "\C-m" 'vip-next-line-at-bol)
|
||||
(define-key vip-vi-basic-map "\C-u" 'vip-scroll-down)
|
||||
(define-key vip-vi-basic-map "\C-y" 'vip-scroll-down-one)
|
||||
(define-key vip-vi-basic-map "\C-s" 'vip-isearch-forward)
|
||||
(define-key vip-vi-basic-map "\C-r" 'vip-isearch-backward)
|
||||
(define-key vip-vi-basic-map "\C-c/" 'vip-toggle-search-style)
|
||||
(define-key vip-vi-basic-map "\C-cg" 'vip-info-on-file)
|
||||
(define-key viper-vi-basic-map "\C-^"
|
||||
(function (lambda () (interactive) (viper-ex "e#"))))
|
||||
(define-key viper-vi-basic-map "\C-b" 'viper-scroll-screen-back)
|
||||
(define-key viper-vi-basic-map "\C-d" 'viper-scroll-up)
|
||||
(define-key viper-vi-basic-map "\C-e" 'viper-scroll-up-one)
|
||||
(define-key viper-vi-basic-map "\C-f" 'viper-scroll-screen)
|
||||
(define-key viper-vi-basic-map "\C-m" 'viper-next-line-at-bol)
|
||||
(define-key viper-vi-basic-map "\C-u" 'viper-scroll-down)
|
||||
(define-key viper-vi-basic-map "\C-y" 'viper-scroll-down-one)
|
||||
(define-key viper-vi-basic-map "\C-s" 'viper-isearch-forward)
|
||||
(define-key viper-vi-basic-map "\C-r" 'viper-isearch-backward)
|
||||
(define-key viper-vi-basic-map "\C-c/" 'viper-toggle-search-style)
|
||||
(define-key viper-vi-basic-map "\C-cg" 'viper-info-on-file)
|
||||
|
||||
(define-key vip-vi-basic-map "\C-c\M-p" 'vip-prev-destructive-command)
|
||||
(define-key vip-vi-basic-map "\C-c\M-n" 'vip-next-destructive-command)
|
||||
(define-key viper-vi-basic-map "\C-c\M-p" 'viper-prev-destructive-command)
|
||||
(define-key viper-vi-basic-map "\C-c\M-n" 'viper-next-destructive-command)
|
||||
|
||||
|
||||
(define-key vip-vi-basic-map " " 'vip-forward-char)
|
||||
(define-key vip-vi-basic-map "!" 'vip-command-argument)
|
||||
(define-key vip-vi-basic-map "\"" 'vip-command-argument)
|
||||
(define-key vip-vi-basic-map "#" 'vip-command-argument)
|
||||
(define-key vip-vi-basic-map "$" 'vip-goto-eol)
|
||||
(define-key vip-vi-basic-map "%" 'vip-paren-match)
|
||||
(define-key vip-vi-basic-map "&"
|
||||
(function (lambda () (interactive) (vip-ex "&"))))
|
||||
(define-key vip-vi-basic-map "'" 'vip-goto-mark-and-skip-white)
|
||||
(define-key vip-vi-basic-map "(" 'vip-backward-sentence)
|
||||
(define-key vip-vi-basic-map ")" 'vip-forward-sentence)
|
||||
(define-key vip-vi-basic-map "*" 'call-last-kbd-macro)
|
||||
(define-key vip-vi-basic-map "+" 'vip-next-line-at-bol)
|
||||
(define-key vip-vi-basic-map "," 'vip-repeat-find-opposite)
|
||||
(define-key vip-vi-basic-map "-" 'vip-previous-line-at-bol)
|
||||
(define-key vip-vi-basic-map "." 'vip-repeat)
|
||||
(define-key vip-vi-basic-map "/" 'vip-search-forward)
|
||||
(define-key viper-vi-basic-map " " 'viper-forward-char)
|
||||
(define-key viper-vi-basic-map "!" 'viper-command-argument)
|
||||
(define-key viper-vi-basic-map "\"" 'viper-command-argument)
|
||||
(define-key viper-vi-basic-map "#" 'viper-command-argument)
|
||||
(define-key viper-vi-basic-map "$" 'viper-goto-eol)
|
||||
(define-key viper-vi-basic-map "%" 'viper-paren-match)
|
||||
(define-key viper-vi-basic-map "&"
|
||||
(function (lambda () (interactive) (viper-ex "&"))))
|
||||
(define-key viper-vi-basic-map "'" 'viper-goto-mark-and-skip-white)
|
||||
(define-key viper-vi-basic-map "(" 'viper-backward-sentence)
|
||||
(define-key viper-vi-basic-map ")" 'viper-forward-sentence)
|
||||
(define-key viper-vi-basic-map "*" 'call-last-kbd-macro)
|
||||
(define-key viper-vi-basic-map "+" 'viper-next-line-at-bol)
|
||||
(define-key viper-vi-basic-map "," 'viper-repeat-find-opposite)
|
||||
(define-key viper-vi-basic-map "-" 'viper-previous-line-at-bol)
|
||||
(define-key viper-vi-basic-map "." 'viper-repeat)
|
||||
(define-key viper-vi-basic-map "/" 'viper-search-forward)
|
||||
|
||||
(define-key vip-vi-basic-map "0" 'vip-beginning-of-line)
|
||||
(define-key vip-vi-basic-map "1" 'vip-digit-argument)
|
||||
(define-key vip-vi-basic-map "2" 'vip-digit-argument)
|
||||
(define-key vip-vi-basic-map "3" 'vip-digit-argument)
|
||||
(define-key vip-vi-basic-map "4" 'vip-digit-argument)
|
||||
(define-key vip-vi-basic-map "5" 'vip-digit-argument)
|
||||
(define-key vip-vi-basic-map "6" 'vip-digit-argument)
|
||||
(define-key vip-vi-basic-map "7" 'vip-digit-argument)
|
||||
(define-key vip-vi-basic-map "8" 'vip-digit-argument)
|
||||
(define-key vip-vi-basic-map "9" 'vip-digit-argument)
|
||||
(define-key viper-vi-basic-map "0" 'viper-beginning-of-line)
|
||||
(define-key viper-vi-basic-map "1" 'viper-digit-argument)
|
||||
(define-key viper-vi-basic-map "2" 'viper-digit-argument)
|
||||
(define-key viper-vi-basic-map "3" 'viper-digit-argument)
|
||||
(define-key viper-vi-basic-map "4" 'viper-digit-argument)
|
||||
(define-key viper-vi-basic-map "5" 'viper-digit-argument)
|
||||
(define-key viper-vi-basic-map "6" 'viper-digit-argument)
|
||||
(define-key viper-vi-basic-map "7" 'viper-digit-argument)
|
||||
(define-key viper-vi-basic-map "8" 'viper-digit-argument)
|
||||
(define-key viper-vi-basic-map "9" 'viper-digit-argument)
|
||||
|
||||
(define-key vip-vi-basic-map ":" 'vip-ex)
|
||||
(define-key vip-vi-basic-map ";" 'vip-repeat-find)
|
||||
(define-key vip-vi-basic-map "<" 'vip-command-argument)
|
||||
(define-key vip-vi-basic-map "=" 'vip-command-argument)
|
||||
(define-key vip-vi-basic-map ">" 'vip-command-argument)
|
||||
(define-key vip-vi-basic-map "?" 'vip-search-backward)
|
||||
(define-key vip-vi-basic-map "@" 'vip-register-macro)
|
||||
(define-key viper-vi-basic-map ":" 'viper-ex)
|
||||
(define-key viper-vi-basic-map ";" 'viper-repeat-find)
|
||||
(define-key viper-vi-basic-map "<" 'viper-command-argument)
|
||||
(define-key viper-vi-basic-map "=" 'viper-command-argument)
|
||||
(define-key viper-vi-basic-map ">" 'viper-command-argument)
|
||||
(define-key viper-vi-basic-map "?" 'viper-search-backward)
|
||||
(define-key viper-vi-basic-map "@" 'viper-register-macro)
|
||||
|
||||
(define-key vip-vi-basic-map "A" 'vip-Append)
|
||||
(define-key vip-vi-basic-map "B" 'vip-backward-Word)
|
||||
(define-key vip-vi-basic-map "C" 'vip-change-to-eol)
|
||||
(define-key vip-vi-basic-map "D" 'vip-kill-line)
|
||||
(define-key vip-vi-basic-map "E" 'vip-end-of-Word)
|
||||
(define-key vip-vi-basic-map "F" 'vip-find-char-backward)
|
||||
(define-key vip-vi-basic-map "G" 'vip-goto-line)
|
||||
(define-key vip-vi-basic-map "H" 'vip-window-top)
|
||||
(define-key vip-vi-basic-map "I" 'vip-Insert)
|
||||
(define-key vip-vi-basic-map "J" 'vip-join-lines)
|
||||
(define-key vip-vi-basic-map "K" 'vip-nil)
|
||||
(define-key vip-vi-basic-map "L" 'vip-window-bottom)
|
||||
(define-key vip-vi-basic-map "M" 'vip-window-middle)
|
||||
(define-key vip-vi-basic-map "N" 'vip-search-Next)
|
||||
(define-key vip-vi-basic-map "O" 'vip-Open-line)
|
||||
(define-key vip-vi-basic-map "P" 'vip-Put-back)
|
||||
(define-key vip-vi-basic-map "Q" 'vip-query-replace)
|
||||
(define-key vip-vi-basic-map "R" 'vip-overwrite)
|
||||
(define-key vip-vi-basic-map "S" 'vip-substitute-line)
|
||||
(define-key vip-vi-basic-map "T" 'vip-goto-char-backward)
|
||||
(define-key vip-vi-basic-map "U" 'vip-undo)
|
||||
(define-key vip-vi-basic-map "V" 'find-file-other-window)
|
||||
(define-key vip-vi-basic-map "W" 'vip-forward-Word)
|
||||
(define-key vip-vi-basic-map "X" 'vip-delete-backward-char)
|
||||
(define-key vip-vi-basic-map "Y" 'vip-yank-line)
|
||||
(define-key vip-vi-basic-map "ZZ" 'vip-save-kill-buffer)
|
||||
(define-key viper-vi-basic-map "A" 'viper-Append)
|
||||
(define-key viper-vi-basic-map "B" 'viper-backward-Word)
|
||||
(define-key viper-vi-basic-map "C" 'viper-change-to-eol)
|
||||
(define-key viper-vi-basic-map "D" 'viper-kill-line)
|
||||
(define-key viper-vi-basic-map "E" 'viper-end-of-Word)
|
||||
(define-key viper-vi-basic-map "F" 'viper-find-char-backward)
|
||||
(define-key viper-vi-basic-map "G" 'viper-goto-line)
|
||||
(define-key viper-vi-basic-map "H" 'viper-window-top)
|
||||
(define-key viper-vi-basic-map "I" 'viper-Insert)
|
||||
(define-key viper-vi-basic-map "J" 'viper-join-lines)
|
||||
(define-key viper-vi-basic-map "K" 'viper-nil)
|
||||
(define-key viper-vi-basic-map "L" 'viper-window-bottom)
|
||||
(define-key viper-vi-basic-map "M" 'viper-window-middle)
|
||||
(define-key viper-vi-basic-map "N" 'viper-search-Next)
|
||||
(define-key viper-vi-basic-map "O" 'viper-Open-line)
|
||||
(define-key viper-vi-basic-map "P" 'viper-Put-back)
|
||||
(define-key viper-vi-basic-map "Q" 'viper-query-replace)
|
||||
(define-key viper-vi-basic-map "R" 'viper-overwrite)
|
||||
(define-key viper-vi-basic-map "S" 'viper-substitute-line)
|
||||
(define-key viper-vi-basic-map "T" 'viper-goto-char-backward)
|
||||
(define-key viper-vi-basic-map "U" 'viper-undo)
|
||||
(define-key viper-vi-basic-map "V" 'find-file-other-window)
|
||||
(define-key viper-vi-basic-map "W" 'viper-forward-Word)
|
||||
(define-key viper-vi-basic-map "X" 'viper-delete-backward-char)
|
||||
(define-key viper-vi-basic-map "Y" 'viper-yank-line)
|
||||
(define-key viper-vi-basic-map "ZZ" 'viper-save-kill-buffer)
|
||||
|
||||
(define-key vip-vi-basic-map "\\" 'vip-escape-to-emacs)
|
||||
(define-key vip-vi-basic-map "[" 'vip-brac-function)
|
||||
(define-key vip-vi-basic-map "]" 'vip-ket-function)
|
||||
(define-key vip-vi-basic-map "\C-\\" 'vip-alternate-Meta-key)
|
||||
(define-key vip-vi-basic-map "^" 'vip-bol-and-skip-white)
|
||||
(define-key vip-vi-basic-map "`" 'vip-goto-mark)
|
||||
(define-key viper-vi-basic-map "\\" 'viper-escape-to-emacs)
|
||||
(define-key viper-vi-basic-map "[" 'viper-brac-function)
|
||||
(define-key viper-vi-basic-map "]" 'viper-ket-function)
|
||||
(define-key viper-vi-basic-map "\C-\\" 'viper-alternate-Meta-key)
|
||||
(define-key viper-vi-basic-map "^" 'viper-bol-and-skip-white)
|
||||
(define-key viper-vi-basic-map "`" 'viper-goto-mark)
|
||||
|
||||
(define-key vip-vi-basic-map "a" 'vip-append)
|
||||
(define-key vip-vi-basic-map "b" 'vip-backward-word)
|
||||
(define-key vip-vi-basic-map "c" 'vip-command-argument)
|
||||
(define-key vip-vi-basic-map "d" 'vip-command-argument)
|
||||
(define-key vip-vi-basic-map "e" 'vip-end-of-word)
|
||||
(define-key vip-vi-basic-map "f" 'vip-find-char-forward)
|
||||
(define-key vip-vi-basic-map "g" 'vip-nil)
|
||||
(define-key vip-vi-basic-map "h" 'vip-backward-char)
|
||||
(define-key vip-vi-basic-map "i" 'vip-insert)
|
||||
(define-key vip-vi-basic-map "j" 'vip-next-line)
|
||||
(define-key vip-vi-basic-map "k" 'vip-previous-line)
|
||||
(define-key vip-vi-basic-map "l" 'vip-forward-char)
|
||||
(define-key vip-vi-basic-map "m" 'vip-mark-point)
|
||||
(define-key vip-vi-basic-map "n" 'vip-search-next)
|
||||
(define-key vip-vi-basic-map "o" 'vip-open-line)
|
||||
(define-key vip-vi-basic-map "p" 'vip-put-back)
|
||||
(define-key vip-vi-basic-map "q" 'vip-nil)
|
||||
(define-key vip-vi-basic-map "r" 'vip-replace-char)
|
||||
(define-key vip-vi-basic-map "s" 'vip-substitute)
|
||||
(define-key vip-vi-basic-map "t" 'vip-goto-char-forward)
|
||||
(define-key vip-vi-basic-map "u" 'vip-undo)
|
||||
(define-key vip-vi-basic-map "v" 'find-file)
|
||||
(define-key vip-vi-basic-map "\C-v" 'find-file-other-frame)
|
||||
(define-key vip-vi-basic-map "w" 'vip-forward-word)
|
||||
(define-key vip-vi-basic-map "x" 'vip-delete-char)
|
||||
(define-key vip-vi-basic-map "y" 'vip-command-argument)
|
||||
(define-key vip-vi-basic-map "zH" 'vip-line-to-top)
|
||||
(define-key vip-vi-basic-map "zM" 'vip-line-to-middle)
|
||||
(define-key vip-vi-basic-map "zL" 'vip-line-to-bottom)
|
||||
(define-key vip-vi-basic-map "z\C-m" 'vip-line-to-top)
|
||||
(define-key vip-vi-basic-map "z." 'vip-line-to-middle)
|
||||
(define-key vip-vi-basic-map "z-" 'vip-line-to-bottom)
|
||||
(define-key viper-vi-basic-map "a" 'viper-append)
|
||||
(define-key viper-vi-basic-map "b" 'viper-backward-word)
|
||||
(define-key viper-vi-basic-map "c" 'viper-command-argument)
|
||||
(define-key viper-vi-basic-map "d" 'viper-command-argument)
|
||||
(define-key viper-vi-basic-map "e" 'viper-end-of-word)
|
||||
(define-key viper-vi-basic-map "f" 'viper-find-char-forward)
|
||||
(define-key viper-vi-basic-map "g" 'viper-nil)
|
||||
(define-key viper-vi-basic-map "h" 'viper-backward-char)
|
||||
(define-key viper-vi-basic-map "i" 'viper-insert)
|
||||
(define-key viper-vi-basic-map "j" 'viper-next-line)
|
||||
(define-key viper-vi-basic-map "k" 'viper-previous-line)
|
||||
(define-key viper-vi-basic-map "l" 'viper-forward-char)
|
||||
(define-key viper-vi-basic-map "m" 'viper-mark-point)
|
||||
(define-key viper-vi-basic-map "n" 'viper-search-next)
|
||||
(define-key viper-vi-basic-map "o" 'viper-open-line)
|
||||
(define-key viper-vi-basic-map "p" 'viper-put-back)
|
||||
(define-key viper-vi-basic-map "q" 'viper-nil)
|
||||
(define-key viper-vi-basic-map "r" 'viper-replace-char)
|
||||
(define-key viper-vi-basic-map "s" 'viper-substitute)
|
||||
(define-key viper-vi-basic-map "t" 'viper-goto-char-forward)
|
||||
(define-key viper-vi-basic-map "u" 'viper-undo)
|
||||
(define-key viper-vi-basic-map "v" 'find-file)
|
||||
(define-key viper-vi-basic-map "\C-v" 'find-file-other-frame)
|
||||
(define-key viper-vi-basic-map "w" 'viper-forward-word)
|
||||
(define-key viper-vi-basic-map "x" 'viper-delete-char)
|
||||
(define-key viper-vi-basic-map "y" 'viper-command-argument)
|
||||
(define-key viper-vi-basic-map "zH" 'viper-line-to-top)
|
||||
(define-key viper-vi-basic-map "zM" 'viper-line-to-middle)
|
||||
(define-key viper-vi-basic-map "zL" 'viper-line-to-bottom)
|
||||
(define-key viper-vi-basic-map "z\C-m" 'viper-line-to-top)
|
||||
(define-key viper-vi-basic-map "z." 'viper-line-to-middle)
|
||||
(define-key viper-vi-basic-map "z-" 'viper-line-to-bottom)
|
||||
|
||||
(define-key vip-vi-basic-map "{" 'vip-backward-paragraph)
|
||||
(define-key vip-vi-basic-map "|" 'vip-goto-col)
|
||||
(define-key vip-vi-basic-map "}" 'vip-forward-paragraph)
|
||||
(define-key vip-vi-basic-map "~" 'vip-toggle-case)
|
||||
(define-key vip-vi-basic-map "\C-?" 'vip-backward-char)
|
||||
(define-key vip-vi-basic-map "_" 'vip-nil)
|
||||
(define-key viper-vi-basic-map "{" 'viper-backward-paragraph)
|
||||
(define-key viper-vi-basic-map "|" 'viper-goto-col)
|
||||
(define-key viper-vi-basic-map "}" 'viper-forward-paragraph)
|
||||
(define-key viper-vi-basic-map "~" 'viper-toggle-case)
|
||||
(define-key viper-vi-basic-map "\C-?" 'viper-backward-char)
|
||||
(define-key viper-vi-basic-map "_" 'viper-nil)
|
||||
|
||||
;;; Escape from Emacs to Vi for one command
|
||||
(global-set-key "\C-c\\" 'vip-escape-to-vi) ; everywhere
|
||||
(global-set-key "\C-c\\" 'viper-escape-to-vi) ; everywhere
|
||||
|
||||
;;; This is vip-vi-diehard-map. Used when vip-vi-diehard-minor-mode is on.
|
||||
;;; This is viper-vi-diehard-map. Used when viper-vi-diehard-minor-mode is on.
|
||||
|
||||
(define-key vip-vi-diehard-map "\C-a" 'vip-nil)
|
||||
(define-key vip-vi-diehard-map "\C-c" 'vip-nil)
|
||||
(define-key vip-vi-diehard-map "\C-g" 'vip-info-on-file)
|
||||
(define-key vip-vi-diehard-map "\C-i" 'vip-nil)
|
||||
(define-key vip-vi-diehard-map "\C-k" 'vip-nil)
|
||||
(define-key vip-vi-diehard-map "\C-l" 'redraw-display)
|
||||
(define-key vip-vi-diehard-map "\C-n" 'vip-next-line)
|
||||
(define-key vip-vi-diehard-map "\C-o" 'vip-nil)
|
||||
(define-key vip-vi-diehard-map "\C-p" 'vip-previous-line)
|
||||
(define-key vip-vi-diehard-map "\C-q" 'vip-nil)
|
||||
(define-key vip-vi-diehard-map "\C-r" 'redraw-display)
|
||||
(define-key vip-vi-diehard-map "\C-s" 'vip-nil)
|
||||
(define-key vip-vi-diehard-map "\C-t" 'vip-nil)
|
||||
(define-key vip-vi-diehard-map "\C-v" 'vip-nil)
|
||||
(define-key vip-vi-diehard-map "\C-w" 'vip-nil)
|
||||
(define-key vip-vi-diehard-map "@" 'vip-nil)
|
||||
(define-key vip-vi-diehard-map "_" 'vip-nil)
|
||||
(define-key vip-vi-diehard-map "*" 'vip-nil)
|
||||
(define-key vip-vi-diehard-map "#" 'vip-nil)
|
||||
(define-key vip-vi-diehard-map "\C-_" 'vip-nil)
|
||||
(define-key vip-vi-diehard-map "\C-]" 'vip-nil) ; This is actually tags.
|
||||
(define-key viper-vi-diehard-map "\C-a" 'viper-nil)
|
||||
(define-key viper-vi-diehard-map "\C-c" 'viper-nil)
|
||||
(define-key viper-vi-diehard-map "\C-g" 'viper-info-on-file)
|
||||
(define-key viper-vi-diehard-map "\C-i" 'viper-nil)
|
||||
(define-key viper-vi-diehard-map "\C-k" 'viper-nil)
|
||||
(define-key viper-vi-diehard-map "\C-l" 'redraw-display)
|
||||
(define-key viper-vi-diehard-map "\C-n" 'viper-next-line)
|
||||
(define-key viper-vi-diehard-map "\C-o" 'viper-nil)
|
||||
(define-key viper-vi-diehard-map "\C-p" 'viper-previous-line)
|
||||
(define-key viper-vi-diehard-map "\C-q" 'viper-nil)
|
||||
(define-key viper-vi-diehard-map "\C-r" 'redraw-display)
|
||||
(define-key viper-vi-diehard-map "\C-s" 'viper-nil)
|
||||
(define-key viper-vi-diehard-map "\C-t" 'viper-nil)
|
||||
(define-key viper-vi-diehard-map "\C-v" 'viper-nil)
|
||||
(define-key viper-vi-diehard-map "\C-w" 'viper-nil)
|
||||
(define-key viper-vi-diehard-map "@" 'viper-nil)
|
||||
(define-key viper-vi-diehard-map "_" 'viper-nil)
|
||||
(define-key viper-vi-diehard-map "*" 'viper-nil)
|
||||
(define-key viper-vi-diehard-map "#" 'viper-nil)
|
||||
(define-key viper-vi-diehard-map "\C-_" 'viper-nil)
|
||||
(define-key viper-vi-diehard-map "\C-]" 'viper-nil) ; This is actually tags.
|
||||
|
||||
|
||||
;;; Minibuffer keymap
|
||||
|
||||
|
||||
(defvar vip-minibuffer-map (make-sparse-keymap)
|
||||
(defvar viper-minibuffer-map (make-sparse-keymap)
|
||||
"Keymap used to modify keys when Minibuffer is in Insert state.")
|
||||
|
||||
(define-key vip-minibuffer-map "\C-m" 'vip-exit-minibuffer)
|
||||
(define-key vip-minibuffer-map "\C-j" 'vip-exit-minibuffer)
|
||||
(define-key viper-minibuffer-map "\C-m" 'viper-exit-minibuffer)
|
||||
(define-key viper-minibuffer-map "\C-j" 'viper-exit-minibuffer)
|
||||
|
||||
;; Map used to read Ex-style commands.
|
||||
(defvar vip-ex-cmd-map (make-sparse-keymap))
|
||||
(define-key vip-ex-cmd-map " " 'ex-cmd-read-exit)
|
||||
(define-key vip-ex-cmd-map "\t" 'ex-cmd-complete)
|
||||
(defvar viper-ex-cmd-map (make-sparse-keymap))
|
||||
(define-key viper-ex-cmd-map " " 'ex-cmd-read-exit)
|
||||
(define-key viper-ex-cmd-map "\t" 'ex-cmd-complete)
|
||||
|
||||
;; Keymap for reading file names in Ex-style commands.
|
||||
(defvar ex-read-filename-map (make-sparse-keymap))
|
||||
(define-key ex-read-filename-map " " 'vip-complete-filename-or-exit)
|
||||
(define-key ex-read-filename-map "!" 'vip-handle-!)
|
||||
(define-key ex-read-filename-map " " 'viper-complete-filename-or-exit)
|
||||
(define-key ex-read-filename-map "!" 'viper-handle-!)
|
||||
|
||||
;; Some other maps
|
||||
(defvar vip-slash-and-colon-map (make-sparse-keymap)
|
||||
(defvar viper-slash-and-colon-map (make-sparse-keymap)
|
||||
"This map redefines `/' and `:' to behave as in Vi.
|
||||
Useful in some modes, such as Gnus, MH, etc.")
|
||||
(define-key vip-slash-and-colon-map ":" 'vip-ex)
|
||||
(define-key vip-slash-and-colon-map "/" 'vip-search-forward)
|
||||
(define-key viper-slash-and-colon-map ":" 'viper-ex)
|
||||
(define-key viper-slash-and-colon-map "/" 'viper-search-forward)
|
||||
|
||||
(defvar vip-comint-mode-modifier-map (make-sparse-keymap)
|
||||
(defvar viper-comint-mode-modifier-map (make-sparse-keymap)
|
||||
"This map modifies comint mode.")
|
||||
(define-key vip-comint-mode-modifier-map "\C-m" 'comint-send-input)
|
||||
(define-key vip-comint-mode-modifier-map "\C-d" 'comint-delchar-or-maybe-eof)
|
||||
(define-key viper-comint-mode-modifier-map "\C-m" 'comint-send-input)
|
||||
(define-key viper-comint-mode-modifier-map "\C-d" 'comint-delchar-or-maybe-eof)
|
||||
|
||||
(defvar vip-dired-modifier-map (make-sparse-keymap)
|
||||
(defvar viper-dired-modifier-map (make-sparse-keymap)
|
||||
"This map modifies Dired behavior.")
|
||||
(define-key vip-dired-modifier-map ":" 'vip-ex)
|
||||
(define-key vip-dired-modifier-map "/" 'vip-search-forward)
|
||||
(define-key viper-dired-modifier-map ":" 'viper-ex)
|
||||
(define-key viper-dired-modifier-map "/" 'viper-search-forward)
|
||||
|
||||
(defvar vip-help-modifier-map (make-sparse-keymap)
|
||||
(defvar viper-help-modifier-map (make-sparse-keymap)
|
||||
"This map modifies Help mode behavior.")
|
||||
(define-key vip-help-modifier-map "q" (if vip-xemacs-p 'help-mode-quit))
|
||||
(define-key viper-help-modifier-map "q" (if viper-xemacs-p 'help-mode-quit))
|
||||
|
||||
|
||||
|
||||
;;; Code
|
||||
|
||||
(defun vip-add-local-keys (state alist)
|
||||
(defun viper-add-local-keys (state alist)
|
||||
"Override some vi-state or insert-state bindings in the current buffer.
|
||||
The effect is seen in the current buffer only.
|
||||
Useful for customizing mailer buffers, gnus, etc.
|
||||
|
|
@ -469,64 +469,64 @@ ALIST is of the form ((key . func) (key . func) ...)
|
|||
Normally, this would be called from a hook to a major mode or
|
||||
on a per buffer basis.
|
||||
Usage:
|
||||
(vip-add-local-keys state '((key-str . func) (key-str . func)...)) "
|
||||
(viper-add-local-keys state '((key-str . func) (key-str . func)...)) "
|
||||
|
||||
(let (map)
|
||||
(cond ((eq state 'vi-state)
|
||||
(if vip-need-new-vi-local-map
|
||||
(setq vip-vi-local-user-map (make-sparse-keymap)))
|
||||
(setq vip-need-new-vi-local-map nil
|
||||
map vip-vi-local-user-map))
|
||||
(if viper-need-new-vi-local-map
|
||||
(setq viper-vi-local-user-map (make-sparse-keymap)))
|
||||
(setq viper-need-new-vi-local-map nil
|
||||
map viper-vi-local-user-map))
|
||||
((eq state 'insert-state)
|
||||
(if vip-need-new-insert-local-map
|
||||
(setq vip-insert-local-user-map (make-sparse-keymap)))
|
||||
(setq vip-need-new-insert-local-map nil
|
||||
map vip-insert-local-user-map))
|
||||
(if viper-need-new-insert-local-map
|
||||
(setq viper-insert-local-user-map (make-sparse-keymap)))
|
||||
(setq viper-need-new-insert-local-map nil
|
||||
map viper-insert-local-user-map))
|
||||
((eq state 'emacs-state)
|
||||
(if vip-need-new-emacs-local-map
|
||||
(setq vip-emacs-local-user-map (make-sparse-keymap)))
|
||||
(setq vip-need-new-emacs-local-map nil
|
||||
map vip-emacs-local-user-map))
|
||||
(if viper-need-new-emacs-local-map
|
||||
(setq viper-emacs-local-user-map (make-sparse-keymap)))
|
||||
(setq viper-need-new-emacs-local-map nil
|
||||
map viper-emacs-local-user-map))
|
||||
(t
|
||||
(error
|
||||
"Invalid state in vip-add-local-keys: %S. Valid states: vi-state, insert-state or emacs-state" state)))
|
||||
"Invalid state in viper-add-local-keys: %S. Valid states: vi-state, insert-state or emacs-state" state)))
|
||||
|
||||
(vip-modify-keymap map alist)
|
||||
(vip-normalize-minor-mode-map-alist)
|
||||
(vip-set-mode-vars-for vip-current-state)))
|
||||
(viper-modify-keymap map alist)
|
||||
(viper-normalize-minor-mode-map-alist)
|
||||
(viper-set-mode-vars-for viper-current-state)))
|
||||
|
||||
(defun vip-zap-local-keys ()
|
||||
"Unconditionally reset Viper vip-*-local-user-map's.
|
||||
(defun viper-zap-local-keys ()
|
||||
"Unconditionally reset Viper viper-*-local-user-map's.
|
||||
Rarely useful, but if u made a mistake by switching to a mode that adds
|
||||
undesirable local keys, e.g., comint-mode, then this function can restore
|
||||
sanity."
|
||||
(interactive)
|
||||
(setq vip-vi-local-user-map (make-sparse-keymap)
|
||||
vip-need-new-vi-local-map nil
|
||||
vip-insert-local-user-map (make-sparse-keymap)
|
||||
vip-need-new-insert-local-map nil
|
||||
vip-emacs-local-user-map (make-sparse-keymap)
|
||||
vip-need-new-emacs-local-map nil)
|
||||
(vip-normalize-minor-mode-map-alist))
|
||||
(setq viper-vi-local-user-map (make-sparse-keymap)
|
||||
viper-need-new-vi-local-map nil
|
||||
viper-insert-local-user-map (make-sparse-keymap)
|
||||
viper-need-new-insert-local-map nil
|
||||
viper-emacs-local-user-map (make-sparse-keymap)
|
||||
viper-need-new-emacs-local-map nil)
|
||||
(viper-normalize-minor-mode-map-alist))
|
||||
|
||||
|
||||
(defun vip-modify-major-mode (mode state keymap)
|
||||
(defun viper-modify-major-mode (mode state keymap)
|
||||
"Modify key bindings in a major-mode in a Viper state using a keymap.
|
||||
|
||||
If the default for a major mode is emacs-state, then modifications to this
|
||||
major mode may not take effect until the buffer switches state to Vi,
|
||||
Insert or Emacs. If this happens, add vip-change-state-to-emacs to this
|
||||
Insert or Emacs. If this happens, add viper-change-state-to-emacs to this
|
||||
major mode's hook. If no such hook exists, you may have to put an advice on
|
||||
the function that invokes the major mode. See vip-set-hooks for hints.
|
||||
the function that invokes the major mode. See viper-set-hooks for hints.
|
||||
|
||||
The above needs not to be done for major modes that come up in Vi or Insert
|
||||
state by default.
|
||||
|
||||
Arguments: (major-mode vip-state keymap)"
|
||||
Arguments: (major-mode viper-state keymap)"
|
||||
(let ((alist
|
||||
(cond ((eq state 'vi-state) 'vip-vi-state-modifier-alist)
|
||||
((eq state 'insert-state) 'vip-insert-state-modifier-alist)
|
||||
((eq state 'emacs-state) 'vip-emacs-state-modifier-alist)))
|
||||
(cond ((eq state 'vi-state) 'viper-vi-state-modifier-alist)
|
||||
((eq state 'insert-state) 'viper-insert-state-modifier-alist)
|
||||
((eq state 'emacs-state) 'viper-emacs-state-modifier-alist)))
|
||||
elt)
|
||||
(if (setq elt (assoc mode (eval alist)))
|
||||
(set alist (delq elt (eval alist))))
|
||||
|
|
@ -536,74 +536,74 @@ Arguments: (major-mode vip-state keymap)"
|
|||
;; normalize in the actual buffer where changes to the keymap are
|
||||
;; to take place. However, it doesn't hurt, and it helps whenever this
|
||||
;; function is actually called from within the right buffer.
|
||||
(vip-normalize-minor-mode-map-alist)
|
||||
(viper-normalize-minor-mode-map-alist)
|
||||
|
||||
(vip-set-mode-vars-for vip-current-state)))
|
||||
(viper-set-mode-vars-for viper-current-state)))
|
||||
|
||||
|
||||
;; Displays variables that control Viper's keymaps
|
||||
(defun vip-debug-keymaps ()
|
||||
(defun viper-debug-keymaps ()
|
||||
(interactive)
|
||||
(with-output-to-temp-buffer " *vip-debug*"
|
||||
(with-output-to-temp-buffer " *viper-debug*"
|
||||
(princ (format "Buffer name: %s\n\n" (buffer-name)))
|
||||
(princ "Variables: \n")
|
||||
(princ (format "major-mode: %S\n" major-mode))
|
||||
(princ (format "vip-current-state: %S\n" vip-current-state))
|
||||
(princ (format "vip-mode-string: %S\n\n" vip-mode-string))
|
||||
(princ (format "vip-vi-intercept-minor-mode: %S\n"
|
||||
vip-vi-intercept-minor-mode))
|
||||
(princ (format "vip-insert-intercept-minor-mode: %S\n"
|
||||
vip-insert-intercept-minor-mode))
|
||||
(princ (format "vip-emacs-intercept-minor-mode: %S\n"
|
||||
vip-emacs-intercept-minor-mode))
|
||||
(princ (format "vip-vi-minibuffer-minor-mode: %S\n"
|
||||
vip-vi-minibuffer-minor-mode))
|
||||
(princ (format "vip-insert-minibuffer-minor-mode: %S\n\n"
|
||||
vip-insert-minibuffer-minor-mode))
|
||||
(princ (format "vip-vi-local-user-minor-mode: %S\n"
|
||||
vip-vi-local-user-minor-mode))
|
||||
(princ (format "vip-vi-global-user-minor-mode: %S\n"
|
||||
vip-vi-global-user-minor-mode))
|
||||
(princ (format "vip-vi-kbd-minor-mode: %S\n" vip-vi-kbd-minor-mode))
|
||||
(princ (format "vip-vi-state-modifier-minor-mode: %S\n"
|
||||
vip-vi-state-modifier-minor-mode))
|
||||
(princ (format "vip-vi-diehard-minor-mode: %S\n"
|
||||
vip-vi-diehard-minor-mode))
|
||||
(princ (format "vip-vi-basic-minor-mode: %S\n" vip-vi-basic-minor-mode))
|
||||
(princ (format "vip-replace-minor-mode: %S\n" vip-replace-minor-mode))
|
||||
(princ (format "vip-insert-local-user-minor-mode: %S\n"
|
||||
vip-insert-local-user-minor-mode))
|
||||
(princ (format "vip-insert-global-user-minor-mode: %S\n"
|
||||
vip-insert-global-user-minor-mode))
|
||||
(princ (format "vip-insert-kbd-minor-mode: %S\n"
|
||||
vip-insert-kbd-minor-mode))
|
||||
(princ (format "vip-insert-state-modifier-minor-mode: %S\n"
|
||||
vip-insert-state-modifier-minor-mode))
|
||||
(princ (format "vip-insert-diehard-minor-mode: %S\n"
|
||||
vip-insert-diehard-minor-mode))
|
||||
(princ (format "vip-insert-basic-minor-mode: %S\n"
|
||||
vip-insert-basic-minor-mode))
|
||||
(princ (format "vip-emacs-local-user-minor-mode: %S\n"
|
||||
vip-emacs-local-user-minor-mode))
|
||||
(princ (format "vip-emacs-kbd-minor-mode: %S\n"
|
||||
vip-emacs-kbd-minor-mode))
|
||||
(princ (format "vip-emacs-global-user-minor-mode: %S\n"
|
||||
vip-emacs-global-user-minor-mode))
|
||||
(princ (format "vip-emacs-state-modifier-minor-mode: %S\n"
|
||||
vip-emacs-state-modifier-minor-mode))
|
||||
(princ (format "viper-current-state: %S\n" viper-current-state))
|
||||
(princ (format "viper-mode-string: %S\n\n" viper-mode-string))
|
||||
(princ (format "viper-vi-intercept-minor-mode: %S\n"
|
||||
viper-vi-intercept-minor-mode))
|
||||
(princ (format "viper-insert-intercept-minor-mode: %S\n"
|
||||
viper-insert-intercept-minor-mode))
|
||||
(princ (format "viper-emacs-intercept-minor-mode: %S\n"
|
||||
viper-emacs-intercept-minor-mode))
|
||||
(princ (format "viper-vi-minibuffer-minor-mode: %S\n"
|
||||
viper-vi-minibuffer-minor-mode))
|
||||
(princ (format "viper-insert-minibuffer-minor-mode: %S\n\n"
|
||||
viper-insert-minibuffer-minor-mode))
|
||||
(princ (format "viper-vi-local-user-minor-mode: %S\n"
|
||||
viper-vi-local-user-minor-mode))
|
||||
(princ (format "viper-vi-global-user-minor-mode: %S\n"
|
||||
viper-vi-global-user-minor-mode))
|
||||
(princ (format "viper-vi-kbd-minor-mode: %S\n" viper-vi-kbd-minor-mode))
|
||||
(princ (format "viper-vi-state-modifier-minor-mode: %S\n"
|
||||
viper-vi-state-modifier-minor-mode))
|
||||
(princ (format "viper-vi-diehard-minor-mode: %S\n"
|
||||
viper-vi-diehard-minor-mode))
|
||||
(princ (format "viper-vi-basic-minor-mode: %S\n" viper-vi-basic-minor-mode))
|
||||
(princ (format "viper-replace-minor-mode: %S\n" viper-replace-minor-mode))
|
||||
(princ (format "viper-insert-local-user-minor-mode: %S\n"
|
||||
viper-insert-local-user-minor-mode))
|
||||
(princ (format "viper-insert-global-user-minor-mode: %S\n"
|
||||
viper-insert-global-user-minor-mode))
|
||||
(princ (format "viper-insert-kbd-minor-mode: %S\n"
|
||||
viper-insert-kbd-minor-mode))
|
||||
(princ (format "viper-insert-state-modifier-minor-mode: %S\n"
|
||||
viper-insert-state-modifier-minor-mode))
|
||||
(princ (format "viper-insert-diehard-minor-mode: %S\n"
|
||||
viper-insert-diehard-minor-mode))
|
||||
(princ (format "viper-insert-basic-minor-mode: %S\n"
|
||||
viper-insert-basic-minor-mode))
|
||||
(princ (format "viper-emacs-local-user-minor-mode: %S\n"
|
||||
viper-emacs-local-user-minor-mode))
|
||||
(princ (format "viper-emacs-kbd-minor-mode: %S\n"
|
||||
viper-emacs-kbd-minor-mode))
|
||||
(princ (format "viper-emacs-global-user-minor-mode: %S\n"
|
||||
viper-emacs-global-user-minor-mode))
|
||||
(princ (format "viper-emacs-state-modifier-minor-mode: %S\n"
|
||||
viper-emacs-state-modifier-minor-mode))
|
||||
|
||||
(princ (format "\nviper-expert-level %S\n" viper-expert-level))
|
||||
(princ (format "vip-no-multiple-ESC %S\n" vip-no-multiple-ESC))
|
||||
(princ (format "viper-no-multiple-ESC %S\n" viper-no-multiple-ESC))
|
||||
(princ (format "viper-always %S\n" viper-always))
|
||||
(princ (format "vip-ex-style-motion %S\n"
|
||||
vip-ex-style-motion))
|
||||
(princ (format "vip-ex-style-editing-in-insert %S\n"
|
||||
vip-ex-style-editing-in-insert))
|
||||
(princ (format "vip-want-emacs-keys-in-vi %S\n"
|
||||
vip-want-emacs-keys-in-vi))
|
||||
(princ (format "vip-want-emacs-keys-in-insert %S\n"
|
||||
vip-want-emacs-keys-in-insert))
|
||||
(princ (format "vip-want-ctl-h-help %S\n" vip-want-ctl-h-help))
|
||||
(princ (format "viper-ex-style-motion %S\n"
|
||||
viper-ex-style-motion))
|
||||
(princ (format "viper-ex-style-editing-in-insert %S\n"
|
||||
viper-ex-style-editing-in-insert))
|
||||
(princ (format "viper-want-emacs-keys-in-vi %S\n"
|
||||
viper-want-emacs-keys-in-vi))
|
||||
(princ (format "viper-want-emacs-keys-in-insert %S\n"
|
||||
viper-want-emacs-keys-in-insert))
|
||||
(princ (format "viper-want-ctl-h-help %S\n" viper-want-ctl-h-help))
|
||||
|
||||
(princ "\n\n\n")
|
||||
(princ (format "Default value for minor-mode-map-alist: \n%S\n\n"
|
||||
|
|
@ -615,9 +615,9 @@ Arguments: (major-mode vip-state keymap)"
|
|||
|
||||
;;; Keymap utils
|
||||
|
||||
(defun vip-add-keymap (mapsrc mapdst)
|
||||
(defun viper-add-keymap (mapsrc mapdst)
|
||||
"Add contents of mapsrc to mapdst. It is assumed that mapsrc is sparse."
|
||||
(if vip-xemacs-p
|
||||
(if viper-xemacs-p
|
||||
(map-keymap (function (lambda (key binding)
|
||||
(define-key mapdst key binding)))
|
||||
mapsrc)
|
||||
|
|
@ -627,7 +627,7 @@ Arguments: (major-mode vip-state keymap)"
|
|||
))
|
||||
(cdr mapsrc))))
|
||||
|
||||
(defun vip-modify-keymap (map alist)
|
||||
(defun viper-modify-keymap (map alist)
|
||||
"Modifies MAP with bindings specified in the ALIST. The alist has the
|
||||
form ((key . function) (key . function) ... )."
|
||||
(mapcar (function (lambda (p)
|
||||
|
|
@ -636,7 +636,7 @@ form ((key . function) (key . function) ... )."
|
|||
|
||||
|
||||
;;; Local Variables:
|
||||
;;; eval: (put 'vip-deflocalvar 'lisp-indent-hook 'defun)
|
||||
;;; eval: (put 'viper-deflocalvar 'lisp-indent-hook 'defun)
|
||||
;;; End:
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -24,10 +24,10 @@
|
|||
(provide 'viper-macs)
|
||||
|
||||
;; compiler pacifier
|
||||
(defvar vip-ex-work-buf)
|
||||
(defvar vip-custom-file-name)
|
||||
(defvar vip-current-state)
|
||||
(defvar vip-fast-keyseq-timeout)
|
||||
(defvar viper-ex-work-buf)
|
||||
(defvar viper-custom-file-name)
|
||||
(defvar viper-current-state)
|
||||
(defvar viper-fast-keyseq-timeout)
|
||||
|
||||
;; loading happens only in non-interactive compilation
|
||||
;; in order to spare non-viperized emacs from being viperized
|
||||
|
|
@ -52,27 +52,27 @@
|
|||
;;; Variables
|
||||
|
||||
;; Register holding last macro.
|
||||
(defvar vip-last-macro-reg nil)
|
||||
(defvar viper-last-macro-reg nil)
|
||||
|
||||
;; format of the elements of kbd alists:
|
||||
;; (name ((buf . macr)...(buf . macr)) ((maj-mode . macr)...) (t . macr))
|
||||
;; kbd macro alist for Vi state
|
||||
(defvar vip-vi-kbd-macro-alist nil)
|
||||
(defvar viper-vi-kbd-macro-alist nil)
|
||||
;; same for insert/replace state
|
||||
(defvar vip-insert-kbd-macro-alist nil)
|
||||
(defvar viper-insert-kbd-macro-alist nil)
|
||||
;; same for emacs state
|
||||
(defvar vip-emacs-kbd-macro-alist nil)
|
||||
(defvar viper-emacs-kbd-macro-alist nil)
|
||||
|
||||
;; Internal var that passes info between start-kbd-macro and end-kbd-macro
|
||||
;; in :map and :map!
|
||||
(defvar vip-kbd-macro-parameters nil)
|
||||
(defvar viper-kbd-macro-parameters nil)
|
||||
|
||||
(defvar vip-this-kbd-macro nil
|
||||
(defvar viper-this-kbd-macro nil
|
||||
"Vector of keys representing the name of currently running Viper kbd macro.")
|
||||
(defvar vip-last-kbd-macro nil
|
||||
(defvar viper-last-kbd-macro nil
|
||||
"Vector of keys representing the name of last Viper keyboard macro.")
|
||||
|
||||
(defcustom vip-repeat-from-history-key 'f12
|
||||
(defcustom viper-repeat-from-history-key 'f12
|
||||
"Prefix key for accessing previously typed Vi commands.
|
||||
|
||||
The previous command is accessible, as usual, via `.'. The command before this
|
||||
|
|
@ -93,7 +93,7 @@ a key is a symbol, e.g., `a', `\\1', `f2', etc., or a list, e.g.,
|
|||
(let ((mod-char "")
|
||||
macro-name macro-body map-args ins)
|
||||
(save-window-excursion
|
||||
(set-buffer vip-ex-work-buf)
|
||||
(set-buffer viper-ex-work-buf)
|
||||
(if (looking-at "!")
|
||||
(progn
|
||||
(setq ins t
|
||||
|
|
@ -102,19 +102,19 @@ a key is a symbol, e.g., `a', `\\1', `f2', etc., or a list, e.g.,
|
|||
(setq map-args (ex-map-read-args mod-char)
|
||||
macro-name (car map-args)
|
||||
macro-body (cdr map-args))
|
||||
(setq vip-kbd-macro-parameters (list ins mod-char macro-name macro-body))
|
||||
(setq viper-kbd-macro-parameters (list ins mod-char macro-name macro-body))
|
||||
(if macro-body
|
||||
(vip-end-mapping-kbd-macro 'ignore)
|
||||
(viper-end-mapping-kbd-macro 'ignore)
|
||||
(ex-fixup-history (format "map%s %S" mod-char
|
||||
(vip-display-macro macro-name)))
|
||||
(viper-display-macro macro-name)))
|
||||
;; if defining macro for insert, switch there for authentic WYSIWYG
|
||||
(if ins (vip-change-state-to-insert))
|
||||
(if ins (viper-change-state-to-insert))
|
||||
(start-kbd-macro nil)
|
||||
(define-key vip-vi-intercept-map "\C-x)" 'vip-end-mapping-kbd-macro)
|
||||
(define-key vip-insert-intercept-map "\C-x)" 'vip-end-mapping-kbd-macro)
|
||||
(define-key vip-emacs-intercept-map "\C-x)" 'vip-end-mapping-kbd-macro)
|
||||
(define-key viper-vi-intercept-map "\C-x)" 'viper-end-mapping-kbd-macro)
|
||||
(define-key viper-insert-intercept-map "\C-x)" 'viper-end-mapping-kbd-macro)
|
||||
(define-key viper-emacs-intercept-map "\C-x)" 'viper-end-mapping-kbd-macro)
|
||||
(message "Mapping %S in %s state. Hit `C-x )' to complete the mapping"
|
||||
(vip-display-macro macro-name)
|
||||
(viper-display-macro macro-name)
|
||||
(if ins "Insert" "Vi")))
|
||||
))
|
||||
|
||||
|
|
@ -124,7 +124,7 @@ a key is a symbol, e.g., `a', `\\1', `f2', etc., or a list, e.g.,
|
|||
(let ((mod-char "")
|
||||
temp macro-name ins)
|
||||
(save-window-excursion
|
||||
(set-buffer vip-ex-work-buf)
|
||||
(set-buffer viper-ex-work-buf)
|
||||
(if (looking-at "!")
|
||||
(progn
|
||||
(setq ins t
|
||||
|
|
@ -132,10 +132,10 @@ a key is a symbol, e.g., `a', `\\1', `f2', etc., or a list, e.g.,
|
|||
(forward-char 1))))
|
||||
|
||||
(setq macro-name (ex-unmap-read-args mod-char))
|
||||
(setq temp (vip-fixup-macro (vconcat macro-name))) ;; copy and fixup
|
||||
(setq temp (viper-fixup-macro (vconcat macro-name))) ;; copy and fixup
|
||||
(ex-fixup-history (format "unmap%s %S" mod-char
|
||||
(vip-display-macro temp)))
|
||||
(vip-unrecord-kbd-macro macro-name (if ins 'insert-state 'vi-state))
|
||||
(viper-display-macro temp)))
|
||||
(viper-unrecord-kbd-macro macro-name (if ins 'insert-state 'vi-state))
|
||||
))
|
||||
|
||||
|
||||
|
|
@ -179,31 +179,31 @@ a key is a symbol, e.g., `a', `\\1', `f2', etc., or a list, e.g.,
|
|||
(format
|
||||
":map%s %s"
|
||||
variant (if (> (length key-seq) 0)
|
||||
(prin1-to-string (vip-display-macro key-seq))
|
||||
(prin1-to-string (viper-display-macro key-seq))
|
||||
"")))
|
||||
(message message)
|
||||
(setq event (vip-read-key))
|
||||
;;(setq event (vip-read-event))
|
||||
(setq event (viper-read-key))
|
||||
;;(setq event (viper-read-event))
|
||||
(setq key
|
||||
(if (vip-mouse-event-p event)
|
||||
(if (viper-mouse-event-p event)
|
||||
(progn
|
||||
(message "%s (No mouse---only keyboard keys, please)"
|
||||
message)
|
||||
(sit-for 2)
|
||||
nil)
|
||||
(vip-event-key event)))
|
||||
(viper-event-key event)))
|
||||
)
|
||||
(setq macro-name key-seq))
|
||||
|
||||
(if (= (length macro-name) 0)
|
||||
(error "Can't map an empty macro name"))
|
||||
(setq macro-name (vip-fixup-macro macro-name))
|
||||
(if (vip-char-array-p macro-name)
|
||||
(setq macro-name (vip-char-array-to-macro macro-name)))
|
||||
(setq macro-name (viper-fixup-macro macro-name))
|
||||
(if (viper-char-array-p macro-name)
|
||||
(setq macro-name (viper-char-array-to-macro macro-name)))
|
||||
|
||||
(if macro-body
|
||||
(cond ((vip-char-array-p macro-body)
|
||||
(setq macro-body (vip-char-array-to-macro macro-body)))
|
||||
(cond ((viper-char-array-p macro-body)
|
||||
(setq macro-body (viper-char-array-to-macro macro-body)))
|
||||
((vectorp macro-body) nil)
|
||||
(t (error "map: Invalid syntax in macro definition"))))
|
||||
(setq cursor-in-echo-area nil)(sit-for 0) ; this overcomes xemacs tty bug
|
||||
|
|
@ -215,14 +215,14 @@ a key is a symbol, e.g., `a', `\\1', `f2', etc., or a list, e.g.,
|
|||
(defun ex-unmap-read-args (variant)
|
||||
(let ((cursor-in-echo-area t)
|
||||
(macro-alist (if (string= variant "!")
|
||||
vip-insert-kbd-macro-alist
|
||||
vip-vi-kbd-macro-alist))
|
||||
viper-insert-kbd-macro-alist
|
||||
viper-vi-kbd-macro-alist))
|
||||
;; these are disabled just in case, to avoid surprises when doing
|
||||
;; completing-read
|
||||
vip-vi-kbd-minor-mode vip-insert-kbd-minor-mode
|
||||
vip-emacs-kbd-minor-mode
|
||||
vip-vi-intercept-minor-mode vip-insert-intercept-minor-mode
|
||||
vip-emacs-intercept-minor-mode
|
||||
viper-vi-kbd-minor-mode viper-insert-kbd-minor-mode
|
||||
viper-emacs-kbd-minor-mode
|
||||
viper-vi-intercept-minor-mode viper-insert-intercept-minor-mode
|
||||
viper-emacs-intercept-minor-mode
|
||||
event message
|
||||
key key-seq macro-name)
|
||||
(setq macro-name (ex-get-inline-cmd-args ".*unma?p?[!]*[ \t]*"))
|
||||
|
|
@ -246,29 +246,29 @@ a key is a symbol, e.g., `a', `\\1', `f2', etc., or a list, e.g.,
|
|||
":unmap%s %s"
|
||||
variant (if (> (length key-seq) 0)
|
||||
(prin1-to-string
|
||||
(vip-display-macro key-seq))
|
||||
(viper-display-macro key-seq))
|
||||
"")))
|
||||
(setq key-seq
|
||||
(vip-do-sequence-completion key-seq macro-alist message))
|
||||
(viper-do-sequence-completion key-seq macro-alist message))
|
||||
))
|
||||
(setq message
|
||||
(format
|
||||
":unmap%s %s"
|
||||
variant (if (> (length key-seq) 0)
|
||||
(prin1-to-string
|
||||
(vip-display-macro key-seq))
|
||||
(viper-display-macro key-seq))
|
||||
"")))
|
||||
(message message)
|
||||
(setq event (vip-read-key))
|
||||
;;(setq event (vip-read-event))
|
||||
(setq event (viper-read-key))
|
||||
;;(setq event (viper-read-event))
|
||||
(setq key
|
||||
(if (vip-mouse-event-p event)
|
||||
(if (viper-mouse-event-p event)
|
||||
(progn
|
||||
(message "%s (No mouse---only keyboard keys, please)"
|
||||
message)
|
||||
(sit-for 2)
|
||||
nil)
|
||||
(vip-event-key event)))
|
||||
(viper-event-key event)))
|
||||
)
|
||||
(setq macro-name key-seq))
|
||||
|
||||
|
|
@ -286,35 +286,35 @@ a key is a symbol, e.g., `a', `\\1', `f2', etc., or a list, e.g.,
|
|||
;; optional argument IGNORE, if t, indicates that we are dealing with an
|
||||
;; existing macro that needs to be registered, but there is no need to
|
||||
;; terminate a kbd macro.
|
||||
(defun vip-end-mapping-kbd-macro (&optional ignore)
|
||||
(defun viper-end-mapping-kbd-macro (&optional ignore)
|
||||
(interactive)
|
||||
(define-key vip-vi-intercept-map "\C-x)" nil)
|
||||
(define-key vip-insert-intercept-map "\C-x)" nil)
|
||||
(define-key vip-emacs-intercept-map "\C-x)" nil)
|
||||
(define-key viper-vi-intercept-map "\C-x)" nil)
|
||||
(define-key viper-insert-intercept-map "\C-x)" nil)
|
||||
(define-key viper-emacs-intercept-map "\C-x)" nil)
|
||||
(if (and (not ignore)
|
||||
(or (not vip-kbd-macro-parameters)
|
||||
(or (not viper-kbd-macro-parameters)
|
||||
(not defining-kbd-macro)))
|
||||
(error "Not mapping a kbd-macro"))
|
||||
(let ((mod-char (nth 1 vip-kbd-macro-parameters))
|
||||
(ins (nth 0 vip-kbd-macro-parameters))
|
||||
(macro-name (nth 2 vip-kbd-macro-parameters))
|
||||
(macro-body (nth 3 vip-kbd-macro-parameters)))
|
||||
(setq vip-kbd-macro-parameters nil)
|
||||
(let ((mod-char (nth 1 viper-kbd-macro-parameters))
|
||||
(ins (nth 0 viper-kbd-macro-parameters))
|
||||
(macro-name (nth 2 viper-kbd-macro-parameters))
|
||||
(macro-body (nth 3 viper-kbd-macro-parameters)))
|
||||
(setq viper-kbd-macro-parameters nil)
|
||||
(or ignore
|
||||
(progn
|
||||
(end-kbd-macro nil)
|
||||
(setq macro-body (vip-events-to-macro last-kbd-macro))
|
||||
(setq macro-body (viper-events-to-macro last-kbd-macro))
|
||||
;; always go back to Vi, since this is where we started
|
||||
;; defining macro
|
||||
(vip-change-state-to-vi)))
|
||||
(viper-change-state-to-vi)))
|
||||
|
||||
(vip-record-kbd-macro macro-name
|
||||
(viper-record-kbd-macro macro-name
|
||||
(if ins 'insert-state 'vi-state)
|
||||
(vip-display-macro macro-body))
|
||||
(viper-display-macro macro-body))
|
||||
|
||||
(ex-fixup-history (format "map%s %S %S" mod-char
|
||||
(vip-display-macro macro-name)
|
||||
(vip-display-macro macro-body)))
|
||||
(viper-display-macro macro-name)
|
||||
(viper-display-macro macro-body)))
|
||||
))
|
||||
|
||||
|
||||
|
|
@ -325,8 +325,8 @@ a key is a symbol, e.g., `a', `\\1', `f2', etc., or a list, e.g.,
|
|||
;; accepts as macro names: strings and vectors.
|
||||
;; strings must be strings of characters; vectors must be vectors of keys
|
||||
;; in canonic form. the canonic form is essentially the form used in XEmacs
|
||||
(defun vip-record-kbd-macro (macro-name state macro-body &optional scope)
|
||||
"Record a Vi macro. Can be used in `.vip' file to define permanent macros.
|
||||
(defun viper-record-kbd-macro (macro-name state macro-body &optional scope)
|
||||
"Record a Vi macro. Can be used in `.viper' file to define permanent macros.
|
||||
MACRO-NAME is a string of characters or a vector of keys. STATE is
|
||||
either `vi-state' or `insert-state'. It specifies the Viper state in which to
|
||||
define the macro. MACRO-BODY is a string that represents the keyboard macro.
|
||||
|
|
@ -337,16 +337,16 @@ If SCOPE is nil, the user is asked to specify the scope."
|
|||
(macro-alist-var
|
||||
(cond ((eq state 'vi-state)
|
||||
(setq state-name "Vi state"
|
||||
keymap vip-vi-kbd-map)
|
||||
'vip-vi-kbd-macro-alist)
|
||||
keymap viper-vi-kbd-map)
|
||||
'viper-vi-kbd-macro-alist)
|
||||
((memq state '(insert-state replace-state))
|
||||
(setq state-name "Insert state"
|
||||
keymap vip-insert-kbd-map)
|
||||
'vip-insert-kbd-macro-alist)
|
||||
keymap viper-insert-kbd-map)
|
||||
'viper-insert-kbd-macro-alist)
|
||||
(t
|
||||
(setq state-name "Emacs state"
|
||||
keymap vip-emacs-kbd-map)
|
||||
'vip-emacs-kbd-macro-alist)
|
||||
keymap viper-emacs-kbd-map)
|
||||
'viper-emacs-kbd-macro-alist)
|
||||
))
|
||||
new-elt old-elt old-sub-elt msg
|
||||
temp lis lis2)
|
||||
|
|
@ -355,13 +355,13 @@ If SCOPE is nil, the user is asked to specify the scope."
|
|||
(error "Can't map an empty macro name"))
|
||||
|
||||
;; Macro-name is usually a vector. However, command history or macros
|
||||
;; recorded in ~/.vip may be recorded as strings. So, convert to vectors.
|
||||
(setq macro-name (vip-fixup-macro macro-name))
|
||||
(if (vip-char-array-p macro-name)
|
||||
(setq macro-name (vip-char-array-to-macro macro-name)))
|
||||
(setq macro-body (vip-fixup-macro macro-body))
|
||||
(if (vip-char-array-p macro-body)
|
||||
(setq macro-body (vip-char-array-to-macro macro-body)))
|
||||
;; recorded in ~/.viper may be recorded as strings. So, convert to vectors.
|
||||
(setq macro-name (viper-fixup-macro macro-name))
|
||||
(if (viper-char-array-p macro-name)
|
||||
(setq macro-name (viper-char-array-to-macro macro-name)))
|
||||
(setq macro-body (viper-fixup-macro macro-body))
|
||||
(if (viper-char-array-p macro-body)
|
||||
(setq macro-body (viper-char-array-to-macro macro-body)))
|
||||
|
||||
;; don't ask if scope is given and is of the right type
|
||||
(or (eq scope t)
|
||||
|
|
@ -377,11 +377,11 @@ If SCOPE is nil, the user is asked to specify the scope."
|
|||
(setq msg
|
||||
(format
|
||||
"%S is mapped to %s for %s in `%s'"
|
||||
(vip-display-macro macro-name)
|
||||
(vip-abbreviate-string
|
||||
(viper-display-macro macro-name)
|
||||
(viper-abbreviate-string
|
||||
(format
|
||||
"%S"
|
||||
(setq temp (vip-display-macro macro-body)))
|
||||
(setq temp (viper-display-macro macro-body)))
|
||||
14 "" ""
|
||||
(if (stringp temp) " ....\"" " ....]"))
|
||||
state-name (buffer-name)))
|
||||
|
|
@ -393,11 +393,11 @@ If SCOPE is nil, the user is asked to specify the scope."
|
|||
(setq msg
|
||||
(format
|
||||
"%S is mapped to %s for %s in `%S'"
|
||||
(vip-display-macro macro-name)
|
||||
(vip-abbreviate-string
|
||||
(viper-display-macro macro-name)
|
||||
(viper-abbreviate-string
|
||||
(format
|
||||
"%S"
|
||||
(setq temp (vip-display-macro macro-body)))
|
||||
(setq temp (viper-display-macro macro-body)))
|
||||
14 "" ""
|
||||
(if (stringp macro-body) " ....\"" " ....]"))
|
||||
state-name major-mode))
|
||||
|
|
@ -406,33 +406,33 @@ If SCOPE is nil, the user is asked to specify the scope."
|
|||
(setq msg
|
||||
(format
|
||||
"%S is globally mapped to %s in %s"
|
||||
(vip-display-macro macro-name)
|
||||
(vip-abbreviate-string
|
||||
(viper-display-macro macro-name)
|
||||
(viper-abbreviate-string
|
||||
(format
|
||||
"%S"
|
||||
(setq temp (vip-display-macro macro-body)))
|
||||
(setq temp (viper-display-macro macro-body)))
|
||||
14 "" ""
|
||||
(if (stringp macro-body) " ....\"" " ....]"))
|
||||
state-name))
|
||||
t)))
|
||||
(if (y-or-n-p
|
||||
(format "Save this macro in %s? "
|
||||
(vip-abbreviate-file-name vip-custom-file-name)))
|
||||
(vip-save-string-in-file
|
||||
(format "\n(vip-record-kbd-macro %S '%S %s '%S)"
|
||||
(vip-display-macro macro-name)
|
||||
(viper-abbreviate-file-name viper-custom-file-name)))
|
||||
(viper-save-string-in-file
|
||||
(format "\n(viper-record-kbd-macro %S '%S %s '%S)"
|
||||
(viper-display-macro macro-name)
|
||||
state
|
||||
;; if we don't let vector macro-body through %S,
|
||||
;; the symbols `\.' `\[' etc will be converted into
|
||||
;; characters, causing invalid read error on recorded
|
||||
;; macros in .vip.
|
||||
;; macros in .viper.
|
||||
;; I am not sure is macro-body can still be a string at
|
||||
;; this point, but I am preserving this option anyway.
|
||||
(if (vectorp macro-body)
|
||||
(format "%S" macro-body)
|
||||
macro-body)
|
||||
scope)
|
||||
vip-custom-file-name))
|
||||
viper-custom-file-name))
|
||||
|
||||
(message msg)
|
||||
))
|
||||
|
|
@ -451,11 +451,11 @@ If SCOPE is nil, the user is asked to specify the scope."
|
|||
;; insert new-elt in macro-alist-var and keep the list sorted
|
||||
(define-key
|
||||
keymap
|
||||
(vector (vip-key-to-emacs-key (aref macro-name 0)))
|
||||
'vip-exec-mapped-kbd-macro)
|
||||
(vector (viper-key-to-emacs-key (aref macro-name 0)))
|
||||
'viper-exec-mapped-kbd-macro)
|
||||
(setq lis (eval macro-alist-var))
|
||||
(while (and lis (string< (vip-array-to-string (car (car lis)))
|
||||
(vip-array-to-string macro-name)))
|
||||
(while (and lis (string< (viper-array-to-string (car (car lis)))
|
||||
(viper-array-to-string macro-name)))
|
||||
(setq lis2 (cons (car lis) lis2))
|
||||
(setq lis (cdr lis)))
|
||||
|
||||
|
|
@ -463,90 +463,90 @@ If SCOPE is nil, the user is asked to specify the scope."
|
|||
(set macro-alist-var (append lis2 (cons new-elt lis)))
|
||||
(setq old-elt new-elt)))
|
||||
(setq old-sub-elt
|
||||
(cond ((eq scope t) (vip-kbd-global-pair old-elt))
|
||||
((symbolp scope) (assoc scope (vip-kbd-mode-alist old-elt)))
|
||||
((stringp scope) (assoc scope (vip-kbd-buf-alist old-elt)))))
|
||||
(cond ((eq scope t) (viper-kbd-global-pair old-elt))
|
||||
((symbolp scope) (assoc scope (viper-kbd-mode-alist old-elt)))
|
||||
((stringp scope) (assoc scope (viper-kbd-buf-alist old-elt)))))
|
||||
(if old-sub-elt
|
||||
(setcdr old-sub-elt macro-body)
|
||||
(cond ((symbolp scope) (setcar (cdr (cdr old-elt))
|
||||
(cons (cons scope macro-body)
|
||||
(vip-kbd-mode-alist old-elt))))
|
||||
(viper-kbd-mode-alist old-elt))))
|
||||
((stringp scope) (setcar (cdr old-elt)
|
||||
(cons (cons scope macro-body)
|
||||
(vip-kbd-buf-alist old-elt))))))
|
||||
(viper-kbd-buf-alist old-elt))))))
|
||||
))
|
||||
|
||||
|
||||
|
||||
;; macro name must be a vector of vip-style keys
|
||||
(defun vip-unrecord-kbd-macro (macro-name state)
|
||||
;; macro name must be a vector of viper-style keys
|
||||
(defun viper-unrecord-kbd-macro (macro-name state)
|
||||
"Delete macro MACRO-NAME from Viper STATE.
|
||||
MACRO-NAME must be a vector of vip-style keys. This command is used by Viper
|
||||
internally, but the user can also use it in ~/.vip to delete pre-defined macros
|
||||
supplied with Viper. The best way to avoid mistakes in macro names to be passed
|
||||
to this function is to use vip-describe-kbd-macros and copy the name from
|
||||
there."
|
||||
MACRO-NAME must be a vector of viper-style keys. This command is used by Viper
|
||||
internally, but the user can also use it in ~/.viper to delete pre-defined
|
||||
macros supplied with Viper. The best way to avoid mistakes in macro names to be
|
||||
passed to this function is to use viper-describe-kbd-macros and copy the name
|
||||
from there."
|
||||
(let* (state-name keymap
|
||||
(macro-alist-var
|
||||
(cond ((eq state 'vi-state)
|
||||
(setq state-name "Vi state"
|
||||
keymap vip-vi-kbd-map)
|
||||
'vip-vi-kbd-macro-alist)
|
||||
keymap viper-vi-kbd-map)
|
||||
'viper-vi-kbd-macro-alist)
|
||||
((memq state '(insert-state replace-state))
|
||||
(setq state-name "Insert state"
|
||||
keymap vip-insert-kbd-map)
|
||||
'vip-insert-kbd-macro-alist)
|
||||
keymap viper-insert-kbd-map)
|
||||
'viper-insert-kbd-macro-alist)
|
||||
(t
|
||||
(setq state-name "Emacs state"
|
||||
keymap vip-emacs-kbd-map)
|
||||
'vip-emacs-kbd-macro-alist)
|
||||
keymap viper-emacs-kbd-map)
|
||||
'viper-emacs-kbd-macro-alist)
|
||||
))
|
||||
buf-mapping mode-mapping global-mapping
|
||||
macro-pair macro-entry)
|
||||
|
||||
;; Macro-name is usually a vector. However, command history or macros
|
||||
;; recorded in ~/.vip may appear as strings. So, convert to vectors.
|
||||
(setq macro-name (vip-fixup-macro macro-name))
|
||||
(if (vip-char-array-p macro-name)
|
||||
(setq macro-name (vip-char-array-to-macro macro-name)))
|
||||
;; recorded in ~/.viper may appear as strings. So, convert to vectors.
|
||||
(setq macro-name (viper-fixup-macro macro-name))
|
||||
(if (viper-char-array-p macro-name)
|
||||
(setq macro-name (viper-char-array-to-macro macro-name)))
|
||||
|
||||
(setq macro-entry (assoc macro-name (eval macro-alist-var)))
|
||||
(if (= (length macro-name) 0)
|
||||
(error "Can't unmap an empty macro name"))
|
||||
(if (null macro-entry)
|
||||
(error "%S is not mapped to a macro for %s in `%s'"
|
||||
(vip-display-macro macro-name)
|
||||
(viper-display-macro macro-name)
|
||||
state-name (buffer-name)))
|
||||
|
||||
(setq buf-mapping (vip-kbd-buf-pair macro-entry)
|
||||
mode-mapping (vip-kbd-mode-pair macro-entry)
|
||||
global-mapping (vip-kbd-global-pair macro-entry))
|
||||
(setq buf-mapping (viper-kbd-buf-pair macro-entry)
|
||||
mode-mapping (viper-kbd-mode-pair macro-entry)
|
||||
global-mapping (viper-kbd-global-pair macro-entry))
|
||||
|
||||
(cond ((and (cdr buf-mapping)
|
||||
(or (and (not (cdr mode-mapping)) (not (cdr global-mapping)))
|
||||
(y-or-n-p
|
||||
(format "Unmap %S for `%s' only? "
|
||||
(vip-display-macro macro-name)
|
||||
(viper-display-macro macro-name)
|
||||
(buffer-name)))))
|
||||
(setq macro-pair buf-mapping)
|
||||
(message "%S is unmapped for %s in `%s'"
|
||||
(vip-display-macro macro-name)
|
||||
(viper-display-macro macro-name)
|
||||
state-name (buffer-name)))
|
||||
((and (cdr mode-mapping)
|
||||
(or (not (cdr global-mapping))
|
||||
(y-or-n-p
|
||||
(format "Unmap %S for the major mode `%S' only? "
|
||||
(vip-display-macro macro-name)
|
||||
(viper-display-macro macro-name)
|
||||
major-mode))))
|
||||
(setq macro-pair mode-mapping)
|
||||
(message "%S is unmapped for %s in %S"
|
||||
(vip-display-macro macro-name) state-name major-mode))
|
||||
((cdr (setq macro-pair (vip-kbd-global-pair macro-entry)))
|
||||
(viper-display-macro macro-name) state-name major-mode))
|
||||
((cdr (setq macro-pair (viper-kbd-global-pair macro-entry)))
|
||||
(message
|
||||
"Global mapping for %S in %s is removed"
|
||||
(vip-display-macro macro-name) state-name))
|
||||
(viper-display-macro macro-name) state-name))
|
||||
(t (error "%S is not mapped to a macro for %s in `%s'"
|
||||
(vip-display-macro macro-name)
|
||||
(viper-display-macro macro-name)
|
||||
state-name (buffer-name))))
|
||||
(setcdr macro-pair nil)
|
||||
(or (cdr buf-mapping)
|
||||
|
|
@ -554,19 +554,19 @@ there."
|
|||
(cdr global-mapping)
|
||||
(progn
|
||||
(set macro-alist-var (delq macro-entry (eval macro-alist-var)))
|
||||
(if (vip-can-release-key (aref macro-name 0)
|
||||
(if (viper-can-release-key (aref macro-name 0)
|
||||
(eval macro-alist-var))
|
||||
(define-key
|
||||
keymap
|
||||
(vector (vip-key-to-emacs-key (aref macro-name 0)))
|
||||
(vector (viper-key-to-emacs-key (aref macro-name 0)))
|
||||
nil))
|
||||
))
|
||||
))
|
||||
|
||||
;; Check if MACRO-ALIST has an entry for a macro name starting with
|
||||
;; CHAR. If not, this indicates that the binding for this char
|
||||
;; in vip-vi/insert-kbd-map can be released.
|
||||
(defun vip-can-release-key (char macro-alist)
|
||||
;; in viper-vi/insert-kbd-map can be released.
|
||||
(defun viper-can-release-key (char macro-alist)
|
||||
(let ((lis macro-alist)
|
||||
(can-release t)
|
||||
macro-name)
|
||||
|
|
@ -579,52 +579,52 @@ there."
|
|||
can-release))
|
||||
|
||||
|
||||
(defun vip-exec-mapped-kbd-macro (count)
|
||||
(defun viper-exec-mapped-kbd-macro (count)
|
||||
"Dispatch kbd macro."
|
||||
(interactive "P")
|
||||
(let* ((macro-alist (cond ((eq vip-current-state 'vi-state)
|
||||
vip-vi-kbd-macro-alist)
|
||||
((memq vip-current-state
|
||||
(let* ((macro-alist (cond ((eq viper-current-state 'vi-state)
|
||||
viper-vi-kbd-macro-alist)
|
||||
((memq viper-current-state
|
||||
'(insert-state replace-state))
|
||||
vip-insert-kbd-macro-alist)
|
||||
viper-insert-kbd-macro-alist)
|
||||
(t
|
||||
vip-emacs-kbd-macro-alist)))
|
||||
viper-emacs-kbd-macro-alist)))
|
||||
(unmatched-suffix "")
|
||||
;; Macros and keys are executed with other macros turned off
|
||||
;; For macros, this is done to avoid macro recursion
|
||||
vip-vi-kbd-minor-mode vip-insert-kbd-minor-mode
|
||||
vip-emacs-kbd-minor-mode
|
||||
viper-vi-kbd-minor-mode viper-insert-kbd-minor-mode
|
||||
viper-emacs-kbd-minor-mode
|
||||
next-best-match keyseq event-seq
|
||||
macro-first-char macro-alist-elt macro-body
|
||||
command)
|
||||
|
||||
(setq macro-first-char last-command-event
|
||||
event-seq (vip-read-fast-keysequence macro-first-char macro-alist)
|
||||
keyseq (vip-events-to-macro event-seq)
|
||||
event-seq (viper-read-fast-keysequence macro-first-char macro-alist)
|
||||
keyseq (viper-events-to-macro event-seq)
|
||||
macro-alist-elt (assoc keyseq macro-alist)
|
||||
next-best-match (vip-find-best-matching-macro macro-alist keyseq))
|
||||
next-best-match (viper-find-best-matching-macro macro-alist keyseq))
|
||||
|
||||
(if (null macro-alist-elt)
|
||||
(setq macro-alist-elt (car next-best-match)
|
||||
unmatched-suffix (subseq event-seq (cdr next-best-match))))
|
||||
|
||||
(cond ((null macro-alist-elt))
|
||||
((setq macro-body (vip-kbd-buf-definition macro-alist-elt)))
|
||||
((setq macro-body (vip-kbd-mode-definition macro-alist-elt)))
|
||||
((setq macro-body (vip-kbd-global-definition macro-alist-elt))))
|
||||
((setq macro-body (viper-kbd-buf-definition macro-alist-elt)))
|
||||
((setq macro-body (viper-kbd-mode-definition macro-alist-elt)))
|
||||
((setq macro-body (viper-kbd-global-definition macro-alist-elt))))
|
||||
|
||||
;; when defining keyboard macro, don't use the macro mappings
|
||||
(if (and macro-body (not defining-kbd-macro))
|
||||
;; block cmd executed as part of a macro from entering command history
|
||||
(let ((command-history command-history))
|
||||
(setq vip-this-kbd-macro (car macro-alist-elt))
|
||||
(execute-kbd-macro (vip-macro-to-events macro-body) count)
|
||||
(setq vip-this-kbd-macro nil
|
||||
vip-last-kbd-macro (car macro-alist-elt))
|
||||
(vip-set-unread-command-events unmatched-suffix))
|
||||
(setq viper-this-kbd-macro (car macro-alist-elt))
|
||||
(execute-kbd-macro (viper-macro-to-events macro-body) count)
|
||||
(setq viper-this-kbd-macro nil
|
||||
viper-last-kbd-macro (car macro-alist-elt))
|
||||
(viper-set-unread-command-events unmatched-suffix))
|
||||
;; If not a macro, or the macro is suppressed while defining another
|
||||
;; macro, put keyseq back on the event queue
|
||||
(vip-set-unread-command-events event-seq)
|
||||
(viper-set-unread-command-events event-seq)
|
||||
;; if the user typed arg, then use it if prefix arg is not set by
|
||||
;; some other command (setting prefix arg can happen if we do, say,
|
||||
;; 2dw and there is a macro starting with 2. Then control will go to
|
||||
|
|
@ -640,36 +640,36 @@ there."
|
|||
|
||||
;;; Displaying and completing macros
|
||||
|
||||
(defun vip-describe-kbd-macros ()
|
||||
(defun viper-describe-kbd-macros ()
|
||||
"Show currently defined keyboard macros."
|
||||
(interactive)
|
||||
(with-output-to-temp-buffer " *vip-info*"
|
||||
(with-output-to-temp-buffer " *viper-info*"
|
||||
(princ "Macros in Vi state:\n===================\n")
|
||||
(mapcar 'vip-describe-one-macro vip-vi-kbd-macro-alist)
|
||||
(mapcar 'viper-describe-one-macro viper-vi-kbd-macro-alist)
|
||||
(princ "\n\nMacros in Insert and Replace states:\n====================================\n")
|
||||
(mapcar 'vip-describe-one-macro vip-insert-kbd-macro-alist)
|
||||
(mapcar 'viper-describe-one-macro viper-insert-kbd-macro-alist)
|
||||
(princ "\n\nMacros in Emacs state:\n======================\n")
|
||||
(mapcar 'vip-describe-one-macro vip-emacs-kbd-macro-alist)
|
||||
(mapcar 'viper-describe-one-macro viper-emacs-kbd-macro-alist)
|
||||
))
|
||||
|
||||
(defun vip-describe-one-macro (macro)
|
||||
(defun viper-describe-one-macro (macro)
|
||||
(princ (format "\n *** Mappings for %S:\n ------------\n"
|
||||
(vip-display-macro (car macro))))
|
||||
(viper-display-macro (car macro))))
|
||||
(princ " ** Buffer-specific:")
|
||||
(if (vip-kbd-buf-alist macro)
|
||||
(mapcar 'vip-describe-one-macro-elt (vip-kbd-buf-alist macro))
|
||||
(if (viper-kbd-buf-alist macro)
|
||||
(mapcar 'viper-describe-one-macro-elt (viper-kbd-buf-alist macro))
|
||||
(princ " none\n"))
|
||||
(princ "\n ** Mode-specific:")
|
||||
(if (vip-kbd-mode-alist macro)
|
||||
(mapcar 'vip-describe-one-macro-elt (vip-kbd-mode-alist macro))
|
||||
(if (viper-kbd-mode-alist macro)
|
||||
(mapcar 'viper-describe-one-macro-elt (viper-kbd-mode-alist macro))
|
||||
(princ " none\n"))
|
||||
(princ "\n ** Global:")
|
||||
(if (vip-kbd-global-definition macro)
|
||||
(princ (format "\n %S" (cdr (vip-kbd-global-pair macro))))
|
||||
(if (viper-kbd-global-definition macro)
|
||||
(princ (format "\n %S" (cdr (viper-kbd-global-pair macro))))
|
||||
(princ " none"))
|
||||
(princ "\n"))
|
||||
|
||||
(defun vip-describe-one-macro-elt (elt)
|
||||
(defun viper-describe-one-macro-elt (elt)
|
||||
(let ((name (car elt))
|
||||
(defn (cdr elt)))
|
||||
(princ (format "\n * %S:\n %S\n" name defn))))
|
||||
|
|
@ -677,23 +677,23 @@ there."
|
|||
|
||||
|
||||
;; check if SEQ is a prefix of some car of an element in ALIST
|
||||
(defun vip-keyseq-is-a-possible-macro (seq alist)
|
||||
(let ((converted-seq (vip-events-to-macro seq)))
|
||||
(defun viper-keyseq-is-a-possible-macro (seq alist)
|
||||
(let ((converted-seq (viper-events-to-macro seq)))
|
||||
(eval (cons 'or
|
||||
(mapcar
|
||||
(function (lambda (elt)
|
||||
(vip-prefix-subseq-p converted-seq elt)))
|
||||
(vip-this-buffer-macros alist))))))
|
||||
(viper-prefix-subseq-p converted-seq elt)))
|
||||
(viper-this-buffer-macros alist))))))
|
||||
|
||||
;; whether SEQ1 is a prefix of SEQ2
|
||||
(defun vip-prefix-subseq-p (seq1 seq2)
|
||||
(defun viper-prefix-subseq-p (seq1 seq2)
|
||||
(let ((len1 (length seq1))
|
||||
(len2 (length seq2)))
|
||||
(if (<= len1 len2)
|
||||
(equal seq1 (subseq seq2 0 len1)))))
|
||||
|
||||
;; find the longest common prefix
|
||||
(defun vip-common-seq-prefix (&rest seqs)
|
||||
(defun viper-common-seq-prefix (&rest seqs)
|
||||
(let* ((first (car seqs))
|
||||
(rest (cdr seqs))
|
||||
(pref [])
|
||||
|
|
@ -713,15 +713,15 @@ there."
|
|||
pref))
|
||||
|
||||
;; get all sequences that match PREFIX from a given A-LIST
|
||||
(defun vip-extract-matching-alist-members (pref alist)
|
||||
(defun viper-extract-matching-alist-members (pref alist)
|
||||
(delq nil (mapcar (function (lambda (elt)
|
||||
(if (vip-prefix-subseq-p pref elt)
|
||||
(if (viper-prefix-subseq-p pref elt)
|
||||
elt)))
|
||||
(vip-this-buffer-macros alist))))
|
||||
(viper-this-buffer-macros alist))))
|
||||
|
||||
(defun vip-do-sequence-completion (seq alist compl-message)
|
||||
(let* ((matches (vip-extract-matching-alist-members seq alist))
|
||||
(new-seq (apply 'vip-common-seq-prefix matches))
|
||||
(defun viper-do-sequence-completion (seq alist compl-message)
|
||||
(let* ((matches (viper-extract-matching-alist-members seq alist))
|
||||
(new-seq (apply 'viper-common-seq-prefix matches))
|
||||
)
|
||||
(cond ((and (equal seq new-seq) (= (length matches) 1))
|
||||
(message "%s (Sole completion)" compl-message)
|
||||
|
|
@ -733,24 +733,24 @@ there."
|
|||
((member seq matches)
|
||||
(message "%s (Complete, but not unique)" compl-message)
|
||||
(sit-for 2)
|
||||
(vip-display-vector-completions matches))
|
||||
(viper-display-vector-completions matches))
|
||||
((equal seq new-seq)
|
||||
(vip-display-vector-completions matches)))
|
||||
(viper-display-vector-completions matches)))
|
||||
new-seq))
|
||||
|
||||
|
||||
(defun vip-display-vector-completions (list)
|
||||
(defun viper-display-vector-completions (list)
|
||||
(with-output-to-temp-buffer "*Completions*"
|
||||
(display-completion-list
|
||||
(mapcar 'prin1-to-string
|
||||
(mapcar 'vip-display-macro list)))))
|
||||
(mapcar 'viper-display-macro list)))))
|
||||
|
||||
|
||||
|
||||
;; alist is the alist of macros
|
||||
;; str is the fast key sequence entered
|
||||
;; returns: (matching-macro-def . unmatched-suffix-start-index)
|
||||
(defun vip-find-best-matching-macro (alist str)
|
||||
(defun viper-find-best-matching-macro (alist str)
|
||||
(let ((lis alist)
|
||||
(def-len 0)
|
||||
(str-len (length str))
|
||||
|
|
@ -760,9 +760,9 @@ there."
|
|||
def-len (length (car macro-def)))
|
||||
(if (and (>= str-len def-len)
|
||||
(equal (car macro-def) (subseq str 0 def-len)))
|
||||
(if (or (vip-kbd-buf-definition macro-def)
|
||||
(vip-kbd-mode-definition macro-def)
|
||||
(vip-kbd-global-definition macro-def))
|
||||
(if (or (viper-kbd-buf-definition macro-def)
|
||||
(viper-kbd-mode-definition macro-def)
|
||||
(viper-kbd-global-definition macro-def))
|
||||
(setq found t))
|
||||
)
|
||||
(setq lis (cdr lis)))
|
||||
|
|
@ -778,14 +778,14 @@ there."
|
|||
|
||||
|
||||
;; returns a list of names of macros defined for the current buffer
|
||||
(defun vip-this-buffer-macros (macro-alist)
|
||||
(defun viper-this-buffer-macros (macro-alist)
|
||||
(let (candidates)
|
||||
(setq candidates
|
||||
(mapcar (function
|
||||
(lambda (elt)
|
||||
(if (or (vip-kbd-buf-definition elt)
|
||||
(vip-kbd-mode-definition elt)
|
||||
(vip-kbd-global-definition elt))
|
||||
(if (or (viper-kbd-buf-definition elt)
|
||||
(viper-kbd-mode-definition elt)
|
||||
(viper-kbd-global-definition elt))
|
||||
(car elt))))
|
||||
macro-alist))
|
||||
(setq candidates (delq nil candidates))))
|
||||
|
|
@ -793,10 +793,10 @@ there."
|
|||
|
||||
;; if seq of Viper key symbols (representing a macro) can be converted to a
|
||||
;; string--do so. Otherwise, do nothing.
|
||||
(defun vip-display-macro (macro-name-or-body)
|
||||
(cond ((vip-char-symbol-sequence-p macro-name-or-body)
|
||||
(defun viper-display-macro (macro-name-or-body)
|
||||
(cond ((viper-char-symbol-sequence-p macro-name-or-body)
|
||||
(mapconcat 'symbol-name macro-name-or-body ""))
|
||||
((vip-char-array-p macro-name-or-body)
|
||||
((viper-char-array-p macro-name-or-body)
|
||||
(mapconcat 'char-to-string macro-name-or-body ""))
|
||||
(t macro-name-or-body)))
|
||||
|
||||
|
|
@ -809,27 +809,27 @@ there."
|
|||
;; during a macro definition, then something like (switch-frame ...) might get
|
||||
;; in. Another reason for purging lists-events is that we can't store them in
|
||||
;; textual form (say, in .emacs) and then read them back.
|
||||
(defun vip-events-to-macro (event-seq)
|
||||
(defun viper-events-to-macro (event-seq)
|
||||
(vconcat (delq nil (mapcar (function (lambda (elt)
|
||||
(if (consp elt)
|
||||
nil
|
||||
(vip-event-key elt))))
|
||||
(viper-event-key elt))))
|
||||
event-seq))))
|
||||
|
||||
;; convert strings or arrays of characters to Viper macro form
|
||||
(defun vip-char-array-to-macro (array)
|
||||
(defun viper-char-array-to-macro (array)
|
||||
(let ((vec (vconcat array))
|
||||
macro)
|
||||
(if vip-xemacs-p
|
||||
(if viper-xemacs-p
|
||||
(setq macro (mapcar 'character-to-event vec))
|
||||
(setq macro vec))
|
||||
(vconcat (mapcar 'vip-event-key macro))))
|
||||
(vconcat (mapcar 'viper-event-key macro))))
|
||||
|
||||
;; For macros bodies and names, goes over MACRO and checks if all members are
|
||||
;; names of keys (actually, it only checks if they are symbols or lists
|
||||
;; if a digit is found, it is converted into a symbol (e.g., 0 -> \0, etc).
|
||||
;; If MACRO is not a list or vector -- doesn't change MACRO.
|
||||
(defun vip-fixup-macro (macro)
|
||||
(defun viper-fixup-macro (macro)
|
||||
(let ((len (length macro))
|
||||
(idx 0)
|
||||
elt break)
|
||||
|
|
@ -848,7 +848,7 @@ there."
|
|||
(intern (char-to-string (+ ?0 elt)))))
|
||||
)))
|
||||
((listp elt)
|
||||
(vip-fixup-macro elt))
|
||||
(viper-fixup-macro elt))
|
||||
((symbolp elt) nil)
|
||||
(t (setq break t)))
|
||||
(setq idx (1+ idx))))
|
||||
|
|
@ -857,15 +857,15 @@ there."
|
|||
(error "Wrong type macro component, symbol-or-listp, %S" elt)
|
||||
macro)))
|
||||
|
||||
(defun vip-char-array-p (array)
|
||||
(eval (cons 'and (mapcar 'vip-characterp array))))
|
||||
(defun viper-char-array-p (array)
|
||||
(eval (cons 'and (mapcar 'viper-characterp array))))
|
||||
|
||||
(defun vip-macro-to-events (macro-body)
|
||||
(vconcat (mapcar 'vip-key-to-emacs-key macro-body)))
|
||||
(defun viper-macro-to-events (macro-body)
|
||||
(vconcat (mapcar 'viper-key-to-emacs-key macro-body)))
|
||||
|
||||
|
||||
;; check if vec is a vector of character symbols
|
||||
(defun vip-char-symbol-sequence-p (vec)
|
||||
(defun viper-char-symbol-sequence-p (vec)
|
||||
(and
|
||||
(sequencep vec)
|
||||
(eval
|
||||
|
|
@ -878,7 +878,7 @@ there."
|
|||
|
||||
;; Check if vec is a vector of key-press events representing characters
|
||||
;; XEmacs only
|
||||
(defun vip-event-vector-p (vec)
|
||||
(defun viper-event-vector-p (vec)
|
||||
(and (vectorp vec)
|
||||
(eval (cons 'and (mapcar '(lambda (elt) (if (eventp elt) t)) vec)))))
|
||||
|
||||
|
|
@ -889,15 +889,15 @@ there."
|
|||
;; strokes, read the rest. Return the vector of keys that was entered in
|
||||
;; this fast succession of key strokes.
|
||||
;; A fast keysequence is one that is terminated by a pause longer than
|
||||
;; vip-fast-keyseq-timeout.
|
||||
(defun vip-read-fast-keysequence (event macro-alist)
|
||||
;; viper-fast-keyseq-timeout.
|
||||
(defun viper-read-fast-keysequence (event macro-alist)
|
||||
(let ((lis (vector event))
|
||||
next-event)
|
||||
(while (and (vip-fast-keysequence-p)
|
||||
(vip-keyseq-is-a-possible-macro lis macro-alist))
|
||||
(setq next-event (vip-read-key))
|
||||
;;(setq next-event (vip-read-event))
|
||||
(or (vip-mouse-event-p 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))
|
||||
(or (viper-mouse-event-p next-event)
|
||||
(setq lis (vconcat lis (vector next-event)))))
|
||||
lis))
|
||||
|
||||
|
|
@ -905,7 +905,7 @@ there."
|
|||
;;; Keyboard macros in registers
|
||||
|
||||
;; sets register to last-kbd-macro carefully.
|
||||
(defun vip-set-register-macro (reg)
|
||||
(defun viper-set-register-macro (reg)
|
||||
(if (get-register reg)
|
||||
(if (y-or-n-p "Register contains data. Overwrite? ")
|
||||
()
|
||||
|
|
@ -913,35 +913,35 @@ there."
|
|||
"Macro not saved in register. Can still be invoked via `C-x e'")))
|
||||
(set-register reg last-kbd-macro))
|
||||
|
||||
(defun vip-register-macro (count)
|
||||
(defun viper-register-macro (count)
|
||||
"Keyboard macros in registers - a modified \@ command."
|
||||
(interactive "P")
|
||||
(let ((reg (downcase (read-char))))
|
||||
(cond ((or (and (<= ?a reg) (<= reg ?z)))
|
||||
(setq vip-last-macro-reg reg)
|
||||
(setq viper-last-macro-reg reg)
|
||||
(if defining-kbd-macro
|
||||
(progn
|
||||
(end-kbd-macro)
|
||||
(vip-set-register-macro reg))
|
||||
(viper-set-register-macro reg))
|
||||
(execute-kbd-macro (get-register reg) count)))
|
||||
((or (= ?@ reg) (= ?\^j reg) (= ?\^m reg))
|
||||
(if vip-last-macro-reg
|
||||
(if viper-last-macro-reg
|
||||
nil
|
||||
(error "No previous kbd macro"))
|
||||
(execute-kbd-macro (get-register vip-last-macro-reg) count))
|
||||
(execute-kbd-macro (get-register viper-last-macro-reg) count))
|
||||
((= ?\# reg)
|
||||
(start-kbd-macro count))
|
||||
((= ?! reg)
|
||||
(setq reg (downcase (read-char)))
|
||||
(if (or (and (<= ?a reg) (<= reg ?z)))
|
||||
(progn
|
||||
(setq vip-last-macro-reg reg)
|
||||
(vip-set-register-macro reg))))
|
||||
(setq viper-last-macro-reg reg)
|
||||
(viper-set-register-macro reg))))
|
||||
(t
|
||||
(error "`%c': Unknown register" reg)))))
|
||||
|
||||
|
||||
(defun vip-global-execute ()
|
||||
(defun viper-global-execute ()
|
||||
"Call last keyboad macro for each line in the region."
|
||||
(if (> (point) (mark t)) (exchange-point-and-mark))
|
||||
(beginning-of-line)
|
||||
|
|
|
|||
|
|
@ -26,11 +26,11 @@
|
|||
;; compiler pacifier
|
||||
(defvar double-click-time)
|
||||
(defvar mouse-track-multi-click-time)
|
||||
(defvar vip-search-start-marker)
|
||||
(defvar vip-local-search-start-marker)
|
||||
(defvar vip-search-history)
|
||||
(defvar vip-s-string)
|
||||
(defvar vip-re-search)
|
||||
(defvar viper-search-start-marker)
|
||||
(defvar viper-local-search-start-marker)
|
||||
(defvar viper-search-history)
|
||||
(defvar viper-s-string)
|
||||
(defvar viper-re-search)
|
||||
|
||||
;; loading happens only in non-interactive compilation
|
||||
;; in order to spare non-viperized emacs from being viperized
|
||||
|
|
@ -49,7 +49,7 @@
|
|||
|
||||
(defgroup viper-mouse nil
|
||||
"Support for Viper special mouse-bound commands"
|
||||
:prefix "vip-"
|
||||
:prefix "viper-"
|
||||
:group 'viper)
|
||||
|
||||
|
||||
|
|
@ -57,13 +57,13 @@
|
|||
|
||||
;; Variable used for catching the switch-frame event.
|
||||
;; If non-nil, indicates that previous-frame should be the selected
|
||||
;; one. Used by vip-mouse-click-get-word. Not a user option.
|
||||
(defvar vip-frame-of-focus nil)
|
||||
;; one. Used by viper-mouse-click-get-word. Not a user option.
|
||||
(defvar viper-frame-of-focus nil)
|
||||
|
||||
;; Frame that was selected before the switch-frame event.
|
||||
(defconst vip-current-frame-saved (selected-frame))
|
||||
(defconst viper-current-frame-saved (selected-frame))
|
||||
|
||||
(defcustom vip-surrounding-word-function 'vip-surrounding-word
|
||||
(defcustom viper-surrounding-word-function 'viper-surrounding-word
|
||||
"*Function that determines what constitutes a word for clicking events.
|
||||
Takes two parameters: a COUNT, indicating how many words to return,
|
||||
and CLICK-COUNT, telling whether this is the first click, a double-click,
|
||||
|
|
@ -73,8 +73,8 @@ or a tripple-click."
|
|||
|
||||
;; time interval in millisecond within which successive clicks are
|
||||
;; considered related
|
||||
(defcustom vip-multiclick-timeout (if (vip-window-display-p)
|
||||
(if vip-xemacs-p
|
||||
(defcustom viper-multiclick-timeout (if (viper-window-display-p)
|
||||
(if viper-xemacs-p
|
||||
mouse-track-multi-click-time
|
||||
double-click-time)
|
||||
500)
|
||||
|
|
@ -84,55 +84,63 @@ considered related."
|
|||
:group 'viper-mouse)
|
||||
|
||||
;; current event click count; XEmacs only
|
||||
(defvar vip-current-click-count 0)
|
||||
(defvar viper-current-click-count 0)
|
||||
;; time stamp of the last click event; XEmacs only
|
||||
(defvar vip-last-click-event-timestamp 0)
|
||||
(defvar viper-last-click-event-timestamp 0)
|
||||
|
||||
;; Local variable used to toggle wraparound search on click.
|
||||
(vip-deflocalvar vip-mouse-click-search-noerror t)
|
||||
(viper-deflocalvar viper-mouse-click-search-noerror t)
|
||||
|
||||
;; Local variable used to delimit search after wraparound.
|
||||
(vip-deflocalvar vip-mouse-click-search-limit nil)
|
||||
(viper-deflocalvar viper-mouse-click-search-limit nil)
|
||||
|
||||
;; remembers prefix argument to pass along to commands invoked by second
|
||||
;; click.
|
||||
;; This is needed because in Emacs (not XEmacs), assigning to preix-arg
|
||||
;; causes Emacs to count the second click as if it was a single click
|
||||
(defvar vip-global-prefix-argument nil)
|
||||
(defvar viper-global-prefix-argument nil)
|
||||
|
||||
|
||||
;; same keys, but parsed
|
||||
(defvar viper-mouse-up-search-key-parsed nil)
|
||||
(defvar viper-mouse-down-search-key-parsed nil)
|
||||
(defvar viper-mouse-up-insert-key-parsed nil)
|
||||
(defvar viper-mouse-down-insert-key-parsed nil)
|
||||
|
||||
|
||||
|
||||
|
||||
;;; Code
|
||||
|
||||
(defsubst vip-multiclick-p ()
|
||||
(not (vip-sit-for-short vip-multiclick-timeout t)))
|
||||
(defsubst viper-multiclick-p ()
|
||||
(not (viper-sit-for-short viper-multiclick-timeout t)))
|
||||
|
||||
;; Returns window where click occurs
|
||||
(defsubst vip-mouse-click-window (click)
|
||||
(if vip-xemacs-p
|
||||
(defsubst viper-mouse-click-window (click)
|
||||
(if viper-xemacs-p
|
||||
(event-window click)
|
||||
(posn-window (event-start click))))
|
||||
|
||||
;; Returns window where click occurs
|
||||
(defsubst vip-mouse-click-frame (click)
|
||||
(window-frame (vip-mouse-click-window click)))
|
||||
(defsubst viper-mouse-click-frame (click)
|
||||
(window-frame (viper-mouse-click-window click)))
|
||||
|
||||
;; Returns the buffer of the window where click occurs
|
||||
(defsubst vip-mouse-click-window-buffer (click)
|
||||
(window-buffer (vip-mouse-click-window click)))
|
||||
(defsubst viper-mouse-click-window-buffer (click)
|
||||
(window-buffer (viper-mouse-click-window click)))
|
||||
|
||||
;; Returns the name of the buffer in the window where click occurs
|
||||
(defsubst vip-mouse-click-window-buffer-name (click)
|
||||
(buffer-name (vip-mouse-click-window-buffer click)))
|
||||
(defsubst viper-mouse-click-window-buffer-name (click)
|
||||
(buffer-name (viper-mouse-click-window-buffer click)))
|
||||
|
||||
;; Returns position of a click
|
||||
(defsubst vip-mouse-click-posn (click)
|
||||
(if vip-xemacs-p
|
||||
(defsubst viper-mouse-click-posn (click)
|
||||
(if viper-xemacs-p
|
||||
(event-point click)
|
||||
(posn-point (event-start click))))
|
||||
|
||||
|
||||
(defun vip-surrounding-word (count click-count)
|
||||
(defun viper-surrounding-word (count click-count)
|
||||
"Returns word surrounding point according to a heuristic.
|
||||
COUNT indicates how many regions to return.
|
||||
If CLICK-COUNT is 1, `word' is a word in Vi sense.
|
||||
|
|
@ -153,16 +161,16 @@ is ignored."
|
|||
(if (> click-count 2)
|
||||
(save-excursion
|
||||
(beginning-of-line)
|
||||
(vip-skip-all-separators-forward 'within-line)
|
||||
(viper-skip-all-separators-forward 'within-line)
|
||||
(setq beg (point))
|
||||
(end-of-line)
|
||||
(setq result (buffer-substring beg (point))))
|
||||
|
||||
(if (and (not (vip-looking-at-alphasep))
|
||||
(or (save-excursion (vip-backward-char-carefully)
|
||||
(vip-looking-at-alpha))
|
||||
(save-excursion (vip-forward-char-carefully)
|
||||
(vip-looking-at-alpha))))
|
||||
(if (and (not (viper-looking-at-alphasep))
|
||||
(or (save-excursion (viper-backward-char-carefully)
|
||||
(viper-looking-at-alpha))
|
||||
(save-excursion (viper-forward-char-carefully)
|
||||
(viper-looking-at-alpha))))
|
||||
(setq modifiers
|
||||
(cond ((looking-at "\\\\") "\\\\")
|
||||
((looking-at "-") "C-C-")
|
||||
|
|
@ -172,7 +180,7 @@ is ignored."
|
|||
((looking-at "[<>]") "<>")
|
||||
((looking-at "[`']") "`'")
|
||||
((looking-at "\\^") "\\^")
|
||||
((vip-looking-at-separator) "")
|
||||
((viper-looking-at-separator) "")
|
||||
(t (char-to-string (following-char))))
|
||||
))
|
||||
|
||||
|
|
@ -183,45 +191,45 @@ is ignored."
|
|||
|
||||
|
||||
(save-excursion
|
||||
(cond ((> click-count 1) (vip-skip-nonseparators 'backward))
|
||||
((vip-looking-at-alpha modifiers)
|
||||
(vip-skip-alpha-backward modifiers))
|
||||
((not (vip-looking-at-alphasep modifiers))
|
||||
(vip-skip-nonalphasep-backward))
|
||||
(cond ((> click-count 1) (viper-skip-nonseparators 'backward))
|
||||
((viper-looking-at-alpha modifiers)
|
||||
(viper-skip-alpha-backward modifiers))
|
||||
((not (viper-looking-at-alphasep modifiers))
|
||||
(viper-skip-nonalphasep-backward))
|
||||
(t (if (> click-count 1)
|
||||
(vip-skip-nonseparators 'backward)
|
||||
(vip-skip-alpha-backward modifiers))))
|
||||
(viper-skip-nonseparators 'backward)
|
||||
(viper-skip-alpha-backward modifiers))))
|
||||
|
||||
(setq word-beg (point))
|
||||
|
||||
(setq skip-flag nil) ; don't move 1 char forw the first time
|
||||
(while (> count 0)
|
||||
(if skip-flag (vip-forward-char-carefully 1))
|
||||
(if skip-flag (viper-forward-char-carefully 1))
|
||||
(setq skip-flag t) ; now always move 1 char forward
|
||||
(if (> click-count 1)
|
||||
(vip-skip-nonseparators 'forward)
|
||||
(vip-skip-alpha-forward modifiers))
|
||||
(viper-skip-nonseparators 'forward)
|
||||
(viper-skip-alpha-forward modifiers))
|
||||
(setq count (1- count)))
|
||||
|
||||
(setq result (buffer-substring word-beg (point))))
|
||||
) ; if
|
||||
;; XEmacs doesn't have set-text-properties, but there buffer-substring
|
||||
;; doesn't return properties together with the string, so it's not needed.
|
||||
(if vip-emacs-p
|
||||
(if viper-emacs-p
|
||||
(set-text-properties 0 (length result) nil result))
|
||||
result
|
||||
))
|
||||
|
||||
|
||||
(defun vip-mouse-click-get-word (click count click-count)
|
||||
(defun viper-mouse-click-get-word (click count click-count)
|
||||
"Returns word surrounding the position of a mouse click.
|
||||
Click may be in another window. Current window and buffer isn't changed.
|
||||
On single or double click, returns the word as determined by
|
||||
`vip-surrounding-word-function'."
|
||||
`viper-surrounding-word-function'."
|
||||
|
||||
(let ((click-word "")
|
||||
(click-pos (vip-mouse-click-posn click))
|
||||
(click-buf (vip-mouse-click-window-buffer click)))
|
||||
(click-pos (viper-mouse-click-posn click))
|
||||
(click-buf (viper-mouse-click-window-buffer click)))
|
||||
(or (natnump count) (setq count 1))
|
||||
(or (natnump click-count) (setq click-count 1))
|
||||
|
||||
|
|
@ -233,21 +241,21 @@ On single or double click, returns the word as determined by
|
|||
|
||||
(goto-char click-pos)
|
||||
(setq click-word
|
||||
(funcall vip-surrounding-word-function count click-count)))
|
||||
(funcall viper-surrounding-word-function count click-count)))
|
||||
(error "Click must be over a window."))
|
||||
click-word))))
|
||||
|
||||
|
||||
(defun vip-mouse-click-insert-word (click arg)
|
||||
(defun viper-mouse-click-insert-word (click arg)
|
||||
"Insert word clicked or double-clicked on.
|
||||
With prefix argument, N, insert that many words.
|
||||
This command must be bound to a mouse click.
|
||||
The double-click action of the same mouse button must not be bound
|
||||
\(or it must be bound to the same function\).
|
||||
See `vip-surrounding-word' for the definition of a word in this case."
|
||||
See `viper-surrounding-word' for the definition of a word in this case."
|
||||
(interactive "e\nP")
|
||||
(if vip-frame-of-focus ;; to handle clicks in another frame
|
||||
(select-frame vip-frame-of-focus))
|
||||
(if viper-frame-of-focus ;; to handle clicks in another frame
|
||||
(select-frame viper-frame-of-focus))
|
||||
|
||||
;; turn arg into a number
|
||||
(cond ((integerp arg) nil)
|
||||
|
|
@ -256,168 +264,175 @@ See `vip-surrounding-word' for the definition of a word in this case."
|
|||
(setq arg (car arg)))
|
||||
(t (setq arg 1)))
|
||||
|
||||
(let (click-count interrupting-event)
|
||||
(if (and
|
||||
(vip-multiclick-p)
|
||||
;; This trick checks if there is a pending mouse event
|
||||
;; if so, we use this latter event and discard the current mouse click
|
||||
;; If the next pending event is not a mouse event, we execute
|
||||
;; the current mouse event
|
||||
(progn
|
||||
(setq interrupting-event (vip-read-event))
|
||||
(vip-mouse-event-p last-input-event)))
|
||||
(progn ;; interrupted wait
|
||||
(setq vip-global-prefix-argument arg)
|
||||
;; count this click for XEmacs
|
||||
(vip-event-click-count click))
|
||||
;; uninterrupted wait or the interrupting event wasn't a mouse event
|
||||
(setq click-count (vip-event-click-count click))
|
||||
(if (> click-count 1)
|
||||
(setq arg vip-global-prefix-argument
|
||||
vip-global-prefix-argument nil))
|
||||
(insert (vip-mouse-click-get-word click arg click-count))
|
||||
(if (and interrupting-event
|
||||
(eventp interrupting-event)
|
||||
(not (vip-mouse-event-p interrupting-event)))
|
||||
(vip-set-unread-command-events interrupting-event))
|
||||
)))
|
||||
(if (not (eq (key-binding viper-mouse-down-insert-key-parsed)
|
||||
'viper-mouse-catch-frame-switch))
|
||||
() ; do nothing
|
||||
(let (click-count interrupting-event)
|
||||
(if (and
|
||||
(viper-multiclick-p)
|
||||
;; This trick checks if there is a pending mouse event if so, we use
|
||||
;; this latter event and discard the current mouse click If the next
|
||||
;; pending event is not a mouse event, we execute the current mouse
|
||||
;; event
|
||||
(progn
|
||||
(setq interrupting-event (viper-read-event))
|
||||
(viper-mouse-event-p last-input-event)))
|
||||
(progn ; interrupted wait
|
||||
(setq viper-global-prefix-argument arg)
|
||||
;; count this click for XEmacs
|
||||
(viper-event-click-count click))
|
||||
;; uninterrupted wait or the interrupting event wasn't a mouse event
|
||||
(setq click-count (viper-event-click-count click))
|
||||
(if (> click-count 1)
|
||||
(setq arg viper-global-prefix-argument
|
||||
viper-global-prefix-argument nil))
|
||||
(insert (viper-mouse-click-get-word click arg click-count))
|
||||
(if (and interrupting-event
|
||||
(eventp interrupting-event)
|
||||
(not (viper-mouse-event-p interrupting-event)))
|
||||
(viper-set-unread-command-events interrupting-event))
|
||||
))))
|
||||
|
||||
;; arg is an event. accepts symbols and numbers, too
|
||||
(defun vip-mouse-event-p (event)
|
||||
(defun viper-mouse-event-p (event)
|
||||
(if (eventp event)
|
||||
(string-match "\\(mouse-\\|frame\\|screen\\|track\\)"
|
||||
(prin1-to-string (vip-event-key event)))))
|
||||
(prin1-to-string (viper-event-key event)))))
|
||||
|
||||
;; XEmacs has no double-click events. So, we must simulate.
|
||||
;; So, we have to simulate event-click-count.
|
||||
(defun vip-event-click-count (click)
|
||||
(if vip-xemacs-p
|
||||
(defun viper-event-click-count (click)
|
||||
(if viper-xemacs-p
|
||||
(progn
|
||||
;; if more than 1 second
|
||||
(if (> (- (event-timestamp click) vip-last-click-event-timestamp)
|
||||
vip-multiclick-timeout)
|
||||
(setq vip-current-click-count 0))
|
||||
(setq vip-last-click-event-timestamp (event-timestamp click)
|
||||
vip-current-click-count (1+ vip-current-click-count)))
|
||||
(if (> (- (event-timestamp click) viper-last-click-event-timestamp)
|
||||
viper-multiclick-timeout)
|
||||
(setq viper-current-click-count 0))
|
||||
(setq viper-last-click-event-timestamp (event-timestamp click)
|
||||
viper-current-click-count (1+ viper-current-click-count)))
|
||||
(event-click-count click)))
|
||||
|
||||
|
||||
|
||||
(defun vip-mouse-click-search-word (click arg)
|
||||
(defun viper-mouse-click-search-word (click arg)
|
||||
"Find the word clicked or double-clicked on. Word may be in another window.
|
||||
With prefix argument, N, search for N-th occurrence.
|
||||
This command must be bound to a mouse click. The double-click action of the
|
||||
same button must not be bound \(or it must be bound to the same function\).
|
||||
See `vip-surrounding-word' for the details on what constitutes a word for
|
||||
See `viper-surrounding-word' for the details on what constitutes a word for
|
||||
this command."
|
||||
(interactive "e\nP")
|
||||
(if vip-frame-of-focus ;; to handle clicks in another frame
|
||||
(select-frame vip-frame-of-focus))
|
||||
(let (click-word click-count
|
||||
(previous-search-string vip-s-string))
|
||||
(if viper-frame-of-focus ;; to handle clicks in another frame
|
||||
(select-frame viper-frame-of-focus))
|
||||
(if (not (eq (key-binding viper-mouse-down-search-key-parsed)
|
||||
'viper-mouse-catch-frame-switch))
|
||||
() ; do nothing
|
||||
(let ((previous-search-string viper-s-string)
|
||||
click-word click-count)
|
||||
|
||||
(if (and
|
||||
(vip-multiclick-p)
|
||||
;; This trick checks if there is a pending mouse event
|
||||
;; if so, we use this latter event and discard the current mouse click
|
||||
;; If the next pending event is not a mouse event, we execute
|
||||
;; the current mouse event
|
||||
(progn
|
||||
(vip-read-event)
|
||||
(vip-mouse-event-p last-input-event)))
|
||||
(progn ;; interrupted wait
|
||||
(setq vip-global-prefix-argument
|
||||
(or vip-global-prefix-argument arg))
|
||||
;; remember command that was before the multiclick
|
||||
(setq this-command last-command)
|
||||
;; make sure we counted this event---needed for XEmacs only
|
||||
(vip-event-click-count click))
|
||||
;; uninterrupted wait
|
||||
(setq click-count (vip-event-click-count click))
|
||||
(setq click-word (vip-mouse-click-get-word click nil click-count))
|
||||
|
||||
(if (> click-count 1)
|
||||
(setq arg vip-global-prefix-argument
|
||||
vip-global-prefix-argument nil))
|
||||
(setq arg (or arg 1))
|
||||
|
||||
(vip-deactivate-mark)
|
||||
(if (or (not (string= click-word vip-s-string))
|
||||
(not (markerp vip-search-start-marker))
|
||||
(not (equal (marker-buffer vip-search-start-marker)
|
||||
(current-buffer)))
|
||||
(not (eq last-command 'vip-mouse-click-search-word)))
|
||||
(progn
|
||||
(setq vip-search-start-marker (point-marker)
|
||||
vip-local-search-start-marker vip-search-start-marker
|
||||
vip-mouse-click-search-noerror t
|
||||
vip-mouse-click-search-limit nil)
|
||||
|
||||
;; make search string known to Viper
|
||||
(setq vip-s-string (if vip-re-search
|
||||
(regexp-quote click-word)
|
||||
click-word))
|
||||
(if (not (string= vip-s-string (car vip-search-history)))
|
||||
(setq vip-search-history
|
||||
(cons vip-s-string vip-search-history)))
|
||||
))
|
||||
|
||||
(push-mark nil t)
|
||||
(while (> arg 0)
|
||||
(vip-forward-word 1)
|
||||
(condition-case nil
|
||||
(if (and
|
||||
(viper-multiclick-p)
|
||||
;; This trick checks if there is a pending mouse event if so, we use
|
||||
;; this latter event and discard the current mouse click If the next
|
||||
;; pending event is not a mouse event, we execute the current mouse
|
||||
;; event
|
||||
(progn
|
||||
(viper-read-event)
|
||||
(viper-mouse-event-p last-input-event)))
|
||||
(progn ; interrupted wait
|
||||
(setq viper-global-prefix-argument
|
||||
(or viper-global-prefix-argument arg))
|
||||
;; remember command that was before the multiclick
|
||||
(setq this-command last-command)
|
||||
;; make sure we counted this event---needed for XEmacs only
|
||||
(viper-event-click-count click))
|
||||
;; uninterrupted wait
|
||||
(setq click-count (viper-event-click-count click))
|
||||
(setq click-word (viper-mouse-click-get-word click nil click-count))
|
||||
|
||||
(if (> click-count 1)
|
||||
(setq arg viper-global-prefix-argument
|
||||
viper-global-prefix-argument nil))
|
||||
(setq arg (or arg 1))
|
||||
|
||||
(viper-deactivate-mark)
|
||||
(if (or (not (string= click-word viper-s-string))
|
||||
(not (markerp viper-search-start-marker))
|
||||
(not (equal (marker-buffer viper-search-start-marker)
|
||||
(current-buffer)))
|
||||
(not (eq last-command 'viper-mouse-click-search-word)))
|
||||
(progn
|
||||
(if (not (search-forward click-word vip-mouse-click-search-limit
|
||||
vip-mouse-click-search-noerror))
|
||||
(progn
|
||||
(setq vip-mouse-click-search-noerror nil)
|
||||
(setq vip-mouse-click-search-limit
|
||||
(save-excursion
|
||||
(if (and
|
||||
(markerp vip-local-search-start-marker)
|
||||
(marker-buffer vip-local-search-start-marker))
|
||||
(goto-char vip-local-search-start-marker))
|
||||
(vip-line-pos 'end)))
|
||||
|
||||
(goto-char (point-min))
|
||||
(search-forward click-word
|
||||
vip-mouse-click-search-limit nil)))
|
||||
(goto-char (match-beginning 0))
|
||||
(message "Searching for: %s" vip-s-string)
|
||||
(if (<= arg 1) ; found the right occurrence of the pattern
|
||||
(progn
|
||||
(vip-adjust-window)
|
||||
(vip-flash-search-pattern)))
|
||||
)
|
||||
(error (beep 1)
|
||||
(if (or (not (string= click-word previous-search-string))
|
||||
(not (eq last-command 'vip-mouse-click-search-word)))
|
||||
(message "`%s': String not found in %s"
|
||||
vip-s-string (buffer-name (current-buffer)))
|
||||
(message
|
||||
"`%s': Last occurrence in %s. Back to beginning of search"
|
||||
click-word (buffer-name (current-buffer)))
|
||||
(setq arg 1) ;; to terminate the loop
|
||||
(sit-for 2))
|
||||
(setq vip-mouse-click-search-noerror t)
|
||||
(setq vip-mouse-click-search-limit nil)
|
||||
(if (and (markerp vip-local-search-start-marker)
|
||||
(marker-buffer vip-local-search-start-marker))
|
||||
(goto-char vip-local-search-start-marker))))
|
||||
(setq arg (1- arg)))
|
||||
)))
|
||||
(setq viper-search-start-marker (point-marker)
|
||||
viper-local-search-start-marker viper-search-start-marker
|
||||
viper-mouse-click-search-noerror t
|
||||
viper-mouse-click-search-limit nil)
|
||||
|
||||
;; make search string known to Viper
|
||||
(setq viper-s-string (if viper-re-search
|
||||
(regexp-quote click-word)
|
||||
click-word))
|
||||
(if (not (string= viper-s-string (car viper-search-history)))
|
||||
(setq viper-search-history
|
||||
(cons viper-s-string viper-search-history)))
|
||||
))
|
||||
|
||||
(push-mark nil t)
|
||||
(while (> arg 0)
|
||||
(viper-forward-word 1)
|
||||
(condition-case nil
|
||||
(progn
|
||||
(if (not (search-forward
|
||||
click-word viper-mouse-click-search-limit
|
||||
viper-mouse-click-search-noerror))
|
||||
(progn
|
||||
(setq viper-mouse-click-search-noerror nil)
|
||||
(setq viper-mouse-click-search-limit
|
||||
(save-excursion
|
||||
(if (and
|
||||
(markerp viper-local-search-start-marker)
|
||||
(marker-buffer viper-local-search-start-marker))
|
||||
(goto-char viper-local-search-start-marker))
|
||||
(viper-line-pos 'end)))
|
||||
|
||||
(goto-char (point-min))
|
||||
(search-forward click-word
|
||||
viper-mouse-click-search-limit nil)))
|
||||
(goto-char (match-beginning 0))
|
||||
(message "Searching for: %s" viper-s-string)
|
||||
(if (<= arg 1) ; found the right occurrence of the pattern
|
||||
(progn
|
||||
(viper-adjust-window)
|
||||
(viper-flash-search-pattern)))
|
||||
)
|
||||
(error (beep 1)
|
||||
(if (or (not (string= click-word previous-search-string))
|
||||
(not (eq last-command 'viper-mouse-click-search-word)))
|
||||
(message "`%s': String not found in %s"
|
||||
viper-s-string (buffer-name (current-buffer)))
|
||||
(message
|
||||
"`%s': Last occurrence in %s. Back to beginning of search"
|
||||
click-word (buffer-name (current-buffer)))
|
||||
(setq arg 1) ;; to terminate the loop
|
||||
(sit-for 2))
|
||||
(setq viper-mouse-click-search-noerror t)
|
||||
(setq viper-mouse-click-search-limit nil)
|
||||
(if (and (markerp viper-local-search-start-marker)
|
||||
(marker-buffer viper-local-search-start-marker))
|
||||
(goto-char viper-local-search-start-marker))))
|
||||
(setq arg (1- arg)))
|
||||
))))
|
||||
|
||||
(defun vip-mouse-catch-frame-switch (event arg)
|
||||
(defun viper-mouse-catch-frame-switch (event arg)
|
||||
"Catch the event of switching frame.
|
||||
Usually is bound to a 'down-mouse' event to work properly. See sample
|
||||
bindings in the Viper manual."
|
||||
(interactive "e\nP")
|
||||
(setq vip-frame-of-focus nil)
|
||||
;; pass prefix arg along to vip-mouse-click-search/insert-word
|
||||
(setq viper-frame-of-focus nil)
|
||||
;; pass prefix arg along to viper-mouse-click-search/insert-word
|
||||
(setq prefix-arg arg)
|
||||
(if (eq last-command 'handle-switch-frame)
|
||||
(setq vip-frame-of-focus vip-current-frame-saved))
|
||||
;; make Emacs forget that it executed vip-mouse-catch-frame-switch
|
||||
(setq viper-frame-of-focus viper-current-frame-saved))
|
||||
;; make Emacs forget that it executed viper-mouse-catch-frame-switch
|
||||
(setq this-command last-command))
|
||||
|
||||
;; Called just before switching frames. Saves the old selected frame.
|
||||
|
|
@ -431,18 +446,185 @@ bindings in the Viper manual."
|
|||
;; Also, in Emacs sending input to frame B generates handle-switch-frame
|
||||
;; event, while in XEmacs it doesn't.
|
||||
;; All this accounts for the difference in the behavior of
|
||||
;; vip-mouse-click-* commands when you click in a frame other than the one
|
||||
;; viper-mouse-click-* commands when you click in a frame other than the one
|
||||
;; that was the last to receive input. In Emacs, focus will be in frame A
|
||||
;; until you do something other than vip-mouse-click-* command.
|
||||
;; until you do something other than viper-mouse-click-* command.
|
||||
;; In XEmacs, you have to manually select frame B (with the mouse click) in
|
||||
;; order to shift focus to frame B.
|
||||
(defsubst vip-remember-current-frame (frame)
|
||||
(defsubst viper-remember-current-frame (frame)
|
||||
(setq last-command 'handle-switch-frame
|
||||
vip-current-frame-saved (selected-frame)))
|
||||
viper-current-frame-saved (selected-frame)))
|
||||
|
||||
|
||||
;; The key is of the form (MODIFIER ... BUTTON-NUMBER)
|
||||
;; Converts into a valid mouse button spec for the appropriate version of
|
||||
;; Emacs. EVENT-TYPE is either `up' or `down'. Up returns button-up key; down
|
||||
;; returns button-down key.
|
||||
(defun viper-parse-mouse-key (key-var event-type)
|
||||
(let ((key (eval key-var))
|
||||
button-spec meta-spec shift-spec control-spec key-spec)
|
||||
(if (null key)
|
||||
;; just return nil
|
||||
()
|
||||
(setq button-spec
|
||||
(cond ((memq 1 key)
|
||||
(if viper-emacs-p
|
||||
(if (eq 'up event-type)
|
||||
"mouse-1" "down-mouse-1")
|
||||
(if (eq 'up event-type)
|
||||
'button1up 'button1)))
|
||||
((memq 2 key)
|
||||
(if viper-emacs-p
|
||||
(if (eq 'up event-type)
|
||||
"mouse-2" "down-mouse-2")
|
||||
(if (eq 'up event-type)
|
||||
'button2up 'button2)))
|
||||
((memq 3 key)
|
||||
(if viper-emacs-p
|
||||
(if (eq 'up event-type)
|
||||
"mouse-3" "down-mouse-3")
|
||||
(if (eq 'up event-type)
|
||||
'button3up 'button3)))
|
||||
(t (error
|
||||
"%S: invalid button number, %S" key-var key)))
|
||||
meta-spec
|
||||
(if (memq 'meta key)
|
||||
(if viper-emacs-p "M-" 'meta)
|
||||
(if viper-emacs-p "" nil))
|
||||
shift-spec
|
||||
(if (memq 'shift key)
|
||||
(if viper-emacs-p "S-" 'shift)
|
||||
(if viper-emacs-p "" nil))
|
||||
control-spec
|
||||
(if (memq 'control key)
|
||||
(if viper-emacs-p "C-" 'control)
|
||||
(if viper-emacs-p "" nil)))
|
||||
|
||||
(setq key-spec (if viper-emacs-p
|
||||
(vector
|
||||
(intern
|
||||
(concat
|
||||
control-spec meta-spec shift-spec button-spec)))
|
||||
(vector
|
||||
(delq
|
||||
nil
|
||||
(list
|
||||
control-spec meta-spec shift-spec button-spec)))))
|
||||
)))
|
||||
|
||||
(defun viper-unbind-mouse-search-key ()
|
||||
(if viper-mouse-up-search-key-parsed
|
||||
(global-unset-key viper-mouse-up-search-key-parsed))
|
||||
(if viper-mouse-down-search-key-parsed
|
||||
(global-unset-key viper-mouse-down-search-key-parsed))
|
||||
(setq viper-mouse-up-search-key-parsed nil
|
||||
viper-mouse-down-search-key-parsed nil))
|
||||
|
||||
(defun viper-unbind-mouse-insert-key ()
|
||||
(if viper-mouse-up-insert-key-parsed
|
||||
(global-unset-key viper-mouse-up-insert-key-parsed))
|
||||
(if viper-mouse-down-insert-key-parsed
|
||||
(global-unset-key viper-mouse-down-insert-key-parsed))
|
||||
(setq viper-mouse-up-insert-key-parsed nil
|
||||
viper-mouse-down-insert-key-parsed nil))
|
||||
|
||||
;; If FORCE, bind even if this mouse action is already bound to something else
|
||||
(defun viper-bind-mouse-search-key (&optional force)
|
||||
(setq viper-mouse-up-search-key-parsed
|
||||
(viper-parse-mouse-key 'viper-mouse-search-key 'up)
|
||||
viper-mouse-down-search-key-parsed
|
||||
(viper-parse-mouse-key 'viper-mouse-search-key 'down))
|
||||
(cond ((or (null viper-mouse-up-search-key-parsed)
|
||||
(null viper-mouse-down-search-key-parsed))
|
||||
nil) ; just quit
|
||||
((and (null force)
|
||||
(key-binding viper-mouse-up-search-key-parsed)
|
||||
(not (eq (key-binding viper-mouse-up-search-key-parsed)
|
||||
'viper-mouse-click-search-word)))
|
||||
(message
|
||||
"%S already bound to a mouse event. Viper mouse-search feature disabled"
|
||||
viper-mouse-up-search-key-parsed))
|
||||
((and (null force)
|
||||
(key-binding viper-mouse-down-search-key-parsed)
|
||||
(not (eq (key-binding viper-mouse-down-search-key-parsed)
|
||||
'viper-mouse-catch-frame-switch)))
|
||||
(message
|
||||
"%S already bound to a mouse event. Viper mouse-search feature disabled"
|
||||
viper-mouse-down-search-key-parsed))
|
||||
(t
|
||||
(global-set-key viper-mouse-up-search-key-parsed
|
||||
'viper-mouse-click-search-word)
|
||||
(global-set-key viper-mouse-down-search-key-parsed
|
||||
'viper-mouse-catch-frame-switch))))
|
||||
|
||||
;; If FORCE, bind even if this mouse action is already bound to something else
|
||||
(defun viper-bind-mouse-insert-key (&optional force)
|
||||
(setq viper-mouse-up-insert-key-parsed
|
||||
(viper-parse-mouse-key 'viper-mouse-insert-key 'up)
|
||||
viper-mouse-down-insert-key-parsed
|
||||
(viper-parse-mouse-key 'viper-mouse-insert-key 'down))
|
||||
(cond ((or (null viper-mouse-up-insert-key-parsed)
|
||||
(null viper-mouse-down-insert-key-parsed))
|
||||
nil) ; just quit
|
||||
((and (null force)
|
||||
(key-binding viper-mouse-up-insert-key-parsed)
|
||||
(not (eq (key-binding viper-mouse-up-insert-key-parsed)
|
||||
'viper-mouse-click-insert-word)))
|
||||
(message
|
||||
"%S already bound to a mouse event. Viper mouse-insert feature disabled"
|
||||
viper-mouse-up-insert-key-parsed))
|
||||
((and (null force)
|
||||
(key-binding viper-mouse-down-insert-key-parsed)
|
||||
(not (eq (key-binding viper-mouse-down-insert-key-parsed)
|
||||
'viper-mouse-catch-frame-switch)))
|
||||
(message
|
||||
"%S already bound to a mouse event. Viper mouse-insert feature disabled"
|
||||
viper-mouse-down-insert-key-parsed))
|
||||
(t
|
||||
(global-set-key viper-mouse-up-insert-key-parsed
|
||||
'viper-mouse-click-insert-word)
|
||||
(global-set-key viper-mouse-down-insert-key-parsed
|
||||
'viper-mouse-catch-frame-switch))))
|
||||
|
||||
(defun viper-reset-mouse-search-key (symb val)
|
||||
(viper-unbind-mouse-search-key)
|
||||
(set symb val)
|
||||
(viper-bind-mouse-search-key 'force))
|
||||
|
||||
(defun viper-reset-mouse-insert-key (symb val)
|
||||
(viper-unbind-mouse-insert-key)
|
||||
(set symb val)
|
||||
(viper-bind-mouse-insert-key 'force))
|
||||
|
||||
|
||||
(defcustom viper-mouse-search-key '(meta shift 1)
|
||||
"*Key used to click-search in Viper.
|
||||
Must be a list that specifies the mouse button and modifiers. The supported
|
||||
modifiers are `meta', `shift', and `control'. For instance, `(meta shift 1)'
|
||||
means that holding the meta and shift keys down and clicking on a word with
|
||||
mouse button 1 will initiate search for that word in the buffer that was
|
||||
current just before the click. This buffer may be different from the one where
|
||||
the click occurred."
|
||||
:type 'list
|
||||
:set 'viper-reset-mouse-search-key
|
||||
:group 'viper-mouse)
|
||||
|
||||
(defcustom viper-mouse-insert-key '(meta shift 2)
|
||||
"*Key used to click-insert in Viper.
|
||||
Must be a list that specifies the mouse button and modifiers. The supported
|
||||
modifiers are `meta', `shift', and `control'. For instance, `(meta shift 2)'
|
||||
means that holding the meta and shift keys down and clicking on a word with
|
||||
mouse button 2 will insert that word at the cursor in the buffer that was
|
||||
current just before the click. This buffer may be different from the one where
|
||||
the click occurred."
|
||||
:type 'list
|
||||
:set 'viper-reset-mouse-insert-key
|
||||
:group 'viper-mouse)
|
||||
|
||||
|
||||
|
||||
;;; Local Variables:
|
||||
;;; eval: (put 'vip-deflocalvar 'lisp-indent-hook 'defun)
|
||||
;;; eval: (put 'viper-deflocalvar 'lisp-indent-hook 'defun)
|
||||
;;; End:
|
||||
|
||||
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue