summaryrefslogtreecommitdiff
path: root/lisp/emulation
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/emulation')
-rw-r--r--lisp/emulation/viper-cmd.el55
-rw-r--r--lisp/emulation/viper-ex.el42
-rw-r--r--lisp/emulation/viper.el33
3 files changed, 88 insertions, 42 deletions
diff --git a/lisp/emulation/viper-cmd.el b/lisp/emulation/viper-cmd.el
index 51de44bee54..3fb8cce6dfa 100644
--- a/lisp/emulation/viper-cmd.el
+++ b/lisp/emulation/viper-cmd.el
@@ -1720,21 +1720,32 @@ Undo previous insertion and inserts new."
;; Quote region by each line with a user supplied string.
(defun viper-quote-region ()
- (setq viper-quote-string
- (viper-read-string-with-history
- "Quote string: "
- nil
- 'viper-quote-region-history
- viper-quote-string))
- (viper-enlarge-region (point) (mark t))
- (if (> (point) (mark t)) (exchange-point-and-mark))
- (insert viper-quote-string)
- (beginning-of-line)
- (forward-line 1)
- (while (and (< (point) (mark t)) (bolp))
- (insert viper-quote-string)
+ (let ((quote-str viper-quote-string)
+ (donot-change-dafault t))
+ (setq quote-str
+ (viper-read-string-with-history
+ "Quote string: "
+ nil
+ 'viper-quote-region-history
+ (cond ((string-match "tex.*-mode" (symbol-name major-mode)) "%%")
+ ((string-match "java.*-mode" (symbol-name major-mode)) "//")
+ ((string-match "perl.*-mode" (symbol-name major-mode)) "#")
+ ((string-match "lisp.*-mode" (symbol-name major-mode)) ";;")
+ ((memq major-mode '(c-mode cc-mode c++-mode)) "//")
+ ((memq major-mode '(sh-mode shell-mode)) "#")
+ (t (setq donot-change-dafault nil)
+ quote-str))))
+ (or donot-change-dafault
+ (setq viper-quote-string quote-str))
+ (viper-enlarge-region (point) (mark t))
+ (if (> (point) (mark t)) (exchange-point-and-mark))
+ (insert quote-str)
(beginning-of-line)
- (forward-line 1)))
+ (forward-line 1)
+ (while (and (< (point) (mark t)) (bolp))
+ (insert quote-str)
+ (beginning-of-line)
+ (forward-line 1))))
;; Tells whether BEG is on the same line as END.
;; If one of the args is nil, it'll return nil.
@@ -1870,15 +1881,21 @@ problems."
;;; Reading string with history
(defun viper-read-string-with-history (prompt &optional initial
- history-var default keymap)
+ history-var default keymap
+ init-message)
;; Read string, prompting with PROMPT and inserting the INITIAL
;; value. Uses HISTORY-VAR. DEFAULT is the default value to accept if the
- ;; input is an empty string. Use KEYMAP, if given, or the
- ;; minibuffer-local-map.
+ ;; input is an empty string.
;; Default value is displayed until the user types something in the
;; minibuffer.
+ ;; KEYMAP is used, if given, instead of minibuffer-local-map.
+ ;; INIT-MESSAGE is the message temporarily displayed after entering the
+ ;; minibuffer.
(let ((minibuffer-setup-hook
- '(lambda ()
+ (function
+ (lambda ()
+ (if (stringp init-message)
+ (viper-tmp-insert-at-eob init-message))
(if (stringp initial)
(progn
;; don't wait if we have unread events or in kbd macro
@@ -1887,7 +1904,7 @@ problems."
(sit-for 840))
(erase-buffer)
(insert initial)))
- (viper-minibuffer-setup-sentinel)))
+ (viper-minibuffer-setup-sentinel))))
(val "")
(padding "")
temp-msg)
diff --git a/lisp/emulation/viper-ex.el b/lisp/emulation/viper-ex.el
index bd9ac3d3eb7..0cc2bd1bc3d 100644
--- a/lisp/emulation/viper-ex.el
+++ b/lisp/emulation/viper-ex.el
@@ -524,8 +524,8 @@ reversed."
;; Read Ex commands
-(defun viper-ex (&optional string)
- (interactive)
+(defun viper-ex (arg &optional string)
+ (interactive "P")
(or string
(setq ex-g-flag nil
ex-g-variant nil))
@@ -533,16 +533,40 @@ reversed."
(address nil)
(cont t)
(dot (point))
+ reg-beg-line reg-end-line
+ reg-beg reg-end
+ initial-str
prev-token-type com-str)
-
(viper-add-keymap viper-ex-cmd-map map)
+
+ (if arg
+ (progn
+ (viper-enlarge-region (mark t) (point))
+ (if (> (point) (mark t))
+ (setq reg-beg (mark t)
+ reg-end (point))
+ (setq reg-end (mark t)
+ reg-beg (point)))
+ (save-excursion
+ (goto-char reg-beg)
+ (setq reg-beg-line (1+ (count-lines (point-min) (point)))
+ reg-end-line
+ (+ reg-beg-line (count-lines reg-beg reg-end) -1)))))
+ (if reg-beg-line
+ (setq initial-str (format "%d,%d" reg-beg-line reg-end-line)))
- (setq com-str (or string (viper-read-string-with-history
- ":"
- nil
- 'viper-ex-history
- (car viper-ex-history)
- map)))
+ (setq com-str
+ (or string (viper-read-string-with-history
+ ":"
+ initial-str
+ 'viper-ex-history
+ ;; no default when working on region
+ (if initial-str
+ "none"
+ (car viper-ex-history))
+ map
+ (if initial-str
+ " [Type command to execute on current region]"))))
(save-window-excursion
;; just a precaution
(setq viper-ex-work-buf (get-buffer-create viper-ex-work-buf-name))
diff --git a/lisp/emulation/viper.el b/lisp/emulation/viper.el
index 303c50645c9..91feb773a24 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.002 (Polyglot) of October 23, 1997"
+(defconst viper-version "3.004 (Polyglot) of November 11, 1997"
"The current version of Viper")
;; This file is part of GNU Emacs.
@@ -531,7 +531,7 @@ remains buffer-local."
(viper-standard-value
'mode-line-buffer-identification viper-saved-non-viper-variables)
global-mode-string
- (viper-standard-value 'global-mode-string viper-saved-non-viper-variables))
+ (delq 'viper-mode-string global-mode-string))
(if viper-emacs-p
(setq-default
@@ -576,6 +576,9 @@ remains buffer-local."
(viper-delocalize-var 'viper-emacs-global-user-minor-mode)
(viper-delocalize-var 'viper-emacs-state-modifier-minor-mode)
+ (viper-delocalize-var 'viper-current-state)
+ (viper-delocalize-var 'viper-mode-string)
+
(setq-default viper-vi-minibuffer-minor-mode nil
viper-insert-minibuffer-minor-mode nil
viper-vi-intercept-minor-mode nil
@@ -602,6 +605,9 @@ remains buffer-local."
viper-emacs-kbd-minor-mode nil
viper-emacs-global-user-minor-mode nil
viper-emacs-state-modifier-minor-mode nil
+
+ viper-current-state 'emacs-state
+ viper-mode-string viper-emacs-state-id
)
;; remove all hooks set by viper
@@ -1218,18 +1224,17 @@ These two lines must come in the order given.
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)
- ))
+ (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 (eq viper-current-state 'emacs-state))
+ (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))
(if (and viper-mode