summaryrefslogtreecommitdiff
path: root/lisp/emulation
diff options
context:
space:
mode:
authorMichael Kifer <kifer@cs.stonybrook.edu>1997-11-01 01:46:51 +0000
committerMichael Kifer <kifer@cs.stonybrook.edu>1997-11-01 01:46:51 +0000
commit328b4b7052a5d464e52818ff0f1a33b96e5e761c (patch)
treeed5b2b58f632de47cdcc20435b0dfeed3d5c7f4e /lisp/emulation
parent9645c179af0e934c92780525788664e42c56e07a (diff)
downloademacs-328b4b7052a5d464e52818ff0f1a33b96e5e761c.tar.gz
new version
Diffstat (limited to 'lisp/emulation')
-rw-r--r--lisp/emulation/viper-ex.el25
-rw-r--r--lisp/emulation/viper-init.el16
-rw-r--r--lisp/emulation/viper-keym.el3
-rw-r--r--lisp/emulation/viper-mous.el11
-rw-r--r--lisp/emulation/viper.el26
5 files changed, 58 insertions, 23 deletions
diff --git a/lisp/emulation/viper-ex.el b/lisp/emulation/viper-ex.el
index a08b75ce4e6..bd9ac3d3eb7 100644
--- a/lisp/emulation/viper-ex.el
+++ b/lisp/emulation/viper-ex.el
@@ -195,6 +195,7 @@ Don't put `-c' here, as it is added automatically."
;; File containing the shell command to be executed at Ex prompt,
;; e.g., :r !date
(defvar ex-cmdfile nil)
+(defvar ex-cmdfile-args "")
;; flag used in viper-ex-read-file-name to indicate that we may be reading
;; multiple file names. Used for :edit and :next
@@ -457,7 +458,11 @@ reversed."
"\\|" "^[ \t]*ta.*"
"\\|" "^[ \t]*una.*"
"\\|" "^[ \t]*su.*"
- "\\|['`][a-z][ \t]*"
+ "\\|" "['`][a-z][ \t]*"
+ ;; r! assumes that the next one is a shell command
+ "\\|" "\\(r\\|re\\|rea\\|read\\)[ \t]*!"
+ ;; w ! assumes that the next one is a shell command
+ "\\|" "\\(w\\|wr\\|wri\\|writ.?\\)[ \t]+!"
"\\|" "![ \t]*[a-zA-Z].*"
"\\)"
"!*")))
@@ -851,14 +856,16 @@ reversed."
(message "%s" ret))
ret))
-;; Get a file name and set ex-variant, `ex-append' and `ex-offset' if found
+;; Get a file name and set `ex-variant', `ex-append' and `ex-offset' if found
+;; If it is r!, then get the command name and whatever args
(defun viper-get-ex-file ()
(let (prompt)
(setq ex-file nil
ex-variant nil
ex-append nil
ex-offset nil
- ex-cmdfile nil)
+ ex-cmdfile nil
+ ex-cmdfile-args "")
(save-excursion
(save-window-excursion
(setq viper-ex-work-buf (get-buffer-create viper-ex-work-buf-name))
@@ -908,6 +915,8 @@ reversed."
;; if file name comes from history, don't leave
;; minibuffer when the user types space
(setq viper-incomplete-ex-cmd nil)
+ (setq ex-cmdfile-args
+ (substring ex-file (match-end 0) nil))
;; this must be the last clause in this progn
(substring ex-file (match-beginning 0) (match-end 0))
)
@@ -958,6 +967,7 @@ reversed."
(defun ex-cmd-accepts-multiple-files-p (token)
(member token '("edit" "next" "Next")))
+;; Read file name from the minibuffer in an ex command.
;; If user doesn't enter anything, then "" is returned, i.e., the
;; prompt-directory is not returned.
(defun viper-ex-read-file-name (prompt)
@@ -1548,10 +1558,12 @@ reversed."
(setq ex-file buffer-file-name)))
(if ex-cmdfile
(progn
- (setq command (ex-expand-filsyms ex-file (current-buffer)))
+ (setq command
+ (concat (ex-expand-filsyms ex-file (current-buffer))
+ ex-cmdfile-args))
(shell-command command t))
(insert-file-contents ex-file)))
- (ex-fixup-history viper-last-ex-prompt ex-file))
+ (ex-fixup-history viper-last-ex-prompt ex-file ex-cmdfile-args))
;; this function fixes ex-history for some commands like ex-read, ex-edit
(defun ex-fixup-history (&rest args)
@@ -1935,7 +1947,8 @@ Please contact your system administrator. "
(if ex-cmdfile
(progn
(viper-enlarge-region beg end)
- (shell-command-on-region (point) (mark t) ex-file))
+ (shell-command-on-region (point) (mark t)
+ (concat ex-file ex-cmdfile-args)))
(if (and (string= ex-file "") (not (buffer-file-name)))
(setq ex-file
(read-file-name
diff --git a/lisp/emulation/viper-init.el b/lisp/emulation/viper-init.el
index bd1bddfebb0..af9fb31ccc1 100644
--- a/lisp/emulation/viper-init.el
+++ b/lisp/emulation/viper-init.el
@@ -204,28 +204,28 @@ the Ex command :map!.")
(viper-deflocalvar viper-replace-minor-mode nil
"Minor mode in effect in replace state (cw, C, and the like commands).")
-;; Mode for vital things like \C-z and \C-x)
-;; This is t, by default. So, any new buffer will have C-z defined as
-;; switch to Vi, unless we switched states in this buffer
-(viper-deflocalvar viper-emacs-intercept-minor-mode t)
+;; Mode for vital things like \C-z and \C-x) This is set to t, when viper-mode
+;; is invoked. So, any new buffer will have C-z defined as switch to Vi, unless
+;; we switched states in this buffer
+(viper-deflocalvar viper-emacs-intercept-minor-mode nil)
-(viper-deflocalvar viper-emacs-local-user-minor-mode t
+(viper-deflocalvar viper-emacs-local-user-minor-mode nil
"Minor mode for local user bindings effective in Emacs state.
Users can use it to override Emacs bindings when Viper is in its Emacs
state.")
-(viper-deflocalvar viper-emacs-global-user-minor-mode t
+(viper-deflocalvar viper-emacs-global-user-minor-mode nil
"Minor mode for global user bindings in effect in Emacs state.
Users can use it to override Emacs bindings when Viper is in its Emacs
state.")
-(viper-deflocalvar viper-emacs-kbd-minor-mode t
+(viper-deflocalvar viper-emacs-kbd-minor-mode nil
"Minor mode for Vi style macros in Emacs state.
The corresponding keymap stores key bindings of Vi macros defined with
`viper-record-kbd-macro' command. There is no Ex-level command to do this
interactively.")
-(viper-deflocalvar viper-emacs-state-modifier-minor-mode t
+(viper-deflocalvar viper-emacs-state-modifier-minor-mode nil
"Minor mode used to make major-mode-specific modification to Emacs state.
For instance, a Vi purist may want to bind `dd' in Dired mode to a function
that deletes a file.")
diff --git a/lisp/emulation/viper-keym.el b/lisp/emulation/viper-keym.el
index 961a7d1a1cc..8cdef6f27fe 100644
--- a/lisp/emulation/viper-keym.el
+++ b/lisp/emulation/viper-keym.el
@@ -389,9 +389,6 @@ viper-insert-basic-map. Not recommended, except for novice users.")
(define-key viper-vi-basic-map "~" 'viper-toggle-case)
(define-key viper-vi-basic-map "\C-?" 'viper-backward-char)
(define-key viper-vi-basic-map "_" 'viper-nil)
-
-;;; Escape from Emacs to Vi for one command
-(global-set-key "\C-c\\" 'viper-escape-to-vi) ; everywhere
;;; This is viper-vi-diehard-map. Used when viper-vi-diehard-minor-mode is on.
diff --git a/lisp/emulation/viper-mous.el b/lisp/emulation/viper-mous.el
index 7a10f42a5a5..ac353ae28ad 100644
--- a/lisp/emulation/viper-mous.el
+++ b/lisp/emulation/viper-mous.el
@@ -116,10 +116,13 @@ considered related."
(not (viper-sit-for-short viper-multiclick-timeout t)))
;; Returns window where click occurs
-(defsubst viper-mouse-click-window (click)
- (if viper-xemacs-p
- (event-window click)
- (posn-window (event-start click))))
+(defun viper-mouse-click-window (click)
+ (let ((win (if viper-xemacs-p
+ (event-window click)
+ (posn-window (event-start click)))))
+ (if (window-live-p win)
+ win
+ (error "Click was not over a live window"))))
;; Returns window where click occurs
(defsubst viper-mouse-click-frame (click)
diff --git a/lisp/emulation/viper.el b/lisp/emulation/viper.el
index cd821cf83a8..303c50645c9 100644
--- a/lisp/emulation/viper.el
+++ b/lisp/emulation/viper.el
@@ -8,7 +8,7 @@
;; Copyright (C) 1994, 1995, 1996, 1997 Free Software Foundation, Inc.
-(defconst viper-version "3.001 (Polyglot) of September 23, 1997"
+(defconst viper-version "3.002 (Polyglot) of October 23, 1997"
"The current version of Viper")
;; This file is part of GNU Emacs.
@@ -385,6 +385,8 @@ it comes up in a wrong Viper state."
;;;###autoload
(defun toggle-viper-mode ()
+ "Toggle Viper on/off.
+If Viper is enabled, turn it off. Otherwise, turn it on."
(interactive)
(if (eq viper-mode t)
(viper-go-away)
@@ -1208,6 +1210,26 @@ These two lines must come in the order given.
(define-key viper-vi-intercept-map viper-toggle-key 'viper-toggle-key-action)
(define-key
viper-emacs-intercept-map viper-toggle-key 'viper-change-state-to-vi)
+
+;;; Escape from Emacs and Insert modes to Vi for one command
+(define-key
+ viper-emacs-intercept-map "\C-c\\" 'viper-escape-to-vi)
+(define-key
+ viper-insert-intercept-map "\C-c\\" 'viper-escape-to-vi)
+
+(if viper-mode
+ (progn
+ (setq viper-emacs-intercept-minor-mode t
+ viper-emacs-local-user-minor-mode t
+ viper-emacs-global-user-minor-mode t
+ viper-emacs-kbd-minor-mode t
+ viper-emacs-state-modifier-minor-mode t)
+ (setq-default viper-emacs-intercept-minor-mode t
+ viper-emacs-local-user-minor-mode t
+ viper-emacs-global-user-minor-mode t
+ viper-emacs-kbd-minor-mode t
+ viper-emacs-state-modifier-minor-mode t)
+ ))
(if (and viper-mode
@@ -1219,7 +1241,7 @@ These two lines must come in the order given.
;; this may not be enough, so we also set default minor-mode-alist.
;; Without setting the default, new buffers that come up in emacs mode have
;; minor-mode-map-alist = nil, unless we call viper-change-state-*
-(if (eq viper-current-state 'emacs-state)
+(if (and viper-mode (eq viper-current-state 'emacs-state))
(progn
(viper-change-state-to-emacs)
(setq-default minor-mode-map-alist minor-mode-map-alist)