diff options
| author | Michael Kifer | 1997-08-07 04:48:48 +0000 |
|---|---|---|
| committer | Michael Kifer | 1997-08-07 04:48:48 +0000 |
| commit | 41497c90ae310d2eec2f59671d85212fc3d6381e (patch) | |
| tree | cba6e8cd387b5907851470453640429f8693d06f /lisp | |
| parent | 8d0cab5714e2f7e19339eadd019de89484e87c88 (diff) | |
| download | emacs-41497c90ae310d2eec2f59671d85212fc3d6381e.tar.gz emacs-41497c90ae310d2eec2f59671d85212fc3d6381e.zip | |
new version
Diffstat (limited to 'lisp')
| -rw-r--r-- | lisp/emulation/viper-cmd.el | 22 | ||||
| -rw-r--r-- | lisp/emulation/viper-init.el | 178 | ||||
| -rw-r--r-- | lisp/emulation/viper-mous.el | 2 | ||||
| -rw-r--r-- | lisp/emulation/viper-util.el | 166 | ||||
| -rw-r--r-- | lisp/emulation/viper.el | 67 |
5 files changed, 248 insertions, 187 deletions
diff --git a/lisp/emulation/viper-cmd.el b/lisp/emulation/viper-cmd.el index 9702af83594..be02683ad10 100644 --- a/lisp/emulation/viper-cmd.el +++ b/lisp/emulation/viper-cmd.el | |||
| @@ -362,12 +362,14 @@ | |||
| 362 | (cons 'viper-vi-global-user-minor-mode viper-vi-global-user-map) | 362 | (cons 'viper-vi-global-user-minor-mode viper-vi-global-user-map) |
| 363 | (cons 'viper-vi-state-modifier-minor-mode | 363 | (cons 'viper-vi-state-modifier-minor-mode |
| 364 | (if (keymapp | 364 | (if (keymapp |
| 365 | (cdr (assoc major-mode viper-vi-state-modifier-alist))) | 365 | (cdr (assoc major-mode |
| 366 | viper-vi-state-modifier-alist))) | ||
| 366 | (cdr (assoc major-mode viper-vi-state-modifier-alist)) | 367 | (cdr (assoc major-mode viper-vi-state-modifier-alist)) |
| 367 | viper-empty-keymap)) | 368 | viper-empty-keymap)) |
| 368 | (cons 'viper-vi-diehard-minor-mode viper-vi-diehard-map) | 369 | (cons 'viper-vi-diehard-minor-mode viper-vi-diehard-map) |
| 369 | (cons 'viper-vi-basic-minor-mode viper-vi-basic-map) | 370 | (cons 'viper-vi-basic-minor-mode viper-vi-basic-map) |
| 370 | (cons 'viper-insert-intercept-minor-mode viper-insert-intercept-map) | 371 | (cons 'viper-insert-intercept-minor-mode |
| 372 | viper-insert-intercept-map) | ||
| 371 | (cons 'viper-replace-minor-mode viper-replace-map) | 373 | (cons 'viper-replace-minor-mode viper-replace-map) |
| 372 | ;; viper-insert-minibuffer-minor-mode must come after | 374 | ;; viper-insert-minibuffer-minor-mode must come after |
| 373 | ;; viper-replace-minor-mode | 375 | ;; viper-replace-minor-mode |
| @@ -380,10 +382,10 @@ | |||
| 380 | viper-insert-global-user-map) | 382 | viper-insert-global-user-map) |
| 381 | (cons 'viper-insert-state-modifier-minor-mode | 383 | (cons 'viper-insert-state-modifier-minor-mode |
| 382 | (if (keymapp | 384 | (if (keymapp |
| 383 | (cdr | 385 | (cdr (assoc major-mode |
| 384 | (assoc major-mode viper-insert-state-modifier-alist))) | 386 | viper-insert-state-modifier-alist))) |
| 385 | (cdr | 387 | (cdr (assoc major-mode |
| 386 | (assoc major-mode viper-insert-state-modifier-alist)) | 388 | viper-insert-state-modifier-alist)) |
| 387 | viper-empty-keymap)) | 389 | viper-empty-keymap)) |
| 388 | (cons 'viper-insert-diehard-minor-mode viper-insert-diehard-map) | 390 | (cons 'viper-insert-diehard-minor-mode viper-insert-diehard-map) |
| 389 | (cons 'viper-insert-basic-minor-mode viper-insert-basic-map) | 391 | (cons 'viper-insert-basic-minor-mode viper-insert-basic-map) |
| @@ -574,8 +576,7 @@ | |||
| 574 | 576 | ||
| 575 | (defsubst viper-downgrade-to-insert () | 577 | (defsubst viper-downgrade-to-insert () |
| 576 | (setq viper-current-state 'insert-state | 578 | (setq viper-current-state 'insert-state |
| 577 | viper-replace-minor-mode nil) | 579 | viper-replace-minor-mode nil)) |
| 578 | ) | ||
| 579 | 580 | ||
| 580 | 581 | ||
| 581 | 582 | ||
| @@ -3576,7 +3577,8 @@ To turn this feature off, set this variable to nil." | |||
| 3576 | (while (and (not found) (< count len)) | 3577 | (while (and (not found) (< count len)) |
| 3577 | (setq suff (nth count viper-smart-suffix-list) | 3578 | (setq suff (nth count viper-smart-suffix-list) |
| 3578 | count (1+ count)) | 3579 | count (1+ count)) |
| 3579 | (if (file-exists-p (format "%s%s" file suff)) | 3580 | (if (file-exists-p |
| 3581 | (format "%s%s" (substitute-in-file-name file) suff)) | ||
| 3580 | (progn | 3582 | (progn |
| 3581 | (setq found t) | 3583 | (setq found t) |
| 3582 | (insert suff)))) | 3584 | (insert suff)))) |
| @@ -3835,7 +3837,7 @@ cursor move past the beginning of line." | |||
| 3835 | (condition-case conds | 3837 | (condition-case conds |
| 3836 | (if (or viper-allow-multiline-replace-regions | 3838 | (if (or viper-allow-multiline-replace-regions |
| 3837 | (viper-same-line (viper-replace-start) | 3839 | (viper-same-line (viper-replace-start) |
| 3838 | (viper-replace-end))) | 3840 | (viper-replace-end))) |
| 3839 | (progn | 3841 | (progn |
| 3840 | ;; tabs cause problems in replace, so untabify | 3842 | ;; tabs cause problems in replace, so untabify |
| 3841 | (goto-char (viper-replace-end)) | 3843 | (goto-char (viper-replace-end)) |
diff --git a/lisp/emulation/viper-init.el b/lisp/emulation/viper-init.el index 4c149494290..47360ed4706 100644 --- a/lisp/emulation/viper-init.el +++ b/lisp/emulation/viper-init.el | |||
| @@ -325,16 +325,6 @@ delete the text being replaced, as in standard Vi." | |||
| 325 | (viper-deflocalvar viper-replace-overlay nil "") | 325 | (viper-deflocalvar viper-replace-overlay nil "") |
| 326 | (put 'viper-replace-overlay 'permanent-local t) | 326 | (put 'viper-replace-overlay 'permanent-local t) |
| 327 | 327 | ||
| 328 | (defcustom viper-replace-overlay-pixmap "gray3" | ||
| 329 | "Pixmap to use for search face on non-color displays." | ||
| 330 | :type 'string | ||
| 331 | :group 'viper) | ||
| 332 | (defcustom viper-search-face-pixmap "gray3" | ||
| 333 | "Pixmap to use for search face on non-color displays." | ||
| 334 | :type 'string | ||
| 335 | :group 'viper) | ||
| 336 | |||
| 337 | |||
| 338 | (defcustom viper-replace-region-end-delimiter "$" | 328 | (defcustom viper-replace-region-end-delimiter "$" |
| 339 | "A string marking the end of replacement regions. | 329 | "A string marking the end of replacement regions. |
| 340 | It is used only with TTYs or if `viper-use-replace-region-delimiters' | 330 | It is used only with TTYs or if `viper-use-replace-region-delimiters' |
| @@ -699,6 +689,174 @@ Related buffers can be cycled through via :R and :P commands." | |||
| 699 | ;; Last shell command executed with ! command. | 689 | ;; Last shell command executed with ! command. |
| 700 | (defvar viper-last-shell-com nil) | 690 | (defvar viper-last-shell-com nil) |
| 701 | 691 | ||
| 692 | |||
| 693 | ;;; Face-saving tricks | ||
| 694 | |||
| 695 | (defcustom viper-replace-overlay-pixmap "gray3" | ||
| 696 | "Pixmap to use for search face on non-color displays." | ||
| 697 | :type 'string | ||
| 698 | :group 'viper) | ||
| 699 | (defcustom viper-search-face-pixmap "gray3" | ||
| 700 | "Pixmap to use for search face on non-color displays." | ||
| 701 | :type 'string | ||
| 702 | :group 'viper) | ||
| 703 | |||
| 704 | (defun viper-hide-face (face) | ||
| 705 | (if (and (viper-has-face-support-p) viper-emacs-p) | ||
| 706 | (add-to-list 'facemenu-unlisted-faces face))) | ||
| 707 | |||
| 708 | |||
| 709 | (defgroup viper-highlighting nil | ||
| 710 | "Hilighting of replace region, search pattern, minibuffer, etc." | ||
| 711 | :prefix "viper-" | ||
| 712 | :group 'viper) | ||
| 713 | |||
| 714 | ;;(defvar viper-search-face | ||
| 715 | ;; (if (viper-has-face-support-p) | ||
| 716 | ;; (progn | ||
| 717 | ;; (make-face 'viper-search-face) | ||
| 718 | ;; (or (face-differs-from-default-p 'viper-search-face) | ||
| 719 | ;; ;; face wasn't set in .viper or .Xdefaults | ||
| 720 | ;; (if (viper-can-use-colors "Black" "khaki") | ||
| 721 | ;; (progn | ||
| 722 | ;; (set-face-background 'viper-search-face "khaki") | ||
| 723 | ;; (set-face-foreground 'viper-search-face "Black")) | ||
| 724 | ;; (set-face-underline-p 'viper-search-face t) | ||
| 725 | ;; (viper-set-face-pixmap 'viper-search-face | ||
| 726 | ;; viper-search-face-pixmap))) | ||
| 727 | ;; 'viper-search-face)) | ||
| 728 | ;; "*Face used to flash out the search pattern.") | ||
| 729 | |||
| 730 | (defface viper-search-face | ||
| 731 | '((((class color)) (:foreground "Black" :background "khaki")) | ||
| 732 | (t (:underline t :stipple viper-search-face-pixmap))) | ||
| 733 | "*Face used to flash out the search pattern." | ||
| 734 | :group 'viper-highlighting) | ||
| 735 | ;; An internal variable. Viper takes the face from here. | ||
| 736 | (defvar viper-search-face 'viper-search-face) | ||
| 737 | (viper-hide-face 'viper-search-face) | ||
| 738 | |||
| 739 | ;;(defvar viper-replace-overlay-face | ||
| 740 | ;; (if (viper-has-face-support-p) | ||
| 741 | ;; (progn | ||
| 742 | ;; (make-face 'viper-replace-overlay-face) | ||
| 743 | ;; (or (face-differs-from-default-p 'viper-replace-overlay-face) | ||
| 744 | ;; (progn | ||
| 745 | ;; (if (viper-can-use-colors "darkseagreen2" "Black") | ||
| 746 | ;; (progn | ||
| 747 | ;; (set-face-background | ||
| 748 | ;; 'viper-replace-overlay-face "darkseagreen2") | ||
| 749 | ;; (set-face-foreground 'viper-replace-overlay-face "Black"))) | ||
| 750 | ;; (set-face-underline-p 'viper-replace-overlay-face t) | ||
| 751 | ;; (viper-set-face-pixmap | ||
| 752 | ;; 'viper-replace-overlay-face viper-replace-overlay-pixmap))) | ||
| 753 | ;; 'viper-replace-overlay-face)) | ||
| 754 | ;; "*Face for highlighting replace regions on a window display.") | ||
| 755 | |||
| 756 | (defface viper-replace-overlay-face | ||
| 757 | '((((class color)) (:foreground "Black" :background "darkseagreen2")) | ||
| 758 | (t (:underline t :stipple viper-replace-overlay-face-pixmap))) | ||
| 759 | "*Face for highlighting replace regions on a window display." | ||
| 760 | :group 'viper-highlighting) | ||
| 761 | ;; An internal variable. Viper takes the face from here. | ||
| 762 | (defvar viper-replace-overlay-face 'viper-replace-overlay-face) | ||
| 763 | (viper-hide-face 'viper-replace-overlay-face) | ||
| 764 | |||
| 765 | ;;(defvar viper-minibuffer-emacs-face | ||
| 766 | ;; (if (viper-has-face-support-p) | ||
| 767 | ;; (progn | ||
| 768 | ;; (make-face 'viper-minibuffer-emacs-face) | ||
| 769 | ;; (or (face-differs-from-default-p 'viper-minibuffer-emacs-face) | ||
| 770 | ;; ;; face wasn't set in .viper or .Xdefaults | ||
| 771 | ;; (if viper-vi-style-in-minibuffer | ||
| 772 | ;; ;; emacs state is an exception in the minibuffer | ||
| 773 | ;; (if (viper-can-use-colors "darkseagreen2" "Black") | ||
| 774 | ;; (progn | ||
| 775 | ;; (set-face-background | ||
| 776 | ;; 'viper-minibuffer-emacs-face "darkseagreen2") | ||
| 777 | ;; (set-face-foreground | ||
| 778 | ;; 'viper-minibuffer-emacs-face "Black")) | ||
| 779 | ;; (copy-face 'modeline 'viper-minibuffer-emacs-face)) | ||
| 780 | ;; ;; emacs state is the main state in the minibuffer | ||
| 781 | ;; (if (viper-can-use-colors "Black" "pink") | ||
| 782 | ;; (progn | ||
| 783 | ;; (set-face-background 'viper-minibuffer-emacs-face "pink") | ||
| 784 | ;; (set-face-foreground | ||
| 785 | ;; 'viper-minibuffer-emacs-face "Black")) | ||
| 786 | ;; (copy-face 'italic 'viper-minibuffer-emacs-face)) | ||
| 787 | ;; )) | ||
| 788 | ;; 'viper-minibuffer-emacs-face)) | ||
| 789 | ;; "Face used in the Minibuffer when it is in Emacs state.") | ||
| 790 | |||
| 791 | (defface viper-minibuffer-emacs-face | ||
| 792 | '((((class color)) (:foreground "Black" :background "darkseagreen2")) | ||
| 793 | (t (:bold t))) | ||
| 794 | "Face used in the Minibuffer when it is in Emacs state." | ||
| 795 | :group 'viper-highlighting) | ||
| 796 | ;; An internal variable. Viper takes the face from here. | ||
| 797 | (defvar viper-minibuffer-emacs-face 'viper-minibuffer-emacs-face) | ||
| 798 | (viper-hide-face 'viper-minibuffer-emacs-face) | ||
| 799 | |||
| 800 | ;;(defvar viper-minibuffer-insert-face | ||
| 801 | ;; (if (viper-has-face-support-p) | ||
| 802 | ;; (progn | ||
| 803 | ;; (make-face 'viper-minibuffer-insert-face) | ||
| 804 | ;; (or (face-differs-from-default-p 'viper-minibuffer-insert-face) | ||
| 805 | ;; (if viper-vi-style-in-minibuffer | ||
| 806 | ;; (if (viper-can-use-colors "Black" "pink") | ||
| 807 | ;; (progn | ||
| 808 | ;; (set-face-background 'viper-minibuffer-insert-face "pink") | ||
| 809 | ;; (set-face-foreground | ||
| 810 | ;; 'viper-minibuffer-insert-face "Black")) | ||
| 811 | ;; (copy-face 'italic 'viper-minibuffer-insert-face)) | ||
| 812 | ;; ;; If Insert state is an exception | ||
| 813 | ;; (if (viper-can-use-colors "darkseagreen2" "Black") | ||
| 814 | ;; (progn | ||
| 815 | ;; (set-face-background | ||
| 816 | ;; 'viper-minibuffer-insert-face "darkseagreen2") | ||
| 817 | ;; (set-face-foreground | ||
| 818 | ;; 'viper-minibuffer-insert-face "Black")) | ||
| 819 | ;; (copy-face 'modeline 'viper-minibuffer-insert-face)) | ||
| 820 | ;; (viper-italicize-face 'viper-minibuffer-insert-face))) | ||
| 821 | ;; 'viper-minibuffer-insert-face)) | ||
| 822 | ;; "Face used in the Minibuffer when it is in Insert state.") | ||
| 823 | |||
| 824 | (defface viper-minibuffer-insert-face | ||
| 825 | '((((class color)) (:foreground "Black" :background "pink")) | ||
| 826 | (t (:italic t))) | ||
| 827 | "Face used in the Minibuffer when it is in Insert state." | ||
| 828 | :group 'viper-highlighting) | ||
| 829 | ;; An internal variable. Viper takes the face from here. | ||
| 830 | (defvar viper-minibuffer-insert-face 'viper-minibuffer-insert-face) | ||
| 831 | (viper-hide-face 'viper-minibuffer-insert-face) | ||
| 832 | |||
| 833 | ;;(defvar viper-minibuffer-vi-face | ||
| 834 | ;; (if (viper-has-face-support-p) | ||
| 835 | ;; (progn | ||
| 836 | ;; (make-face 'viper-minibuffer-vi-face) | ||
| 837 | ;; (or (face-differs-from-default-p 'viper-minibuffer-vi-face) | ||
| 838 | ;; (if viper-vi-style-in-minibuffer | ||
| 839 | ;; (if (viper-can-use-colors "Black" "grey") | ||
| 840 | ;; (progn | ||
| 841 | ;; (set-face-background 'viper-minibuffer-vi-face "grey") | ||
| 842 | ;; (set-face-foreground 'viper-minibuffer-vi-face "Black")) | ||
| 843 | ;; (copy-face 'bold 'viper-minibuffer-vi-face)) | ||
| 844 | ;; (copy-face 'bold 'viper-minibuffer-vi-face) | ||
| 845 | ;; (invert-face 'viper-minibuffer-vi-face))) | ||
| 846 | ;; 'viper-minibuffer-vi-face)) | ||
| 847 | ;; "Face used in the Minibuffer when it is in Vi state.") | ||
| 848 | |||
| 849 | (defface viper-minibuffer-vi-face | ||
| 850 | '((((class color)) (:foreground "DarkGreen" :background "grey")) | ||
| 851 | (t (:inverse-video t))) | ||
| 852 | "Face used in the Minibuffer when it is in Vi state." | ||
| 853 | :group 'viper-highlighting) | ||
| 854 | ;; An internal variable. Viper takes the face from here. | ||
| 855 | (defvar viper-minibuffer-vi-face 'viper-minibuffer-vi-face) | ||
| 856 | (viper-hide-face 'viper-minibuffer-vi-face) | ||
| 857 | |||
| 858 | ;; the current face to be used in the minibuffer | ||
| 859 | (viper-deflocalvar viper-minibuffer-current-face viper-minibuffer-emacs-face "") | ||
| 702 | 860 | ||
| 703 | 861 | ||
| 704 | ;;; Miscellaneous | 862 | ;;; Miscellaneous |
diff --git a/lisp/emulation/viper-mous.el b/lisp/emulation/viper-mous.el index 828b468ed12..d630a64f303 100644 --- a/lisp/emulation/viper-mous.el +++ b/lisp/emulation/viper-mous.el | |||
| @@ -424,7 +424,7 @@ this command." | |||
| 424 | 424 | ||
| 425 | (defun viper-mouse-catch-frame-switch (event arg) | 425 | (defun viper-mouse-catch-frame-switch (event arg) |
| 426 | "Catch the event of switching frame. | 426 | "Catch the event of switching frame. |
| 427 | Usually is bound to a 'down-mouse' event to work properly. See sample | 427 | Usually is bound to a `down-mouse' event to work properly. See sample |
| 428 | bindings in the Viper manual." | 428 | bindings in the Viper manual." |
| 429 | (interactive "e\nP") | 429 | (interactive "e\nP") |
| 430 | (setq viper-frame-of-focus nil) | 430 | (setq viper-frame-of-focus nil) |
diff --git a/lisp/emulation/viper-util.el b/lisp/emulation/viper-util.el index 28584aa3971..d9e39281a70 100644 --- a/lisp/emulation/viper-util.el +++ b/lisp/emulation/viper-util.el | |||
| @@ -50,16 +50,17 @@ | |||
| 50 | (require 'viper-init) | 50 | (require 'viper-init) |
| 51 | 51 | ||
| 52 | 52 | ||
| 53 | ;; A fix for NeXT Step | ||
| 54 | ;; Should go away, when NS people fix the design flaw, which leaves the | ||
| 55 | ;; two x-* functions undefined. | ||
| 56 | (if (and (not (fboundp 'x-display-color-p)) (fboundp 'ns-display-color-p)) | ||
| 57 | (fset 'x-display-color-p (symbol-function 'ns-display-color-p))) | ||
| 58 | (if (and (not (fboundp 'x-color-defined-p)) (fboundp 'ns-color-defined-p)) | ||
| 59 | (fset 'x-color-defined-p (symbol-function 'ns-color-defined-p))) | ||
| 60 | |||
| 53 | 61 | ||
| 54 | ;;; XEmacs support | 62 | ;;; XEmacs support |
| 55 | 63 | ||
| 56 | ;; A fix for NeXT Step | ||
| 57 | ;; Should probably be eliminated in later versions. | ||
| 58 | (if (and (viper-window-display-p) (eq (viper-device-type) 'ns)) | ||
| 59 | (progn | ||
| 60 | (fset 'x-display-color-p (symbol-function 'ns-display-color-p)) | ||
| 61 | (fset 'x-color-defined-p (symbol-function 'ns-color-defined-p)) | ||
| 62 | )) | ||
| 63 | 64 | ||
| 64 | (if viper-xemacs-p | 65 | (if viper-xemacs-p |
| 65 | (progn | 66 | (progn |
| @@ -108,14 +109,14 @@ | |||
| 108 | (cdr (assoc 'cursor-color (frame-parameters))) | 109 | (cdr (assoc 'cursor-color (frame-parameters))) |
| 109 | (color-instance-name (frame-property (selected-frame) 'cursor-color)))) | 110 | (color-instance-name (frame-property (selected-frame) 'cursor-color)))) |
| 110 | 111 | ||
| 111 | (defun viper-set-face-pixmap (face pixmap) | 112 | ;;(defun viper-set-face-pixmap (face pixmap) |
| 112 | "Set face pixmap on a monochrome display." | 113 | ;; "Set face pixmap on a monochrome display." |
| 113 | (if (and (viper-window-display-p) (not (viper-color-display-p))) | 114 | ;; (if (and (viper-window-display-p) (not (viper-color-display-p))) |
| 114 | (condition-case nil | 115 | ;; (condition-case nil |
| 115 | (set-face-background-pixmap face pixmap) | 116 | ;; (set-face-background-pixmap face pixmap) |
| 116 | (error | 117 | ;; (error |
| 117 | (message "Pixmap not found for %S: %s" (face-name face) pixmap) | 118 | ;; (message "Pixmap not found for %S: %s" (face-name face) pixmap) |
| 118 | (sit-for 1))))) | 119 | ;; (sit-for 1))))) |
| 119 | 120 | ||
| 120 | 121 | ||
| 121 | ;; OS/2 | 122 | ;; OS/2 |
| @@ -124,20 +125,16 @@ | |||
| 124 | (function (lambda (color) (assoc color pm-color-alist)))))) | 125 | (function (lambda (color) (assoc color pm-color-alist)))))) |
| 125 | 126 | ||
| 126 | ;; needed to smooth out the difference between Emacs and XEmacs | 127 | ;; needed to smooth out the difference between Emacs and XEmacs |
| 127 | (defsubst viper-italicize-face (face) | 128 | ;;(defsubst viper-italicize-face (face) |
| 128 | (if viper-xemacs-p | 129 | ;; (if viper-xemacs-p |
| 129 | (make-face-italic face) | 130 | ;; (make-face-italic face) |
| 130 | (make-face-italic face nil 'noerror))) | 131 | ;; (make-face-italic face nil 'noerror))) |
| 131 | 132 | ||
| 132 | ;; test if display is color and the colors are defined | 133 | ;; test if display is color and the colors are defined |
| 133 | (defsubst viper-can-use-colors (&rest colors) | 134 | ;;(defsubst viper-can-use-colors (&rest colors) |
| 134 | (if (viper-color-display-p) | 135 | ;; (if (viper-color-display-p) |
| 135 | (not (memq nil (mapcar 'viper-color-defined-p colors))) | 136 | ;; (not (memq nil (mapcar 'viper-color-defined-p colors))) |
| 136 | )) | 137 | ;; )) |
| 137 | |||
| 138 | (defun viper-hide-face (face) | ||
| 139 | (if (and (viper-has-face-support-p) viper-emacs-p) | ||
| 140 | (add-to-list 'facemenu-unlisted-faces face))) | ||
| 141 | 138 | ||
| 142 | ;; cursor colors | 139 | ;; cursor colors |
| 143 | (defun viper-change-cursor-color (new-color) | 140 | (defun viper-change-cursor-color (new-color) |
| @@ -161,114 +158,6 @@ | |||
| 161 | (defsubst viper-restore-cursor-color-after-insert () | 158 | (defsubst viper-restore-cursor-color-after-insert () |
| 162 | (viper-change-cursor-color viper-saved-cursor-color)) | 159 | (viper-change-cursor-color viper-saved-cursor-color)) |
| 163 | 160 | ||
| 164 | |||
| 165 | ;; Face-saving tricks | ||
| 166 | |||
| 167 | (defvar viper-search-face | ||
| 168 | (if (viper-has-face-support-p) | ||
| 169 | (progn | ||
| 170 | (make-face 'viper-search-face) | ||
| 171 | (viper-hide-face 'viper-search-face) | ||
| 172 | (or (face-differs-from-default-p 'viper-search-face) | ||
| 173 | ;; face wasn't set in .viper or .Xdefaults | ||
| 174 | (if (viper-can-use-colors "Black" "khaki") | ||
| 175 | (progn | ||
| 176 | (set-face-background 'viper-search-face "khaki") | ||
| 177 | (set-face-foreground 'viper-search-face "Black")) | ||
| 178 | (set-face-underline-p 'viper-search-face t) | ||
| 179 | (viper-set-face-pixmap 'viper-search-face viper-search-face-pixmap))) | ||
| 180 | 'viper-search-face)) | ||
| 181 | "*Face used to flash out the search pattern.") | ||
| 182 | |||
| 183 | (defvar viper-replace-overlay-face | ||
| 184 | (if (viper-has-face-support-p) | ||
| 185 | (progn | ||
| 186 | (make-face 'viper-replace-overlay-face) | ||
| 187 | (viper-hide-face 'viper-replace-overlay-face) | ||
| 188 | (or (face-differs-from-default-p 'viper-replace-overlay-face) | ||
| 189 | (progn | ||
| 190 | (if (viper-can-use-colors "darkseagreen2" "Black") | ||
| 191 | (progn | ||
| 192 | (set-face-background | ||
| 193 | 'viper-replace-overlay-face "darkseagreen2") | ||
| 194 | (set-face-foreground 'viper-replace-overlay-face "Black"))) | ||
| 195 | (set-face-underline-p 'viper-replace-overlay-face t) | ||
| 196 | (viper-set-face-pixmap | ||
| 197 | 'viper-replace-overlay-face viper-replace-overlay-pixmap))) | ||
| 198 | 'viper-replace-overlay-face)) | ||
| 199 | "*Face for highlighting replace regions on a window display.") | ||
| 200 | |||
| 201 | (defvar viper-minibuffer-emacs-face | ||
| 202 | (if (viper-has-face-support-p) | ||
| 203 | (progn | ||
| 204 | (make-face 'viper-minibuffer-emacs-face) | ||
| 205 | (viper-hide-face 'viper-minibuffer-emacs-face) | ||
| 206 | (or (face-differs-from-default-p 'viper-minibuffer-emacs-face) | ||
| 207 | ;; face wasn't set in .viper or .Xdefaults | ||
| 208 | (if viper-vi-style-in-minibuffer | ||
| 209 | ;; emacs state is an exception in the minibuffer | ||
| 210 | (if (viper-can-use-colors "darkseagreen2" "Black") | ||
| 211 | (progn | ||
| 212 | (set-face-background | ||
| 213 | 'viper-minibuffer-emacs-face "darkseagreen2") | ||
| 214 | (set-face-foreground | ||
| 215 | 'viper-minibuffer-emacs-face "Black")) | ||
| 216 | (copy-face 'modeline 'viper-minibuffer-emacs-face)) | ||
| 217 | ;; emacs state is the main state in the minibuffer | ||
| 218 | (if (viper-can-use-colors "Black" "pink") | ||
| 219 | (progn | ||
| 220 | (set-face-background 'viper-minibuffer-emacs-face "pink") | ||
| 221 | (set-face-foreground | ||
| 222 | 'viper-minibuffer-emacs-face "Black")) | ||
| 223 | (copy-face 'italic 'viper-minibuffer-emacs-face)) | ||
| 224 | )) | ||
| 225 | 'viper-minibuffer-emacs-face)) | ||
| 226 | "Face used in the Minibuffer when it is in Emacs state.") | ||
| 227 | |||
| 228 | (defvar viper-minibuffer-insert-face | ||
| 229 | (if (viper-has-face-support-p) | ||
| 230 | (progn | ||
| 231 | (make-face 'viper-minibuffer-insert-face) | ||
| 232 | (viper-hide-face 'viper-minibuffer-insert-face) | ||
| 233 | (or (face-differs-from-default-p 'viper-minibuffer-insert-face) | ||
| 234 | (if viper-vi-style-in-minibuffer | ||
| 235 | (if (viper-can-use-colors "Black" "pink") | ||
| 236 | (progn | ||
| 237 | (set-face-background 'viper-minibuffer-insert-face "pink") | ||
| 238 | (set-face-foreground | ||
| 239 | 'viper-minibuffer-insert-face "Black")) | ||
| 240 | (copy-face 'italic 'viper-minibuffer-insert-face)) | ||
| 241 | ;; If Insert state is an exception | ||
| 242 | (if (viper-can-use-colors "darkseagreen2" "Black") | ||
| 243 | (progn | ||
| 244 | (set-face-background | ||
| 245 | 'viper-minibuffer-insert-face "darkseagreen2") | ||
| 246 | (set-face-foreground | ||
| 247 | 'viper-minibuffer-insert-face "Black")) | ||
| 248 | (copy-face 'modeline 'viper-minibuffer-insert-face)) | ||
| 249 | (viper-italicize-face 'viper-minibuffer-insert-face))) | ||
| 250 | 'viper-minibuffer-insert-face)) | ||
| 251 | "Face used in the Minibuffer when it is in Insert state.") | ||
| 252 | |||
| 253 | (defvar viper-minibuffer-vi-face | ||
| 254 | (if (viper-has-face-support-p) | ||
| 255 | (progn | ||
| 256 | (make-face 'viper-minibuffer-vi-face) | ||
| 257 | (viper-hide-face 'viper-minibuffer-vi-face) | ||
| 258 | (or (face-differs-from-default-p 'viper-minibuffer-vi-face) | ||
| 259 | (if viper-vi-style-in-minibuffer | ||
| 260 | (if (viper-can-use-colors "Black" "grey") | ||
| 261 | (progn | ||
| 262 | (set-face-background 'viper-minibuffer-vi-face "grey") | ||
| 263 | (set-face-foreground 'viper-minibuffer-vi-face "Black")) | ||
| 264 | (copy-face 'bold 'viper-minibuffer-vi-face)) | ||
| 265 | (copy-face 'bold 'viper-minibuffer-vi-face) | ||
| 266 | (invert-face 'viper-minibuffer-vi-face))) | ||
| 267 | 'viper-minibuffer-vi-face)) | ||
| 268 | "Face used in the Minibuffer when it is in Vi state.") | ||
| 269 | |||
| 270 | ;; the current face to be used in the minibuffer | ||
| 271 | (viper-deflocalvar viper-minibuffer-current-face viper-minibuffer-emacs-face "") | ||
| 272 | 161 | ||
| 273 | 162 | ||
| 274 | ;; Check the current version against the major and minor version numbers | 163 | ;; Check the current version against the major and minor version numbers |
| @@ -979,10 +868,11 @@ to write a custom function, similar to `viper-ex-nontrivial-find-file-unix'." | |||
| 979 | (defun viper-read-key () | 868 | (defun viper-read-key () |
| 980 | (let ((overriding-local-map viper-overriding-map) | 869 | (let ((overriding-local-map viper-overriding-map) |
| 981 | (inhibit-quit t) | 870 | (inhibit-quit t) |
| 982 | key) | 871 | help-char key) |
| 983 | (use-global-map viper-overriding-map) | 872 | (use-global-map viper-overriding-map) |
| 984 | (setq key (elt (read-key-sequence nil) 0)) | 873 | (unwind-protect |
| 985 | (use-global-map global-map) | 874 | (setq key (elt (read-key-sequence nil) 0)) |
| 875 | (use-global-map global-map)) | ||
| 986 | key)) | 876 | key)) |
| 987 | 877 | ||
| 988 | 878 | ||
diff --git a/lisp/emulation/viper.el b/lisp/emulation/viper.el index d09fddb941a..84fac506164 100644 --- a/lisp/emulation/viper.el +++ b/lisp/emulation/viper.el | |||
| @@ -361,8 +361,11 @@ DO NOT set this variable interactively." | |||
| 361 | :tag "Set Viper Mode on Loading" | 361 | :tag "Set Viper Mode on Loading" |
| 362 | :group 'viper) | 362 | :group 'viper) |
| 363 | 363 | ||
| 364 | (defcustom viper-non-vi-major-modes nil | 364 | (defcustom viper-non-vi-major-modes |
| 365 | "*A list of major modes that should never come up in vi command mode. | 365 | '(custom-mode dired-mode efs-mode internal-ange-ftp-mode tar-mode |
| 366 | mh-folder-mode gnus-group-mode gnus-summary-mode Info-mode | ||
| 367 | Buffer-menu-mode view-mode vm-mode vm-summary-mode) | ||
| 368 | "*A list of major modes that should never come up in Vi command mode. | ||
| 366 | Viper automatically augments this list with some obvious modes, such as | 369 | Viper automatically augments this list with some obvious modes, such as |
| 367 | `dired-mode', `tar-mode', etc. So, don't put modes on this list, unless | 370 | `dired-mode', `tar-mode', etc. So, don't put modes on this list, unless |
| 368 | it comes up in a wrong Viper state." | 371 | it comes up in a wrong Viper state." |
| @@ -599,7 +602,12 @@ remains buffer-local." | |||
| 599 | ;; unbind Viper mouse bindings | 602 | ;; unbind Viper mouse bindings |
| 600 | (viper-unbind-mouse-search-key) | 603 | (viper-unbind-mouse-search-key) |
| 601 | (viper-unbind-mouse-insert-key) | 604 | (viper-unbind-mouse-insert-key) |
| 602 | ) | 605 | ;; In emacs, we have to advice handle-switch-frame |
| 606 | ;; This advice is undone earlier, when all advices matchine "viper-" are | ||
| 607 | ;; deactivated. | ||
| 608 | (if viper-xemacs-p | ||
| 609 | (remove-hook 'mouse-leave-frame-hook 'viper-remember-current-frame)) | ||
| 610 | ) ; end viper-go-away | ||
| 603 | 611 | ||
| 604 | 612 | ||
| 605 | 613 | ||
| @@ -754,14 +762,10 @@ remains buffer-local." | |||
| 754 | (viper-modify-major-mode 'dired-mode 'emacs-state viper-dired-modifier-map) | 762 | (viper-modify-major-mode 'dired-mode 'emacs-state viper-dired-modifier-map) |
| 755 | (viper-set-emacs-state-searchstyle-macros nil 'dired-mode) | 763 | (viper-set-emacs-state-searchstyle-macros nil 'dired-mode) |
| 756 | (add-hook 'dired-mode-hook 'viper-change-state-to-emacs) | 764 | (add-hook 'dired-mode-hook 'viper-change-state-to-emacs) |
| 757 | (setq viper-non-vi-major-modes | ||
| 758 | (append '(dired-mode efs-mode internal-ange-ftp-mode) | ||
| 759 | viper-non-vi-major-modes)) | ||
| 760 | 765 | ||
| 761 | ;; Tar | 766 | ;; Tar |
| 762 | (viper-modify-major-mode 'tar-mode 'emacs-state viper-slash-and-colon-map) | 767 | (viper-modify-major-mode 'tar-mode 'emacs-state viper-slash-and-colon-map) |
| 763 | (viper-set-emacs-state-searchstyle-macros nil 'tar-mode) | 768 | (viper-set-emacs-state-searchstyle-macros nil 'tar-mode) |
| 764 | (setq viper-non-vi-major-modes (cons 'tar-mode viper-non-vi-major-modes)) | ||
| 765 | 769 | ||
| 766 | ;; MH-E | 770 | ;; MH-E |
| 767 | (viper-modify-major-mode | 771 | (viper-modify-major-mode |
| @@ -770,8 +774,6 @@ remains buffer-local." | |||
| 770 | ;; changing state to emacs is needed so the preceding will take hold | 774 | ;; changing state to emacs is needed so the preceding will take hold |
| 771 | (add-hook 'mh-folder-mode-hook 'viper-change-state-to-emacs) | 775 | (add-hook 'mh-folder-mode-hook 'viper-change-state-to-emacs) |
| 772 | (add-hook 'mh-show-mode-hook 'viper-mode) | 776 | (add-hook 'mh-show-mode-hook 'viper-mode) |
| 773 | (setq viper-non-vi-major-modes | ||
| 774 | (cons 'mh-folder-mode viper-non-vi-major-modes)) | ||
| 775 | 777 | ||
| 776 | ;; Gnus | 778 | ;; Gnus |
| 777 | (viper-modify-major-mode | 779 | (viper-modify-major-mode |
| @@ -784,9 +786,6 @@ remains buffer-local." | |||
| 784 | (add-hook 'gnus-group-mode-hook 'viper-change-state-to-emacs) | 786 | (add-hook 'gnus-group-mode-hook 'viper-change-state-to-emacs) |
| 785 | (add-hook 'gnus-summary-mode-hook 'viper-change-state-to-emacs) | 787 | (add-hook 'gnus-summary-mode-hook 'viper-change-state-to-emacs) |
| 786 | (add-hook 'gnus-article-mode-hook 'viper-mode) | 788 | (add-hook 'gnus-article-mode-hook 'viper-mode) |
| 787 | (setq viper-non-vi-major-modes | ||
| 788 | (append '(gnus-group-mode gnus-summary-mode) | ||
| 789 | viper-non-vi-major-modes)) | ||
| 790 | 789 | ||
| 791 | ;; Info | 790 | ;; Info |
| 792 | (viper-modify-major-mode 'Info-mode 'emacs-state viper-slash-and-colon-map) | 791 | (viper-modify-major-mode 'Info-mode 'emacs-state viper-slash-and-colon-map) |
| @@ -795,7 +794,6 @@ remains buffer-local." | |||
| 795 | (defadvice Info-mode (after viper-Info-ad activate) | 794 | (defadvice Info-mode (after viper-Info-ad activate) |
| 796 | "Switch to emacs mode." | 795 | "Switch to emacs mode." |
| 797 | (viper-change-state-to-emacs)) | 796 | (viper-change-state-to-emacs)) |
| 798 | (setq viper-non-vi-major-modes (cons 'Info-mode viper-non-vi-major-modes)) | ||
| 799 | 797 | ||
| 800 | ;; Buffer menu | 798 | ;; Buffer menu |
| 801 | (viper-modify-major-mode | 799 | (viper-modify-major-mode |
| @@ -805,15 +803,12 @@ remains buffer-local." | |||
| 805 | (defadvice Buffer-menu-mode (after viper-Buffer-menu-ad activate) | 803 | (defadvice Buffer-menu-mode (after viper-Buffer-menu-ad activate) |
| 806 | "Switch to emacs mode." | 804 | "Switch to emacs mode." |
| 807 | (viper-change-state-to-emacs)) | 805 | (viper-change-state-to-emacs)) |
| 808 | (setq viper-non-vi-major-modes | ||
| 809 | (cons 'Buffer-menu-mode viper-non-vi-major-modes)) | ||
| 810 | 806 | ||
| 811 | ;; View mode | 807 | ;; View mode |
| 812 | (defvar view-mode-hook) | 808 | (defvar view-mode-hook) |
| 813 | (defvar view-hook) | 809 | (defvar view-hook) |
| 814 | (add-hook 'view-hook 'viper-change-state-to-emacs) | 810 | (add-hook 'view-hook 'viper-change-state-to-emacs) |
| 815 | (add-hook 'view-mode-hook 'viper-change-state-to-emacs) | 811 | (add-hook 'view-mode-hook 'viper-change-state-to-emacs) |
| 816 | (setq viper-non-vi-major-modes (cons 'view-mode viper-non-vi-major-modes)) | ||
| 817 | 812 | ||
| 818 | ;; For VM users. | 813 | ;; For VM users. |
| 819 | ;; Put summary and other VM buffers in Emacs state. | 814 | ;; Put summary and other VM buffers in Emacs state. |
| @@ -821,8 +816,6 @@ remains buffer-local." | |||
| 821 | (defvar vm-summary-mode-hooks) | 816 | (defvar vm-summary-mode-hooks) |
| 822 | (add-hook 'vm-mode-hooks 'viper-change-state-to-emacs) | 817 | (add-hook 'vm-mode-hooks 'viper-change-state-to-emacs) |
| 823 | (add-hook 'vm-summary-mode-hooks 'viper-change-state-to-emacs) | 818 | (add-hook 'vm-summary-mode-hooks 'viper-change-state-to-emacs) |
| 824 | (setq viper-non-vi-major-modes | ||
| 825 | (append '(vm-mode vm-summary-mode) viper-non-vi-major-modes)) | ||
| 826 | 819 | ||
| 827 | ;; For RMAIL users. | 820 | ;; For RMAIL users. |
| 828 | ;; Put buf in Emacs state after edit. | 821 | ;; Put buf in Emacs state after edit. |
| @@ -970,14 +963,24 @@ remains buffer-local." | |||
| 970 | (define-key viper-vi-intercept-map "\C-x)" nil) | 963 | (define-key viper-vi-intercept-map "\C-x)" nil) |
| 971 | (define-key viper-insert-intercept-map "\C-x)" nil) | 964 | (define-key viper-insert-intercept-map "\C-x)" nil) |
| 972 | (define-key viper-emacs-intercept-map "\C-x)" nil)) | 965 | (define-key viper-emacs-intercept-map "\C-x)" nil)) |
| 966 | |||
| 967 | ;; catch frame switching event | ||
| 968 | (if (viper-window-display-p) | ||
| 969 | (if viper-xemacs-p | ||
| 970 | (add-hook 'mouse-leave-frame-hook | ||
| 971 | 'viper-remember-current-frame) | ||
| 972 | (defadvice handle-switch-frame (before viper-frame-advice activate) | ||
| 973 | "Remember the selected frame before the switch-frame event." | ||
| 974 | (viper-remember-current-frame (selected-frame)))) ) | ||
| 975 | |||
| 973 | ) ; end viper-non-hook-settings | 976 | ) ; end viper-non-hook-settings |
| 974 | 977 | ||
| 975 | 978 | ||
| 976 | (if (eq viper-mode 'ask) | 979 | ;; Ask only if this-command/last-command are nil, i.e., when loading |
| 977 | (progn | 980 | (cond ((and (eq viper-mode 'ask) (null this-command) (null last-command)) |
| 978 | (save-window-excursion | 981 | (save-window-excursion |
| 979 | (with-output-to-temp-buffer " *viper-info*" | 982 | (with-output-to-temp-buffer " *viper-info*" |
| 980 | (princ " | 983 | (princ " |
| 981 | You have loaded Viper, and are about to Viperize your emacs! | 984 | You have loaded Viper, and are about to Viperize your emacs! |
| 982 | 985 | ||
| 983 | Viper is a Package for Emacs Rebels and a venomous VI PERil, | 986 | Viper is a Package for Emacs Rebels and a venomous VI PERil, |
| @@ -995,11 +998,19 @@ These two lines must come in the order given. | |||
| 995 | ** Viper users: | 998 | ** Viper users: |
| 996 | **** The startup file name has been changed from .vip to .viper | 999 | **** The startup file name has been changed from .vip to .viper |
| 997 | **** All vip-* style names have been converted to viper-* style.")) | 1000 | **** All vip-* style names have been converted to viper-* style.")) |
| 998 | (if (y-or-n-p "Viperize? ") | 1001 | (if (y-or-n-p "Viperize? ") |
| 999 | (setq viper-mode t) | 1002 | (setq viper-mode t) |
| 1000 | (setq viper-mode nil)) | 1003 | (setq viper-mode nil)) |
| 1001 | (message "") | 1004 | (message "") |
| 1002 | (kill-buffer " *viper-info*")))) | 1005 | (kill-buffer " *viper-info*"))) |
| 1006 | |||
| 1007 | ;; If viper-mode is t, then just continue. Viper will kick in. | ||
| 1008 | ((eq viper-mode t)) | ||
| 1009 | ;; Otherwise, it was asking mode and Viper was not loaded through .emacs | ||
| 1010 | ;; In this case, it was either through M-x viper-mode or via something | ||
| 1011 | ;; else, like the custom widget. If Viper was loaded through | ||
| 1012 | ;; M-x viper-mode, then viper will kick in anyway. | ||
| 1013 | (t (setq viper-mode nil))) | ||
| 1003 | 1014 | ||
| 1004 | (defun viper-load-custom-file () | 1015 | (defun viper-load-custom-file () |
| 1005 | (if (and (file-exists-p viper-custom-file-name) | 1016 | (if (and (file-exists-p viper-custom-file-name) |