Mercurial > hg > xemacs-beta
comparison lisp/viper/viper-cmd.el @ 175:2d532a89d707 r20-3b14
Import from CVS: tag r20-3b14
author | cvs |
---|---|
date | Mon, 13 Aug 2007 09:50:14 +0200 |
parents | 0132846995bd |
children | bfd6434d15b3 |
comparison
equal
deleted
inserted
replaced
174:bb3568571b84 | 175:2d532a89d707 |
---|---|
11 (defvar vip-minibuffer-current-face) | 11 (defvar vip-minibuffer-current-face) |
12 (defvar vip-minibuffer-insert-face) | 12 (defvar vip-minibuffer-insert-face) |
13 (defvar vip-minibuffer-vi-face) | 13 (defvar vip-minibuffer-vi-face) |
14 (defvar vip-minibuffer-emacs-face) | 14 (defvar vip-minibuffer-emacs-face) |
15 (defvar viper-always) | 15 (defvar viper-always) |
16 (defvar vip-mode-string ) | 16 (defvar vip-mode-string) |
17 (defvar vip-custom-file-name) | |
17 (defvar iso-accents-mode) | 18 (defvar iso-accents-mode) |
18 (defvar zmacs-region-stays) | 19 (defvar zmacs-region-stays) |
19 (defvar mark-even-if-inactive) | 20 (defvar mark-even-if-inactive) |
20 | 21 |
21 ;; loading happens only in non-interactive compilation | 22 ;; loading happens only in non-interactive compilation |
75 (vip-test-com-defun vip-charpair-command) | 76 (vip-test-com-defun vip-charpair-command) |
76 | 77 |
77 (defconst vip-movement-commands '(?b ?B ?e ?E ?f ?F ?G ?h ?H ?j ?k ?l | 78 (defconst vip-movement-commands '(?b ?B ?e ?E ?f ?F ?G ?h ?H ?j ?k ?l |
78 ?H ?M ?L ?n ?t ?T ?w ?W ?$ ?% | 79 ?H ?M ?L ?n ?t ?T ?w ?W ?$ ?% |
79 ?^ ?( ?) ?- ?+ ?| ?{ ?} ?[ ?] ?' ?` | 80 ?^ ?( ?) ?- ?+ ?| ?{ ?} ?[ ?] ?' ?` |
80 ?; ?, ?0 ?? ?/ | 81 ?; ?, ?0 ?? ?/ ?\C-m ?\ |
81 ) | 82 ) |
82 "Movement commands") | 83 "Movement commands") |
83 ;; define vip-movement-command-p | 84 ;; define vip-movement-command-p |
84 (vip-test-com-defun vip-movement-command) | 85 (vip-test-com-defun vip-movement-command) |
85 | 86 |
86 (defconst vip-digit-commands '(?1 ?2 ?3 ?4 ?5 ?6 ?7 ?8 ?9) | 87 ;; Vi digit commands |
87 "Digit commands") | 88 (defconst vip-digit-commands '(?1 ?2 ?3 ?4 ?5 ?6 ?7 ?8 ?9)) |
89 | |
88 ;; define vip-digit-command-p | 90 ;; define vip-digit-command-p |
89 (vip-test-com-defun vip-digit-command) | 91 (vip-test-com-defun vip-digit-command) |
90 | 92 |
91 ;; Commands that can be repeated by . (dotted) | 93 ;; Commands that can be repeated by . (dotted) |
92 (defconst vip-dotable-commands '(?c ?d ?C ?s ?S ?D ?> ?<)) | 94 (defconst vip-dotable-commands '(?c ?d ?C ?s ?S ?D ?> ?<)) |
763 (vip-escape-to-emacs arg '(?\e))) | 765 (vip-escape-to-emacs arg '(?\e))) |
764 | 766 |
765 (defun vip-toggle-key-action () | 767 (defun vip-toggle-key-action () |
766 "Action bound to `vip-toggle-key'." | 768 "Action bound to `vip-toggle-key'." |
767 (interactive) | 769 (interactive) |
768 (if (and (< vip-expert-level 2) (equal vip-toggle-key "\C-z")) | 770 (if (and (< viper-expert-level 2) (equal vip-toggle-key "\C-z")) |
769 (if (vip-window-display-p) | 771 (if (vip-window-display-p) |
770 (vip-iconify) | 772 (vip-iconify) |
771 (suspend-emacs)) | 773 (suspend-emacs)) |
772 (vip-change-state-to-emacs))) | 774 (vip-change-state-to-emacs))) |
773 | 775 |
1356 (setq vip-use-register reg) | 1358 (setq vip-use-register reg) |
1357 (if (nth 4 vip-d-com) ; text inserted by command | 1359 (if (nth 4 vip-d-com) ; text inserted by command |
1358 (setq vip-last-insertion (nth 4 vip-d-com) | 1360 (setq vip-last-insertion (nth 4 vip-d-com) |
1359 vip-d-char (nth 4 vip-d-com))) | 1361 vip-d-char (nth 4 vip-d-com))) |
1360 (funcall m-com (cons val com)) | 1362 (funcall m-com (cons val com)) |
1361 (if (and vip-keep-point-on-repeat (< save-point (point))) | 1363 (cond ((and (< save-point (point)) vip-keep-point-on-repeat) |
1362 (goto-char save-point)) ; go back to before repeat. | 1364 (goto-char save-point)) ; go back to before repeat. |
1365 ((and (< save-point (point)) vip-ex-style-editing-in-insert) | |
1366 (or (bolp) (backward-char 1)))) | |
1363 (if (and (eolp) (not (bolp))) | 1367 (if (and (eolp) (not (bolp))) |
1364 (backward-char 1)) | 1368 (backward-char 1)) |
1365 )) | 1369 )) |
1366 (if vip-undo-needs-adjustment (vip-adjust-undo)) ; take care of undo | 1370 (if vip-undo-needs-adjustment (vip-adjust-undo)) ; take care of undo |
1367 ;; If the prev cmd was rotating the command ring, this means that `.' has | 1371 ;; If the prev cmd was rotating the command ring, this means that `.' has |
2981 (t (error "")))))) | 2985 (t (error "")))))) |
2982 | 2986 |
2983 (defun vip-toggle-parse-sexp-ignore-comments () | 2987 (defun vip-toggle-parse-sexp-ignore-comments () |
2984 (interactive) | 2988 (interactive) |
2985 (setq vip-parse-sexp-ignore-comments (not vip-parse-sexp-ignore-comments)) | 2989 (setq vip-parse-sexp-ignore-comments (not vip-parse-sexp-ignore-comments)) |
2986 (prin1 (format "`%%' will %signore parentheses inside the comments" | 2990 (princ (format |
2987 (if vip-parse-sexp-ignore-comments "" "NOT "))) | 2991 "From now on, `%%' will %signore parentheses inside comment fields" |
2988 ) | 2992 (if vip-parse-sexp-ignore-comments "" "NOT ")))) |
2989 | 2993 |
2990 | 2994 |
2991 ;; sentence ,paragraph and heading | 2995 ;; sentence ,paragraph and heading |
2992 | 2996 |
2993 (defun vip-forward-sentence (arg) | 2997 (defun vip-forward-sentence (arg) |
3178 (if vip-re-search | 3182 (if vip-re-search |
3179 (setq msg "Search becomes regexp-style") | 3183 (setq msg "Search becomes regexp-style") |
3180 (setq msg "Search becomes vanilla-style"))) | 3184 (setq msg "Search becomes vanilla-style"))) |
3181 (t | 3185 (t |
3182 (setq msg "Search style remains unchanged"))) | 3186 (setq msg "Search style remains unchanged"))) |
3183 (prin1 msg t))) | 3187 (princ msg t))) |
3184 | 3188 |
3185 (defun vip-set-vi-search-style-macros (unset) | 3189 (defun vip-set-searchstyle-toggling-macros (unset) |
3186 "Set the macros for toggling the search style in Viper's vi-state. | 3190 "Set the macros for toggling the search style in Viper's vi-state. |
3187 The macro that toggles case sensitivity is bound to `//', and the one that | 3191 The macro that toggles case sensitivity is bound to `//', and the one that |
3188 toggles regexp search is bound to `///'. | 3192 toggles regexp search is bound to `///'. |
3189 With a prefix argument, this function unsets the macros. " | 3193 With a prefix argument, this function unsets the macros. " |
3190 (interactive "P") | 3194 (interactive "P") |
3201 "///" 'vi-state | 3205 "///" 'vi-state |
3202 [2 (meta x) v i p - t o g g l e - s e a r c h - s t y l e return] | 3206 [2 (meta x) v i p - t o g g l e - s e a r c h - s t y l e return] |
3203 't) | 3207 't) |
3204 (if (interactive-p) | 3208 (if (interactive-p) |
3205 (message | 3209 (message |
3206 "// and /// now toggle case-sensitivity and regexp search."))) | 3210 "// and /// now toggle case-sensitivity and regexp search"))) |
3207 (vip-unrecord-kbd-macro "//" 'vi-state) | 3211 (vip-unrecord-kbd-macro "//" 'vi-state) |
3208 (sit-for 2) | 3212 (sit-for 2) |
3209 (vip-unrecord-kbd-macro "///" 'vi-state)))) | 3213 (vip-unrecord-kbd-macro "///" 'vi-state)))) |
3210 | 3214 |
3211 (defun vip-set-emacs-search-style-macros (unset &optional arg-majormode) | 3215 |
3216 (defun vip-set-parsing-style-toggling-macro (unset) | |
3217 "Set `%%%' to be a macro that toggles whether comment fields should be parsed for matching parentheses. | |
3218 This is used in conjunction with the `%' command. | |
3219 | |
3220 With a prefix argument, unsets the macro." | |
3221 (interactive "P") | |
3222 (or noninteractive | |
3223 (if (not unset) | |
3224 (progn | |
3225 ;; Make %%% toggle parsing comments for matching parentheses | |
3226 (vip-record-kbd-macro | |
3227 "%%%" 'vi-state | |
3228 [(meta x) v i p - t o g g l e - p a r s e - s e x p - i g n o r e - c o m m e n t s return] | |
3229 't) | |
3230 (if (interactive-p) | |
3231 (message | |
3232 "%%%%%% now toggles whether comments should be parsed for matching parentheses"))) | |
3233 (vip-unrecord-kbd-macro "%%%" 'vi-state)))) | |
3234 | |
3235 | |
3236 (defun vip-set-emacs-state-searchstyle-macros (unset &optional arg-majormode) | |
3212 "Set the macros for toggling the search style in Viper's emacs-state. | 3237 "Set the macros for toggling the search style in Viper's emacs-state. |
3213 The macro that toggles case sensitivity is bound to `//', and the one that | 3238 The macro that toggles case sensitivity is bound to `//', and the one that |
3214 toggles regexp search is bound to `///'. | 3239 toggles regexp search is bound to `///'. |
3215 With a prefix argument, this function unsets the macros. | 3240 With a prefix argument, this function unsets the macros. |
3216 If the optional prefix argument is non-nil and specifies a valid major mode, | 3241 If the optional prefix argument is non-nil and specifies a valid major mode, |
3454 buffer-name))) | 3479 buffer-name))) |
3455 (kill-buffer buffer) | 3480 (kill-buffer buffer) |
3456 (error "Buffer not killed")))) | 3481 (error "Buffer not killed")))) |
3457 | 3482 |
3458 | 3483 |
3459 (defvar vip-smart-suffix-list | 3484 (defcustom vip-smart-suffix-list |
3460 '("" "tex" "c" "cc" "C" "el" "java" "html" "htm" "pl" "P" "p") | 3485 '("" "tex" "c" "cc" "C" "el" "java" "html" "htm" "pl" "P" "p") |
3461 "*List of suffixes that Viper automatically tries to append to filenames ending with a `.'. | 3486 "*List of suffixes that Viper automatically tries to append to filenames ending with a `.'. |
3462 This is useful when you the current directory contains files with the same | 3487 This is useful when you the current directory contains files with the same |
3463 prefix and many different suffixes. Usually, only one of the suffixes | 3488 prefix and many different suffixes. Usually, only one of the suffixes |
3464 represents an editable file. However, file completion will stop at the `.' | 3489 represents an editable file. However, file completion will stop at the `.' |
3467 | 3492 |
3468 Suffixes are tried in the order given and the first suffix for which a | 3493 Suffixes are tried in the order given and the first suffix for which a |
3469 corresponding file exists is selected. If no file exists for any of the | 3494 corresponding file exists is selected. If no file exists for any of the |
3470 suffixes, the user is asked to confirm. | 3495 suffixes, the user is asked to confirm. |
3471 | 3496 |
3472 To turn this feature off, set this variable to nil.") | 3497 To turn this feature off, set this variable to nil." |
3498 :type '(set string) | |
3499 :group 'viper) | |
3473 | 3500 |
3474 ;; Try to add suffix to files ending with a `.' | 3501 ;; Try to add suffix to files ending with a `.' |
3475 ;; Useful when the user hits RET on a non-completed file name. | 3502 ;; Useful when the user hits RET on a non-completed file name. |
3476 (defun vip-file-add-suffix () | 3503 (defun vip-file-add-suffix () |
3477 (let ((count 0) | 3504 (let ((count 0) |
3700 (end-of-line) | 3727 (end-of-line) |
3701 (if (not (eobp)) | 3728 (if (not (eobp)) |
3702 (progn | 3729 (progn |
3703 (forward-line 1) | 3730 (forward-line 1) |
3704 (delete-region (point) (1- (point))) | 3731 (delete-region (point) (1- (point))) |
3705 (fixup-whitespace))))))) | 3732 (fixup-whitespace) |
3733 ;; fixup-whitespace sometimes does not leave space | |
3734 ;; between objects, so we insert it as in Vi | |
3735 (or (looking-at " ") | |
3736 (insert " ") | |
3737 (backward-char 1)) | |
3738 )))))) | |
3706 | 3739 |
3707 | 3740 |
3708 ;; Replace state | 3741 ;; Replace state |
3709 | 3742 |
3710 (defun vip-change (beg end) | 3743 (defun vip-change (beg end) |
4129 (backward-word arg) | 4162 (backward-word arg) |
4130 (delete-region (point) (mark t)) | 4163 (delete-region (point) (mark t)) |
4131 (pop-mark))) | 4164 (pop-mark))) |
4132 | 4165 |
4133 | 4166 |
4134 (defun vip-set-expert-level (&optional dont-change-unless) | 4167 (defun viper-set-expert-level (&optional dont-change-unless) |
4135 "Sets the expert level for a Viper user. | 4168 "Sets the expert level for a Viper user. |
4136 Can be called interactively to change (temporarily or permanently) the | 4169 Can be called interactively to change (temporarily or permanently) the |
4137 current expert level. | 4170 current expert level. |
4138 | 4171 |
4139 The optional argument DONT-CHANGE-UNLESS, if not nil, says that | 4172 The optional argument DONT-CHANGE-UNLESS, if not nil, says that |
4143 User level determines the setting of Viper variables that are most | 4176 User level determines the setting of Viper variables that are most |
4144 sensitive for VI-style look-and-feel." | 4177 sensitive for VI-style look-and-feel." |
4145 | 4178 |
4146 (interactive) | 4179 (interactive) |
4147 | 4180 |
4148 (if (not (natnump vip-expert-level)) (setq vip-expert-level 0)) | 4181 (if (not (natnump viper-expert-level)) (setq viper-expert-level 0)) |
4149 | 4182 |
4150 (save-window-excursion | 4183 (save-window-excursion |
4151 (delete-other-windows) | 4184 (delete-other-windows) |
4152 ;; if 0 < vip-expert-level < vip-max-expert-level | 4185 ;; if 0 < viper-expert-level < viper-max-expert-level |
4153 ;; & dont-change-unless = t -- use it; else ask | 4186 ;; & dont-change-unless = t -- use it; else ask |
4154 (vip-ask-level dont-change-unless)) | 4187 (vip-ask-level dont-change-unless)) |
4155 | 4188 |
4156 (setq viper-always t | 4189 (setq viper-always t |
4157 vip-ex-style-motion t | 4190 vip-ex-style-motion t |
4158 vip-ex-style-editing-in-insert t | 4191 vip-ex-style-editing-in-insert t |
4159 vip-want-ctl-h-help nil) | 4192 vip-want-ctl-h-help nil) |
4160 | 4193 |
4161 (cond ((eq vip-expert-level 1) ; novice or beginner | 4194 (cond ((eq viper-expert-level 1) ; novice or beginner |
4162 (global-set-key ; in emacs-state | 4195 (global-set-key ; in emacs-state |
4163 vip-toggle-key | 4196 vip-toggle-key |
4164 (if (vip-window-display-p) 'vip-iconify 'suspend-emacs)) | 4197 (if (vip-window-display-p) 'vip-iconify 'suspend-emacs)) |
4165 (setq vip-no-multiple-ESC t | 4198 (setq vip-no-multiple-ESC t |
4166 vip-re-search t | 4199 vip-re-search t |
4168 vip-search-wrap-around-t t | 4201 vip-search-wrap-around-t t |
4169 vip-electric-mode nil | 4202 vip-electric-mode nil |
4170 vip-want-emacs-keys-in-vi nil | 4203 vip-want-emacs-keys-in-vi nil |
4171 vip-want-emacs-keys-in-insert nil)) | 4204 vip-want-emacs-keys-in-insert nil)) |
4172 | 4205 |
4173 ((and (> vip-expert-level 1) (< vip-expert-level 5)) | 4206 ((and (> viper-expert-level 1) (< viper-expert-level 5)) |
4174 ;; intermediate to guru | 4207 ;; intermediate to guru |
4175 (setq vip-no-multiple-ESC (if (vip-window-display-p) | 4208 (setq vip-no-multiple-ESC (if (vip-window-display-p) |
4176 t 'twice) | 4209 t 'twice) |
4177 vip-electric-mode t | 4210 vip-electric-mode t |
4178 vip-want-emacs-keys-in-vi t | 4211 vip-want-emacs-keys-in-vi t |
4179 vip-want-emacs-keys-in-insert (> vip-expert-level 2)) | 4212 vip-want-emacs-keys-in-insert (> viper-expert-level 2)) |
4180 | 4213 |
4181 (if (eq vip-expert-level 4) ; respect user's ex-style motion | 4214 (if (eq viper-expert-level 4) ; respect user's ex-style motion |
4182 ; and vip-no-multiple-ESC | 4215 ; and vip-no-multiple-ESC |
4183 (progn | 4216 (progn |
4184 (setq-default vip-ex-style-editing-in-insert | 4217 (setq-default |
4185 (cdr (assoc 'vip-ex-style-editing-in-insert | 4218 vip-ex-style-editing-in-insert |
4186 vip-saved-user-settings)) | 4219 (viper-standard-value 'vip-ex-style-editing-in-insert) |
4187 vip-ex-style-motion | 4220 vip-ex-style-motion |
4188 (cdr (assoc 'vip-ex-style-motion | 4221 (viper-standard-value 'vip-ex-style-motion)) |
4189 vip-saved-user-settings))) | |
4190 (setq vip-ex-style-motion | 4222 (setq vip-ex-style-motion |
4191 (cdr (assoc 'vip-ex-style-motion vip-saved-user-settings)) | 4223 (viper-standard-value 'vip-ex-style-motion) |
4192 vip-ex-style-editing-in-insert | 4224 vip-ex-style-editing-in-insert |
4193 (cdr (assoc 'vip-ex-style-editing-in-insert | 4225 (viper-standard-value 'vip-ex-style-editing-in-insert) |
4194 vip-saved-user-settings)) | |
4195 vip-re-search | 4226 vip-re-search |
4196 (cdr (assoc 'vip-re-search vip-saved-user-settings)) | 4227 (viper-standard-value 'vip-re-search) |
4197 vip-no-multiple-ESC | 4228 vip-no-multiple-ESC |
4198 (cdr (assoc 'vip-no-multiple-ESC | 4229 (viper-standard-value 'vip-no-multiple-ESC))))) |
4199 vip-saved-user-settings)))))) | 4230 |
4200 | |
4201 ;; A wizard!! | 4231 ;; A wizard!! |
4202 ;; Ideally, if 5 is selected, a buffer should pop up to let the | 4232 ;; Ideally, if 5 is selected, a buffer should pop up to let the |
4203 ;; user toggle the values of variables. | 4233 ;; user toggle the values of variables. |
4204 (t (setq-default vip-ex-style-editing-in-insert | 4234 (t (setq-default vip-ex-style-editing-in-insert |
4205 (cdr (assoc 'vip-ex-style-editing-in-insert | 4235 (viper-standard-value 'vip-ex-style-editing-in-insert) |
4206 vip-saved-user-settings)) | |
4207 vip-ex-style-motion | 4236 vip-ex-style-motion |
4208 (cdr (assoc 'vip-ex-style-motion | 4237 (viper-standard-value 'vip-ex-style-motion)) |
4209 vip-saved-user-settings))) | |
4210 (setq vip-want-ctl-h-help | 4238 (setq vip-want-ctl-h-help |
4211 (cdr (assoc 'vip-want-ctl-h-help vip-saved-user-settings)) | 4239 (viper-standard-value 'vip-want-ctl-h-help) |
4212 viper-always | 4240 viper-always |
4213 (cdr (assoc 'viper-always vip-saved-user-settings)) | 4241 (viper-standard-value 'viper-always) |
4214 vip-no-multiple-ESC | 4242 vip-no-multiple-ESC |
4215 (cdr (assoc 'vip-no-multiple-ESC vip-saved-user-settings)) | 4243 (viper-standard-value 'vip-no-multiple-ESC) |
4216 vip-ex-style-motion | 4244 vip-ex-style-motion |
4217 (cdr (assoc 'vip-ex-style-motion vip-saved-user-settings)) | 4245 (viper-standard-value 'vip-ex-style-motion) |
4218 vip-ex-style-editing-in-insert | 4246 vip-ex-style-editing-in-insert |
4219 (cdr (assoc 'vip-ex-style-editing-in-insert | 4247 (viper-standard-value 'vip-ex-style-editing-in-insert) |
4220 vip-saved-user-settings)) | |
4221 vip-re-search | 4248 vip-re-search |
4222 (cdr (assoc 'vip-re-search vip-saved-user-settings)) | 4249 (viper-standard-value 'vip-re-search) |
4223 vip-electric-mode | 4250 vip-electric-mode |
4224 (cdr (assoc 'vip-electric-mode | 4251 (viper-standard-value 'vip-electric-mode) |
4225 vip-saved-user-settings)) | |
4226 vip-want-emacs-keys-in-vi | 4252 vip-want-emacs-keys-in-vi |
4227 (cdr (assoc 'vip-want-emacs-keys-in-vi | 4253 (viper-standard-value 'vip-want-emacs-keys-in-vi) |
4228 vip-saved-user-settings)) | |
4229 vip-want-emacs-keys-in-insert | 4254 vip-want-emacs-keys-in-insert |
4230 (cdr (assoc 'vip-want-emacs-keys-in-insert | 4255 (viper-standard-value 'vip-want-emacs-keys-in-insert)))) |
4231 vip-saved-user-settings))))) | 4256 |
4232 (vip-set-mode-vars-for vip-current-state) | 4257 (vip-set-mode-vars-for vip-current-state) |
4233 (if (or viper-always | 4258 (if (or viper-always |
4234 (and (> vip-expert-level 0) (> 5 vip-expert-level))) | 4259 (and (> viper-expert-level 0) (> 5 viper-expert-level))) |
4235 (vip-set-hooks))) | 4260 (vip-set-hooks))) |
4236 | 4261 |
4237 ;; Ask user expert level. | 4262 ;; Ask user expert level. |
4238 (defun vip-ask-level (dont-change-unless) | 4263 (defun vip-ask-level (dont-change-unless) |
4239 (let ((ask-buffer " *vip-ask-level*") | 4264 (let ((ask-buffer " *vip-ask-level*") |
4240 level-changed repeated) | 4265 level-changed repeated) |
4241 (save-window-excursion | 4266 (save-window-excursion |
4242 (switch-to-buffer ask-buffer) | 4267 (switch-to-buffer ask-buffer) |
4243 | 4268 |
4244 (or (eq this-command 'vip-set-expert-level) | 4269 (while (or (> viper-expert-level viper-max-expert-level) |
4245 (and | 4270 (< viper-expert-level 1) |
4246 (<= vip-expert-level vip-max-expert-level) | |
4247 (>= vip-expert-level 1)) | |
4248 (progn | |
4249 (insert " | |
4250 | |
4251 *** Important Notice for VIP users*** | |
4252 | |
4253 This is VIPER | |
4254 | |
4255 @joke | |
4256 Viper Is a Package for Emacs Rebels, | |
4257 a VI Plan for Emacs Rescue, | |
4258 and a venomous VI PERil. | |
4259 @end joke | |
4260 | |
4261 Technically speaking, Viper is a new Vi emulator that replaces | |
4262 the old VIP package. | |
4263 | |
4264 Viper emulates Vi much better than VIP. It also significantly | |
4265 extends and improves upon Vi in many useful ways. | |
4266 | |
4267 Although many VIP settings in your ~/.vip are compatible with Viper, | |
4268 you may have to change some of them. Please refer to the documentation, | |
4269 which can be obtained by executing | |
4270 | |
4271 :help | |
4272 | |
4273 when Viper is in Vi state. | |
4274 | |
4275 If you will be so lucky as to find a bug, report it via the command | |
4276 | |
4277 :submitReport | |
4278 | |
4279 Type any key to continue... ") | |
4280 | |
4281 (read-char) | |
4282 (erase-buffer))) | |
4283 | |
4284 (while (or (> vip-expert-level vip-max-expert-level) | |
4285 (< vip-expert-level 1) | |
4286 (null dont-change-unless)) | 4271 (null dont-change-unless)) |
4287 (erase-buffer) | 4272 (erase-buffer) |
4288 (if repeated | 4273 (if repeated |
4289 (progn | 4274 (progn |
4290 (message "Invalid user level") | 4275 (message "Invalid user level") |
4293 (setq dont-change-unless t | 4278 (setq dont-change-unless t |
4294 level-changed t) | 4279 level-changed t) |
4295 (insert " | 4280 (insert " |
4296 Please specify your level of familiarity with the venomous VI PERil | 4281 Please specify your level of familiarity with the venomous VI PERil |
4297 (and the VI Plan for Emacs Rescue). | 4282 (and the VI Plan for Emacs Rescue). |
4298 You can change it at any time by typing `M-x vip-set-expert-level RET' | 4283 You can change it at any time by typing `M-x viper-set-expert-level RET' |
4299 | 4284 |
4300 1 -- BEGINNER: Almost all Emacs features are suppressed. | 4285 1 -- BEGINNER: Almost all Emacs features are suppressed. |
4301 Feels almost like straight Vi. File name completion and | 4286 Feels almost like straight Vi. File name completion and |
4302 command history in the minibuffer are thrown in as a bonus. | 4287 command history in the minibuffer are thrown in as a bonus. |
4303 To use Emacs productively, you must reach level 3 or higher. | 4288 To use Emacs productively, you must reach level 3 or higher. |
4313 vip-electric-mode, vip-want-ctl-h-help, vip-want-emacs-keys-in-vi, | 4298 vip-electric-mode, vip-want-ctl-h-help, vip-want-emacs-keys-in-vi, |
4314 and vip-want-emacs-keys-in-insert. Adjust these to your taste. | 4299 and vip-want-emacs-keys-in-insert. Adjust these to your taste. |
4315 | 4300 |
4316 Please, specify your level now: ") | 4301 Please, specify your level now: ") |
4317 | 4302 |
4318 (setq vip-expert-level (- (vip-read-char-exclusive) ?0)) | 4303 (setq viper-expert-level (- (vip-read-char-exclusive) ?0)) |
4319 ) ; end while | 4304 ) ; end while |
4320 | 4305 |
4321 ;; tell the user if level was changed | 4306 ;; tell the user if level was changed |
4322 (and level-changed | 4307 (and level-changed |
4323 (progn | 4308 (progn |
4324 (insert | 4309 (insert |
4325 (format "\n\n\n\n\n\t\tYou have selected user level %d" | 4310 (format "\n\n\n\n\n\t\tYou have selected user level %d" |
4326 vip-expert-level)) | 4311 viper-expert-level)) |
4327 (if (y-or-n-p "Do you wish to make this change permanent? ") | 4312 (if (y-or-n-p "Do you wish to make this change permanent? ") |
4328 ;; save the setting for vip-expert-level | 4313 ;; save the setting for viper-expert-level |
4329 (vip-save-setting | 4314 (vip-save-setting |
4330 'vip-expert-level | 4315 'viper-expert-level |
4331 (format "Saving user level %d ..." vip-expert-level) | 4316 (format "Saving user level %d ..." viper-expert-level) |
4332 vip-custom-file-name)) | 4317 vip-custom-file-name)) |
4333 )) | 4318 )) |
4334 (bury-buffer) ; remove ask-buffer from screen | 4319 (bury-buffer) ; remove ask-buffer from screen |
4335 (message "") | 4320 (message "") |
4336 ))) | 4321 ))) |
4366 | 4351 |
4367 | 4352 |
4368 (defun vip-save-kill-buffer () | 4353 (defun vip-save-kill-buffer () |
4369 "Save then kill current buffer. " | 4354 "Save then kill current buffer. " |
4370 (interactive) | 4355 (interactive) |
4371 (if (< vip-expert-level 2) | 4356 (if (< viper-expert-level 2) |
4372 (save-buffers-kill-emacs) | 4357 (save-buffers-kill-emacs) |
4373 (save-buffer) | 4358 (save-buffer) |
4374 (kill-buffer (current-buffer)))) | 4359 (kill-buffer (current-buffer)))) |
4375 | 4360 |
4376 | 4361 |
4440 'vip-insert-state-hook | 4425 'vip-insert-state-hook |
4441 'vip-replace-state-hook | 4426 'vip-replace-state-hook |
4442 'vip-emacs-state-hook | 4427 'vip-emacs-state-hook |
4443 'ex-cycle-other-window | 4428 'ex-cycle-other-window |
4444 'ex-cycle-through-non-files | 4429 'ex-cycle-through-non-files |
4445 'vip-expert-level | 4430 'viper-expert-level |
4446 'major-mode | 4431 'major-mode |
4447 'vip-device-type | 4432 'vip-device-type |
4448 'color-display-p | 4433 'color-display-p |
4449 'frame-parameters | 4434 'frame-parameters |
4450 'minibuffer-vi-face | 4435 'minibuffer-vi-face |