diff options
| author | Michael Kifer | 1996-01-20 03:10:57 +0000 |
|---|---|---|
| committer | Michael Kifer | 1996-01-20 03:10:57 +0000 |
| commit | 151496c02bd493cfd37e2524455b2dbad276d8ba (patch) | |
| tree | aafbc12c50e6ecba1005863503b811313114a6c8 | |
| parent | 717e06e505aac4ddd4e7f870436e3bf3ab369cb2 (diff) | |
| download | emacs-151496c02bd493cfd37e2524455b2dbad276d8ba.tar.gz emacs-151496c02bd493cfd37e2524455b2dbad276d8ba.zip | |
Sat Jan 20 01:41:56 1996 Michael Kifer <kifer@sbkifer>
* viper.el (vip-auto-indent,vip-electric-mode): are now local
variables.
(vip-open-line,vip-Open-line,vip-autoindent):
are now electrified functions.
(vip-set-hooks): viperized awk, ksh, makefile, and html-helper modes.
(vip-custom-file-name): adapted to non-Unix systems.
(vip-move-minibuffer-overlay): removed.
(vip-read-string-with-history):
now accepts correct defaults when called to
read a shell command.
| -rw-r--r-- | lisp/emulation/viper.el | 178 |
1 files changed, 116 insertions, 62 deletions
diff --git a/lisp/emulation/viper.el b/lisp/emulation/viper.el index 151cbc2cd74..e6b25f0ba7b 100644 --- a/lisp/emulation/viper.el +++ b/lisp/emulation/viper.el | |||
| @@ -1,16 +1,16 @@ | |||
| 1 | ;;; viper.el --- A full-featured Vi emulator. | 1 | ;;; viper.el --- A full-featured Vi emulator for GNU Emacs 19 and XEmacs 19, |
| 2 | ;; a VI Plan for Emacs Rescue, | 2 | ;; a VI Plan for Emacs Rescue, |
| 3 | ;; and a venomous VI PERil. | 3 | ;; and a venomous VI PERil. |
| 4 | ;; Viper Is also a Package for Emacs Rebels. | 4 | ;; Viper Is also a Package for Emacs Rebels. |
| 5 | 5 | ;; | |
| 6 | ;; Copyright (C) 1994, 1995 Free Software Foundation, Inc. | ||
| 7 | |||
| 8 | ;; Keywords: emulations | 6 | ;; Keywords: emulations |
| 9 | ;; Author: Michael Kifer <kifer@cs.sunysb.edu> | 7 | ;; Author: Michael Kifer <kifer@cs.sunysb.edu> |
| 10 | 8 | ||
| 11 | (defconst viper-version "2.82 of October 12, 1995" | 9 | (defconst viper-version "2.85 of January 15, 1996" |
| 12 | "The current version of Viper") | 10 | "The current version of Viper") |
| 13 | 11 | ||
| 12 | ;; Copyright (C) 1994, 1995 Free Software Foundation, Inc. | ||
| 13 | |||
| 14 | ;; This file is part of GNU Emacs. | 14 | ;; This file is part of GNU Emacs. |
| 15 | 15 | ||
| 16 | ;; GNU Emacs is free software; you can redistribute it and/or modify | 16 | ;; GNU Emacs is free software; you can redistribute it and/or modify |
| @@ -24,9 +24,8 @@ | |||
| 24 | ;; GNU General Public License for more details. | 24 | ;; GNU General Public License for more details. |
| 25 | 25 | ||
| 26 | ;; You should have received a copy of the GNU General Public License | 26 | ;; You should have received a copy of the GNU General Public License |
| 27 | ;; along with GNU Emacs; see the file COPYING. If not, write to the | 27 | ;; along with GNU Emacs; see the file COPYING. If not, write to |
| 28 | ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 28 | ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. |
| 29 | ;; Boston, MA 02111-1307, USA. | ||
| 30 | 29 | ||
| 31 | ;;; Commentary: | 30 | ;;; Commentary: |
| 32 | 31 | ||
| @@ -372,7 +371,7 @@ designated buffers.") | |||
| 372 | 371 | ||
| 373 | (vip-deflocalvar vip-insert-diehard-minor-mode nil | 372 | (vip-deflocalvar vip-insert-diehard-minor-mode nil |
| 374 | "Minor mode that simulates Vi very closely. | 373 | "Minor mode that simulates Vi very closely. |
| 375 | Not recommended, except for the novice user.") | 374 | Not recommened, except for the novice user.") |
| 376 | 375 | ||
| 377 | (vip-deflocalvar vip-insert-kbd-minor-mode nil | 376 | (vip-deflocalvar vip-insert-kbd-minor-mode nil |
| 378 | "Minor mode for Ex command macros Insert state. | 377 | "Minor mode for Ex command macros Insert state. |
| @@ -470,8 +469,8 @@ it better fits your working style.") | |||
| 470 | 469 | ||
| 471 | (if (vip-window-display-p) | 470 | (if (vip-window-display-p) |
| 472 | (progn | 471 | (progn |
| 473 | (add-to-list 'facemenu-unlisted-faces 'vip-replace-overlay-face) | ||
| 474 | (make-face 'vip-replace-overlay-face) | 472 | (make-face 'vip-replace-overlay-face) |
| 473 | (vip-hide-face 'vip-replace-overlay-face) | ||
| 475 | (or (face-differs-from-default-p 'vip-replace-overlay-face) | 474 | (or (face-differs-from-default-p 'vip-replace-overlay-face) |
| 476 | (progn | 475 | (progn |
| 477 | (if (vip-can-use-colors "darkseagreen2" "Black") | 476 | (if (vip-can-use-colors "darkseagreen2" "Black") |
| @@ -591,8 +590,11 @@ bound to delete-backward-char.") | |||
| 591 | ;; Whether to preserve the indent, used by C-d in insert mode. | 590 | ;; Whether to preserve the indent, used by C-d in insert mode. |
| 592 | (vip-deflocalvar vip-preserve-indent nil) | 591 | (vip-deflocalvar vip-preserve-indent nil) |
| 593 | 592 | ||
| 594 | (defconst vip-auto-indent nil | 593 | (vip-deflocalvar vip-auto-indent nil |
| 595 | "*Autoindent if t.") | 594 | "*Autoindent if t.") |
| 595 | (vip-deflocalvar vip-electric-mode t | ||
| 596 | "*If t, enable electric behavior. | ||
| 597 | Currently only enables auto-indentation `according to mode'.") | ||
| 596 | 598 | ||
| 597 | (defconst vip-shift-width 8 | 599 | (defconst vip-shift-width 8 |
| 598 | "*The shiftwidth variable.") | 600 | "*The shiftwidth variable.") |
| @@ -616,7 +618,7 @@ to a new place after repeating previous Vi command.") | |||
| 616 | ;; The reason this is needed is because dabbrev-expand (and possibly | 618 | ;; The reason this is needed is because dabbrev-expand (and possibly |
| 617 | ;; others) may jump to before the insertion point, delete something and | 619 | ;; others) may jump to before the insertion point, delete something and |
| 618 | ;; then reinsert a bigger piece. For instance: bla^blo | 620 | ;; then reinsert a bigger piece. For instance: bla^blo |
| 619 | ;; If dabbrev-expand is called after `blo' and ^ indicates vip-insert-point, | 621 | ;; If dabbrev-expand is called after `blo' and ^ undicates vip-insert-point, |
| 620 | ;; then point jumps to the beginning of `blo'. If expansion is found, `blablo' | 622 | ;; then point jumps to the beginning of `blo'. If expansion is found, `blablo' |
| 621 | ;; is deleted, and we have |^, where | denotes point. Next, dabbrev-expand | 623 | ;; is deleted, and we have |^, where | denotes point. Next, dabbrev-expand |
| 622 | ;; will insert the expansion, and we get: blablo^ | 624 | ;; will insert the expansion, and we get: blablo^ |
| @@ -808,7 +810,14 @@ These buffers can be cycled through via :R and :P commands.") | |||
| 808 | (defvar vip-always t | 810 | (defvar vip-always t |
| 809 | "t means, arrange that vi-state will be a default.") | 811 | "t means, arrange that vi-state will be a default.") |
| 810 | 812 | ||
| 811 | (defvar vip-custom-file-name (convert-standard-filename "~/.vip") | 813 | (defvar vip-custom-file-name (cond ((memq system-type '(vax-vms axp-vms)) |
| 814 | "sys$login:.vip") | ||
| 815 | ((memq system-type '(emx ms-dos)) | ||
| 816 | "/_vip") | ||
| 817 | ((memq system-type '(windows-nt windows-95)) | ||
| 818 | "~/_vip") | ||
| 819 | (t ; Unix | ||
| 820 | "~/.vip")) | ||
| 812 | "Viper customisation file. | 821 | "Viper customisation file. |
| 813 | This variable must be set _before_ loading Viper.") | 822 | This variable must be set _before_ loading Viper.") |
| 814 | 823 | ||
| @@ -938,7 +947,7 @@ Should be set in `~/.vip' file.") | |||
| 938 | (defun vip-change-state (new-state) | 947 | (defun vip-change-state (new-state) |
| 939 | ;; Keep vip-post/pre-command-hooks fresh. | 948 | ;; Keep vip-post/pre-command-hooks fresh. |
| 940 | ;; We remove then add vip-post/pre-command-sentinel since it is very | 949 | ;; We remove then add vip-post/pre-command-sentinel since it is very |
| 941 | ;; desirable that no one gets in-between | 950 | ;; desirable that noone gets in-between |
| 942 | (remove-hook 'post-command-hook 'vip-post-command-sentinel) | 951 | (remove-hook 'post-command-hook 'vip-post-command-sentinel) |
| 943 | (add-hook 'post-command-hook 'vip-post-command-sentinel) | 952 | (add-hook 'post-command-hook 'vip-post-command-sentinel) |
| 944 | (remove-hook 'pre-command-hook 'vip-pre-command-sentinel) | 953 | (remove-hook 'pre-command-hook 'vip-pre-command-sentinel) |
| @@ -1362,7 +1371,7 @@ This startup message appears whenever you load Viper, unless you type `y' now." | |||
| 1362 | (error | 1371 | (error |
| 1363 | (vip-message-conditions conds)))) | 1372 | (vip-message-conditions conds)))) |
| 1364 | 1373 | ||
| 1365 | ;; escape to emacs mode temporarily | 1374 | ;; escape to emacs mode termporarily |
| 1366 | (defun vip-escape-to-emacs (arg &optional events) | 1375 | (defun vip-escape-to-emacs (arg &optional events) |
| 1367 | "Escape to Emacs state from Vi state for one Emacs command. | 1376 | "Escape to Emacs state from Vi state for one Emacs command. |
| 1368 | ARG is used as the prefix value for the executed command. If | 1377 | ARG is used as the prefix value for the executed command. If |
| @@ -1370,7 +1379,7 @@ EVENTS is a list of events, which become the beginning of the command." | |||
| 1370 | (interactive "P") | 1379 | (interactive "P") |
| 1371 | (vip-escape-to-state arg events 'emacs-state)) | 1380 | (vip-escape-to-state arg events 'emacs-state)) |
| 1372 | 1381 | ||
| 1373 | ;; escape to Vi mode temporarily | 1382 | ;; escape to Vi mode termporarily |
| 1374 | (defun vip-escape-to-vi () | 1383 | (defun vip-escape-to-vi () |
| 1375 | "Escape from Emacs state to Vi state for one Vi 1-character command. | 1384 | "Escape from Emacs state to Vi state for one Vi 1-character command. |
| 1376 | This doesn't work with prefix arguments or most complex commands like | 1385 | This doesn't work with prefix arguments or most complex commands like |
| @@ -1464,7 +1473,7 @@ Suffixes such as .el or .elc should be stripped." | |||
| 1464 | (vip-eval-after-load | 1473 | (vip-eval-after-load |
| 1465 | load-file '(setq-default minor-mode-map-alist minor-mode-map-alist)) | 1474 | load-file '(setq-default minor-mode-map-alist minor-mode-map-alist)) |
| 1466 | ) | 1475 | ) |
| 1467 | 1476 | ||
| 1468 | 1477 | ||
| 1469 | (defun vip-ESC (arg) | 1478 | (defun vip-ESC (arg) |
| 1470 | "Emulate ESC key in Emacs. | 1479 | "Emulate ESC key in Emacs. |
| @@ -1701,7 +1710,7 @@ behaves as in Emacs, any number of multiple escapes is allowed." | |||
| 1701 | ) | 1710 | ) |
| 1702 | ;; as com is non-nil, this means that we have a command to execute | 1711 | ;; as com is non-nil, this means that we have a command to execute |
| 1703 | (if (memq (car com) '(?r ?R)) | 1712 | (if (memq (car com) '(?r ?R)) |
| 1704 | ;; execute appropriate region command. | 1713 | ;; execute apropriate region command. |
| 1705 | (let ((char (car com)) (com (cdr com))) | 1714 | (let ((char (car com)) (com (cdr com))) |
| 1706 | (setq prefix-arg (cons value com)) | 1715 | (setq prefix-arg (cons value com)) |
| 1707 | (if (= char ?r) (vip-region prefix-arg) | 1716 | (if (= char ?r) (vip-region prefix-arg) |
| @@ -2067,10 +2076,11 @@ invokes the command before that, etc." | |||
| 2067 | (vip-d-com vip-d-com)) | 2076 | (vip-d-com vip-d-com)) |
| 2068 | 2077 | ||
| 2069 | (or (and (numberp num) (<= 0 num) (<= num 9)) | 2078 | (or (and (numberp num) (<= 0 num) (<= num 9)) |
| 2070 | (setq idx 0 | 2079 | (progn |
| 2071 | num 0) | 2080 | (setq idx 0 |
| 2072 | (message | 2081 | num 0) |
| 2073 | "`vip-repeat-from-history' must be invoked as a Vi macro bound to `<key><digit>'")) | 2082 | (message |
| 2083 | "`vip-repeat-from-history' must be invoked as a Vi macro bound to `<key><digit>'"))) | ||
| 2074 | (while (< 0 num) | 2084 | (while (< 0 num) |
| 2075 | (setq vip-d-com (vip-special-ring-rotate1 vip-command-ring -1)) | 2085 | (setq vip-d-com (vip-special-ring-rotate1 vip-command-ring -1)) |
| 2076 | (setq num (1- num))) | 2086 | (setq num (1- num))) |
| @@ -2369,10 +2379,6 @@ Undo previous insertion and inserts new." | |||
| 2369 | 'vip-change-state-to-insert | 2379 | 'vip-change-state-to-insert |
| 2370 | 'vip-change-state-to-emacs))) | 2380 | 'vip-change-state-to-emacs))) |
| 2371 | (funcall hook) | 2381 | (funcall hook) |
| 2372 | |||
| 2373 | ;; Make sure the minibuffer overlay is kept up-to-date. In XEmacs also | ||
| 2374 | ;; guards against the possibility of detaching this overlay. | ||
| 2375 | (vip-add-hook 'vip-post-command-hooks 'vip-move-minibuffer-overlay) | ||
| 2376 | )) | 2382 | )) |
| 2377 | 2383 | ||
| 2378 | ;; Interpret last event in the local map | 2384 | ;; Interpret last event in the local map |
| @@ -2390,8 +2396,8 @@ Undo previous insertion and inserts new." | |||
| 2390 | () | 2396 | () |
| 2391 | (defvar vip-search-face | 2397 | (defvar vip-search-face |
| 2392 | (progn | 2398 | (progn |
| 2393 | (add-to-list 'facemenu-unlisted-faces 'vip-search-face) | ||
| 2394 | (make-face 'vip-search-face) | 2399 | (make-face 'vip-search-face) |
| 2400 | (vip-hide-face 'vip-search-face) | ||
| 2395 | (or (face-differs-from-default-p 'vip-search-face) | 2401 | (or (face-differs-from-default-p 'vip-search-face) |
| 2396 | ;; face wasn't set in .vip or .Xdefaults | 2402 | ;; face wasn't set in .vip or .Xdefaults |
| 2397 | (if (vip-can-use-colors "Black" "khaki") | 2403 | (if (vip-can-use-colors "Black" "khaki") |
| @@ -2410,8 +2416,8 @@ Undo previous insertion and inserts new." | |||
| 2410 | () | 2416 | () |
| 2411 | (defvar vip-minibuffer-emacs-face | 2417 | (defvar vip-minibuffer-emacs-face |
| 2412 | (progn | 2418 | (progn |
| 2413 | (add-to-list 'facemenu-unlisted-faces 'vip-minibuffer-emacs-face) | ||
| 2414 | (make-face 'vip-minibuffer-emacs-face) | 2419 | (make-face 'vip-minibuffer-emacs-face) |
| 2420 | (vip-hide-face 'vip-minibuffer-emacs-face) | ||
| 2415 | (or (face-differs-from-default-p 'vip-minibuffer-emacs-face) | 2421 | (or (face-differs-from-default-p 'vip-minibuffer-emacs-face) |
| 2416 | ;; face wasn't set in .vip or .Xdefaults | 2422 | ;; face wasn't set in .vip or .Xdefaults |
| 2417 | (if vip-vi-style-in-minibuffer | 2423 | (if vip-vi-style-in-minibuffer |
| @@ -2436,8 +2442,8 @@ Undo previous insertion and inserts new." | |||
| 2436 | 2442 | ||
| 2437 | (defvar vip-minibuffer-insert-face | 2443 | (defvar vip-minibuffer-insert-face |
| 2438 | (progn | 2444 | (progn |
| 2439 | (add-to-list 'facemenu-unlisted-faces 'vip-minibuffer-insert-face) | ||
| 2440 | (make-face 'vip-minibuffer-insert-face) | 2445 | (make-face 'vip-minibuffer-insert-face) |
| 2446 | (vip-hide-face 'vip-minibuffer-insert-face) | ||
| 2441 | (or (face-differs-from-default-p 'vip-minibuffer-insert-face) | 2447 | (or (face-differs-from-default-p 'vip-minibuffer-insert-face) |
| 2442 | (if vip-vi-style-in-minibuffer | 2448 | (if vip-vi-style-in-minibuffer |
| 2443 | (if (vip-can-use-colors "Black" "pink") | 2449 | (if (vip-can-use-colors "Black" "pink") |
| @@ -2460,8 +2466,8 @@ Undo previous insertion and inserts new." | |||
| 2460 | 2466 | ||
| 2461 | (defvar vip-minibuffer-vi-face | 2467 | (defvar vip-minibuffer-vi-face |
| 2462 | (progn | 2468 | (progn |
| 2463 | (add-to-list 'facemenu-unlisted-faces 'vip-minibuffer-vi-face) | ||
| 2464 | (make-face 'vip-minibuffer-vi-face) | 2469 | (make-face 'vip-minibuffer-vi-face) |
| 2470 | (vip-hide-face 'vip-minibuffer-vi-face) | ||
| 2465 | (or (face-differs-from-default-p 'vip-minibuffer-vi-face) | 2471 | (or (face-differs-from-default-p 'vip-minibuffer-vi-face) |
| 2466 | (if vip-vi-style-in-minibuffer | 2472 | (if vip-vi-style-in-minibuffer |
| 2467 | (if (vip-can-use-colors "Black" "grey") | 2473 | (if (vip-can-use-colors "Black" "grey") |
| @@ -2484,9 +2490,9 @@ Undo previous insertion and inserts new." | |||
| 2484 | 2490 | ||
| 2485 | (defun vip-read-string-with-history (prompt &optional initial | 2491 | (defun vip-read-string-with-history (prompt &optional initial |
| 2486 | history-var default keymap) | 2492 | history-var default keymap) |
| 2487 | ;; Reads string, prompting with PROMPT and inserting the INITIAL | 2493 | ;; Read string, prompting with PROMPT and inserting the INITIAL |
| 2488 | ;; value. Uses HISTORY-VAR. DEFAULT is the default value to accept if the | 2494 | ;; value. Uses HISTORY-VAR. DEFAULT is the default value to accept if the |
| 2489 | ;; input is an empty string. Uses KEYMAP, if given, or the | 2495 | ;; input is an empty string. Use KEYMAP, if given, or the |
| 2490 | ;; minibuffer-local-map. | 2496 | ;; minibuffer-local-map. |
| 2491 | ;; Default value is displayed until the user types something in the | 2497 | ;; Default value is displayed until the user types something in the |
| 2492 | ;; minibuffer. | 2498 | ;; minibuffer. |
| @@ -2524,13 +2530,17 @@ Undo previous insertion and inserts new." | |||
| 2524 | (if (or (string= (nth 0 (eval history-var)) (nth 1 (eval history-var))) | 2530 | (if (or (string= (nth 0 (eval history-var)) (nth 1 (eval history-var))) |
| 2525 | (string= (nth 0 (eval history-var)) "")) | 2531 | (string= (nth 0 (eval history-var)) "")) |
| 2526 | (set history-var (cdr (eval history-var)))) | 2532 | (set history-var (cdr (eval history-var)))) |
| 2527 | ;; if the user enters nothing but the prev cmd wasn't vip-ex or | 2533 | ;; If the user enters nothing but the prev cmd wasn't vip-ex, |
| 2528 | ;; vip-command-argument, this means that the user typed something then | 2534 | ;; vip-command-argument, or `! shell-command', this probably means |
| 2529 | ;; erased. Return "" in this case, not the default---default is too | 2535 | ;; that the user typed something then erased. Return "" in this case, not |
| 2530 | ;; confusing in this case | 2536 | ;; the default---the default is too confusing in this case. |
| 2531 | (cond ((and (string= val "") | 2537 | (cond ((and (string= val "") |
| 2538 | (not (string= prompt "!")) ; was a `! shell-command' | ||
| 2532 | (not (memq last-command | 2539 | (not (memq last-command |
| 2533 | (list 'vip-ex 'vip-command-argument t)))) | 2540 | '(vip-ex |
| 2541 | vip-command-argument | ||
| 2542 | t) | ||
| 2543 | ))) | ||
| 2534 | "") | 2544 | "") |
| 2535 | ((string= val "") (or default "")) | 2545 | ((string= val "") (or default "")) |
| 2536 | (t val)) | 2546 | (t val)) |
| @@ -2615,11 +2625,22 @@ Undo previous insertion and inserts new." | |||
| 2615 | (end-of-line) | 2625 | (end-of-line) |
| 2616 | (newline 1) | 2626 | (newline 1) |
| 2617 | (if vip-auto-indent | 2627 | (if vip-auto-indent |
| 2618 | (progn (setq vip-cted t) (indent-to col))) | 2628 | (progn |
| 2629 | (setq vip-cted t) | ||
| 2630 | (if vip-electric-mode | ||
| 2631 | (indent-according-to-mode) | ||
| 2632 | (indent-to col)) | ||
| 2633 | )) | ||
| 2619 | (vip-yank-last-insertion))) | 2634 | (vip-yank-last-insertion))) |
| 2620 | (end-of-line) | 2635 | (end-of-line) |
| 2621 | (newline 1) | 2636 | (newline 1) |
| 2622 | (if vip-auto-indent (progn (setq vip-cted t) (indent-to col))) | 2637 | (if vip-auto-indent |
| 2638 | (progn | ||
| 2639 | (setq vip-cted t) | ||
| 2640 | (if vip-electric-mode | ||
| 2641 | (indent-according-to-mode) | ||
| 2642 | (indent-to col)) | ||
| 2643 | )) | ||
| 2623 | (vip-change-state-to-insert) | 2644 | (vip-change-state-to-insert) |
| 2624 | )))) | 2645 | )))) |
| 2625 | 2646 | ||
| @@ -2637,11 +2658,22 @@ Undo previous insertion and inserts new." | |||
| 2637 | (beginning-of-line) | 2658 | (beginning-of-line) |
| 2638 | (open-line 1) | 2659 | (open-line 1) |
| 2639 | (if vip-auto-indent | 2660 | (if vip-auto-indent |
| 2640 | (progn (setq vip-cted t) (indent-to col))) | 2661 | (progn |
| 2662 | (setq vip-cted t) | ||
| 2663 | (if vip-electric-mode | ||
| 2664 | (indent-according-to-mode) | ||
| 2665 | (indent-to col)) | ||
| 2666 | )) | ||
| 2641 | (vip-yank-last-insertion))) | 2667 | (vip-yank-last-insertion))) |
| 2642 | (beginning-of-line) | 2668 | (beginning-of-line) |
| 2643 | (open-line 1) | 2669 | (open-line 1) |
| 2644 | (if vip-auto-indent (progn (setq vip-cted t) (indent-to col))) | 2670 | (if vip-auto-indent |
| 2671 | (progn | ||
| 2672 | (setq vip-cted t) | ||
| 2673 | (if vip-electric-mode | ||
| 2674 | (indent-according-to-mode) | ||
| 2675 | (indent-to col)) | ||
| 2676 | )) | ||
| 2645 | (vip-change-state-to-insert))))) | 2677 | (vip-change-state-to-insert))))) |
| 2646 | 2678 | ||
| 2647 | (defun vip-open-line-at-point (arg) | 2679 | (defun vip-open-line-at-point (arg) |
| @@ -2832,8 +2864,8 @@ Undo previous insertion and inserts new." | |||
| 2832 | ;; deleting an equal amount of characters. | 2864 | ;; deleting an equal amount of characters. |
| 2833 | ;; | 2865 | ;; |
| 2834 | ;; The reason why new-dabbrev.el causes this are this: | 2866 | ;; The reason why new-dabbrev.el causes this are this: |
| 2835 | ;; if one dynamically completes a partial word that starts before the | 2867 | ;; if one dinamically completes a partial word that starts before the |
| 2836 | ;; replacement region (but ends inside)then new-dabbrev.el first | 2868 | ;; replacement region (but ends inside) then new-dabbrev.el first |
| 2837 | ;; moves cursor backwards, to the beginning of the word to be | 2869 | ;; moves cursor backwards, to the beginning of the word to be |
| 2838 | ;; completed (say, pt A). Then it inserts the | 2870 | ;; completed (say, pt A). Then it inserts the |
| 2839 | ;; completed word and then deletes the old, incomplete part. | 2871 | ;; completed word and then deletes the old, incomplete part. |
| @@ -2842,9 +2874,7 @@ Undo previous insertion and inserts new." | |||
| 2842 | ;; unless we check for the current command, which must be | 2874 | ;; unless we check for the current command, which must be |
| 2843 | ;; dabbrev-expand. | 2875 | ;; dabbrev-expand. |
| 2844 | ;; | 2876 | ;; |
| 2845 | ;; We should be able deal with these problems in a better way | 2877 | ;; In fact, it might be also useful to have overlays for insert |
| 2846 | ;; when emacs will have overlays with sticky back ends. | ||
| 2847 | ;; In fact, it would be also useful to add overlays for insert | ||
| 2848 | ;; regions as well, since this will let us capture the situation when | 2878 | ;; regions as well, since this will let us capture the situation when |
| 2849 | ;; dabbrev-expand goes back past the insertion point to find the | 2879 | ;; dabbrev-expand goes back past the insertion point to find the |
| 2850 | ;; beginning of the word to be expanded. | 2880 | ;; beginning of the word to be expanded. |
| @@ -3887,7 +3917,7 @@ Although this function is bound to \\[vip-toggle-search-style], the most | |||
| 3887 | convenient way to use it is to bind `//' to the macro | 3917 | convenient way to use it is to bind `//' to the macro |
| 3888 | `1 M-x vip-toggle-search-style' and `///' to | 3918 | `1 M-x vip-toggle-search-style' and `///' to |
| 3889 | `2 M-x vip-toggle-search-style'. In this way, hitting `//' quickly will | 3919 | `2 M-x vip-toggle-search-style'. In this way, hitting `//' quickly will |
| 3890 | toggle case-fold-search and hitting `/' three times with toggle regexp | 3920 | toggle case-fold-search and hitting `/' three times witth toggle regexp |
| 3891 | search. Macros are more convenient in this case because they don't affect | 3921 | search. Macros are more convenient in this case because they don't affect |
| 3892 | the Emacs binding of `/'." | 3922 | the Emacs binding of `/'." |
| 3893 | (interactive "P") | 3923 | (interactive "P") |
| @@ -4073,7 +4103,7 @@ Null string will repeat previous search." | |||
| 4073 | (aset vip-exec-array vip-buffer-search-char 'vip-exec-buffer-search) | 4103 | (aset vip-exec-array vip-buffer-search-char 'vip-exec-buffer-search) |
| 4074 | (setq vip-prefix-commands (cons vip-buffer-search-char vip-prefix-commands))) | 4104 | (setq vip-prefix-commands (cons vip-buffer-search-char vip-prefix-commands))) |
| 4075 | 4105 | ||
| 4076 | ;; This is a Viper wrapper for isearch-forward. | 4106 | ;; This is a Viper wraper for isearch-forward. |
| 4077 | (defun vip-isearch-forward (arg) | 4107 | (defun vip-isearch-forward (arg) |
| 4078 | "Do incremental search forward." | 4108 | "Do incremental search forward." |
| 4079 | (interactive "P") | 4109 | (interactive "P") |
| @@ -4081,7 +4111,7 @@ Null string will repeat previous search." | |||
| 4081 | (if (listp arg) (setq arg (car arg))) | 4111 | (if (listp arg) (setq arg (car arg))) |
| 4082 | (vip-exec-form-in-emacs (list 'isearch-forward arg))) | 4112 | (vip-exec-form-in-emacs (list 'isearch-forward arg))) |
| 4083 | 4113 | ||
| 4084 | ;; This is a Viper wrapper for isearch-backward." | 4114 | ;; This is a Viper wraper for isearch-backward." |
| 4085 | (defun vip-isearch-backward (arg) | 4115 | (defun vip-isearch-backward (arg) |
| 4086 | "Do incremental search backward." | 4116 | "Do incremental search backward." |
| 4087 | (interactive "P") | 4117 | (interactive "P") |
| @@ -4389,7 +4419,7 @@ To turn this feature off, set this variable to nil.") | |||
| 4389 | (defun vip-del-backward-char-in-replace () | 4419 | (defun vip-del-backward-char-in-replace () |
| 4390 | "Delete one character in replace mode. | 4420 | "Delete one character in replace mode. |
| 4391 | If `vip-delete-backwards-in-replace' is t, then DEL key actually deletes | 4421 | If `vip-delete-backwards-in-replace' is t, then DEL key actually deletes |
| 4392 | characters. If it is nil, then the cursor just moves backwards, similarly | 4422 | charecters. If it is nil, then the cursor just moves backwards, similarly |
| 4393 | to Vi. The variable `vip-ex-style-editing-in-insert', if t, doesn't let the | 4423 | to Vi. The variable `vip-ex-style-editing-in-insert', if t, doesn't let the |
| 4394 | cursor move past the beginning of line." | 4424 | cursor move past the beginning of line." |
| 4395 | (interactive) | 4425 | (interactive) |
| @@ -4517,7 +4547,7 @@ cursor move past the beginning of line." | |||
| 4517 | 4547 | ||
| 4518 | (defun vip-query-replace () | 4548 | (defun vip-query-replace () |
| 4519 | "Query replace. | 4549 | "Query replace. |
| 4520 | If a null string is supplied as the string to be replaced, | 4550 | If a null string is suplied as the string to be replaced, |
| 4521 | the query replace mode will toggle between string replace | 4551 | the query replace mode will toggle between string replace |
| 4522 | and regexp replace." | 4552 | and regexp replace." |
| 4523 | (interactive) | 4553 | (interactive) |
| @@ -4717,7 +4747,8 @@ One can use `` and '' to temporarily jump 1 step back." | |||
| 4717 | (let ((p (point)) (c (current-column)) bol (indent t)) | 4747 | (let ((p (point)) (c (current-column)) bol (indent t)) |
| 4718 | (if (vip-looking-back "[0^]") | 4748 | (if (vip-looking-back "[0^]") |
| 4719 | (progn | 4749 | (progn |
| 4720 | (if (= ?^ (preceding-char)) (setq vip-preserve-indent t)) | 4750 | (if (eq ?^ (preceding-char)) |
| 4751 | (setq vip-preserve-indent t)) | ||
| 4721 | (delete-backward-char 1) | 4752 | (delete-backward-char 1) |
| 4722 | (setq p (point)) | 4753 | (setq p (point)) |
| 4723 | (setq indent nil))) | 4754 | (setq indent nil))) |
| @@ -4735,9 +4766,9 @@ One can use `` and '' to temporarily jump 1 step back." | |||
| 4735 | "Auto Indentation, Vi-style." | 4766 | "Auto Indentation, Vi-style." |
| 4736 | (interactive) | 4767 | (interactive) |
| 4737 | (let ((col (current-indentation))) | 4768 | (let ((col (current-indentation))) |
| 4738 | (if (not vip-preserve-indent) | 4769 | (if vip-preserve-indent |
| 4739 | (setq vip-current-indent col) | 4770 | (setq vip-preserve-indent nil) |
| 4740 | (setq vip-preserve-indent nil)) | 4771 | (setq vip-current-indent col)) |
| 4741 | ;; don't leave whitespace lines around | 4772 | ;; don't leave whitespace lines around |
| 4742 | (if (memq last-command | 4773 | (if (memq last-command |
| 4743 | '(vip-autoindent | 4774 | '(vip-autoindent |
| @@ -4748,7 +4779,11 @@ One can use `` and '' to temporarily jump 1 step back." | |||
| 4748 | (if vip-auto-indent | 4779 | (if vip-auto-indent |
| 4749 | (progn | 4780 | (progn |
| 4750 | (setq vip-cted t) | 4781 | (setq vip-cted t) |
| 4751 | (indent-to vip-current-indent))))) | 4782 | (if vip-electric-mode |
| 4783 | (indent-according-to-mode) | ||
| 4784 | (indent-to vip-current-indent)) | ||
| 4785 | )) | ||
| 4786 | )) | ||
| 4752 | 4787 | ||
| 4753 | 4788 | ||
| 4754 | ;; Viewing registers | 4789 | ;; Viewing registers |
| @@ -4884,7 +4919,7 @@ sensitive for VI-style look-and-feel." | |||
| 4884 | (setq vip-no-multiple-ESC (if (vip-window-display-p) t 'twice) | 4919 | (setq vip-no-multiple-ESC (if (vip-window-display-p) t 'twice) |
| 4885 | vip-want-emacs-keys-in-vi t | 4920 | vip-want-emacs-keys-in-vi t |
| 4886 | vip-want-emacs-keys-in-insert (> vip-expert-level 2)) | 4921 | vip-want-emacs-keys-in-insert (> vip-expert-level 2)) |
| 4887 | 4922 | ||
| 4888 | (if (eq vip-expert-level 4) ; respect user's ex-style motions | 4923 | (if (eq vip-expert-level 4) ; respect user's ex-style motions |
| 4889 | ; and vip-no-multiple-ESC | 4924 | ; and vip-no-multiple-ESC |
| 4890 | (progn | 4925 | (progn |
| @@ -5320,14 +5355,22 @@ Mail anyway (y or n)? ") | |||
| 5320 | "Run `vip-change-state-to-vi' on entry." | 5355 | "Run `vip-change-state-to-vi' on entry." |
| 5321 | (vip-change-state-to-vi)) | 5356 | (vip-change-state-to-vi)) |
| 5322 | 5357 | ||
| 5358 | (defvar makefile-mode-hook nil) | ||
| 5359 | (add-hook 'makefile-mode-hook 'viper-mode) | ||
| 5360 | |||
| 5323 | (defvar help-mode-hook nil) | 5361 | (defvar help-mode-hook nil) |
| 5324 | (add-hook 'help-mode-hook 'viper-mode) | 5362 | (add-hook 'help-mode-hook 'viper-mode) |
| 5325 | 5363 | ||
| 5326 | (defvar emacs-lisp-mode-hook nil) | 5364 | (defvar awk-mode-hook nil) |
| 5327 | (add-hook 'emacs-lisp-mode-hook 'viper-mode) | 5365 | (add-hook 'awk-mode-hook 'viper-mode) |
| 5328 | 5366 | ||
| 5329 | (defvar html-mode-hook nil) | 5367 | (defvar html-mode-hook nil) |
| 5330 | (add-hook 'html-mode-hook 'viper-mode) | 5368 | (add-hook 'html-mode-hook 'viper-mode) |
| 5369 | (defvar html-helper-mode-hook nil) | ||
| 5370 | (add-hook 'html-helper-mode-hook 'viper-mode) | ||
| 5371 | |||
| 5372 | (defvar emacs-lisp-mode-hook nil) | ||
| 5373 | (add-hook 'emacs-lisp-mode-hook 'viper-mode) | ||
| 5331 | 5374 | ||
| 5332 | (defvar lisp-mode-hook nil) | 5375 | (defvar lisp-mode-hook nil) |
| 5333 | (add-hook 'lisp-mode-hook 'viper-mode) | 5376 | (add-hook 'lisp-mode-hook 'viper-mode) |
| @@ -5352,6 +5395,8 @@ Mail anyway (y or n)? ") | |||
| 5352 | 5395 | ||
| 5353 | (add-hook 'completion-list-mode-hook 'viper-mode) | 5396 | (add-hook 'completion-list-mode-hook 'viper-mode) |
| 5354 | (add-hook 'compilation-mode-hook 'viper-mode) | 5397 | (add-hook 'compilation-mode-hook 'viper-mode) |
| 5398 | |||
| 5399 | (add-hook 'perl-mode-hook 'viper-mode) | ||
| 5355 | 5400 | ||
| 5356 | (defvar emerge-startup-hook nil) | 5401 | (defvar emerge-startup-hook nil) |
| 5357 | (add-hook 'emerge-startup-hook 'vip-change-state-to-emacs) | 5402 | (add-hook 'emerge-startup-hook 'vip-change-state-to-emacs) |
| @@ -5379,6 +5424,12 @@ Mail anyway (y or n)? ") | |||
| 5379 | '(defadvice read-passwd-1 (before vip-passwd-ad activate) | 5424 | '(defadvice read-passwd-1 (before vip-passwd-ad activate) |
| 5380 | "Switch to emacs state while reading password." | 5425 | "Switch to emacs state while reading password." |
| 5381 | (vip-change-state-to-emacs))) | 5426 | (vip-change-state-to-emacs))) |
| 5427 | |||
| 5428 | (vip-eval-after-load | ||
| 5429 | "prolog" | ||
| 5430 | '(defadvice prolog-mode (after vip-prolog-ad activate) | ||
| 5431 | "Switch to Vi state in Prolog mode." | ||
| 5432 | (vip-change-state-to-vi))) | ||
| 5382 | 5433 | ||
| 5383 | ;; Emacs shell, ange-ftp, and comint-based modes | 5434 | ;; Emacs shell, ange-ftp, and comint-based modes |
| 5384 | (defvar comint-mode-hook nil) | 5435 | (defvar comint-mode-hook nil) |
| @@ -5388,6 +5439,8 @@ Mail anyway (y or n)? ") | |||
| 5388 | ;; Shell scripts | 5439 | ;; Shell scripts |
| 5389 | (defvar sh-mode-hook nil) | 5440 | (defvar sh-mode-hook nil) |
| 5390 | (add-hook 'sh-mode-hook 'viper-mode) | 5441 | (add-hook 'sh-mode-hook 'viper-mode) |
| 5442 | (defvar ksh-mode-hook nil) | ||
| 5443 | (add-hook 'ksh-mode-hook 'viper-mode) | ||
| 5391 | 5444 | ||
| 5392 | ;; Dired | 5445 | ;; Dired |
| 5393 | ;; This is only necessary when the user uses vip-modify-major-mode | 5446 | ;; This is only necessary when the user uses vip-modify-major-mode |
| @@ -5443,7 +5496,7 @@ Mail anyway (y or n)? ") | |||
| 5443 | (vip-record-kbd-macro | 5496 | (vip-record-kbd-macro |
| 5444 | "//" 'vi-state | 5497 | "//" 'vi-state |
| 5445 | [1 (meta x) v i p - t o g g l e - s e a r c h - s t y l e return] 't) | 5498 | [1 (meta x) v i p - t o g g l e - s e a r c h - s t y l e return] 't) |
| 5446 | ;; toggle regexp/vanilla search | 5499 | ;; toggle regexp/vanila search |
| 5447 | (vip-record-kbd-macro | 5500 | (vip-record-kbd-macro |
| 5448 | "///" 'vi-state | 5501 | "///" 'vi-state |
| 5449 | [2 (meta x) v i p - t o g g l e - s e a r c h - s t y l e return] 't) | 5502 | [2 (meta x) v i p - t o g g l e - s e a r c h - s t y l e return] 't) |
| @@ -5461,7 +5514,7 @@ Mail anyway (y or n)? ") | |||
| 5461 | 5514 | ||
| 5462 | ;; Applying Viper customization -- runs after (load .vip) | 5515 | ;; Applying Viper customization -- runs after (load .vip) |
| 5463 | 5516 | ||
| 5464 | ;; Save user settings or Viper defaults for vars controlled by vip-expert-level | 5517 | ;; Save user settings or Viper defaults for vars controled by vip-expert-level |
| 5465 | (setq vip-saved-user-settings | 5518 | (setq vip-saved-user-settings |
| 5466 | (list (cons 'vip-want-ctl-h-help vip-want-ctl-h-help) | 5519 | (list (cons 'vip-want-ctl-h-help vip-want-ctl-h-help) |
| 5467 | (cons 'vip-always vip-always) | 5520 | (cons 'vip-always vip-always) |
| @@ -5493,6 +5546,7 @@ Mail anyway (y or n)? ") | |||
| 5493 | (vip-harness-minor-mode "cyrillic") | 5546 | (vip-harness-minor-mode "cyrillic") |
| 5494 | (vip-harness-minor-mode "russian") | 5547 | (vip-harness-minor-mode "russian") |
| 5495 | (vip-harness-minor-mode "view-less") | 5548 | (vip-harness-minor-mode "view-less") |
| 5549 | (vip-harness-minor-mode "view") | ||
| 5496 | 5550 | ||
| 5497 | 5551 | ||
| 5498 | ;; Intercept maps could go in viper-keym.el | 5552 | ;; Intercept maps could go in viper-keym.el |