Mercurial > hg > xemacs-beta
diff lisp/viper/viper-ex.el @ 163:0132846995bd r20-3b8
Import from CVS: tag r20-3b8
author | cvs |
---|---|
date | Mon, 13 Aug 2007 09:43:35 +0200 |
parents | cf808b4c4290 |
children | 2d532a89d707 |
line wrap: on
line diff
--- a/lisp/viper/viper-ex.el Mon Aug 13 09:42:28 2007 +0200 +++ b/lisp/viper/viper-ex.el Mon Aug 13 09:43:35 2007 +0200 @@ -34,16 +34,20 @@ (defvar vip-expert-level) (defvar vip-custom-file-name) (defvar vip-case-fold-search) +(defvar explicit-shell-file-name) -(eval-when-compile - (let ((load-path (cons (expand-file-name ".") load-path))) - (or (featurep 'viper-util) - (load "viper-util.el" nil nil 'nosuffix)) - (or (featurep 'viper-keym) - (load "viper-keym.el" nil nil 'nosuffix)) - (or (featurep 'viper) - (load "viper.el" nil nil 'nosuffix)) - )) +;; loading happens only in non-interactive compilation +;; in order to spare non-viperized emacs from being viperized +(if noninteractive + (eval-when-compile + (let ((load-path (cons (expand-file-name ".") load-path))) + (or (featurep 'viper-util) + (load "viper-util.el" nil nil 'nosuffix)) + (or (featurep 'viper-keym) + (load "viper-keym.el" nil nil 'nosuffix)) + (or (featurep 'viper-cmd) + (load "viper-cmd.el" nil nil 'nosuffix)) + ))) ;; end pacifier (require 'viper-util) @@ -73,15 +77,16 @@ ;; A-list of Ex variables that can be set using the :set command. (defconst ex-variable-alist '(("wrapscan") ("ws") ("wrapmargin") ("wm") - ("global-tabstop") ("gts") ("tabstop") ("ts") + ("tabstop-global") ("ts-g") ("tabstop") ("ts") ("showmatch") ("sm") ("shiftwidth") ("sw") ("shell") ("sh") ("readonly") ("ro") ("nowrapscan") ("nows") ("noshowmatch") ("nosm") ("noreadonly") ("noro") ("nomagic") ("noma") ("noignorecase") ("noic") - ("global-noautoindent") ("gnoai") ("noautoindent") ("noai") + ("noautoindent-global") ("noai-g") ("noautoindent") ("noai") ("magic") ("ma") ("ignorecase") ("ic") - ("global-autoindent") ("gai") ("autoindent") ("ai") + ("autoindent-global") ("ai-g") ("autoindent") ("ai") + ("all") )) @@ -1561,7 +1566,7 @@ (while (string-match "^[ \\t\\n]*$" (setq str (completing-read ":set " ex-variable-alist))) - (message ":set <Variable> ") + (message ":set <Variable> [= <Value>]") ;; if there are unread events, don't wait (or (vip-set-unread-command-events "") (sit-for 2)) ) ; while @@ -1579,12 +1584,15 @@ actual-lisp-cmd lisp-cmd-del-pattern val2 orig-var) (setq orig-var var) - (cond ((member var '("ai" "autoindent")) + (cond ((string= var "all") + (setq ask-if-save nil + set-cmd nil)) + ((member var '("ai" "autoindent")) (setq var "vip-auto-indent" set-cmd "setq" ask-if-save nil val "t")) - ((member var '("gai" "global-autoindent")) + ((member var '("ai-g" "autoindent-global")) (kill-local-variable 'vip-auto-indent) (setq var "vip-auto-indent" set-cmd "setq-default" @@ -1593,7 +1601,7 @@ (setq var "vip-auto-indent" ask-if-save nil val "nil")) - ((member var '("gnoai" "global-noautoindent")) + ((member var '("noai-g" "noautoindent-global")) (kill-local-variable 'vip-auto-indent) (setq var "vip-auto-indent" set-cmd "setq-default" @@ -1607,7 +1615,7 @@ ((member var '("ma" "magic")) (setq var "vip-re-search" val "t")) - ((member var '("noma" "nomagic")) + ((member var '("noma" "nomagic")) (setq var "vip-re-search" val "nil")) ((member var '("ro" "readonly")) @@ -1628,7 +1636,7 @@ ((member var '("nows" "nowrapscan")) (setq var "vip-search-wrap-around-t" val "nil"))) - (if (eq val 0) ; value must be set by the user + (if (and set-cmd (eq val 0)) ; value must be set by the user (let ((cursor-in-echo-area t)) (message ":set %s = <Value>" var) ;; if there are unread events, don't wait @@ -1640,7 +1648,7 @@ (if (member var '("sw" "shiftwidth" "ts" "tabstop" - "gts" "global-tabstop" + "ts-g" "tabstop-global" "wm" "wrapmargin")) (condition-case nil (or (numberp (setq val2 (car (read-from-string val)))) @@ -1656,7 +1664,7 @@ (setq var "tab-width" set-cmd "setq" ask-if-save nil)) - ((member var '("gts" "global-tabstop")) + ((member var '("ts-g" "tabstop-global")) (kill-local-variable 'tab-width) (setq var "tab-width" set-cmd "setq-default")) @@ -1671,11 +1679,12 @@ val (format "\"%s\"" val))))) (ex-fixup-history "set" orig-var)) - (setq actual-lisp-cmd (format "\n(%s %s %s) %s" - set-cmd var val auto-cmd-label)) - (setq lisp-cmd-del-pattern - (format "^\n?[ \t]*([ \t]*%s[ \t]+%s[ \t].*)[ \t]*%s" - set-cmd var auto-cmd-label)) + (if set-cmd + (setq actual-lisp-cmd + (format "\n(%s %s %s) %s" set-cmd var val auto-cmd-label) + lisp-cmd-del-pattern + (format "^\n?[ \t]*([ \t]*%s[ \t]+%s[ \t].*)[ \t]*%s" + set-cmd var auto-cmd-label))) (if (and ask-if-save (y-or-n-p (format "Do you want to save this setting in %s " @@ -1702,15 +1711,19 @@ )) )) - (message "%s %s %s" set-cmd var (if (string-match "^[ \t]*$" val) - (format "%S" val) - val)) - (eval (car (read-from-string actual-lisp-cmd))) - (if (string= var "fill-column") - (if (> val2 0) - (auto-fill-mode 1) - (auto-fill-mode -1))) - + (if set-cmd + (message "%s %s %s" + set-cmd var + (if (string-match "^[ \t]*$" val) + (format "%S" val) + val))) + (if actual-lisp-cmd + (eval (car (read-from-string actual-lisp-cmd)))) + (if (string= var "fill-column") + (if (> val2 0) + (auto-fill-mode 1) + (auto-fill-mode -1))) + (if (string= var "all") (ex-show-vars)) )) ;; In inline args, skip regex-forw and (optionally) chars-back. @@ -2074,5 +2087,32 @@ (kill-buffer " *vip-info*"))) )) +;; display all variables set through :set +(defun ex-show-vars () + (with-output-to-temp-buffer " *vip-info*" + (princ (if vip-auto-indent + "autoindent (local)\n" "noautoindent (local)\n")) + (princ (if (default-value 'vip-auto-indent) + "autoindent (global) \n" "noautoindent (global) \n")) + (princ (if vip-case-fold-search "ignorecase\n" "noignorecase\n")) + (princ (if vip-re-search "magic\n" "nomagic\n")) + (princ (if buffer-read-only "readonly\n" "noreadonly\n")) + (princ (if blink-matching-paren "showmatch\n" "noshowmatch\n")) + (princ (if vip-search-wrap-around-t "wrapscan\n" "nowrapscan\n")) + (princ (format "shiftwidth \t\t= %S\n" vip-shift-width)) + (princ (format "tabstop (local) \t= %S\n" tab-width)) + (princ (format "tabstop (global) \t= %S\n" (default-value 'tab-width))) + (princ (format "wrapmargin (local) \t= %S\n" + (- (window-width) fill-column))) + (princ (format "wrapmargin (global) \t= %S\n" + (- (window-width) (default-value 'fill-column)))) + (princ (format "shell \t\t\t= %S\n" (if (boundp 'explicit-shell-file-name) + explicit-shell-file-name + 'none))) + )) + + + + ;;; viper-ex.el ends here