From d3e1167fd1821ad7a4c760cbb86415b2ab8b0619 Mon Sep 17 00:00:00 2001 From: Michael Kifer Date: Sat, 20 Jan 1996 03:19:26 +0000 Subject: [PATCH] *** empty log message *** --- lisp/emulation/viper-ex.el | 88 +++++++++++++++++++++++++----------- lisp/emulation/viper-keym.el | 19 +++++++- lisp/emulation/viper-mous.el | 8 ++-- lisp/emulation/viper-util.el | 63 +++++++++++--------------- 4 files changed, 110 insertions(+), 68 deletions(-) diff --git a/lisp/emulation/viper-ex.el b/lisp/emulation/viper-ex.el index bf8d697d112..57a813f6c19 100644 --- a/lisp/emulation/viper-ex.el +++ b/lisp/emulation/viper-ex.el @@ -45,13 +45,15 @@ ;; A-list of Ex variables that can be set using the :set command. (defconst ex-variable-alist '(("wrapscan") ("ws") ("wrapmargin") ("wm") - ("tab-stop-local") ("tsl") ("tabstop") ("ts") + ("global-tabstop") ("gts") ("tabstop") ("ts") ("showmatch") ("sm") ("shiftwidth") ("sw") ("shell") ("sh") ("readonly") ("ro") ("nowrapscan") ("nows") ("noshowmatch") ("nosm") ("noreadonly") ("noro") ("nomagic") ("noma") - ("noignorecase") ("noic") ("noautoindent") ("noai") - ("magic") ("ma") ("ignorecase") ("ic") ("autoindent") ("ai") + ("noignorecase") ("noic") + ("global-noautoindent") ("gnoai") ("noautoindent") ("noai") + ("magic") ("ma") ("ignorecase") ("ic") + ("global-autoindent") ("gai") ("autoindent") ("ai") )) @@ -345,9 +347,11 @@ reversed.") (interactive) (setq vip-incomplete-ex-cmd t) (let ((quit-regex1 (concat - "\\(" - "set[ \t]*" "\\|" "edit[ \t]*" "\\|" "[nN]ext[ \t]*" - "\\|" "unm[ \t]*" "\\|" "^[ \t]*rep" + "\\(" "set[ \t]*" + "\\|" "edit[ \t]*" + "\\|" "[nN]ext[ \t]*" + "\\|" "unm[ \t]*" + "\\|" "^[ \t]*rep" "\\)")) (quit-regex2 (concat "[a-zA-Z][ \t]*" @@ -356,13 +360,22 @@ reversed.") "\\)" "*[ \t]*$")) (stay-regex (concat - "\\(" - "^[ \t]*$" "\\|" "[ktgjmsz][ \t]*$" "\\|" "^[ \t]*ab.*" - "\\|" "tr[ansfer \t]*" "\\|" "sr[ \t]*" - "\\|" "mo.*" "\\|" "^[ \t]*k?ma[^p]*" - "\\|" "^[ \t]*fi.*" "\\|" "v?gl.*" "\\|" "[vg][ \t]*$" - "\\|" "jo.*" "\\|" "^[ \t]*ta.*" "\\|" "^[ \t]*una.*" - "\\|" "^[ \t]*su.*" "\\|['`][a-z][ \t]*" + "\\(" "^[ \t]*$" + "\\|" "[?/].*[?/].*" + "\\|" "[ktgjmsz][ \t]*$" + "\\|" "^[ \t]*ab.*" + "\\|" "tr[ansfer \t]*" + "\\|" "sr[ \t]*" + "\\|" "mo.*" + "\\|" "^[ \t]*k?ma[^p]*" + "\\|" "^[ \t]*fi.*" + "\\|" "v?gl.*" + "\\|" "[vg][ \t]*$" + "\\|" "jo.*" + "\\|" "^[ \t]*ta.*" + "\\|" "^[ \t]*una.*" + "\\|" "^[ \t]*su.*" + "\\|['`][a-z][ \t]*" "\\|" "![ \t]*[a-zA-Z].*" "\\)" "!*"))) @@ -1356,8 +1369,9 @@ reversed.") (if (equal buf (current-buffer)) (or no-recursion ;; try again - (setq skip-rest t) - (ex-next-related-buffer direction 'norecursion))) + (progn + (setq skip-rest t) + (ex-next-related-buffer direction 'norecursion)))) (if skip-rest () @@ -1497,9 +1511,22 @@ reversed.") (setq orig-var var) (cond ((member var '("ai" "autoindent")) (setq var "vip-auto-indent" + set-cmd "setq" + ask-if-save nil + val "t")) + ((member var '("gai" "global-autoindent")) + (kill-local-variable 'vip-auto-indent) + (setq var "vip-auto-indent" + set-cmd "setq-default" val "t")) ((member var '("noai" "noautoindent")) (setq var "vip-auto-indent" + ask-if-save nil + val "nil")) + ((member var '("gnoai" "global-noautoindent")) + (kill-local-variable 'vip-auto-indent) + (setq var "vip-auto-indent" + set-cmd "setq-default" val "nil")) ((member var '("ic" "ignorecase")) (setq var "vip-case-fold-search" @@ -1541,7 +1568,10 @@ reversed.") ;; check numerical values (if (member var - '("sw" "shiftwidth" "ts" "tabstop" "wm" "wrapmargin")) + '("sw" "shiftwidth" + "ts" "tabstop" + "gts" "global-tabstop" + "wm" "wrapmargin")) (condition-case nil (or (numberp (setq val2 (car (read-from-string val)))) (error "%s: Invalid value, numberp, %S" var val)) @@ -1553,13 +1583,13 @@ reversed.") (setq var "vip-shift-width")) ((member var '("ts" "tabstop")) ;; make it take effect in curr buff and new bufs - (kill-local-variable 'tab-width) - (setq var "tab-width" - set-cmd "setq-default")) - ((member var '("tsl" "tab-stop-local")) (setq var "tab-width" set-cmd "setq" ask-if-save nil)) + ((member var '("gts" "global-tabstop")) + (kill-local-variable 'tab-width) + (setq var "tab-width" + set-cmd "setq-default")) ((member var '("wm" "wrapmargin")) ;; make it take effect in curr buff and new bufs (kill-local-variable 'fill-column) @@ -1728,7 +1758,7 @@ Please contact your system administrator. " (setq matched-pos (point)) (if (not (stringp repl)) (error "Can't perform Ex substitution: No previous replacement pattern")) - (replace-match repl t t)))) + (replace-match repl t)))) (end-of-line) (vip-forward-char-carefully)) (if (null pat) @@ -1740,7 +1770,7 @@ Please contact your system administrator. " (setq matched-pos (point)) (if (not (stringp repl)) (error "Can't perform Ex substitution: No previous replacement pattern")) - (replace-match repl t t))) + (replace-match repl t))) (end-of-line) (vip-forward-char-carefully)))))) (if matched-pos (goto-char matched-pos)) @@ -1915,12 +1945,17 @@ Please contact your system administrator. " ;; Give information on the file visited by the current buffer (defun vip-info-on-file () (interactive) - (let (file info) - (setq file (if (buffer-file-name) + (let ((pos1 (vip-line-pos 'start)) + (pos2 (vip-line-pos 'end)) + lines file info) + (setq lines (count-lines (point-min) (vip-line-pos 'end)) + file (if (buffer-file-name) (concat (abbreviate-file-name (buffer-file-name)) ":") (concat (buffer-name) " [Not visiting any file]:")) info (format "line=%d/%d pos=%d/%d col=%d %s" - (count-lines (point-min) (vip-line-pos 'end)) + (if (= pos1 pos2) + (1+ lines) + lines) (count-lines (point-min) (point-max)) (point) (1- (point-max)) (1+ (current-column)) @@ -1933,7 +1968,8 @@ Please contact your system administrator. " (princ (concat "\n" file "\n\n\t" info "\n\n\nPress any key to continue...\n\n"))) - (vip-read-event))) + (vip-read-event) + (kill-buffer " *vip-info*"))) )) diff --git a/lisp/emulation/viper-keym.el b/lisp/emulation/viper-keym.el index 26f90e8b908..39eb92b2286 100644 --- a/lisp/emulation/viper-keym.el +++ b/lisp/emulation/viper-keym.el @@ -1,4 +1,4 @@ -;;; viper-keym.el --- main Viper keymaps +;;; viper-keym.el --- Viper keymaps ;; Copyright (C) 1994, 1995 Free Software Foundation, Inc. @@ -31,7 +31,8 @@ (defvar vip-insert-intercept-map (make-sparse-keymap)) (defvar vip-emacs-intercept-map (make-sparse-keymap)) -;; keymap used to zap all keymaps other than function-key-map, etc. +;; keymap used to zap all keymaps other than function-key-map, +;; device-function-key-map, etc. (defvar vip-overriding-map (make-sparse-keymap)) (vip-deflocalvar vip-vi-local-user-map (make-sparse-keymap) @@ -403,6 +404,20 @@ Usage: (vip-modify-keymap map alist) (vip-normalize-minor-mode-map-alist) (vip-set-mode-vars-for vip-current-state))) + +(defun vip-zap-local-keys () + "Unconditionally reset Viper vip-*-local-user-map's. +Rarely useful, but if u made a mistake by switching to a mode that adds +undesirable local keys, e.g., comint-mode, then this function can return +you to sanity." + (interactive) + (setq vip-vi-local-user-map (make-sparse-keymap) + vip-need-new-vi-local-map nil + vip-insert-local-user-map (make-sparse-keymap) + vip-need-new-insert-local-map nil + vip-emacs-local-user-map (make-sparse-keymap) + vip-need-new-emacs-local-map nil) + (vip-normalize-minor-mode-map-alist)) (defun vip-modify-major-mode (mode state keymap) diff --git a/lisp/emulation/viper-mous.el b/lisp/emulation/viper-mous.el index 6372b7e9d6d..d9b8d252514 100644 --- a/lisp/emulation/viper-mous.el +++ b/lisp/emulation/viper-mous.el @@ -402,13 +402,13 @@ bindings in viper.el and in the Viper manual." (cond ((vip-window-display-p) (let* ((search-key (if vip-xemacs-p - [(meta shift button1up)] [S-mouse-1])) + [(meta shift button1up)] [M-S-mouse-1])) (search-key-catch (if vip-xemacs-p - [(meta shift button1)] [S-down-mouse-1])) + [(meta shift button1)] [M-S-down-mouse-1])) (insert-key (if vip-xemacs-p - [(meta shift button2up)] [S-mouse-2])) + [(meta shift button2up)] [M-S-mouse-2])) (insert-key-catch (if vip-xemacs-p - [(meta shift button2)] [S-down-mouse-2])) + [(meta shift button2)] [M-S-down-mouse-2])) (search-key-unbound (and (not (key-binding search-key)) (not (key-binding search-key-catch)))) (insert-key-unbound (and (not (key-binding insert-key)) diff --git a/lisp/emulation/viper-util.el b/lisp/emulation/viper-util.el index 5a42f6e2dc0..062ada3f88d 100644 --- a/lisp/emulation/viper-util.el +++ b/lisp/emulation/viper-util.el @@ -172,7 +172,11 @@ (not (memq nil (mapcar 'vip-color-defined-p colors))) )) -;; currently doesn't work for XEmacs +(defun vip-hide-face (face) + (if (and (vip-window-display-p) vip-emacs-p) + (add-to-list 'facemenu-unlisted-faces face))) + +;; cursor colors (defun vip-change-cursor-color (new-color) (if (and (vip-window-display-p) (vip-color-display-p) (stringp new-color) (vip-color-defined-p new-color) @@ -563,14 +567,6 @@ (if (vip-overlay-p vip-replace-overlay) (vip-move-replace-overlay beg end) (setq vip-replace-overlay (vip-make-overlay beg end (current-buffer))) - (vip-overlay-put vip-replace-overlay - 'vip-start - (move-marker (make-marker) - (vip-overlay-start vip-replace-overlay))) - (vip-overlay-put vip-replace-overlay - 'vip-end - (move-marker (make-marker) - (vip-overlay-end vip-replace-overlay))) (vip-overlay-put vip-replace-overlay 'priority vip-replace-overlay-priority)) (if (vip-window-display-p) @@ -579,7 +575,6 @@ (vip-change-cursor-color vip-replace-overlay-cursor-color) ) - (defsubst vip-hide-replace-overlay () (vip-set-replace-overlay-glyphs nil nil) @@ -589,7 +584,7 @@ (defsubst vip-set-replace-overlay-glyphs (before-glyph after-glyph) (if (or (not (vip-window-display-p)) - vip-use-replace-region-delimiters) + vip-use-replace-region-delimiters) (let ((before-name (if vip-xemacs-p 'begin-glyph 'before-string)) (after-name (if vip-xemacs-p 'end-glyph 'after-string))) (vip-overlay-put vip-replace-overlay before-name before-glyph) @@ -597,47 +592,43 @@ (defsubst vip-replace-start () - (vip-overlay-get vip-replace-overlay 'vip-start)) + (vip-overlay-start vip-replace-overlay)) (defsubst vip-replace-end () - (vip-overlay-get vip-replace-overlay 'vip-end)) + (vip-overlay-end vip-replace-overlay)) (defsubst vip-move-replace-overlay (beg end) (vip-move-overlay vip-replace-overlay beg end) - (move-marker (vip-replace-start) (vip-overlay-start vip-replace-overlay)) - (move-marker (vip-replace-end) (vip-overlay-end vip-replace-overlay))) + ) ;; Minibuffer (defun vip-set-minibuffer-overlay () (vip-check-minibuffer-overlay) - ;; We always move the minibuffer overlay, since in XEmacs - ;; this overlay may get detached. Moving will reattach it. - ;; This overlay is also moved via the vip-post-command-hook, - ;; to insure that it covers the whole minibuffer. - (vip-move-minibuffer-overlay) (if (vip-window-display-p) (progn (vip-overlay-put vip-minibuffer-overlay 'face vip-minibuffer-current-face) (vip-overlay-put - vip-minibuffer-overlay 'priority vip-minibuffer-overlay-priority)) - )) + vip-minibuffer-overlay 'priority vip-minibuffer-overlay-priority) + ;; prevent detachment and make vip-minibuffer-overlay open-ended + ;; In emacs, it is made open ended at creation time + (if vip-emacs-p + (vip-overlay-put vip-minibuffer-overlay 'evaporate nil) + (vip-overlay-put vip-minibuffer-overlay 'detachable nil) + (vip-overlay-put vip-minibuffer-overlay 'start-open nil) + (vip-overlay-put vip-minibuffer-overlay 'end-open nil)) + ))) (defun vip-check-minibuffer-overlay () - (if (vip-overlay-p vip-minibuffer-overlay) - () - (setq vip-minibuffer-overlay - (vip-make-overlay 1 (1+ (buffer-size)) (current-buffer))))) - -;; arguments to this function are dummies. they are needed just because -;; it is used as a insert-in-front-hook to vip-minibuffer-overlay, and such -;; hooks require 3 arguments. -(defun vip-move-minibuffer-overlay (&optional overl beg end) - (if (vip-is-in-minibuffer) - (progn - (vip-check-minibuffer-overlay) - (vip-move-overlay vip-minibuffer-overlay 1 (1+ (buffer-size)))))) + (or (vip-overlay-p vip-minibuffer-overlay) + (setq vip-minibuffer-overlay + (if vip-xemacs-p + (vip-make-overlay 1 (1+ (buffer-size)) (current-buffer)) + ;; don't move front, move rear + (vip-make-overlay 1 (1+ (buffer-size)) (current-buffer) nil t))) + )) + (defsubst vip-is-in-minibuffer () (string-match "\*Minibuf-" (buffer-name))) @@ -768,7 +759,7 @@ ;; Emacs has a bug in eventp, which causes (eventp nil) to return (nil) -;; instead of nil, if '(nil) was previously inadvertently assigned to +;; instead of nil, if '(nil) was previously inadvertantly assigned to ;; unread-command-events (defun vip-event-key (event) (or (and event (eventp event)) -- 2.39.2