comparison lisp/emulation/viper-cmd.el @ 106895:181539c8b6a4

Fix typos in docstrings, error messages, etc.
author Juanma Barranquero <lekktu@gmail.com>
date Mon, 18 Jan 2010 05:39:40 +0100
parents 1d1d5d9bd884
children 5e3accd3ae49 376148b31b5e
comparison
equal deleted inserted replaced
106894:b3b9ebd930e1 106895:181539c8b6a4
477 (assoc major-mode viper-emacs-state-modifier-alist))) 477 (assoc major-mode viper-emacs-state-modifier-alist)))
478 (cdr 478 (cdr
479 (assoc major-mode viper-emacs-state-modifier-alist)) 479 (assoc major-mode viper-emacs-state-modifier-alist))
480 viper-empty-keymap)) 480 viper-empty-keymap))
481 )) 481 ))
482 482
483 ;; This var is not local in Emacs, so we make it local. It must be local 483 ;; This var is not local in Emacs, so we make it local. It must be local
484 ;; because although the stack of minor modes can be the same for all buffers, 484 ;; because although the stack of minor modes can be the same for all buffers,
485 ;; the associated *keymaps* can be different. In Viper, 485 ;; the associated *keymaps* can be different. In Viper,
486 ;; viper-vi-local-user-map, viper-insert-local-user-map, and others can have 486 ;; viper-vi-local-user-map, viper-insert-local-user-map, and others can have
487 ;; different keymaps for different buffers. Also, the keymaps associated 487 ;; different keymaps for different buffers. Also, the keymaps associated
889 (viper-set-mode-vars-for viper-current-state) 889 (viper-set-mode-vars-for viper-current-state)
890 ) 890 )
891 891
892 892
893 (defun viper-exec-form-in-vi (form) 893 (defun viper-exec-form-in-vi (form)
894 "Execute FORM in Vi state, regardless of the Ccurrent Vi state." 894 "Execute FORM in Vi state, regardless of the current Vi state."
895 (let ((buff (current-buffer)) 895 (let ((buff (current-buffer))
896 result) 896 result)
897 (viper-set-mode-vars-for 'vi-state) 897 (viper-set-mode-vars-for 'vi-state)
898 898
899 (condition-case nil 899 (condition-case nil
908 (viper-set-mode-vars-for viper-current-state) 908 (viper-set-mode-vars-for viper-current-state)
909 result)) 909 result))
910 910
911 (defun viper-exec-form-in-emacs (form) 911 (defun viper-exec-form-in-emacs (form)
912 "Execute FORM in Emacs, temporarily disabling Viper's minor modes. 912 "Execute FORM in Emacs, temporarily disabling Viper's minor modes.
913 Similar to viper-escape-to-emacs, but accepts forms rather than keystrokes." 913 Similar to `viper-escape-to-emacs', but accepts forms rather than keystrokes."
914 (let ((buff (current-buffer)) 914 (let ((buff (current-buffer))
915 result) 915 result)
916 (viper-set-mode-vars-for 'emacs-state) 916 (viper-set-mode-vars-for 'emacs-state)
917 (setq result (eval form)) 917 (setq result (eval form))
918 (if (not (equal buff (current-buffer))) ; cmd switched buffer 918 (if (not (equal buff (current-buffer))) ; cmd switched buffer
937 This function is designed to make Viper aware of the packages that define 937 This function is designed to make Viper aware of the packages that define
938 such minor modes. 938 such minor modes.
939 Usage: 939 Usage:
940 (viper-harness-minor-mode load-file) 940 (viper-harness-minor-mode load-file)
941 941
942 LOAD-FILE is a name of the file where the specific minor mode is defined. 942 LOAD-FILE is the name of the file where the specific minor mode is defined.
943 Suffixes such as .el or .elc should be stripped." 943 Suffixes such as .el or .elc should be stripped."
944 944
945 (interactive "sEnter name of the load file: ") 945 (interactive "sEnter name of the load file: ")
946 946
947 (eval-after-load load-file '(viper-normalize-minor-mode-map-alist)) 947 (eval-after-load load-file '(viper-normalize-minor-mode-map-alist))
959 "Emulate ESC key in Emacs. 959 "Emulate ESC key in Emacs.
960 Prevents multiple escape keystrokes if viper-no-multiple-ESC is true. 960 Prevents multiple escape keystrokes if viper-no-multiple-ESC is true.
961 If viper-no-multiple-ESC is 'twice double ESC would ding in vi-state. 961 If viper-no-multiple-ESC is 'twice double ESC would ding in vi-state.
962 Other ESC sequences are emulated via the current Emacs's major mode 962 Other ESC sequences are emulated via the current Emacs's major mode
963 keymap. This is more convenient on TTYs, since this won't block 963 keymap. This is more convenient on TTYs, since this won't block
964 function keys such as up,down, etc. ESC will also will also work as 964 function keys such as up, down, etc. ESC will also will also work as
965 a Meta key in this case. When viper-no-multiple-ESC is nil, ESC functions 965 a Meta key in this case. When viper-no-multiple-ESC is nil, ESC works
966 as a Meta key and any number of multiple escapes is allowed." 966 as a Meta key and any number of multiple escapes are allowed."
967 (interactive "P") 967 (interactive "P")
968 (let (char) 968 (let (char)
969 (cond ((and (not viper-no-multiple-ESC) (eq viper-current-state 'vi-state)) 969 (cond ((and (not viper-no-multiple-ESC) (eq viper-current-state 'vi-state))
970 (setq char (viper-read-char-exclusive)) 970 (setq char (viper-read-char-exclusive))
971 (viper-escape-to-emacs arg (list ?\e char) )) 971 (viper-escape-to-emacs arg (list ?\e char) ))
1179 ;; we typed. 1179 ;; we typed.
1180 (cond ((eq event-char 'return) (setq event-char ?\C-m)) 1180 (cond ((eq event-char 'return) (setq event-char ?\C-m))
1181 ((eq event-char 'delete) (setq event-char ?\C-?)) 1181 ((eq event-char 'delete) (setq event-char ?\C-?))
1182 ((eq event-char 'backspace) (setq event-char ?\C-h)) 1182 ((eq event-char 'backspace) (setq event-char ?\C-h))
1183 ((eq event-char 'space) (setq event-char ?\ ))) 1183 ((eq event-char 'space) (setq event-char ?\ )))
1184 (setq last-command-event 1184 (setq last-command-event
1185 (if (featurep 'xemacs) 1185 (if (featurep 'xemacs)
1186 (character-to-event (or com event-char)) 1186 (character-to-event (or com event-char))
1187 (or com event-char))) 1187 (or com event-char)))
1188 (setq func (viper-exec-form-in-vi 1188 (setq func (viper-exec-form-in-vi
1189 `(key-binding (char-to-string ,event-char)))) 1189 `(key-binding (char-to-string ,event-char))))
1255 (viper-exec-form-in-vi 1255 (viper-exec-form-in-vi
1256 `(key-binding (char-to-string ,char))))) 1256 `(key-binding (char-to-string ,char)))))
1257 1257
1258 ;; as com is non-nil, this means that we have a command to execute 1258 ;; as com is non-nil, this means that we have a command to execute
1259 (if (viper-memq-char (car com) '(?r ?R)) 1259 (if (viper-memq-char (car com) '(?r ?R))
1260 ;; execute apropriate region command. 1260 ;; execute appropriate region command.
1261 (let ((char (car com)) (com (cdr com))) 1261 (let ((char (car com)) (com (cdr com)))
1262 (setq prefix-arg (cons value com)) 1262 (setq prefix-arg (cons value com))
1263 (if (viper= char ?r) 1263 (if (viper= char ?r)
1264 (viper-region prefix-arg) 1264 (viper-region prefix-arg)
1265 (viper-Region prefix-arg)) 1265 (viper-Region prefix-arg))
1283 ((equal com '(?! . ?!)) (viper-line (cons value ?!))) 1283 ((equal com '(?! . ?!)) (viper-line (cons value ?!)))
1284 ((equal com '(?= . ?=)) (viper-line (cons value ?=))) 1284 ((equal com '(?= . ?=)) (viper-line (cons value ?=)))
1285 ;; gg acts as G0 1285 ;; gg acts as G0
1286 ((equal (car com) ?g) (viper-goto-line 0)) 1286 ((equal (car com) ?g) (viper-goto-line 0))
1287 (t (error "Viper bell"))))) 1287 (t (error "Viper bell")))))
1288 1288
1289 (if cmd-to-exec-at-end 1289 (if cmd-to-exec-at-end
1290 (progn 1290 (progn
1291 (setq last-command-event 1291 (setq last-command-event
1292 (viper-copy-event 1292 (viper-copy-event
1293 (if (featurep 'xemacs) (character-to-event char) char))) 1293 (if (featurep 'xemacs) (character-to-event char) char)))
1619 Use the info in viper-d-com, which has the form 1619 Use the info in viper-d-com, which has the form
1620 \(com val ch reg inserted-text command-keys\), 1620 \(com val ch reg inserted-text command-keys\),
1621 where `com' is the command to be re-executed, `val' is the 1621 where `com' is the command to be re-executed, `val' is the
1622 argument to `com', `ch' is a flag for repeat, and `reg' is optional; 1622 argument to `com', `ch' is a flag for repeat, and `reg' is optional;
1623 if it exists, it is the name of the register for `com'. 1623 if it exists, it is the name of the register for `com'.
1624 If the prefix argument, ARG, is non-nil, it is used instead of `val'." 1624 If the prefix argument ARG is non-nil, it is used instead of `val'."
1625 (interactive "P") 1625 (interactive "P")
1626 (let ((save-point (point)) ; save point before repeating prev cmd 1626 (let ((save-point (point)) ; save point before repeating prev cmd
1627 ;; Pass along that we are repeating a destructive command 1627 ;; Pass along that we are repeating a destructive command
1628 ;; This tells viper-set-destructive-command not to update 1628 ;; This tells viper-set-destructive-command not to update
1629 ;; viper-command-ring 1629 ;; viper-command-ring
1942 (if (and (eobp) 1942 (if (and (eobp)
1943 (not (bolp)) 1943 (not (bolp))
1944 require-final-newline 1944 require-final-newline
1945 ;; add newline only if we actually edited buffer. otherwise it 1945 ;; add newline only if we actually edited buffer. otherwise it
1946 ;; might unintentionally modify binary buffers 1946 ;; might unintentionally modify binary buffers
1947 (buffer-modified-p) 1947 (buffer-modified-p)
1948 (not (viper-is-in-minibuffer)) 1948 (not (viper-is-in-minibuffer))
1949 (not buffer-read-only)) 1949 (not buffer-read-only))
1950 ;; text property may be read-only 1950 ;; text property may be read-only
1951 (condition-case nil 1951 (condition-case nil
1952 (insert "\n") 1952 (insert "\n")
2537 2537
2538 2538
2539 2539
2540 (defun viper-replace-state-exit-cmd () 2540 (defun viper-replace-state-exit-cmd ()
2541 "Binding for keys that cause Replace state to switch to Vi or to Insert. 2541 "Binding for keys that cause Replace state to switch to Vi or to Insert.
2542 These keys are ESC, RET, and LineFeed" 2542 These keys are ESC, RET, and LineFeed."
2543 (interactive) 2543 (interactive)
2544 (if overwrite-mode ; if in replace mode invoked via 'R' 2544 (if overwrite-mode ; if in replace mode invoked via 'R'
2545 (viper-finish-R-mode) 2545 (viper-finish-R-mode)
2546 (viper-finish-change)) 2546 (viper-finish-change))
2547 (let (com) 2547 (let (com)
3709 3709
3710 3710
3711 (defun viper-toggle-search-style (arg) 3711 (defun viper-toggle-search-style (arg)
3712 "Toggle the value of viper-case-fold-search/viper-re-search. 3712 "Toggle the value of viper-case-fold-search/viper-re-search.
3713 Without prefix argument, will ask which search style to toggle. With prefix 3713 Without prefix argument, will ask which search style to toggle. With prefix
3714 arg 1,toggles viper-case-fold-search; with arg 2 toggles viper-re-search. 3714 arg 1, toggles viper-case-fold-search; with arg 2 toggles viper-re-search.
3715 3715
3716 Although this function is bound to \\[viper-toggle-search-style], the most 3716 Although this function is bound to \\[viper-toggle-search-style], the most
3717 convenient way to use it is to bind `//' to the macro 3717 convenient way to use it is to bind `//' to the macro
3718 `1 M-x viper-toggle-search-style' and `///' to 3718 `1 M-x viper-toggle-search-style' and `///' to
3719 `2 M-x viper-toggle-search-style'. In this way, hitting `//' quickly will 3719 `2 M-x viper-toggle-search-style'. In this way, hitting `//' quickly will
4260 4260
4261 4261
4262 (defun viper-del-backward-char-in-replace () 4262 (defun viper-del-backward-char-in-replace ()
4263 "Delete one character in replace mode. 4263 "Delete one character in replace mode.
4264 If `viper-delete-backwards-in-replace' is t, then DEL key actually deletes 4264 If `viper-delete-backwards-in-replace' is t, then DEL key actually deletes
4265 charecters. If it is nil, then the cursor just moves backwards, similarly 4265 characters. If it is nil, then the cursor just moves backwards, similarly
4266 to Vi. The variable `viper-ex-style-editing', if t, doesn't let the 4266 to Vi. The variable `viper-ex-style-editing', if t, doesn't let the
4267 cursor move past the beginning of line." 4267 cursor move past the beginning of line."
4268 (interactive) 4268 (interactive)
4269 (cond (viper-delete-backwards-in-replace 4269 (cond (viper-delete-backwards-in-replace
4270 (cond ((not (bolp)) 4270 (cond ((not (bolp))
4612 (interactive) 4612 (interactive)
4613 (setq viper-cted t) 4613 (setq viper-cted t)
4614 (indent-to (+ (current-column) viper-shift-width))) 4614 (indent-to (+ (current-column) viper-shift-width)))
4615 4615
4616 (defun viper-backward-indent () 4616 (defun viper-backward-indent ()
4617 "Backtab, C-d in VI" 4617 "Backtab, `C-d' in Vi."
4618 (interactive) 4618 (interactive)
4619 (if viper-cted 4619 (if viper-cted
4620 (let ((p (point)) (c (current-column)) bol (indent t)) 4620 (let ((p (point)) (c (current-column)) bol (indent t))
4621 (if (viper-looking-back "[0^]") 4621 (if (viper-looking-back "[0^]")
4622 (progn 4622 (progn
4687 (viper-next-heading arg)) 4687 (viper-next-heading arg))
4688 (t (error 4688 (t (error
4689 viper-InvalidRegister reg))))) 4689 viper-InvalidRegister reg)))))
4690 4690
4691 (defun viper-brac-function (arg) 4691 (defun viper-brac-function (arg)
4692 "Function called by \[, the brac. View textmarkers and call \[\[" 4692 "Function called by \[, the brac. View textmarkers and call \[\[."
4693 (interactive "P") 4693 (interactive "P")
4694 (let ((reg (read-char))) 4694 (let ((reg (read-char)))
4695 (cond ((viper= ?\[ reg) 4695 (cond ((viper= ?\[ reg)
4696 (viper-prev-heading arg)) 4696 (viper-prev-heading arg))
4697 ((viper= ?\] reg) 4697 ((viper= ?\] reg)
4920 (beep 1)) 4920 (beep 1))
4921 4921
4922 4922
4923 ;; if ENFORCE-BUFFER is not nil, error if CHAR is a marker in another buffer 4923 ;; if ENFORCE-BUFFER is not nil, error if CHAR is a marker in another buffer
4924 (defun viper-register-to-point (char &optional enforce-buffer) 4924 (defun viper-register-to-point (char &optional enforce-buffer)
4925 "Like jump-to-register, but switches to another buffer in another window." 4925 "Like `jump-to-register', but switches to another buffer in another window."
4926 (interactive "cViper register to point: ") 4926 (interactive "cViper register to point: ")
4927 (let ((val (get-register char))) 4927 (let ((val (get-register char)))
4928 (cond 4928 (cond
4929 ((and (fboundp 'frame-configuration-p) 4929 ((and (fboundp 'frame-configuration-p)
4930 (frame-configuration-p val)) 4930 (frame-configuration-p val))
5045 (princ " 5045 (princ "
5046 PLEASE FOLLOW THESE PROCEDURES 5046 PLEASE FOLLOW THESE PROCEDURES
5047 ------------------------------ 5047 ------------------------------
5048 5048
5049 Before reporting a bug, please verify that it is related to Viper, and is 5049 Before reporting a bug, please verify that it is related to Viper, and is
5050 not cause by other packages you are using. 5050 not caused by other packages you are using.
5051 5051
5052 Don't report compilation warnings, unless you are certain that there is a 5052 Don't report compilation warnings, unless you are certain that there is a
5053 problem. These warnings are normal and unavoidable. 5053 problem. These warnings are normal and unavoidable.
5054 5054
5055 Please note that users should not modify variables and keymaps other than 5055 Please note that users should not modify variables and keymaps other than