comparison lisp/viper/viper.el @ 185:3d6bfa290dbd r20-3b19

Import from CVS: tag r20-3b19
author cvs
date Mon, 13 Aug 2007 09:55:28 +0200
parents bfd6434d15b3
children b405438285a2
comparison
equal deleted inserted replaced
184:bcd2674570bf 185:3d6bfa290dbd
6 ;; Keywords: emulations 6 ;; Keywords: emulations
7 ;; Author: Michael Kifer <kifer@cs.sunysb.edu> 7 ;; Author: Michael Kifer <kifer@cs.sunysb.edu>
8 8
9 ;; Copyright (C) 1994, 1995, 1996, 1997 Free Software Foundation, Inc. 9 ;; Copyright (C) 1994, 1995, 1996, 1997 Free Software Foundation, Inc.
10 10
11 (defconst viper-version "2.96 of August 7, 1997" 11 (defconst viper-version "3.00 (Polyglot) of August 18, 1997"
12 "The current version of Viper") 12 "The current version of Viper")
13 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
300 (require 'cl) 300 (require 'cl)
301 (require 'ring) 301 (require 'ring)
302 302
303 ;; compiler pacifier 303 ;; compiler pacifier
304 (defvar mark-even-if-inactive) 304 (defvar mark-even-if-inactive)
305 (defvar quail-mode)
305 (defvar viper-expert-level) 306 (defvar viper-expert-level)
306 (defvar viper-expert-level) 307 (defvar viper-expert-level)
307 308
308 ;; loading happens only in non-interactive compilation 309 ;; loading happens only in non-interactive compilation
309 ;; in order to spare non-viperized emacs from being viperized 310 ;; in order to spare non-viperized emacs from being viperized
467 468
468 469
469 ;; This hook designed to enable Vi-style editing in comint-based modes." 470 ;; This hook designed to enable Vi-style editing in comint-based modes."
470 (defun viper-comint-mode-hook () 471 (defun viper-comint-mode-hook ()
471 (setq require-final-newline nil 472 (setq require-final-newline nil
472 viper-ex-style-editing-in-insert nil 473 viper-ex-style-editing nil
473 viper-ex-style-motion nil) 474 viper-ex-style-motion nil)
474 (viper-change-state-to-insert)) 475 (viper-change-state-to-insert))
475 476
476 477
477 ;; remove viper hooks from SYMBOL 478 ;; remove viper hooks from SYMBOL
826 (viper-change-state-to-emacs))) 827 (viper-change-state-to-emacs)))
827 ;; In case RMAIL was loaded before Viper. 828 ;; In case RMAIL was loaded before Viper.
828 (defadvice rmail-cease-edit (after viper-rmail-advice activate) 829 (defadvice rmail-cease-edit (after viper-rmail-advice activate)
829 "Switch to emacs state when done editing message." 830 "Switch to emacs state when done editing message."
830 (viper-change-state-to-emacs)) 831 (viper-change-state-to-emacs))
832
833 ;; ISO accents
834 ;; Need to do it after loading iso-acc, or else this loading will wipe out
835 ;; the advice.
836 (eval-after-load
837 "iso-acc"
838 (defadvice iso-accents-mode (around viper-iso-accents-advice activate)
839 "Set viper-automatic-iso-accents to iso-accents-mode."
840 (let ((arg (ad-get-arg 0)))
841 ad-do-it
842 (setq viper-automatic-iso-accents
843 (if (eq viper-current-state 'vi-state)
844 (if arg
845 ;; if iso-accents-mode was called with positive arg, turn
846 ;; accents on
847 (> (prefix-numeric-value arg) 0)
848 ;; else: toggle viper-automatic-iso-accents
849 (not viper-automatic-iso-accents))
850 ;; other states: accept what iso-accents-mode has done
851 iso-accents-mode))
852 ;; turn off ISO accents in vi-state
853 (if (eq viper-current-state 'vi-state)
854 (viper-set-iso-accents-mode nil))
855 (if (memq viper-current-state '(vi-state insert-state replace-state))
856 (message "Viper ISO accents mode: %s"
857 (if viper-automatic-iso-accents "on" "off")))
858 )))
859
860 ;; International input methods
861 (if viper-emacs-p
862 (eval-after-load "mule-cmds"
863 (progn
864 (defadvice inactivate-input-method (after viper-mule-advice activate)
865 "Set viper-special-input-method to disable intl. input methods."
866 (viper-inactivate-input-method-action))
867 (defadvice activate-input-method (after viper-mule-advice activate)
868 "Set viper-special-input-method to enable intl. input methods."
869 (viper-activate-input-method-action))
870 ))
871 ;; XEmacs Although these hooks exist in Emacs, they don't seem to be always
872 ;; called on input-method activation/deactivation, so we the above advise
873 ;; functions instead.
874 (eval-after-load "mule-cmds"
875 (progn
876 (add-hook 'input-method-activate-hook
877 'viper-activate-input-method-action t)
878 (add-hook 'input-method-inactivate-hook
879 'viper-inactivate-input-method-action t)))
880 )
881 (eval-after-load "mule-cmds"
882 (defadvice toggle-input-method (around viper-mule-advice activate)
883 "Adjust input-method toggling in vi-state."
884 (if (and viper-special-input-method (eq viper-current-state 'vi-state))
885 (viper-inactivate-input-method)
886 ad-do-it)))
887
831 ) ; viper-set-hooks 888 ) ; viper-set-hooks
832 889
833 890
834 ;; these are primarily advices and Vi-ish variable settings 891 ;; these are primarily advices and Vi-ish variable settings
835 (defun viper-non-hook-settings () 892 (defun viper-non-hook-settings ()
893 "Force to read key via `read-key-sequence'." 950 "Force to read key via `read-key-sequence'."
894 (interactive (list (viper-events-to-keys 951 (interactive (list (viper-events-to-keys
895 (read-key-sequence "Describe key briefly: "))))) 952 (read-key-sequence "Describe key briefly: ")))))
896 953
897 954
898 ;; Advice for use in find-file and read-file-name commands. 955 ;; This is now done in viper-minibuffer-exit-hook
899 (defadvice exit-minibuffer (before viper-exit-minibuffer-advice activate) 956 ;;;; Advice for use in find-file and read-file-name commands.
900 "Run `viper-minibuffer-exit-hook' just before exiting the minibuffer." 957 ;;(defadvice exit-minibuffer (before viper-exit-minibuffer-advice activate)
901 (run-hooks 'viper-minibuffer-exit-hook)) 958 ;; "Run `viper-minibuffer-exit-hook' just before exiting the minibuffer."
959 ;; (run-hooks 'viper-minibuffer-exit-hook))
902 960
903 (defadvice find-file (before viper-add-suffix-advice activate) 961 (defadvice find-file (before viper-add-suffix-advice activate)
904 "Use `read-file-name' for reading arguments." 962 "Use `read-file-name' for reading arguments."
905 (interactive (cons (read-file-name "Find file: " nil default-directory) 963 (interactive (cons (read-file-name "Find file: " nil default-directory)
906 ;; if Mule and prefix argument, ask for coding system 964 ;; if Mule and prefix argument, ask for coding system
952 ))) 1010 )))
953 1011
954 1012
955 (defadvice read-file-name (around viper-suffix-advice activate) 1013 (defadvice read-file-name (around viper-suffix-advice activate)
956 "Tell `exit-minibuffer' to run `viper-file-add-suffix' as a hook." 1014 "Tell `exit-minibuffer' to run `viper-file-add-suffix' as a hook."
957 (let ((viper-minibuffer-exit-hook 'viper-file-add-suffix)) 1015 (let ((viper-minibuffer-exit-hook
1016 (append viper-minibuffer-exit-hook '(viper-file-add-suffix))))
958 ad-do-it)) 1017 ad-do-it))
959 1018
960 (defadvice start-kbd-macro (after viper-kbd-advice activate) 1019 (defadvice start-kbd-macro (after viper-kbd-advice activate)
961 "Remove Viper's intercepting bindings for C-x ). 1020 "Remove Viper's intercepting bindings for C-x ).
962 This may be needed if the previous `:map' command terminated abnormally." 1021 This may be needed if the previous `:map' command terminated abnormally."
1087 (setq viper-saved-user-settings 1146 (setq viper-saved-user-settings
1088 (list (cons 'viper-want-ctl-h-help (list viper-want-ctl-h-help)) 1147 (list (cons 'viper-want-ctl-h-help (list viper-want-ctl-h-help))
1089 (cons 'viper-always (list viper-always)) 1148 (cons 'viper-always (list viper-always))
1090 (cons 'viper-no-multiple-ESC (list viper-no-multiple-ESC)) 1149 (cons 'viper-no-multiple-ESC (list viper-no-multiple-ESC))
1091 (cons 'viper-ex-style-motion (list viper-ex-style-motion)) 1150 (cons 'viper-ex-style-motion (list viper-ex-style-motion))
1092 (cons 'viper-ex-style-editing-in-insert 1151 (cons 'viper-ex-style-editing
1093 (list viper-ex-style-editing-in-insert)) 1152 (list viper-ex-style-editing))
1094 (cons 'viper-want-emacs-keys-in-vi 1153 (cons 'viper-want-emacs-keys-in-vi
1095 (list viper-want-emacs-keys-in-vi)) 1154 (list viper-want-emacs-keys-in-vi))
1096 (cons 'viper-electric-mode (list viper-electric-mode)) 1155 (cons 'viper-electric-mode (list viper-electric-mode))
1097 (cons 'viper-want-emacs-keys-in-insert 1156 (cons 'viper-want-emacs-keys-in-insert
1098 (list viper-want-emacs-keys-in-insert)) 1157 (list viper-want-emacs-keys-in-insert))
1102 (if viper-mode 1161 (if viper-mode
1103 (progn 1162 (progn
1104 (viper-set-minibuffer-style) 1163 (viper-set-minibuffer-style)
1105 (if viper-buffer-search-char 1164 (if viper-buffer-search-char
1106 (viper-buffer-search-enable)) 1165 (viper-buffer-search-enable))
1107 (viper-update-alphanumeric-class) 1166 (viper-update-syntax-classes 'set-default)
1108 )) 1167 ))
1109 1168
1110 1169
1111 ;;; Familiarize Viper with some minor modes that have their own keymaps 1170 ;;; Familiarize Viper with some minor modes that have their own keymaps
1112 (if viper-mode 1171 (if viper-mode