Mercurial > emacs
annotate lisp/emulation/viper-ex.el @ 30841:3e3ae9ba5169
*** empty log message ***
author | Eli Zaretskii <eliz@gnu.org> |
---|---|
date | Wed, 16 Aug 2000 05:22:00 +0000 |
parents | ea19f6424132 |
children | f5af79327a46 |
rev | line source |
---|---|
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1 ;;; viper-ex.el --- functions implementing the Ex commands for Viper |
13337 | 2 |
21940 | 3 ;; Copyright (C) 1994, 1995, 1996, 1997, 1998 Free Software Foundation, Inc. |
10789 | 4 |
5 ;; This file is part of GNU Emacs. | |
6 | |
7 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
8 ;; it under the terms of the GNU General Public License as published by | |
9 ;; the Free Software Foundation; either version 2, or (at your option) | |
10 ;; any later version. | |
11 | |
12 ;; GNU Emacs is distributed in the hope that it will be useful, | |
13 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 ;; GNU General Public License for more details. | |
16 | |
17 ;; You should have received a copy of the GNU General Public License | |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
18 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
19 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
20 ;; Boston, MA 02111-1307, USA. |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
21 |
18047 | 22 ;; Code |
14909
7ff1df13b124
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
23 |
18047 | 24 (provide 'viper-ex) |
25 | |
26 ;; Compiler pacifier | |
27 (defvar read-file-name-map) | |
19079 | 28 (defvar viper-use-register) |
29 (defvar viper-s-string) | |
30 (defvar viper-shift-width) | |
31 (defvar viper-ex-history) | |
32 (defvar viper-related-files-and-buffers-ring) | |
33 (defvar viper-local-search-start-marker) | |
18839 | 34 (defvar viper-expert-level) |
19079 | 35 (defvar viper-custom-file-name) |
36 (defvar viper-case-fold-search) | |
18289 | 37 (defvar explicit-shell-file-name) |
18047 | 38 |
18172 | 39 ;; loading happens only in non-interactive compilation |
40 ;; in order to spare non-viperized emacs from being viperized | |
41 (if noninteractive | |
42 (eval-when-compile | |
43 (let ((load-path (cons (expand-file-name ".") load-path))) | |
44 (or (featurep 'viper-util) | |
45 (load "viper-util.el" nil nil 'nosuffix)) | |
46 (or (featurep 'viper-keym) | |
47 (load "viper-keym.el" nil nil 'nosuffix)) | |
48 (or (featurep 'viper-cmd) | |
49 (load "viper-cmd.el" nil nil 'nosuffix)) | |
50 ))) | |
18047 | 51 ;; end pacifier |
14909
7ff1df13b124
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
52 |
10789 | 53 (require 'viper-util) |
54 | |
18839 | 55 (defgroup viper-ex nil |
56 "Viper support for Ex commands" | |
57 :prefix "ex-" | |
58 :group 'viper) | |
59 | |
60 | |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
61 |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
62 ;;; Variables |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
63 |
19079 | 64 (defconst viper-ex-work-buf-name " *ex-working-space*") |
65 (defconst viper-ex-work-buf (get-buffer-create viper-ex-work-buf-name)) | |
66 (defconst viper-ex-tmp-buf-name " *ex-tmp*") | |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
67 |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
68 |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
69 ;;; Variable completion in :set command |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
70 |
26263
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
21940
diff
changeset
|
71 ;; The list of Ex commands. Used for completing command names. |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
72 (defconst ex-token-alist |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
73 '(("!") ("=") (">") ("&") ("~") |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
74 ("yank") ("xit") ("WWrite") ("Write") ("write") ("wq") ("visual") |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
75 ("version") ("vglobal") ("unmap") ("undo") ("tag") ("transfer") ("suspend") |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
76 ("substitute") ("submitReport") ("stop") ("sr") ("source") ("shell") |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
77 ("set") ("rewind") ("recover") ("read") ("quit") ("pwd") |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
78 ("put") ("preserve") ("PreviousRelatedFile") ("RelatedFile") |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
79 ("next") ("Next") ("move") ("mark") ("map") ("kmark") ("join") |
26263
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
21940
diff
changeset
|
80 ("help") ("goto") ("global") ("file") ("edit") ("delete") ("customize") |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
21940
diff
changeset
|
81 ("copy") ("chdir") ("cd") ("Buffer") ("buffer") ("args")) ) |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
82 |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
83 ;; A-list of Ex variables that can be set using the :set command. |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
84 (defconst ex-variable-alist |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
85 '(("wrapscan") ("ws") ("wrapmargin") ("wm") |
18289 | 86 ("tabstop-global") ("ts-g") ("tabstop") ("ts") |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
87 ("showmatch") ("sm") ("shiftwidth") ("sw") ("shell") ("sh") |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
88 ("readonly") ("ro") |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
89 ("nowrapscan") ("nows") ("noshowmatch") ("nosm") |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
90 ("noreadonly") ("noro") ("nomagic") ("noma") |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
91 ("noignorecase") ("noic") |
18289 | 92 ("noautoindent-global") ("noai-g") ("noautoindent") ("noai") |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
93 ("magic") ("ma") ("ignorecase") ("ic") |
18289 | 94 ("autoindent-global") ("ai-g") ("autoindent") ("ai") |
95 ("all") | |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
96 )) |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
97 |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
98 |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
99 |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
100 ;; Token recognized during parsing of Ex commands (e.g., "read", "comma") |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
101 (defvar ex-token nil) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
102 |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
103 ;; Type of token. |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
104 ;; If non-nil, gives type of address; if nil, it is a command. |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
105 (defvar ex-token-type nil) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
106 |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
107 ;; List of addresses passed to Ex command |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
108 (defvar ex-addresses nil) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
109 |
20003 | 110 ;; This flag is supposed to be set only by `#', `print', and `list', |
26263
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
21940
diff
changeset
|
111 ;; none of which is implemented. So, it and the pices of the code it |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
21940
diff
changeset
|
112 ;; controls are dead weight. We keep it just in case this might be |
20003 | 113 ;; needed in the future. |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
114 (defvar ex-flag nil) |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
115 |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
116 ;; "buffer" where Ex commands keep deleted data. |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
117 ;; In Emacs terms, this is a register. |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
118 (defvar ex-buffer nil) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
119 |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
120 ;; Value of ex count. |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
121 (defvar ex-count nil) |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
122 |
18839 | 123 ;; Flag indicating that :global Ex command is being executed. |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
124 (defvar ex-g-flag nil) |
18839 | 125 ;; Flag indicating that :vglobal Ex command is being executed. |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
126 (defvar ex-g-variant nil) |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
127 |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
128 ;; Save reg-exp used in substitute. |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
129 (defvar ex-reg-exp nil) |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
130 |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
131 |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
132 ;; Replace pattern for substitute. |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
133 (defvar ex-repl nil) |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
134 |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
135 ;; Pattern for global command. |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
136 (defvar ex-g-pat nil) |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
137 |
18839 | 138 (defcustom ex-unix-type-shell |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
139 (let ((case-fold-search t)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
140 (and (stringp shell-file-name) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
141 (string-match |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
142 (concat |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
143 "\\(" |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
144 "csh$\\|csh.exe$" |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
145 "\\|" |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
146 "ksh$\\|ksh.exe$" |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
147 "\\|" |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
148 "^sh$\\|sh.exe$" |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
149 "\\|" |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
150 "[^a-z]sh$\\|[^a-z]sh.exe$" |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
151 "\\|" |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
152 "bash$\\|bash.exe$" |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
153 "\\)") |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
154 shell-file-name))) |
18839 | 155 "Is the user using a unix-type shell under a non-OS?" |
19906
9a24e495d968
(ex-unix-type-shell): Fix customize type.
Richard M. Stallman <rms@gnu.org>
parents:
19756
diff
changeset
|
156 :type 'boolean |
18839 | 157 :group 'viper-ex) |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
158 |
18839 | 159 (defcustom ex-unix-type-shell-options |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
160 (let ((case-fold-search t)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
161 (if ex-unix-type-shell |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
162 (cond ((string-match "\\(csh$\\|csh.exe$\\)" shell-file-name) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
163 "-f") ; csh: do it fast |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
164 ((string-match "\\(bash$\\|bash.exe$\\)" shell-file-name) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
165 "-noprofile") ; bash: ignore .profile |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
166 ))) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
167 "Options to pass to the Unix-style shell. |
18839 | 168 Don't put `-c' here, as it is added automatically." |
169 :type 'string | |
170 :group 'viper-ex) | |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
171 |
26263
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
21940
diff
changeset
|
172 (defcustom viper-glob-function |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
21940
diff
changeset
|
173 (cond (ex-unix-type-shell 'viper-glob-unix-files) |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
21940
diff
changeset
|
174 ((eq system-type 'emx) 'viper-glob-mswindows-files) ; OS/2 |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
21940
diff
changeset
|
175 (viper-ms-style-os-p 'viper-glob-mswindows-files) ; Microsoft OS |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
21940
diff
changeset
|
176 (viper-vms-os-p 'viper-glob-unix-files) ; VMS |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
21940
diff
changeset
|
177 (t 'viper-glob-unix-files) ; presumably UNIX |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
21940
diff
changeset
|
178 ) |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
21940
diff
changeset
|
179 "Expand the file spec containing wildcard symbols. |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
21940
diff
changeset
|
180 The default tries to set this variable to work with Unix, Windows, |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
21940
diff
changeset
|
181 OS/2, and VMS. |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
21940
diff
changeset
|
182 |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
21940
diff
changeset
|
183 However, if it doesn't work right for some types of Unix shells or some OS, |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
21940
diff
changeset
|
184 the user should supply the appropriate function and set this variable to the |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
21940
diff
changeset
|
185 corresponding function symbol." |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
21940
diff
changeset
|
186 :type 'symbol |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
21940
diff
changeset
|
187 :group 'viper-ex) |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
21940
diff
changeset
|
188 |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
189 |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
190 ;; Remembers the previous Ex tag. |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
191 (defvar ex-tag nil) |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
192 |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
193 ;; file used by Ex commands like :r, :w, :n |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
194 (defvar ex-file nil) |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
195 |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
196 ;; If t, tells Ex that this is a variant-command, i.e., w>>, r!, etc. |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
197 (defvar ex-variant nil) |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
198 |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
199 ;; Specified the offset of an Ex command, such as :read. |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
200 (defvar ex-offset nil) |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
201 |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
202 ;; Tells Ex that this is a w>> command. |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
203 (defvar ex-append nil) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
204 |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
205 ;; File containing the shell command to be executed at Ex prompt, |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
206 ;; e.g., :r !date |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
207 (defvar ex-cmdfile nil) |
20206 | 208 (defvar ex-cmdfile-args "") |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
209 |
19079 | 210 ;; flag used in viper-ex-read-file-name to indicate that we may be reading |
26263
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
21940
diff
changeset
|
211 ;; multiple file names. Used for :edit and :next |
19079 | 212 (defvar viper-keep-reading-filename nil) |
10789 | 213 |
18839 | 214 (defcustom ex-cycle-other-window t |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
215 "*If t, :n and :b cycles through files and buffers in other window. |
26263
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
21940
diff
changeset
|
216 Then :N and :B cycles in the current window. If nil, this behavior is |
18839 | 217 reversed." |
218 :type 'boolean | |
219 :group 'viper-ex) | |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
220 |
18839 | 221 (defcustom ex-cycle-through-non-files nil |
222 "*Cycle through *scratch* and other buffers that don't visit any file." | |
223 :type 'boolean | |
224 :group 'viper-ex) | |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
225 |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
226 ;; Last shell command executed with :! command. |
19079 | 227 (defvar viper-ex-last-shell-com nil) |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
228 |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
229 ;; Indicates if Minibuffer was exited temporarily in Ex-command. |
19079 | 230 (defvar viper-incomplete-ex-cmd nil) |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
231 |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
232 ;; Remembers the last ex-command prompt. |
19079 | 233 (defvar viper-last-ex-prompt "") |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
234 |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
235 |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
236 ;;; Code |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
237 |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
238 ;; Check if ex-token is an initial segment of STR |
19079 | 239 (defun viper-check-sub (str) |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
240 (let ((length (length ex-token))) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
241 (if (and (<= length (length str)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
242 (string= ex-token (substring str 0 length))) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
243 (setq ex-token str) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
244 (setq ex-token-type 'non-command)))) |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
245 |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
246 ;; Get a complete ex command |
19079 | 247 (defun viper-get-ex-com-subr () |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
248 (let (case-fold-search) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
249 (set-mark (point)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
250 (re-search-forward "[a-zA-Z][a-zA-Z]*") |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
251 (setq ex-token-type 'command) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
252 (setq ex-token (buffer-substring (point) (mark t))) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
253 (exchange-point-and-mark) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
254 (cond ((looking-at "a") |
19079 | 255 (cond ((looking-at "ab") (viper-check-sub "abbreviate")) |
256 ((looking-at "ar") (viper-check-sub "args")) | |
257 (t (viper-check-sub "append")))) | |
258 ((looking-at "h") (viper-check-sub "help")) | |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
259 ((looking-at "c") |
19079 | 260 (cond ((looking-at "cd") (viper-check-sub "cd")) |
261 ((looking-at "ch") (viper-check-sub "chdir")) | |
262 ((looking-at "co") (viper-check-sub "copy")) | |
26263
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
21940
diff
changeset
|
263 ((looking-at "cu") (viper-check-sub "customize")) |
19079 | 264 (t (viper-check-sub "change")))) |
265 ((looking-at "d") (viper-check-sub "delete")) | |
266 ((looking-at "b") (viper-check-sub "buffer")) | |
267 ((looking-at "B") (viper-check-sub "Buffer")) | |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
268 ((looking-at "e") |
19079 | 269 (if (looking-at "ex") (viper-check-sub "ex") |
270 (viper-check-sub "edit"))) | |
271 ((looking-at "f") (viper-check-sub "file")) | |
272 ((looking-at "g") (viper-check-sub "global")) | |
273 ((looking-at "i") (viper-check-sub "insert")) | |
274 ((looking-at "j") (viper-check-sub "join")) | |
275 ((looking-at "l") (viper-check-sub "list")) | |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
276 ((looking-at "m") |
19079 | 277 (cond ((looking-at "map") (viper-check-sub "map")) |
278 ((looking-at "mar") (viper-check-sub "mark")) | |
279 (t (viper-check-sub "move")))) | |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
280 ((looking-at "k[a-z][^a-z]") |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
281 (setq ex-token "kmark") |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
282 (forward-char 1) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
283 (exchange-point-and-mark)) ; this is canceled out by another |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
284 ; exchange-point-and-mark at the end |
19079 | 285 ((looking-at "k") (viper-check-sub "kmark")) |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
286 ((looking-at "n") (if (looking-at "nu") |
19079 | 287 (viper-check-sub "number") |
288 (viper-check-sub "next"))) | |
289 ((looking-at "N") (viper-check-sub "Next")) | |
290 ((looking-at "o") (viper-check-sub "open")) | |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
291 ((looking-at "p") |
19079 | 292 (cond ((looking-at "pre") (viper-check-sub "preserve")) |
293 ((looking-at "pu") (viper-check-sub "put")) | |
294 ((looking-at "pw") (viper-check-sub "pwd")) | |
295 (t (viper-check-sub "print")))) | |
296 ((looking-at "P") (viper-check-sub "PreviousRelatedFile")) | |
297 ((looking-at "R") (viper-check-sub "RelatedFile")) | |
298 ((looking-at "q") (viper-check-sub "quit")) | |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
299 ((looking-at "r") |
19079 | 300 (cond ((looking-at "rec") (viper-check-sub "recover")) |
301 ((looking-at "rew") (viper-check-sub "rewind")) | |
302 (t (viper-check-sub "read")))) | |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
303 ((looking-at "s") |
19079 | 304 (cond ((looking-at "se") (viper-check-sub "set")) |
305 ((looking-at "sh") (viper-check-sub "shell")) | |
306 ((looking-at "so") (viper-check-sub "source")) | |
307 ((looking-at "sr") (viper-check-sub "sr")) | |
308 ((looking-at "st") (viper-check-sub "stop")) | |
309 ((looking-at "sus") (viper-check-sub "suspend")) | |
310 ((looking-at "subm") (viper-check-sub "submitReport")) | |
311 (t (viper-check-sub "substitute")))) | |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
312 ((looking-at "t") |
19079 | 313 (if (looking-at "ta") (viper-check-sub "tag") |
314 (viper-check-sub "transfer"))) | |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
315 ((looking-at "u") |
19079 | 316 (cond ((looking-at "una") (viper-check-sub "unabbreviate")) |
317 ((looking-at "unm") (viper-check-sub "unmap")) | |
318 (t (viper-check-sub "undo")))) | |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
319 ((looking-at "v") |
19079 | 320 (cond ((looking-at "ve") (viper-check-sub "version")) |
321 ((looking-at "vi") (viper-check-sub "visual")) | |
322 (t (viper-check-sub "vglobal")))) | |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
323 ((looking-at "w") |
19079 | 324 (if (looking-at "wq") (viper-check-sub "wq") |
325 (viper-check-sub "write"))) | |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
326 ((looking-at "W") |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
327 (if (looking-at "WW") |
19079 | 328 (viper-check-sub "WWrite") |
329 (viper-check-sub "Write"))) | |
330 ((looking-at "x") (viper-check-sub "xit")) | |
331 ((looking-at "y") (viper-check-sub "yank")) | |
332 ((looking-at "z") (viper-check-sub "z"))) | |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
333 (exchange-point-and-mark) |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
334 )) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
335 |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
336 ;; Get an ex-token which is either an address or a command. |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
337 ;; A token has a type, \(command, address, end-mark\), and a value |
19079 | 338 (defun viper-get-ex-token () |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
339 (save-window-excursion |
19079 | 340 (setq viper-ex-work-buf (get-buffer-create viper-ex-work-buf-name)) |
341 (set-buffer viper-ex-work-buf) | |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
342 (skip-chars-forward " \t|") |
19756 | 343 (let ((case-fold-search t)) |
344 (cond ((looking-at "#") | |
345 (setq ex-token-type 'command) | |
346 (setq ex-token (char-to-string (following-char))) | |
347 (forward-char 1)) | |
348 ((looking-at "[a-z]") (viper-get-ex-com-subr)) | |
349 ((looking-at "\\.") | |
350 (forward-char 1) | |
351 (setq ex-token-type 'dot)) | |
352 ((looking-at "[0-9]") | |
353 (set-mark (point)) | |
354 (re-search-forward "[0-9]*") | |
355 (setq ex-token-type | |
356 (cond ((eq ex-token-type 'plus) 'add-number) | |
357 ((eq ex-token-type 'minus) 'sub-number) | |
358 (t 'abs-number))) | |
359 (setq ex-token | |
360 (string-to-int (buffer-substring (point) (mark t))))) | |
361 ((looking-at "\\$") | |
362 (forward-char 1) | |
363 (setq ex-token-type 'end)) | |
364 ((looking-at "%") | |
365 (forward-char 1) | |
366 (setq ex-token-type 'whole)) | |
367 ((looking-at "+") | |
368 (cond ((or (looking-at "+[-+]") (looking-at "+[\n|]")) | |
369 (forward-char 1) | |
370 (insert "1") | |
371 (backward-char 1) | |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
372 (setq ex-token-type 'plus)) |
19756 | 373 ((looking-at "+[0-9]") |
374 (forward-char 1) | |
375 (setq ex-token-type 'plus)) | |
376 (t | |
377 (error viper-BadAddress)))) | |
378 ((looking-at "-") | |
379 (cond ((or (looking-at "-[-+]") (looking-at "-[\n|]")) | |
380 (forward-char 1) | |
381 (insert "1") | |
382 (backward-char 1) | |
383 (setq ex-token-type 'minus)) | |
384 ((looking-at "-[0-9]") | |
385 (forward-char 1) | |
386 (setq ex-token-type 'minus)) | |
387 (t | |
388 (error viper-BadAddress)))) | |
389 ((looking-at "/") | |
390 (forward-char 1) | |
391 (set-mark (point)) | |
392 (let ((cont t)) | |
393 (while (and (not (eolp)) cont) | |
394 ;;(re-search-forward "[^/]*/") | |
395 (re-search-forward "[^/]*\\(/\\|\n\\)") | |
396 (if (not (viper-looking-back "[^\\\\]\\(\\\\\\\\\\)*\\\\/")) | |
397 (setq cont nil)))) | |
398 (backward-char 1) | |
399 (setq ex-token (buffer-substring (point) (mark t))) | |
400 (if (looking-at "/") (forward-char 1)) | |
401 (setq ex-token-type 'search-forward)) | |
402 ((looking-at "\\?") | |
403 (forward-char 1) | |
404 (set-mark (point)) | |
405 (let ((cont t)) | |
406 (while (and (not (eolp)) cont) | |
407 ;;(re-search-forward "[^\\?]*\\?") | |
408 (re-search-forward "[^\\?]*\\(\\?\\|\n\\)") | |
409 (if (not (viper-looking-back "[^\\\\]\\(\\\\\\\\\\)*\\\\\\?")) | |
410 (setq cont nil)) | |
411 (backward-char 1) | |
412 (if (not (looking-at "\n")) (forward-char 1)))) | |
413 (setq ex-token-type 'search-backward) | |
414 (setq ex-token (buffer-substring (1- (point)) (mark t)))) | |
415 ((looking-at ",") | |
416 (forward-char 1) | |
417 (setq ex-token-type 'comma)) | |
418 ((looking-at ";") | |
419 (forward-char 1) | |
420 (setq ex-token-type 'semi-colon)) | |
421 ((looking-at "[!=><&~]") | |
422 (setq ex-token-type 'command) | |
423 (setq ex-token (char-to-string (following-char))) | |
424 (forward-char 1)) | |
425 ((looking-at "'") | |
426 (setq ex-token-type 'goto-mark) | |
427 (forward-char 1) | |
428 (cond ((looking-at "'") (setq ex-token nil)) | |
429 ((looking-at "[a-z]") (setq ex-token (following-char))) | |
430 (t (error "Marks are ' and a-z"))) | |
431 (forward-char 1)) | |
432 ((looking-at "\n") | |
433 (setq ex-token-type 'end-mark) | |
434 (setq ex-token "goto")) | |
435 (t | |
436 (error viper-BadExCommand)))))) | |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
437 |
26263
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
21940
diff
changeset
|
438 ;; Reads Ex command. Tries to determine if it has to exit because command |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
21940
diff
changeset
|
439 ;; is complete or invalid. If not, keeps reading command. |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
440 (defun ex-cmd-read-exit () |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
441 (interactive) |
19079 | 442 (setq viper-incomplete-ex-cmd t) |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
443 (let ((quit-regex1 (concat |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
444 "\\(" "set[ \t]*" |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
445 "\\|" "edit[ \t]*" |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
446 "\\|" "[nN]ext[ \t]*" |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
447 "\\|" "unm[ \t]*" |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
448 "\\|" "^[ \t]*rep" |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
449 "\\)")) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
450 (quit-regex2 (concat |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
451 "[a-zA-Z][ \t]*" |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
452 "\\(" "!" "\\|" ">>" |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
453 "\\|" "\\+[0-9]+" |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
454 "\\)" |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
455 "*[ \t]*$")) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
456 (stay-regex (concat |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
457 "\\(" "^[ \t]*$" |
18839 | 458 "\\|" "[?/].*" |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
459 "\\|" "[ktgjmsz][ \t]*$" |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
460 "\\|" "^[ \t]*ab.*" |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
461 "\\|" "tr[ansfer \t]*" |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
462 "\\|" "sr[ \t]*" |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
463 "\\|" "mo.*" |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
464 "\\|" "^[ \t]*k?ma[^p]*" |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
465 "\\|" "^[ \t]*fi.*" |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
466 "\\|" "v?gl.*" |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
467 "\\|" "[vg][ \t]*$" |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
468 "\\|" "jo.*" |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
469 "\\|" "^[ \t]*ta.*" |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
470 "\\|" "^[ \t]*una.*" |
21940 | 471 ;; don't jump up in :s command |
472 "\\|" "^[ \t]*\\([`'][a-z]\\|[.,%]\\)*[ \t]*su.*" | |
473 "\\|" "^[ \t]*\\([`'][a-z]\\|[.,%]\\)*[ \t]*s[^a-z].*" | |
20206 | 474 "\\|" "['`][a-z][ \t]*" |
475 ;; r! assumes that the next one is a shell command | |
476 "\\|" "\\(r\\|re\\|rea\\|read\\)[ \t]*!" | |
477 ;; w ! assumes that the next one is a shell command | |
478 "\\|" "\\(w\\|wr\\|wri\\|writ.?\\)[ \t]+!" | |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
479 "\\|" "![ \t]*[a-zA-Z].*" |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
480 "\\)" |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
481 "!*"))) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
482 |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
483 (save-window-excursion ;; put cursor at the end of the Ex working buffer |
19079 | 484 (setq viper-ex-work-buf (get-buffer-create viper-ex-work-buf-name)) |
485 (set-buffer viper-ex-work-buf) | |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
486 (goto-char (point-max))) |
19079 | 487 (cond ((viper-looking-back quit-regex1) (exit-minibuffer)) |
488 ((viper-looking-back stay-regex) (insert " ")) | |
489 ((viper-looking-back quit-regex2) (exit-minibuffer)) | |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
490 (t (insert " "))))) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
491 |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
492 ;; complete Ex command |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
493 (defun ex-cmd-complete () |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
494 (interactive) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
495 (let (save-pos dist compl-list string-to-complete completion-result) |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
496 |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
497 (save-excursion |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
498 (setq dist (skip-chars-backward "[a-zA-Z!=>&~]") |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
499 save-pos (point))) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
500 |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
501 (if (or (= dist 0) |
19079 | 502 (viper-looking-back "\\([ \t]*['`][ \t]*[a-z]*\\)") |
503 (viper-looking-back | |
26263
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
21940
diff
changeset
|
504 "^[ \t]*[a-zA-Z!=>&~][ \t]*[/?]*[ \t]+[a-zA-Z!=>&~]+")) |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
505 ;; Preceding characters are not the ones allowed in an Ex command |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
506 ;; or we have typed past command name. |
26263
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
21940
diff
changeset
|
507 ;; Note: we didn't do parsing, so there can be surprises. |
19079 | 508 (if (or (viper-looking-back "[a-zA-Z!=>&~][ \t]*[/?]*[ \t]*") |
509 (viper-looking-back "\\([ \t]*['`][ \t]*[a-z]*\\)") | |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
510 (looking-at "[^ \t\n\C-m]")) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
511 nil |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
512 (with-output-to-temp-buffer "*Completions*" |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
513 (display-completion-list |
19079 | 514 (viper-alist-to-list ex-token-alist)))) |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
515 ;; Preceding chars may be part of a command name |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
516 (setq string-to-complete (buffer-substring save-pos (point))) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
517 (setq completion-result |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
518 (try-completion string-to-complete ex-token-alist)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
519 |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
520 (cond ((eq completion-result t) ; exact match--do nothing |
19079 | 521 (viper-tmp-insert-at-eob " (Sole completion)")) |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
522 ((eq completion-result nil) |
19079 | 523 (viper-tmp-insert-at-eob " (No match)")) |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
524 (t ;; partial completion |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
525 (goto-char save-pos) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
526 (delete-region (point) (point-max)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
527 (insert completion-result) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
528 (let (case-fold-search) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
529 (setq compl-list |
19079 | 530 (viper-filter-alist (concat "^" completion-result) |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
531 ex-token-alist))) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
532 (if (> (length compl-list) 1) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
533 (with-output-to-temp-buffer "*Completions*" |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
534 (display-completion-list |
19079 | 535 (viper-alist-to-list (reverse compl-list))))))) |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
536 ))) |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
537 |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
538 |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
539 ;; Read Ex commands |
26263
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
21940
diff
changeset
|
540 ;; ARG is a prefix argument. If given, the ex command runs on the region |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
21940
diff
changeset
|
541 ;;(without the user having to specify the address :a,b |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
21940
diff
changeset
|
542 ;; STRING is the command to execute. If nil, then Viper asks you to enter the |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
21940
diff
changeset
|
543 ;; command. |
20343 | 544 (defun viper-ex (arg &optional string) |
545 (interactive "P") | |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
546 (or string |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
547 (setq ex-g-flag nil |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
548 ex-g-variant nil)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
549 (let* ((map (copy-keymap minibuffer-local-map)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
550 (address nil) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
551 (cont t) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
552 (dot (point)) |
20343 | 553 reg-beg-line reg-end-line |
554 reg-beg reg-end | |
555 initial-str | |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
556 prev-token-type com-str) |
19079 | 557 (viper-add-keymap viper-ex-cmd-map map) |
20343 | 558 |
559 (if arg | |
560 (progn | |
561 (viper-enlarge-region (mark t) (point)) | |
562 (if (> (point) (mark t)) | |
563 (setq reg-beg (mark t) | |
564 reg-end (point)) | |
565 (setq reg-end (mark t) | |
566 reg-beg (point))) | |
567 (save-excursion | |
568 (goto-char reg-beg) | |
569 (setq reg-beg-line (1+ (count-lines (point-min) (point))) | |
570 reg-end-line | |
571 (+ reg-beg-line (count-lines reg-beg reg-end) -1))))) | |
572 (if reg-beg-line | |
573 (setq initial-str (format "%d,%d" reg-beg-line reg-end-line))) | |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
574 |
20343 | 575 (setq com-str |
576 (or string (viper-read-string-with-history | |
577 ":" | |
578 initial-str | |
579 'viper-ex-history | |
580 ;; no default when working on region | |
581 (if initial-str | |
582 "none" | |
583 (car viper-ex-history)) | |
584 map | |
585 (if initial-str | |
586 " [Type command to execute on current region]")))) | |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
587 (save-window-excursion |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
588 ;; just a precaution |
19079 | 589 (setq viper-ex-work-buf (get-buffer-create viper-ex-work-buf-name)) |
590 (set-buffer viper-ex-work-buf) | |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
591 (delete-region (point-min) (point-max)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
592 (insert com-str "\n") |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
593 (goto-char (point-min))) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
594 (setq ex-token-type nil |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
595 ex-addresses nil) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
596 (while cont |
19079 | 597 (viper-get-ex-token) |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
598 (cond ((memq ex-token-type '(command end-mark)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
599 (if address (setq ex-addresses (cons address ex-addresses))) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
600 (cond ((string= ex-token "global") |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
601 (ex-global nil) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
602 (setq cont nil)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
603 ((string= ex-token "vglobal") |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
604 (ex-global t) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
605 (setq cont nil)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
606 (t |
19079 | 607 (viper-execute-ex-command) |
26263
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
21940
diff
changeset
|
608 (save-excursion |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
21940
diff
changeset
|
609 (save-window-excursion |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
21940
diff
changeset
|
610 (setq viper-ex-work-buf |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
21940
diff
changeset
|
611 (get-buffer-create viper-ex-work-buf-name)) |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
21940
diff
changeset
|
612 (set-buffer viper-ex-work-buf) |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
21940
diff
changeset
|
613 (skip-chars-forward " \t") |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
21940
diff
changeset
|
614 (cond ((looking-at "|") |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
21940
diff
changeset
|
615 (forward-char 1)) |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
21940
diff
changeset
|
616 ((looking-at "\n") |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
21940
diff
changeset
|
617 (setq cont nil)) |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
21940
diff
changeset
|
618 (t (error |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
21940
diff
changeset
|
619 "`%s': %s" ex-token viper-SpuriousText))) |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
21940
diff
changeset
|
620 ))) |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
621 )) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
622 ((eq ex-token-type 'non-command) |
19079 | 623 (error "`%s': %s" ex-token viper-BadExCommand)) |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
624 ((eq ex-token-type 'whole) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
625 (setq address nil) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
626 (setq ex-addresses |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
627 (if ex-addresses |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
628 (cons (point-max) ex-addresses) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
629 (cons (point-max) (cons (point-min) ex-addresses))))) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
630 ((eq ex-token-type 'comma) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
631 (if (eq prev-token-type 'whole) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
632 (setq address (point-min))) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
633 (setq ex-addresses |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
634 (cons (if (null address) (point) address) ex-addresses))) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
635 ((eq ex-token-type 'semi-colon) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
636 (if (eq prev-token-type 'whole) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
637 (setq address (point-min))) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
638 (if address (setq dot address)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
639 (setq ex-addresses |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
640 (cons (if (null address) (point) address) ex-addresses))) |
19079 | 641 (t (let ((ans (viper-get-ex-address-subr address dot))) |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
642 (if ans (setq address ans))))) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
643 (setq prev-token-type ex-token-type)))) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
644 |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
645 |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
646 ;; Get a regular expression and set `ex-variant', if found |
19079 | 647 (defun viper-get-ex-pat () |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
648 (save-window-excursion |
19079 | 649 (setq viper-ex-work-buf (get-buffer-create viper-ex-work-buf-name)) |
650 (set-buffer viper-ex-work-buf) | |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
651 (skip-chars-forward " \t") |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
652 (if (looking-at "!") |
21940 | 653 ;; this is probably a variant command r! |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
654 (progn |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
655 (setq ex-g-variant (not ex-g-variant) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
656 ex-g-flag (not ex-g-flag)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
657 (forward-char 1) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
658 (skip-chars-forward " \t"))) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
659 (let ((c (following-char))) |
21940 | 660 (cond ((string-match "[0-9A-Za-z]" (format "%c" c)) |
661 (error | |
662 "Global regexp must be inside matching non-alphanumeric chars")) | |
663 ((= c ??) (error "`?' is not an allowed pattern delimiter here"))) | |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
664 (if (looking-at "[^\\\\\n]") |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
665 (progn |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
666 (forward-char 1) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
667 (set-mark (point)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
668 (let ((cont t)) |
21940 | 669 ;; the use of eobp instead of eolp permits the use of newlines in |
670 ;; pat2 in s/pat1/pat2/ | |
671 (while (and (not (eobp)) cont) | |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
672 (if (not (re-search-forward (format "[^%c]*%c" c c) nil t)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
673 (if (member ex-token '("global" "vglobal")) |
21940 | 674 (error "Missing closing delimiter for global regexp") |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
675 (goto-char (point-max)))) |
19079 | 676 (if (not (viper-looking-back |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
677 (format "[^\\\\]\\(\\\\\\\\\\)*\\\\%c" c))) |
21940 | 678 (setq cont nil) |
679 ;; we are at an escaped delimiter: unescape it and continue | |
680 (delete-backward-char 2) | |
681 (insert c) | |
682 (if (eolp) | |
683 ;; if at eol, exit loop and go to next line | |
684 ;; later, delim will be inserted at the end | |
685 (progn | |
686 (setq cont nil) | |
687 (forward-char)))) | |
688 )) | |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
689 (setq ex-token |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
690 (if (= (mark t) (point)) "" |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
691 (buffer-substring (1- (point)) (mark t)))) |
18839 | 692 (backward-char 1) |
21940 | 693 ;; if the user didn't insert the final pattern delimiter, we're |
26263
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
21940
diff
changeset
|
694 ;; at newline now. In this case, insert the initial delimiter |
18839 | 695 ;; specified in variable c |
21940 | 696 (if (eolp) |
18839 | 697 (progn |
21940 | 698 (insert c) |
699 (backward-char 1))) | |
18839 | 700 ) |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
701 (setq ex-token nil)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
702 c))) |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
703 |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
704 ;; get an ex command |
19079 | 705 (defun viper-get-ex-command () |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
706 (save-window-excursion |
19079 | 707 (setq viper-ex-work-buf (get-buffer-create viper-ex-work-buf-name)) |
708 (set-buffer viper-ex-work-buf) | |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
709 (if (looking-at "/") (forward-char 1)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
710 (skip-chars-forward " \t") |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
711 (cond ((looking-at "[a-z]") |
19079 | 712 (viper-get-ex-com-subr) |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
713 (if (eq ex-token-type 'non-command) |
19079 | 714 (error "`%s': %s" ex-token viper-BadExCommand))) |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
715 ((looking-at "[!=><&~]") |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
716 (setq ex-token (char-to-string (following-char))) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
717 (forward-char 1)) |
19079 | 718 (t (error viper-BadExCommand))))) |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
719 |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
720 ;; Get an Ex option g or c |
19079 | 721 (defun viper-get-ex-opt-gc (c) |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
722 (save-window-excursion |
19079 | 723 (setq viper-ex-work-buf (get-buffer-create viper-ex-work-buf-name)) |
724 (set-buffer viper-ex-work-buf) | |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
725 (if (looking-at (format "%c" c)) (forward-char 1)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
726 (skip-chars-forward " \t") |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
727 (cond ((looking-at "g") |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
728 (setq ex-token "g") |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
729 (forward-char 1) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
730 t) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
731 ((looking-at "c") |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
732 (setq ex-token "c") |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
733 (forward-char 1) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
734 t) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
735 (t nil)))) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
736 |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
737 ;; Compute default addresses. WHOLE-FLAG means use the whole buffer |
19079 | 738 (defun viper-default-ex-addresses (&optional whole-flag) |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
739 (cond ((null ex-addresses) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
740 (setq ex-addresses |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
741 (if whole-flag |
21940 | 742 (list (point-max) (point-min)) |
743 (list (point) (point))))) | |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
744 ((null (cdr ex-addresses)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
745 (setq ex-addresses |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
746 (cons (car ex-addresses) ex-addresses))))) |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
747 |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
748 ;; Get an ex-address as a marker and set ex-flag if a flag is found |
19079 | 749 (defun viper-get-ex-address () |
18047 | 750 (let ((address (point-marker)) |
751 (cont t)) | |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
752 (setq ex-token "") |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
753 (setq ex-flag nil) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
754 (while cont |
19079 | 755 (viper-get-ex-token) |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
756 (cond ((eq ex-token-type 'command) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
757 (if (member ex-token '("print" "list" "#")) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
758 (progn |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
759 (setq ex-flag t |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
760 cont nil)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
761 (error "Address expected in this Ex command"))) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
762 ((eq ex-token-type 'end-mark) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
763 (setq cont nil)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
764 ((eq ex-token-type 'whole) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
765 (error "Trailing address expected")) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
766 ((eq ex-token-type 'comma) |
19079 | 767 (error "`%s': %s" ex-token viper-SpuriousText)) |
768 (t (let ((ans (viper-get-ex-address-subr address (point-marker)))) | |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
769 (if ans (setq address ans)))))) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
770 address)) |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
771 |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
772 ;; Returns an address as a point |
19079 | 773 (defun viper-get-ex-address-subr (old-address dot) |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
774 (let ((address nil)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
775 (if (null old-address) (setq old-address dot)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
776 (cond ((eq ex-token-type 'dot) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
777 (setq address dot)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
778 ((eq ex-token-type 'add-number) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
779 (save-excursion |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
780 (goto-char old-address) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
781 (forward-line (if (= old-address 0) (1- ex-token) ex-token)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
782 (setq address (point-marker)))) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
783 ((eq ex-token-type 'sub-number) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
784 (save-excursion |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
785 (goto-char old-address) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
786 (forward-line (- ex-token)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
787 (setq address (point-marker)))) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
788 ((eq ex-token-type 'abs-number) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
789 (save-excursion |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
790 (goto-char (point-min)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
791 (if (= ex-token 0) (setq address 0) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
792 (forward-line (1- ex-token)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
793 (setq address (point-marker))))) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
794 ((eq ex-token-type 'end) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
795 (setq address (point-max-marker))) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
796 ((eq ex-token-type 'plus) t) ; do nothing |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
797 ((eq ex-token-type 'minus) t) ; do nothing |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
798 ((eq ex-token-type 'search-forward) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
799 (save-excursion |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
800 (ex-search-address t) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
801 (setq address (point-marker)))) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
802 ((eq ex-token-type 'search-backward) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
803 (save-excursion |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
804 (ex-search-address nil) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
805 (setq address (point-marker)))) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
806 ((eq ex-token-type 'goto-mark) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
807 (save-excursion |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
808 (if (null ex-token) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
809 (exchange-point-and-mark) |
19079 | 810 (goto-char (viper-register-to-point |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
811 (1+ (- ex-token ?a)) 'enforce-buffer))) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
812 (setq address (point-marker))))) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
813 address)) |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
814 |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
815 |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
816 ;; Search pattern and set address |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
817 (defun ex-search-address (forward) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
818 (if (string= ex-token "") |
19079 | 819 (if (null viper-s-string) |
820 (error viper-NoPrevSearch) | |
821 (setq ex-token viper-s-string)) | |
822 (setq viper-s-string ex-token)) | |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
823 (if forward |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
824 (progn |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
825 (forward-line 1) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
826 (re-search-forward ex-token)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
827 (forward-line -1) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
828 (re-search-backward ex-token))) |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
829 |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
830 ;; Get a buffer name and set `ex-count' and `ex-flag' if found |
19079 | 831 (defun viper-get-ex-buffer () |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
832 (setq ex-buffer nil) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
833 (setq ex-count nil) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
834 (setq ex-flag nil) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
835 (save-window-excursion |
19079 | 836 (setq viper-ex-work-buf (get-buffer-create viper-ex-work-buf-name)) |
837 (set-buffer viper-ex-work-buf) | |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
838 (skip-chars-forward " \t") |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
839 (if (looking-at "[a-zA-Z]") |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
840 (progn |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
841 (setq ex-buffer (following-char)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
842 (forward-char 1) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
843 (skip-chars-forward " \t"))) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
844 (if (looking-at "[0-9]") |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
845 (progn |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
846 (set-mark (point)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
847 (re-search-forward "[0-9][0-9]*") |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
848 (setq ex-count (string-to-int (buffer-substring (point) (mark t)))) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
849 (skip-chars-forward " \t"))) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
850 (if (looking-at "[pl#]") |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
851 (progn |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
852 (setq ex-flag t) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
853 (forward-char 1))) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
854 (if (not (looking-at "[\n|]")) |
19079 | 855 (error "`%s': %s" ex-token viper-SpuriousText)))) |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
856 |
19079 | 857 (defun viper-get-ex-count () |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
858 (setq ex-variant nil |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
859 ex-count nil |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
860 ex-flag nil) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
861 (save-window-excursion |
19079 | 862 (setq viper-ex-work-buf (get-buffer-create viper-ex-work-buf-name)) |
863 (set-buffer viper-ex-work-buf) | |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
864 (skip-chars-forward " \t") |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
865 (if (looking-at "!") |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
866 (progn |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
867 (setq ex-variant t) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
868 (forward-char 1))) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
869 (skip-chars-forward " \t") |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
870 (if (looking-at "[0-9]") |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
871 (progn |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
872 (set-mark (point)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
873 (re-search-forward "[0-9][0-9]*") |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
874 (setq ex-count (string-to-int (buffer-substring (point) (mark t)))) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
875 (skip-chars-forward " \t"))) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
876 (if (looking-at "[pl#]") |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
877 (progn |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
878 (setq ex-flag t) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
879 (forward-char 1))) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
880 (if (not (looking-at "[\n|]")) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
881 (error "`%s': %s" |
19079 | 882 (buffer-substring |
883 (point-min) (1- (point-max))) viper-BadExCommand)))) | |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
884 |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
885 ;; Expand \% and \# in ex command |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
886 (defun ex-expand-filsyms (cmd buf) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
887 (let (cf pf ret) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
888 (save-excursion |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
889 (set-buffer buf) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
890 (setq cf buffer-file-name) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
891 (setq pf (ex-next nil t))) ; this finds alternative file name |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
892 (if (and (null cf) (string-match "[^\\]%\\|\\`%" cmd)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
893 (error "No current file to substitute for `%%'")) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
894 (if (and (null pf) (string-match "[^\\]#\\|\\`#" cmd)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
895 (error "No alternate file to substitute for `#'")) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
896 (save-excursion |
19079 | 897 (set-buffer (get-buffer-create viper-ex-tmp-buf-name)) |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
898 (erase-buffer) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
899 (insert cmd) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
900 (goto-char (point-min)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
901 (while (re-search-forward "%\\|#" nil t) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
902 (let ((data (match-data)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
903 (char (buffer-substring (match-beginning 0) (match-end 0)))) |
19079 | 904 (if (viper-looking-back (concat "\\\\" char)) |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
905 (replace-match char) |
21940 | 906 (store-match-data data) |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
907 (if (string= char "%") |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
908 (replace-match cf) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
909 (replace-match pf))))) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
910 (end-of-line) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
911 (setq ret (buffer-substring (point-min) (point))) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
912 (message "%s" ret)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
913 ret)) |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
914 |
20206 | 915 ;; Get a file name and set `ex-variant', `ex-append' and `ex-offset' if found |
916 ;; If it is r!, then get the command name and whatever args | |
19079 | 917 (defun viper-get-ex-file () |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
918 (let (prompt) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
919 (setq ex-file nil |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
920 ex-variant nil |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
921 ex-append nil |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
922 ex-offset nil |
20206 | 923 ex-cmdfile nil |
924 ex-cmdfile-args "") | |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
925 (save-excursion |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
926 (save-window-excursion |
19079 | 927 (setq viper-ex-work-buf (get-buffer-create viper-ex-work-buf-name)) |
928 (set-buffer viper-ex-work-buf) | |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
929 (skip-chars-forward " \t") |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
930 (if (looking-at "!") |
19079 | 931 (if (and (not (viper-looking-back "[ \t]")) |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
932 ;; read doesn't have a corresponding :r! form, so ! is |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
933 ;; immediately interpreted as a shell command. |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
934 (not (string= ex-token "read"))) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
935 (progn |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
936 (setq ex-variant t) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
937 (forward-char 1) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
938 (skip-chars-forward " \t")) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
939 (setq ex-cmdfile t) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
940 (forward-char 1) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
941 (skip-chars-forward " \t"))) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
942 (if (looking-at ">>") |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
943 (progn |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
944 (setq ex-append t |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
945 ex-variant t) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
946 (forward-char 2) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
947 (skip-chars-forward " \t"))) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
948 (if (looking-at "+") |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
949 (progn |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
950 (forward-char 1) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
951 (set-mark (point)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
952 (re-search-forward "[ \t\n]") |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
953 (backward-char 1) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
954 (setq ex-offset (buffer-substring (point) (mark t))) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
955 (forward-char 1) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
956 (skip-chars-forward " \t"))) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
957 ;; this takes care of :r, :w, etc., when they get file names |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
958 ;; from the history list |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
959 (if (member ex-token '("read" "write" "edit" "visual" "next")) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
960 (progn |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
961 (setq ex-file (buffer-substring (point) (1- (point-max)))) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
962 (setq ex-file |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
963 ;; For :e, match multiple non-white strings separated |
26263
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
21940
diff
changeset
|
964 ;; by white. For others, find the first non-white string |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
965 (if (string-match |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
966 (if (string= ex-token "edit") |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
967 "[^ \t\n]+\\([ \t]+[^ \t\n]+\\)*" |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
968 "[^ \t\n]+") |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
969 ex-file) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
970 (progn |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
971 ;; if file name comes from history, don't leave |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
972 ;; minibuffer when the user types space |
19079 | 973 (setq viper-incomplete-ex-cmd nil) |
20206 | 974 (setq ex-cmdfile-args |
975 (substring ex-file (match-end 0) nil)) | |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
976 ;; this must be the last clause in this progn |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
977 (substring ex-file (match-beginning 0) (match-end 0)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
978 ) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
979 "")) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
980 ;; this leaves only the command name in the work area |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
981 ;; file names are gone |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
982 (delete-region (point) (1- (point-max))) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
983 )) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
984 (goto-char (point-max)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
985 (skip-chars-backward " \t\n") |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
986 (setq prompt (buffer-substring (point-min) (point))) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
987 )) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
988 |
19079 | 989 (setq viper-last-ex-prompt prompt) |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
990 |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
991 ;; If we just finished reading command, redisplay prompt |
19079 | 992 (if viper-incomplete-ex-cmd |
993 (setq ex-file (viper-ex-read-file-name (format ":%s " prompt))) | |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
994 ;; file was typed in-line |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
995 (setq ex-file (or ex-file ""))) |
10789 | 996 )) |
997 | |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
998 |
26263
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
21940
diff
changeset
|
999 ;; Completes file name or exits minibuffer. If Ex command accepts multiple |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1000 ;; file names, arranges to re-enter the minibuffer. |
19079 | 1001 (defun viper-complete-filename-or-exit () |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1002 (interactive) |
19079 | 1003 (setq viper-keep-reading-filename t) |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1004 ;; don't exit if directory---ex-commands don't |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1005 (cond ((ex-cmd-accepts-multiple-files-p ex-token) (exit-minibuffer)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1006 ;; apparently the argument to an Ex command is |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1007 ;; supposed to be a shell command |
19079 | 1008 ((viper-looking-back "^[ \t]*!.*") |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1009 (setq ex-cmdfile t) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1010 (insert " ")) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1011 (t |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1012 (setq ex-cmdfile nil) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1013 (minibuffer-complete-word)))) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1014 |
19079 | 1015 (defun viper-handle-! () |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
1016 (interactive) |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1017 (if (and (string= |
19079 | 1018 (buffer-string) (viper-abbreviate-file-name default-directory)) |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1019 (member ex-token '("read" "write"))) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1020 (erase-buffer)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1021 (insert "!")) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1022 |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1023 (defun ex-cmd-accepts-multiple-files-p (token) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1024 (member token '("edit" "next" "Next"))) |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
1025 |
20206 | 1026 ;; Read file name from the minibuffer in an ex command. |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1027 ;; If user doesn't enter anything, then "" is returned, i.e., the |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1028 ;; prompt-directory is not returned. |
19079 | 1029 (defun viper-ex-read-file-name (prompt) |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1030 (let* ((str "") |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1031 (minibuffer-local-completion-map |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1032 (copy-keymap minibuffer-local-completion-map)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1033 beg end cont val) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1034 |
19079 | 1035 (viper-add-keymap ex-read-filename-map |
1036 (if viper-emacs-p | |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1037 minibuffer-local-completion-map |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1038 read-file-name-map)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1039 |
19079 | 1040 (setq cont (setq viper-keep-reading-filename t)) |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1041 (while cont |
19079 | 1042 (setq viper-keep-reading-filename nil |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1043 val (read-file-name (concat prompt str) nil default-directory)) |
21940 | 1044 (setq val (expand-file-name val)) |
1045 (if (and (string-match " " val) | |
1046 (ex-cmd-accepts-multiple-files-p ex-token)) | |
1047 (setq val (concat "\"" val "\""))) | |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1048 (setq str (concat str (if (equal val "") "" " ") |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1049 val (if (equal val "") "" " "))) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1050 |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1051 ;; Only edit, next, and Next commands accept multiple files. |
19079 | 1052 ;; viper-keep-reading-filename is set in the anonymous function that is |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1053 ;; bound to " " in ex-read-filename-map. |
19079 | 1054 (setq cont (and viper-keep-reading-filename |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1055 (ex-cmd-accepts-multiple-files-p ex-token))) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1056 ) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1057 |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1058 (setq beg (string-match "[^ \t]" str) ; delete leading blanks |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1059 end (string-match "[ \t]*$" str)) ; delete trailing blanks |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1060 (if (member ex-token '("read" "write")) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1061 (if (string-match "[\t ]*!" str) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1062 ;; this is actually a shell command |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1063 (progn |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1064 (setq ex-cmdfile t) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1065 (setq beg (1+ beg)) |
19079 | 1066 (setq viper-last-ex-prompt |
1067 (concat viper-last-ex-prompt " !"))))) | |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1068 (substring str (or beg 0) end))) |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
1069 |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1070 ;; Execute ex command using the value of addresses |
19079 | 1071 (defun viper-execute-ex-command () |
1072 (viper-deactivate-mark) | |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1073 (cond ((string= ex-token "args") (ex-args)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1074 ((string= ex-token "copy") (ex-copy nil)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1075 ((string= ex-token "cd") (ex-cd)) |
26263
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
21940
diff
changeset
|
1076 ((string= ex-token "customize") (customize-group "viper")) |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1077 ((string= ex-token "chdir") (ex-cd)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1078 ((string= ex-token "delete") (ex-delete)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1079 ((string= ex-token "edit") (ex-edit)) |
19079 | 1080 ((string= ex-token "file") (viper-info-on-file)) |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1081 ((string= ex-token "goto") (ex-goto)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1082 ((string= ex-token "help") (ex-help)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1083 ((string= ex-token "join") (ex-line "join")) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1084 ((string= ex-token "kmark") (ex-mark)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1085 ((string= ex-token "mark") (ex-mark)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1086 ((string= ex-token "map") (ex-map)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1087 ((string= ex-token "move") (ex-copy t)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1088 ((string= ex-token "next") (ex-next ex-cycle-other-window)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1089 ((string= ex-token "Next") (ex-next (not ex-cycle-other-window))) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1090 ((string= ex-token "RelatedFile") (ex-next-related-buffer 1)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1091 ((string= ex-token "put") (ex-put)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1092 ((string= ex-token "pwd") (ex-pwd)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1093 ((string= ex-token "preserve") (ex-preserve)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1094 ((string= ex-token "PreviousRelatedFile") (ex-next-related-buffer -1)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1095 ((string= ex-token "quit") (ex-quit)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1096 ((string= ex-token "read") (ex-read)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1097 ((string= ex-token "recover") (ex-recover)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1098 ((string= ex-token "rewind") (ex-rewind)) |
19079 | 1099 ((string= ex-token "submitReport") (viper-submit-report)) |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1100 ((string= ex-token "set") (ex-set)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1101 ((string= ex-token "shell") (ex-shell)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1102 ((string= ex-token "source") (ex-source)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1103 ((string= ex-token "sr") (ex-substitute t t)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1104 ((string= ex-token "substitute") (ex-substitute)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1105 ((string= ex-token "suspend") (suspend-emacs)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1106 ((string= ex-token "stop") (suspend-emacs)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1107 ((string= ex-token "transfer") (ex-copy nil)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1108 ((string= ex-token "buffer") (if ex-cycle-other-window |
19079 | 1109 (viper-switch-to-buffer-other-window) |
1110 (viper-switch-to-buffer))) | |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1111 ((string= ex-token "Buffer") (if ex-cycle-other-window |
19079 | 1112 (viper-switch-to-buffer) |
1113 (viper-switch-to-buffer-other-window))) | |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1114 ((string= ex-token "tag") (ex-tag)) |
19079 | 1115 ((string= ex-token "undo") (viper-undo)) |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1116 ((string= ex-token "unmap") (ex-unmap)) |
19079 | 1117 ((string= ex-token "version") (viper-version)) |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1118 ((string= ex-token "visual") (ex-edit)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1119 ((string= ex-token "write") (ex-write nil)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1120 ((string= ex-token "Write") (save-some-buffers)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1121 ((string= ex-token "wq") (ex-write t)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1122 ((string= ex-token "WWrite") (save-some-buffers t)) ; don't ask |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1123 ((string= ex-token "xit") (ex-write t)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1124 ((string= ex-token "yank") (ex-yank)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1125 ((string= ex-token "!") (ex-command)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1126 ((string= ex-token "=") (ex-line-no)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1127 ((string= ex-token ">") (ex-line "right")) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1128 ((string= ex-token "<") (ex-line "left")) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1129 ((string= ex-token "&") (ex-substitute t)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1130 ((string= ex-token "~") (ex-substitute t t)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1131 ((or (string= ex-token "append") |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1132 (string= ex-token "change") |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1133 (string= ex-token "insert") |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1134 (string= ex-token "open")) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1135 (error "`%s': Obsolete command, not supported by Viper" ex-token)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1136 ((or (string= ex-token "abbreviate") |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1137 (string= ex-token "unabbreviate")) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1138 (error |
26263
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
21940
diff
changeset
|
1139 "`%s': Vi abbrevs are obsolete. Use the more powerful Emacs abbrevs" |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1140 ex-token)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1141 ((or (string= ex-token "list") |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1142 (string= ex-token "print") |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1143 (string= ex-token "z") |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1144 (string= ex-token "#")) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1145 (error "`%s': Command not implemented in Viper" ex-token)) |
19079 | 1146 (t (error "`%s': %s" ex-token viper-BadExCommand)))) |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
1147 |
19079 | 1148 (defun viper-undisplayed-files () |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1149 (mapcar |
26263
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
21940
diff
changeset
|
1150 (lambda (b) |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
21940
diff
changeset
|
1151 (if (null (get-buffer-window b)) |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
21940
diff
changeset
|
1152 (let ((f (buffer-file-name b))) |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
21940
diff
changeset
|
1153 (if f f |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
21940
diff
changeset
|
1154 (if ex-cycle-through-non-files |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
21940
diff
changeset
|
1155 (let ((s (buffer-name b))) |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
21940
diff
changeset
|
1156 (if (string= " " (substring s 0 1)) |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
21940
diff
changeset
|
1157 nil |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
21940
diff
changeset
|
1158 s)) |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
21940
diff
changeset
|
1159 nil))) |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
21940
diff
changeset
|
1160 nil)) |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1161 (buffer-list))) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1162 |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
1163 |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1164 (defun ex-args () |
19079 | 1165 (let ((l (viper-undisplayed-files)) |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1166 (args "") |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1167 (file-count 1)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1168 (while (not (null l)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1169 (if (car l) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1170 (setq args (format "%s %d) %s\n" args file-count (car l)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1171 file-count (1+ file-count))) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1172 (setq l (cdr l))) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1173 (if (string= args "") |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1174 (message "All files are already displayed") |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1175 (save-excursion |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1176 (save-window-excursion |
19079 | 1177 (with-output-to-temp-buffer " *viper-info*" |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1178 (princ "\n\nThese files are not displayed in any window.\n") |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1179 (princ "\n=============\n") |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1180 (princ args) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1181 (princ "\n=============\n") |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1182 (princ "\nThe numbers can be given as counts to :next. ") |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1183 (princ "\n\nPress any key to continue...\n\n")) |
19079 | 1184 (viper-read-event)))))) |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1185 |
26263
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
21940
diff
changeset
|
1186 ;; Ex cd command. Default directory of this buffer changes |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1187 (defun ex-cd () |
19079 | 1188 (viper-get-ex-file) |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1189 (if (string= ex-file "") |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1190 (setq ex-file "~")) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1191 (setq default-directory (file-name-as-directory (expand-file-name ex-file)))) |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
1192 |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1193 ;; Ex copy and move command. DEL-FLAG means delete |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1194 (defun ex-copy (del-flag) |
19079 | 1195 (viper-default-ex-addresses) |
1196 (let ((address (viper-get-ex-address)) | |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1197 (end (car ex-addresses)) (beg (car (cdr ex-addresses)))) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1198 (goto-char end) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1199 (save-excursion |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1200 (push-mark beg t) |
19079 | 1201 (viper-enlarge-region (mark t) (point)) |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1202 (if del-flag |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1203 (kill-region (point) (mark t)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1204 (copy-region-as-kill (point) (mark t))) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1205 (if ex-flag |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1206 (progn |
20003 | 1207 (with-output-to-temp-buffer " *copy text*" |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1208 (princ |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1209 (if (or del-flag ex-g-flag ex-g-variant) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1210 (current-kill 0) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1211 (buffer-substring (point) (mark t))))) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1212 (condition-case nil |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1213 (progn |
20003 | 1214 (read-string "[Hit return to confirm] ") |
1215 (save-excursion (kill-buffer " *copy text*"))) | |
1216 (quit (save-excursion (kill-buffer " *copy text*")) | |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1217 (signal 'quit nil)))))) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1218 (if (= address 0) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1219 (goto-char (point-min)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1220 (goto-char address) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1221 (forward-line 1)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1222 (insert (current-kill 0)))) |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
1223 |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1224 ;; Ex delete command |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1225 (defun ex-delete () |
19079 | 1226 (viper-default-ex-addresses) |
1227 (viper-get-ex-buffer) | |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1228 (let ((end (car ex-addresses)) (beg (car (cdr ex-addresses)))) |
19079 | 1229 (if (> beg end) (error viper-FirstAddrExceedsSecond)) |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1230 (save-excursion |
19079 | 1231 (viper-enlarge-region beg end) |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1232 (exchange-point-and-mark) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1233 (if ex-count |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1234 (progn |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1235 (set-mark (point)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1236 (forward-line (1- ex-count))) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1237 (set-mark end)) |
19079 | 1238 (viper-enlarge-region (point) (mark t)) |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1239 (if ex-flag |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1240 ;; show text to be deleted and ask for confirmation |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1241 (progn |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1242 (with-output-to-temp-buffer " *delete text*" |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1243 (princ (buffer-substring (point) (mark t)))) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1244 (condition-case nil |
20003 | 1245 (read-string "[Hit return to confirm] ") |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1246 (quit |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1247 (save-excursion (kill-buffer " *delete text*")) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1248 (error ""))) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1249 (save-excursion (kill-buffer " *delete text*"))) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1250 (if ex-buffer |
19079 | 1251 (cond ((viper-valid-register ex-buffer '(Letter)) |
1252 (viper-append-to-register | |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1253 (downcase ex-buffer) (point) (mark t))) |
19079 | 1254 ((viper-valid-register ex-buffer) |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1255 (copy-to-register ex-buffer (point) (mark t) nil)) |
19079 | 1256 (t (error viper-InvalidRegister ex-buffer)))) |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1257 (kill-region (point) (mark t)))))) |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
1258 |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
1259 |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
1260 |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1261 ;; Ex edit command |
26263
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
21940
diff
changeset
|
1262 ;; In Viper, `e' and `e!' behave identically. In both cases, the user is |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1263 ;; asked if current buffer should really be discarded. |
26263
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
21940
diff
changeset
|
1264 ;; This command can take multiple file names. It replaces the current buffer |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1265 ;; with the first file in its argument list |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1266 (defun ex-edit (&optional file) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1267 (if (not file) |
19079 | 1268 (viper-get-ex-file)) |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1269 (cond ((and (string= ex-file "") buffer-file-name) |
19079 | 1270 (setq ex-file (viper-abbreviate-file-name (buffer-file-name)))) |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1271 ((string= ex-file "") |
19079 | 1272 (error viper-NoFileSpecified))) |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
1273 |
21940 | 1274 ;;; (let (msg do-edit) |
1275 ;;; (if buffer-file-name | |
1276 ;;; (cond ((buffer-modified-p) | |
1277 ;;; (setq msg | |
26263
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
21940
diff
changeset
|
1278 ;;; (format "Buffer %s is modified. Discard changes? " |
21940 | 1279 ;;; (buffer-name)) |
1280 ;;; do-edit t)) | |
1281 ;;; ((not (verify-visited-file-modtime (current-buffer))) | |
1282 ;;; (setq msg | |
1283 ;;; (format "File %s changed on disk. Reread from disk? " | |
1284 ;;; buffer-file-name) | |
1285 ;;; do-edit t)) | |
1286 ;;; (t (setq do-edit nil)))) | |
1287 ;;; | |
1288 ;;; (if do-edit | |
1289 ;;; (if (yes-or-no-p msg) | |
1290 ;;; (progn | |
1291 ;;; (set-buffer-modified-p nil) | |
1292 ;;; (kill-buffer (current-buffer))) | |
1293 ;;; (message "Buffer %s was left intact" (buffer-name)))) | |
1294 ;;; ) ; let | |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
1295 |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1296 (if (null (setq file (get-file-buffer ex-file))) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1297 (progn |
26263
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
21940
diff
changeset
|
1298 ;; this also does shell-style globbing |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
21940
diff
changeset
|
1299 (ex-find-file |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
21940
diff
changeset
|
1300 ;; replace # and % with the previous/current file |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
21940
diff
changeset
|
1301 (ex-expand-filsyms ex-file (current-buffer))) |
16136
de1340e6ddb4
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15482
diff
changeset
|
1302 (or (eq major-mode 'dired-mode) |
19079 | 1303 (viper-change-state-to-vi)) |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1304 (goto-char (point-min))) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1305 (switch-to-buffer file)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1306 (if ex-offset |
10789 | 1307 (progn |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1308 (save-window-excursion |
19079 | 1309 (setq viper-ex-work-buf (get-buffer-create viper-ex-work-buf-name)) |
1310 (set-buffer viper-ex-work-buf) | |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1311 (delete-region (point-min) (point-max)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1312 (insert ex-offset "\n") |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1313 (goto-char (point-min))) |
19079 | 1314 (goto-char (viper-get-ex-address)) |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1315 (beginning-of-line))) |
19079 | 1316 (ex-fixup-history viper-last-ex-prompt ex-file)) |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
1317 |
16136
de1340e6ddb4
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15482
diff
changeset
|
1318 ;; Find-file FILESPEC if it appears to specify a single file. |
21940 | 1319 ;; Otherwise, assume that FILESPEC is a wildcard. |
16136
de1340e6ddb4
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15482
diff
changeset
|
1320 ;; In this case, split it into substrings separated by newlines. |
26263
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
21940
diff
changeset
|
1321 ;; Each line is assumed to be a file name. |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1322 (defun ex-find-file (filespec) |
16136
de1340e6ddb4
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15482
diff
changeset
|
1323 (let ((nonstandard-filename-chars "[^-a-zA-Z0-9_./,~$\\]")) |
de1340e6ddb4
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15482
diff
changeset
|
1324 (cond ((file-exists-p filespec) (find-file filespec)) |
de1340e6ddb4
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15482
diff
changeset
|
1325 ((string-match nonstandard-filename-chars filespec) |
26263
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
21940
diff
changeset
|
1326 (mapcar 'find-file (funcall viper-glob-function filespec))) |
16136
de1340e6ddb4
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15482
diff
changeset
|
1327 (t (find-file filespec))) |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
1328 )) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
1329 |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
1330 |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1331 ;; Ex global command |
18839 | 1332 ;; This is executed in response to: |
1333 ;; :global "pattern" ex-command | |
1334 ;; :vglobal "pattern" ex-command | |
1335 ;; :global executes ex-command on all lines matching <pattern> | |
1336 ;; :vglobal executes ex-command on all lines that don't match <pattern> | |
1337 ;; | |
1338 ;; With VARIANT nil, this functions executes :global | |
1339 ;; With VARIANT t, executes :vglobal | |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1340 (defun ex-global (variant) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1341 (let ((gcommand ex-token)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1342 (if (or ex-g-flag ex-g-variant) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1343 (error "`%s' within `global' is not allowed" gcommand) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1344 (if variant |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1345 (setq ex-g-flag nil |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1346 ex-g-variant t) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1347 (setq ex-g-flag t |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1348 ex-g-variant nil))) |
19079 | 1349 (viper-get-ex-pat) |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1350 (if (null ex-token) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1351 (error "`%s': Missing regular expression" gcommand))) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1352 |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1353 (if (string= ex-token "") |
19079 | 1354 (if (null viper-s-string) |
1355 (error viper-NoPrevSearch) | |
1356 (setq ex-g-pat viper-s-string)) | |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1357 (setq ex-g-pat ex-token |
19079 | 1358 viper-s-string ex-token)) |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1359 (if (null ex-addresses) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1360 (setq ex-addresses (list (point-max) (point-min))) |
19079 | 1361 (viper-default-ex-addresses)) |
18839 | 1362 (let ((marks nil) |
1363 (mark-count 0) | |
1364 (end (car ex-addresses)) | |
1365 (beg (car (cdr ex-addresses))) | |
1366 com-str) | |
19079 | 1367 (if (> beg end) (error viper-FirstAddrExceedsSecond)) |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1368 (save-excursion |
19079 | 1369 (viper-enlarge-region beg end) |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1370 (exchange-point-and-mark) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1371 (let ((cont t) (limit (point-marker))) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1372 (exchange-point-and-mark) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1373 ;; skip the last line if empty |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1374 (beginning-of-line) |
19079 | 1375 (if (eobp) (viper-backward-char-carefully)) |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1376 (while (and cont (not (bobp)) (>= (point) limit)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1377 (beginning-of-line) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1378 (set-mark (point)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1379 (end-of-line) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1380 (let ((found (re-search-backward ex-g-pat (mark t) t))) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1381 (if (or (and ex-g-flag found) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1382 (and ex-g-variant (not found))) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1383 (progn |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1384 (end-of-line) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1385 (setq mark-count (1+ mark-count)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1386 (setq marks (cons (point-marker) marks))))) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1387 (beginning-of-line) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1388 (if (bobp) (setq cont nil) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1389 (forward-line -1) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1390 (end-of-line))))) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1391 (save-window-excursion |
19079 | 1392 (setq viper-ex-work-buf (get-buffer-create viper-ex-work-buf-name)) |
1393 (set-buffer viper-ex-work-buf) | |
26263
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
21940
diff
changeset
|
1394 ;; com-str is the command string, i.e., g/pattern/ or v/pattern' |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1395 (setq com-str (buffer-substring (1+ (point)) (1- (point-max))))) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1396 (while marks |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1397 (goto-char (car marks)) |
26263
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
21940
diff
changeset
|
1398 (viper-ex nil com-str) |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1399 (setq mark-count (1- mark-count)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1400 (setq marks (cdr marks))))) |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
1401 |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1402 ;; Ex goto command |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1403 (defun ex-goto () |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1404 (if (null ex-addresses) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1405 (setq ex-addresses (cons (point) nil))) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1406 (push-mark (point) t) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1407 (goto-char (car ex-addresses)) |
26263
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
21940
diff
changeset
|
1408 (beginning-of-line) |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
21940
diff
changeset
|
1409 ) |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
1410 |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1411 ;; Ex line commands. COM is join, shift-right or shift-left |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1412 (defun ex-line (com) |
19079 | 1413 (viper-default-ex-addresses) |
1414 (viper-get-ex-count) | |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1415 (let ((end (car ex-addresses)) (beg (car (cdr ex-addresses))) point) |
19079 | 1416 (if (> beg end) (error viper-FirstAddrExceedsSecond)) |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1417 (save-excursion |
19079 | 1418 (viper-enlarge-region beg end) |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1419 (exchange-point-and-mark) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1420 (if ex-count |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1421 (progn |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1422 (set-mark (point)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1423 (forward-line ex-count))) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1424 (if ex-flag |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1425 ;; show text to be joined and ask for confirmation |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1426 (progn |
20003 | 1427 (with-output-to-temp-buffer " *join text*" |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1428 (princ (buffer-substring (point) (mark t)))) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1429 (condition-case nil |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1430 (progn |
20003 | 1431 (read-string "[Hit return to confirm] ") |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1432 (ex-line-subr com (point) (mark t))) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1433 (quit (ding))) |
20003 | 1434 (save-excursion (kill-buffer " *join text*"))) |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1435 (ex-line-subr com (point) (mark t))) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1436 (setq point (point))) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1437 (goto-char (1- point)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1438 (beginning-of-line))) |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
1439 |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1440 (defun ex-line-subr (com beg end) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1441 (cond ((string= com "join") |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1442 (goto-char (min beg end)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1443 (while (and (not (eobp)) (< (point) (max beg end))) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1444 (end-of-line) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1445 (if (and (<= (point) (max beg end)) (not (eobp))) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1446 (progn |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1447 (forward-line 1) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1448 (delete-region (point) (1- (point))) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1449 (if (not ex-variant) (fixup-whitespace)))))) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1450 ((or (string= com "right") (string= com "left")) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1451 (indent-rigidly |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1452 (min beg end) (max beg end) |
19079 | 1453 (if (string= com "right") viper-shift-width (- viper-shift-width))) |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1454 (goto-char (max beg end)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1455 (end-of-line) |
19079 | 1456 (viper-forward-char-carefully)))) |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
1457 |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
1458 |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1459 ;; Ex mark command |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1460 (defun ex-mark () |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1461 (let (char) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1462 (if (null ex-addresses) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1463 (setq ex-addresses |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1464 (cons (point) nil))) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1465 (save-window-excursion |
19079 | 1466 (setq viper-ex-work-buf (get-buffer-create viper-ex-work-buf-name)) |
1467 (set-buffer viper-ex-work-buf) | |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1468 (skip-chars-forward " \t") |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1469 (if (looking-at "[a-z]") |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1470 (progn |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1471 (setq char (following-char)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1472 (forward-char 1) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1473 (skip-chars-forward " \t") |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1474 (if (not (looking-at "[\n|]")) |
19079 | 1475 (error "`%s': %s" ex-token viper-SpuriousText))) |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1476 (error "`%s' requires a following letter" ex-token))) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1477 (save-excursion |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1478 (goto-char (car ex-addresses)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1479 (point-to-register (1+ (- char ?a)))))) |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
1480 |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1481 |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1482 |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1483 ;; Alternate file is the file next to the first one in the buffer ring |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1484 (defun ex-next (cycle-other-window &optional find-alt-file) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1485 (catch 'ex-edit |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1486 (let (count l) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1487 (if (not find-alt-file) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1488 (progn |
19079 | 1489 (viper-get-ex-file) |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1490 (if (or (char-or-string-p ex-offset) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1491 (and (not (string= "" ex-file)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1492 (not (string-match "^[0-9]+$" ex-file)))) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1493 (progn |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1494 (ex-edit t) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1495 (throw 'ex-edit nil)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1496 (setq count (string-to-int ex-file)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1497 (if (= count 0) (setq count 1)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1498 (if (< count 0) (error "Usage: `next <count>' (count >= 0)")))) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1499 (setq count 1)) |
19079 | 1500 (setq l (viper-undisplayed-files)) |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1501 (while (> count 0) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1502 (while (and (not (null l)) (null (car l))) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1503 (setq l (cdr l))) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1504 (setq count (1- count)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1505 (if (> count 0) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1506 (setq l (cdr l)))) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1507 (if find-alt-file (car l) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1508 (progn |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1509 (if (and (car l) (get-file-buffer (car l))) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1510 (let* ((w (if cycle-other-window |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1511 (get-lru-window) (selected-window))) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1512 (b (window-buffer w))) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1513 (set-window-buffer w (get-file-buffer (car l))) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1514 (bury-buffer b) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1515 ;; this puts "next <count>" in the ex-command history |
19079 | 1516 (ex-fixup-history viper-last-ex-prompt ex-file)) |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1517 (error "Not that many undisplayed files"))))))) |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
1518 |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
1519 |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1520 (defun ex-next-related-buffer (direction &optional no-recursion) |
10789 | 1521 |
19079 | 1522 (viper-ring-rotate1 viper-related-files-and-buffers-ring direction) |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
1523 |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1524 (let ((file-or-buffer-name |
19079 | 1525 (viper-current-ring-item viper-related-files-and-buffers-ring)) |
1526 (old-ring viper-related-files-and-buffers-ring) | |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1527 (old-win (selected-window)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1528 skip-rest buf wind) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1529 |
19079 | 1530 (or (and (ring-p viper-related-files-and-buffers-ring) |
1531 (> (ring-length viper-related-files-and-buffers-ring) 0)) | |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1532 (error "This buffer has no related files or buffers")) |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
1533 |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1534 (or (stringp file-or-buffer-name) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1535 (error |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1536 "File and buffer names must be strings, %S" file-or-buffer-name)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1537 |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1538 (setq buf (cond ((get-buffer file-or-buffer-name)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1539 ((file-exists-p file-or-buffer-name) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1540 (find-file-noselect file-or-buffer-name)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1541 )) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1542 |
19079 | 1543 (if (not (viper-buffer-live-p buf)) |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1544 (error "Didn't find buffer %S or file %S" |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1545 file-or-buffer-name |
19079 | 1546 (viper-abbreviate-file-name |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1547 (expand-file-name file-or-buffer-name)))) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1548 |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1549 (if (equal buf (current-buffer)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1550 (or no-recursion |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1551 ;; try again |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1552 (progn |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1553 (setq skip-rest t) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1554 (ex-next-related-buffer direction 'norecursion)))) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1555 |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1556 (if skip-rest |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1557 () |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1558 ;; setup buffer |
19079 | 1559 (if (setq wind (viper-get-visible-buffer-window buf)) |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1560 () |
19079 | 1561 (setq wind (get-lru-window (if viper-xemacs-p nil 'visible))) |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1562 (set-window-buffer wind buf)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1563 |
19079 | 1564 (if (viper-window-display-p) |
10789 | 1565 (progn |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1566 (raise-frame (window-frame wind)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1567 (if (equal (window-frame wind) (window-frame old-win)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1568 (save-window-excursion (select-window wind) (sit-for 1)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1569 (select-window wind))) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1570 (save-window-excursion (select-window wind) (sit-for 1))) |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
1571 |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1572 (save-excursion |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1573 (set-buffer buf) |
19079 | 1574 (setq viper-related-files-and-buffers-ring old-ring)) |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
1575 |
19079 | 1576 (setq viper-local-search-start-marker (point-marker)) |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
1577 ))) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
1578 |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
1579 |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1580 ;; Force auto save |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1581 (defun ex-preserve () |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1582 (message "Autosaving all buffers that need to be saved...") |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1583 (do-auto-save t)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1584 |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1585 ;; Ex put |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1586 (defun ex-put () |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1587 (let ((point (if (null ex-addresses) (point) (car ex-addresses)))) |
19079 | 1588 (viper-get-ex-buffer) |
1589 (setq viper-use-register ex-buffer) | |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1590 (goto-char point) |
19079 | 1591 (if (bobp) (viper-Put-back 1) (viper-put-back 1)))) |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
1592 |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1593 ;; Ex print working directory |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1594 (defun ex-pwd () |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1595 (message default-directory)) |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
1596 |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1597 ;; Ex quit command |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1598 (defun ex-quit () |
26263
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
21940
diff
changeset
|
1599 ;; skip "!", if it is q!. In Viper q!, w!, etc., behave as q, w, etc. |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1600 (save-excursion |
19079 | 1601 (setq viper-ex-work-buf (get-buffer-create viper-ex-work-buf-name)) |
1602 (set-buffer viper-ex-work-buf) | |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1603 (if (looking-at "!") (forward-char 1))) |
18839 | 1604 (if (< viper-expert-level 3) |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
1605 (save-buffers-kill-emacs) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
1606 (kill-buffer (current-buffer)))) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
1607 |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
1608 |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1609 ;; Ex read command |
26263
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
21940
diff
changeset
|
1610 ;; ex-read doesn't support wildcards, because file completion is a better |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
21940
diff
changeset
|
1611 ;; mechanism. We also don't support # and % (except in :r <shell-command> |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
21940
diff
changeset
|
1612 ;; because file history is a better mechanism. |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1613 (defun ex-read () |
19079 | 1614 (viper-get-ex-file) |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1615 (let ((point (if (null ex-addresses) (point) (car ex-addresses))) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1616 command) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1617 (goto-char point) |
19079 | 1618 (viper-add-newline-at-eob-if-necessary) |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1619 (if (not (or (bobp) (eobp))) (forward-line 1)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1620 (if (and (not ex-variant) (string= ex-file "")) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1621 (progn |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1622 (if (null buffer-file-name) |
19079 | 1623 (error viper-NoFileSpecified)) |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1624 (setq ex-file buffer-file-name))) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1625 (if ex-cmdfile |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1626 (progn |
20206 | 1627 (setq command |
26263
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
21940
diff
changeset
|
1628 ;; replace # and % with the previous/current file |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
21940
diff
changeset
|
1629 (ex-expand-filsyms (concat ex-file ex-cmdfile-args) |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
21940
diff
changeset
|
1630 (current-buffer))) |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1631 (shell-command command t)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1632 (insert-file-contents ex-file))) |
20206 | 1633 (ex-fixup-history viper-last-ex-prompt ex-file ex-cmdfile-args)) |
10789 | 1634 |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1635 ;; this function fixes ex-history for some commands like ex-read, ex-edit |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1636 (defun ex-fixup-history (&rest args) |
19079 | 1637 (setq viper-ex-history |
1638 (cons (mapconcat 'identity args " ") (cdr viper-ex-history)))) | |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
1639 |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
1640 |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1641 ;; Ex recover from emacs \#file\# |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1642 (defun ex-recover () |
19079 | 1643 (viper-get-ex-file) |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1644 (if (or ex-append ex-offset) |
19079 | 1645 (error "`recover': %s" viper-SpuriousText)) |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1646 (if (string= ex-file "") |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1647 (progn |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1648 (if (null buffer-file-name) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1649 (error "This buffer isn't visiting any file")) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1650 (setq ex-file buffer-file-name)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1651 (setq ex-file (expand-file-name ex-file))) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1652 (if (and (not (string= ex-file (buffer-file-name))) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1653 (buffer-modified-p) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1654 (not ex-variant)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1655 (error "No write since last change \(:rec! overrides\)")) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1656 (recover-file ex-file)) |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
1657 |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1658 ;; Tell that `rewind' is obsolete and to use `:next count' instead |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1659 (defun ex-rewind () |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1660 (message |
26263
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
21940
diff
changeset
|
1661 "Use `:n <count>' instead. Counts are obtained from the `:args' command")) |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
1662 |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
1663 |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1664 ;; read variable name for ex-set |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1665 (defun ex-set-read-variable () |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1666 (let ((minibuffer-local-completion-map |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1667 (copy-keymap minibuffer-local-completion-map)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1668 (cursor-in-echo-area t) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1669 str batch) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1670 (define-key |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1671 minibuffer-local-completion-map " " 'minibuffer-complete-and-exit) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1672 (define-key minibuffer-local-completion-map "=" 'exit-minibuffer) |
19079 | 1673 (if (viper-set-unread-command-events |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1674 (ex-get-inline-cmd-args "[ \t]*[a-zA-Z]*[ \t]*" nil "\C-m")) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1675 (progn |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1676 (setq batch t) |
19079 | 1677 (viper-set-unread-command-events ?\C-m))) |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1678 (message ":set <Variable> [= <Value>]") |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1679 (or batch (sit-for 2)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1680 |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1681 (while (string-match "^[ \\t\\n]*$" |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1682 (setq str |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1683 (completing-read ":set " ex-variable-alist))) |
18289 | 1684 (message ":set <Variable> [= <Value>]") |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1685 ;; if there are unread events, don't wait |
19079 | 1686 (or (viper-set-unread-command-events "") (sit-for 2)) |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1687 ) ; while |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1688 str)) |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
1689 |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
1690 |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1691 (defun ex-set () |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1692 (let ((var (ex-set-read-variable)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1693 (val 0) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1694 (set-cmd "setq") |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1695 (ask-if-save t) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1696 (auto-cmd-label "; don't touch or else...") |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1697 (delete-turn-on-auto-fill-pattern |
21940 | 1698 "([ \t]*add-hook[ \t]+'viper-insert-state-hook[ \t]+'turn-on-auto-fill.*)") |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1699 actual-lisp-cmd lisp-cmd-del-pattern |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1700 val2 orig-var) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1701 (setq orig-var var) |
18289 | 1702 (cond ((string= var "all") |
1703 (setq ask-if-save nil | |
1704 set-cmd nil)) | |
1705 ((member var '("ai" "autoindent")) | |
19079 | 1706 (setq var "viper-auto-indent" |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1707 set-cmd "setq" |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1708 ask-if-save nil |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1709 val "t")) |
18289 | 1710 ((member var '("ai-g" "autoindent-global")) |
19079 | 1711 (kill-local-variable 'viper-auto-indent) |
1712 (setq var "viper-auto-indent" | |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1713 set-cmd "setq-default" |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1714 val "t")) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1715 ((member var '("noai" "noautoindent")) |
19079 | 1716 (setq var "viper-auto-indent" |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1717 ask-if-save nil |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1718 val "nil")) |
18289 | 1719 ((member var '("noai-g" "noautoindent-global")) |
19079 | 1720 (kill-local-variable 'viper-auto-indent) |
1721 (setq var "viper-auto-indent" | |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1722 set-cmd "setq-default" |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1723 val "nil")) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1724 ((member var '("ic" "ignorecase")) |
19079 | 1725 (setq var "viper-case-fold-search" |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1726 val "t")) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1727 ((member var '("noic" "noignorecase")) |
19079 | 1728 (setq var "viper-case-fold-search" |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1729 val "nil")) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1730 ((member var '("ma" "magic")) |
19079 | 1731 (setq var "viper-re-search" |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1732 val "t")) |
18289 | 1733 ((member var '("noma" "nomagic")) |
19079 | 1734 (setq var "viper-re-search" |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1735 val "nil")) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1736 ((member var '("ro" "readonly")) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1737 (setq var "buffer-read-only" |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1738 val "t")) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1739 ((member var '("noro" "noreadonly")) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1740 (setq var "buffer-read-only" |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1741 val "nil")) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1742 ((member var '("sm" "showmatch")) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1743 (setq var "blink-matching-paren" |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1744 val "t")) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1745 ((member var '("nosm" "noshowmatch")) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1746 (setq var "blink-matching-paren" |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1747 val "nil")) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1748 ((member var '("ws" "wrapscan")) |
19079 | 1749 (setq var "viper-search-wrap-around-t" |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1750 val "t")) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1751 ((member var '("nows" "nowrapscan")) |
19079 | 1752 (setq var "viper-search-wrap-around-t" |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1753 val "nil"))) |
18289 | 1754 (if (and set-cmd (eq val 0)) ; value must be set by the user |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1755 (let ((cursor-in-echo-area t)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1756 (message ":set %s = <Value>" var) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1757 ;; if there are unread events, don't wait |
19079 | 1758 (or (viper-set-unread-command-events "") (sit-for 2)) |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1759 (setq val (read-string (format ":set %s = " var))) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1760 (ex-fixup-history "set" orig-var val) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1761 |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1762 ;; check numerical values |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1763 (if (member var |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1764 '("sw" "shiftwidth" |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1765 "ts" "tabstop" |
18289 | 1766 "ts-g" "tabstop-global" |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1767 "wm" "wrapmargin")) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1768 (condition-case nil |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1769 (or (numberp (setq val2 (car (read-from-string val)))) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1770 (error "%s: Invalid value, numberp, %S" var val)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1771 (error |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1772 (error "%s: Invalid value, numberp, %S" var val)))) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1773 |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1774 (cond |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1775 ((member var '("sw" "shiftwidth")) |
19079 | 1776 (setq var "viper-shift-width")) |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1777 ((member var '("ts" "tabstop")) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1778 ;; make it take effect in curr buff and new bufs |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1779 (setq var "tab-width" |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1780 set-cmd "setq" |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1781 ask-if-save nil)) |
18289 | 1782 ((member var '("ts-g" "tabstop-global")) |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1783 (kill-local-variable 'tab-width) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1784 (setq var "tab-width" |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1785 set-cmd "setq-default")) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1786 ((member var '("wm" "wrapmargin")) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1787 ;; make it take effect in curr buff and new bufs |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1788 (kill-local-variable 'fill-column) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1789 (setq var "fill-column" |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1790 val (format "(- (window-width) %s)" val) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1791 set-cmd "setq-default")) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1792 ((member var '("sh" "shell")) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1793 (setq var "explicit-shell-file-name" |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1794 val (format "\"%s\"" val))))) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1795 (ex-fixup-history "set" orig-var)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1796 |
18289 | 1797 (if set-cmd |
1798 (setq actual-lisp-cmd | |
1799 (format "\n(%s %s %s) %s" set-cmd var val auto-cmd-label) | |
1800 lisp-cmd-del-pattern | |
1801 (format "^\n?[ \t]*([ \t]*%s[ \t]+%s[ \t].*)[ \t]*%s" | |
1802 set-cmd var auto-cmd-label))) | |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1803 |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1804 (if (and ask-if-save |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1805 (y-or-n-p (format "Do you want to save this setting in %s " |
19079 | 1806 viper-custom-file-name))) |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1807 (progn |
19079 | 1808 (viper-save-string-in-file |
1809 actual-lisp-cmd viper-custom-file-name | |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1810 ;; del pattern |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1811 lisp-cmd-del-pattern) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1812 (if (string= var "fill-column") |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1813 (if (> val2 0) |
19079 | 1814 (viper-save-string-in-file |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1815 (concat |
21940 | 1816 "(add-hook 'viper-insert-state-hook 'turn-on-auto-fill) " |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1817 auto-cmd-label) |
19079 | 1818 viper-custom-file-name |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1819 delete-turn-on-auto-fill-pattern) |
19079 | 1820 (viper-save-string-in-file |
1821 nil viper-custom-file-name delete-turn-on-auto-fill-pattern) | |
1822 (viper-save-string-in-file | |
1823 nil viper-custom-file-name | |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1824 ;; del pattern |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1825 lisp-cmd-del-pattern) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1826 )) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1827 )) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1828 |
18289 | 1829 (if set-cmd |
1830 (message "%s %s %s" | |
1831 set-cmd var | |
1832 (if (string-match "^[ \t]*$" val) | |
1833 (format "%S" val) | |
1834 val))) | |
1835 (if actual-lisp-cmd | |
1836 (eval (car (read-from-string actual-lisp-cmd)))) | |
1837 (if (string= var "fill-column") | |
1838 (if (> val2 0) | |
1839 (auto-fill-mode 1) | |
1840 (auto-fill-mode -1))) | |
1841 (if (string= var "all") (ex-show-vars)) | |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1842 )) |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
1843 |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1844 ;; In inline args, skip regex-forw and (optionally) chars-back. |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1845 ;; Optional 3d arg is a string that should replace ' ' to prevent its |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1846 ;; special meaning |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1847 (defun ex-get-inline-cmd-args (regex-forw &optional chars-back replace-str) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1848 (save-excursion |
19079 | 1849 (setq viper-ex-work-buf (get-buffer-create viper-ex-work-buf-name)) |
1850 (set-buffer viper-ex-work-buf) | |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1851 (goto-char (point-min)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1852 (re-search-forward regex-forw nil t) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1853 (let ((beg (point)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1854 end) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1855 (goto-char (point-max)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1856 (if chars-back |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1857 (skip-chars-backward chars-back) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1858 (skip-chars-backward " \t\n\C-m")) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1859 (setq end (point)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1860 ;; replace SPC with `=' to suppress the special meaning SPC has |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1861 ;; in Ex commands |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1862 (goto-char beg) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1863 (if replace-str |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1864 (while (re-search-forward " +" nil t) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1865 (replace-match replace-str nil t) |
19079 | 1866 (viper-forward-char-carefully))) |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1867 (goto-char end) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1868 (buffer-substring beg end)))) |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
1869 |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
1870 |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1871 ;; Ex shell command |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1872 (defun ex-shell () |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1873 (shell)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1874 |
26263
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
21940
diff
changeset
|
1875 ;; Viper help. Invokes Info |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1876 (defun ex-help () |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1877 (condition-case nil |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1878 (progn |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1879 (pop-to-buffer (get-buffer-create "*info*")) |
19079 | 1880 (info (if viper-xemacs-p "viper.info" "viper")) |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1881 (message "Type `i' to search for a specific topic")) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1882 (error (beep 1) |
19079 | 1883 (with-output-to-temp-buffer " *viper-info*" |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1884 (princ (format " |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1885 The Info file for Viper does not seem to be installed. |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1886 |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1887 This file is part of the standard distribution of %sEmacs. |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1888 Please contact your system administrator. " |
19079 | 1889 (if viper-xemacs-p "X" "") |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1890 )))))) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1891 |
26263
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
21940
diff
changeset
|
1892 ;; Ex source command. Loads the file specified as argument or `~/.viper' |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1893 (defun ex-source () |
19079 | 1894 (viper-get-ex-file) |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1895 (if (string= ex-file "") |
19079 | 1896 (load viper-custom-file-name) |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1897 (load ex-file))) |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
1898 |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1899 ;; Ex substitute command |
19079 | 1900 ;; If REPEAT use previous regexp which is ex-reg-exp or viper-s-string |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1901 (defun ex-substitute (&optional repeat r-flag) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1902 (let ((opt-g nil) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1903 (opt-c nil) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1904 (matched-pos nil) |
19079 | 1905 (case-fold-search viper-case-fold-search) |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1906 delim pat repl) |
19079 | 1907 (if repeat (setq ex-token nil) (setq delim (viper-get-ex-pat))) |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1908 (if (null ex-token) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1909 (progn |
19079 | 1910 (setq pat (if r-flag viper-s-string ex-reg-exp)) |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1911 (or (stringp pat) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1912 (error "No previous pattern to use in substitution")) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1913 (setq repl ex-repl |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1914 delim (string-to-char pat))) |
19079 | 1915 (setq pat (if (string= ex-token "") viper-s-string ex-token)) |
1916 (setq viper-s-string pat | |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1917 ex-reg-exp pat) |
19079 | 1918 (setq delim (viper-get-ex-pat)) |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1919 (if (null ex-token) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1920 (setq ex-token "" |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1921 ex-repl "") |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1922 (setq repl ex-token |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1923 ex-repl ex-token))) |
19079 | 1924 (while (viper-get-ex-opt-gc delim) |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1925 (if (string= ex-token "g") (setq opt-g t) (setq opt-c t))) |
19079 | 1926 (viper-get-ex-count) |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1927 (if ex-count |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1928 (save-excursion |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1929 (if ex-addresses (goto-char (car ex-addresses))) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1930 (set-mark (point)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1931 (forward-line (1- ex-count)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1932 (setq ex-addresses (cons (point) (cons (mark t) nil)))) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1933 (if (null ex-addresses) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1934 (setq ex-addresses (cons (point) (cons (point) nil))) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1935 (if (null (cdr ex-addresses)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1936 (setq ex-addresses (cons (car ex-addresses) ex-addresses))))) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1937 ;(setq G opt-g) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1938 (let ((beg (car ex-addresses)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1939 (end (car (cdr ex-addresses))) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1940 eol-mark) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1941 (save-excursion |
19079 | 1942 (viper-enlarge-region beg end) |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1943 (let ((limit (save-excursion |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1944 (goto-char (max (point) (mark t))) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1945 (point-marker)))) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1946 (goto-char (min (point) (mark t))) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1947 (while (< (point) limit) |
21940 | 1948 (save-excursion |
1949 (end-of-line) | |
1950 ;; This move allows the use of newline as the last character in | |
1951 ;; the substitution pattern | |
1952 (viper-forward-char-carefully) | |
1953 (setq eol-mark (point-marker))) | |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1954 (beginning-of-line) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1955 (if opt-g |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1956 (progn |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1957 (while (and (not (eolp)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1958 (re-search-forward pat eol-mark t)) |
28510
6fb7a3864791
2000-04-07 Mikio Nakajima <minakaji@osaka.email.ne.jp>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
26263
diff
changeset
|
1959 (if (or (not opt-c) |
6fb7a3864791
2000-04-07 Mikio Nakajima <minakaji@osaka.email.ne.jp>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
26263
diff
changeset
|
1960 (progn |
6fb7a3864791
2000-04-07 Mikio Nakajima <minakaji@osaka.email.ne.jp>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
26263
diff
changeset
|
1961 (viper-put-on-search-overlay (match-beginning 0) |
6fb7a3864791
2000-04-07 Mikio Nakajima <minakaji@osaka.email.ne.jp>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
26263
diff
changeset
|
1962 (match-end 0)) |
6fb7a3864791
2000-04-07 Mikio Nakajima <minakaji@osaka.email.ne.jp>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
26263
diff
changeset
|
1963 (y-or-n-p "Replace? "))) |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1964 (progn |
28510
6fb7a3864791
2000-04-07 Mikio Nakajima <minakaji@osaka.email.ne.jp>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
26263
diff
changeset
|
1965 (viper-hide-search-overlay) |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1966 (setq matched-pos (point)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1967 (if (not (stringp repl)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1968 (error "Can't perform Ex substitution: No previous replacement pattern")) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1969 (replace-match repl t)))) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1970 (end-of-line) |
19079 | 1971 (viper-forward-char-carefully)) |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1972 (if (null pat) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1973 (error |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1974 "Can't repeat Ex substitution: No previous regular expression")) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1975 (if (and (re-search-forward pat eol-mark t) |
28510
6fb7a3864791
2000-04-07 Mikio Nakajima <minakaji@osaka.email.ne.jp>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
26263
diff
changeset
|
1976 (or (not opt-c) |
6fb7a3864791
2000-04-07 Mikio Nakajima <minakaji@osaka.email.ne.jp>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
26263
diff
changeset
|
1977 (progn |
6fb7a3864791
2000-04-07 Mikio Nakajima <minakaji@osaka.email.ne.jp>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
26263
diff
changeset
|
1978 (viper-put-on-search-overlay (match-beginning 0) |
6fb7a3864791
2000-04-07 Mikio Nakajima <minakaji@osaka.email.ne.jp>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
26263
diff
changeset
|
1979 (match-end 0)) |
6fb7a3864791
2000-04-07 Mikio Nakajima <minakaji@osaka.email.ne.jp>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
26263
diff
changeset
|
1980 (y-or-n-p "Replace? ")))) |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1981 (progn |
28510
6fb7a3864791
2000-04-07 Mikio Nakajima <minakaji@osaka.email.ne.jp>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
26263
diff
changeset
|
1982 (viper-hide-search-overlay) |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1983 (setq matched-pos (point)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1984 (if (not (stringp repl)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1985 (error "Can't perform Ex substitution: No previous replacement pattern")) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1986 (replace-match repl t))) |
21940 | 1987 ;;(end-of-line) |
1988 ;;(viper-forward-char-carefully) | |
1989 (goto-char eol-mark) | |
1990 ))))) | |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1991 (if matched-pos (goto-char matched-pos)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1992 (beginning-of-line) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1993 (if opt-c (message "done")))) |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
1994 |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1995 ;; Ex tag command |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1996 (defun ex-tag () |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1997 (let (tag) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1998 (save-window-excursion |
19079 | 1999 (setq viper-ex-work-buf (get-buffer-create viper-ex-work-buf-name)) |
2000 (set-buffer viper-ex-work-buf) | |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
2001 (skip-chars-forward " \t") |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
2002 (set-mark (point)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
2003 (skip-chars-forward "^ |\t\n") |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
2004 (setq tag (buffer-substring (mark t) (point)))) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
2005 (if (not (string= tag "")) (setq ex-tag tag)) |
19079 | 2006 (viper-change-state-to-emacs) |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
2007 (condition-case conds |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
2008 (progn |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
2009 (if (string= tag "") |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
2010 (find-tag ex-tag t) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
2011 (find-tag-other-window ex-tag)) |
19079 | 2012 (viper-change-state-to-vi)) |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
2013 (error |
19079 | 2014 (viper-change-state-to-vi) |
2015 (viper-message-conditions conds))))) | |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
2016 |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
2017 ;; Ex write command |
26263
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
21940
diff
changeset
|
2018 ;; ex-write doesn't support wildcards, because file completion is a better |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
21940
diff
changeset
|
2019 ;; mechanism. We also don't support # and % |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
21940
diff
changeset
|
2020 ;; because file history is a better mechanism. |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
2021 (defun ex-write (q-flag) |
19079 | 2022 (viper-default-ex-addresses t) |
2023 (viper-get-ex-file) | |
18047 | 2024 (let ((end (car ex-addresses)) |
2025 (beg (car (cdr ex-addresses))) | |
2026 (orig-buf (current-buffer)) | |
2027 (orig-buf-file-name (buffer-file-name)) | |
2028 (orig-buf-name (buffer-name)) | |
2029 (buff-changed-p (buffer-modified-p)) | |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
2030 temp-buf writing-same-file region |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
2031 file-exists writing-whole-file) |
19079 | 2032 (if (> beg end) (error viper-FirstAddrExceedsSecond)) |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
2033 (if ex-cmdfile |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
2034 (progn |
19079 | 2035 (viper-enlarge-region beg end) |
20206 | 2036 (shell-command-on-region (point) (mark t) |
2037 (concat ex-file ex-cmdfile-args))) | |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
2038 (if (and (string= ex-file "") (not (buffer-file-name))) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
2039 (setq ex-file |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
2040 (read-file-name |
26263
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
21940
diff
changeset
|
2041 (format "Buffer %s isn't visiting any file. File to save in: " |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
2042 (buffer-name))))) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
2043 |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
2044 (setq writing-whole-file (and (= (point-min) beg) (= (point-max) end)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
2045 ex-file (if (string= ex-file "") |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
2046 (buffer-file-name) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
2047 (expand-file-name ex-file))) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
2048 ;; if ex-file is a directory use the file portion of the buffer file name |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
2049 (if (and (file-directory-p ex-file) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
2050 buffer-file-name |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
2051 (not (file-directory-p buffer-file-name))) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
2052 (setq ex-file |
18047 | 2053 (concat (file-name-as-directory ex-file) |
2054 (file-name-nondirectory buffer-file-name)))) | |
2055 | |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
2056 (setq file-exists (file-exists-p ex-file) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
2057 writing-same-file (string= ex-file (buffer-file-name))) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
2058 |
21940 | 2059 ;; do actual writing |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
2060 (if (and writing-whole-file writing-same-file) |
21940 | 2061 ;; saving whole buffer in visited file |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
2062 (if (not (buffer-modified-p)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
2063 (message "(No changes need to be saved)") |
21940 | 2064 (viper-maybe-checkout (current-buffer)) |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
2065 (save-buffer) |
18047 | 2066 (save-restriction |
2067 (widen) | |
2068 (ex-write-info file-exists ex-file (point-min) (point-max)) | |
2069 )) | |
21940 | 2070 ;; writing to non-visited file and it already exists |
2071 (if (and file-exists (not writing-same-file) | |
2072 (not (yes-or-no-p | |
26263
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
21940
diff
changeset
|
2073 (format "File %s exists. Overwrite? " ex-file)))) |
21940 | 2074 (error "Quit")) |
2075 ;; writing a region or whole buffer to non-visited file | |
2076 (unwind-protect | |
2077 (save-excursion | |
2078 (viper-enlarge-region beg end) | |
2079 (setq region (buffer-substring (point) (mark t))) | |
2080 ;; create temp buffer for the region | |
2081 (setq temp-buf (get-buffer-create " *ex-write*")) | |
2082 (set-buffer temp-buf) | |
26263
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
21940
diff
changeset
|
2083 (if viper-xemacs-p |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
21940
diff
changeset
|
2084 (set-visited-file-name ex-file) |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
21940
diff
changeset
|
2085 (set-visited-file-name ex-file 'noquerry)) |
21940 | 2086 (erase-buffer) |
2087 (if (and file-exists ex-append) | |
2088 (insert-file-contents ex-file)) | |
2089 (goto-char (point-max)) | |
2090 (insert region) | |
2091 ;; ask user | |
2092 (viper-maybe-checkout (current-buffer)) | |
29163
ea19f6424132
2000-05-24 Michael Kifer <kifer@cs.sunysb.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
28510
diff
changeset
|
2093 (setq selective-display nil) |
21940 | 2094 (save-buffer) |
2095 (ex-write-info | |
2096 file-exists ex-file (point-min) (point-max)) | |
2097 ) | |
2098 ;; this must be under unwind-protect so that | |
2099 ;; temp-buf will be deleted in case of an error | |
2100 (set-buffer temp-buf) | |
2101 (set-buffer-modified-p nil) | |
2102 (kill-buffer temp-buf) | |
2103 ;; buffer/region has been written, now take care of details | |
2104 (set-buffer orig-buf))) | |
2105 ;; set the right file modification time | |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
2106 (if (and (buffer-file-name) writing-same-file) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
2107 (set-visited-file-modtime)) |
21940 | 2108 ;; prevent loss of data if saving part of the buffer in visited file |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
2109 (or writing-whole-file |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
2110 (not writing-same-file) |
21940 | 2111 (progn |
2112 (sit-for 2) | |
2113 (message "Warning: you have saved only part of the buffer!") | |
2114 (set-buffer-modified-p t))) | |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
2115 (if q-flag |
18839 | 2116 (if (< viper-expert-level 2) |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
2117 (save-buffers-kill-emacs) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
2118 (kill-buffer (current-buffer)))) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
2119 ))) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
2120 |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
2121 |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
2122 (defun ex-write-info (exists file-name beg end) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
2123 (message "`%s'%s %d lines, %d characters" |
19079 | 2124 (viper-abbreviate-file-name file-name) |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
2125 (if exists "" " [New file]") |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
2126 (count-lines beg (min (1+ end) (point-max))) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
2127 (- end beg))) |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
2128 |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
2129 ;; Ex yank command |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
2130 (defun ex-yank () |
19079 | 2131 (viper-default-ex-addresses) |
2132 (viper-get-ex-buffer) | |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
2133 (let ((end (car ex-addresses)) (beg (car (cdr ex-addresses)))) |
19079 | 2134 (if (> beg end) (error viper-FirstAddrExceedsSecond)) |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
2135 (save-excursion |
19079 | 2136 (viper-enlarge-region beg end) |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
2137 (exchange-point-and-mark) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
2138 (if (or ex-g-flag ex-g-variant) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
2139 (error "Can't execute `yank' within `global'")) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
2140 (if ex-count |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
2141 (progn |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
2142 (set-mark (point)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
2143 (forward-line (1- ex-count))) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
2144 (set-mark end)) |
19079 | 2145 (viper-enlarge-region (point) (mark t)) |
2146 (if ex-flag (error "`yank': %s" viper-SpuriousText)) | |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
2147 (if ex-buffer |
19079 | 2148 (cond ((viper-valid-register ex-buffer '(Letter)) |
2149 (viper-append-to-register | |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
2150 (downcase ex-buffer) (point) (mark t))) |
19079 | 2151 ((viper-valid-register ex-buffer) |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
2152 (copy-to-register ex-buffer (point) (mark t) nil)) |
19079 | 2153 (t (error viper-InvalidRegister ex-buffer)))) |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
2154 (copy-region-as-kill (point) (mark t))))) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
2155 |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
2156 ;; Execute shell command |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
2157 (defun ex-command () |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
2158 (let (command) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
2159 (save-window-excursion |
19079 | 2160 (setq viper-ex-work-buf (get-buffer-create viper-ex-work-buf-name)) |
2161 (set-buffer viper-ex-work-buf) | |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
2162 (skip-chars-forward " \t") |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
2163 (setq command (buffer-substring (point) (point-max))) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
2164 (end-of-line)) |
26263
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
21940
diff
changeset
|
2165 ;; replace # and % with the previous/current file |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
2166 (setq command (ex-expand-filsyms command (current-buffer))) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
2167 (if (and (> (length command) 0) (string= "!" (substring command 0 1))) |
19079 | 2168 (if viper-ex-last-shell-com |
2169 (setq command | |
2170 (concat viper-ex-last-shell-com (substring command 1))) | |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
2171 (error "No previous shell command"))) |
19079 | 2172 (setq viper-ex-last-shell-com command) |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
2173 (if (null ex-addresses) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
2174 (shell-command command) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
2175 (let ((end (car ex-addresses)) (beg (car (cdr ex-addresses)))) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
2176 (if (null beg) (setq beg end)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
2177 (save-excursion |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
2178 (goto-char beg) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
2179 (set-mark end) |
19079 | 2180 (viper-enlarge-region (point) (mark t)) |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
2181 (shell-command-on-region (point) (mark t) command t)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
2182 (goto-char beg))))) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
2183 |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
2184 ;; Print line number |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
2185 (defun ex-line-no () |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
2186 (message "%d" |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
2187 (1+ (count-lines |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
2188 (point-min) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
2189 (if (null ex-addresses) (point-max) (car ex-addresses)))))) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
2190 |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
2191 ;; Give information on the file visited by the current buffer |
19079 | 2192 (defun viper-info-on-file () |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
2193 (interactive) |
19079 | 2194 (let ((pos1 (viper-line-pos 'start)) |
2195 (pos2 (viper-line-pos 'end)) | |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
2196 lines file info) |
19079 | 2197 (setq lines (count-lines (point-min) (viper-line-pos 'end)) |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
2198 file (if (buffer-file-name) |
19079 | 2199 (concat (viper-abbreviate-file-name (buffer-file-name)) ":") |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
2200 (concat (buffer-name) " [Not visiting any file]:")) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
2201 info (format "line=%d/%d pos=%d/%d col=%d %s" |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
2202 (if (= pos1 pos2) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
2203 (1+ lines) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
2204 lines) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
2205 (count-lines (point-min) (point-max)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
2206 (point) (1- (point-max)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
2207 (1+ (current-column)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
2208 (if (buffer-modified-p) "[Modified]" "[Unchanged]"))) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
2209 (if (< (+ 1 (length info) (length file)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
2210 (window-width (minibuffer-window))) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
2211 (message (concat file " " info)) |
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
2212 (save-window-excursion |
19079 | 2213 (with-output-to-temp-buffer " *viper-info*" |
20003 | 2214 (princ (concat "\n" file "\n\n\t" info "\n\n"))) |
2215 (let ((inhibit-quit t)) | |
2216 (viper-set-unread-command-events (viper-read-event))) | |
19079 | 2217 (kill-buffer " *viper-info*"))) |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
2218 )) |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
2219 |
18289 | 2220 ;; display all variables set through :set |
2221 (defun ex-show-vars () | |
19079 | 2222 (with-output-to-temp-buffer " *viper-info*" |
2223 (princ (if viper-auto-indent | |
18289 | 2224 "autoindent (local)\n" "noautoindent (local)\n")) |
19079 | 2225 (princ (if (default-value 'viper-auto-indent) |
18289 | 2226 "autoindent (global) \n" "noautoindent (global) \n")) |
19079 | 2227 (princ (if viper-case-fold-search "ignorecase\n" "noignorecase\n")) |
2228 (princ (if viper-re-search "magic\n" "nomagic\n")) | |
18289 | 2229 (princ (if buffer-read-only "readonly\n" "noreadonly\n")) |
2230 (princ (if blink-matching-paren "showmatch\n" "noshowmatch\n")) | |
19079 | 2231 (princ (if viper-search-wrap-around-t "wrapscan\n" "nowrapscan\n")) |
2232 (princ (format "shiftwidth \t\t= %S\n" viper-shift-width)) | |
18289 | 2233 (princ (format "tabstop (local) \t= %S\n" tab-width)) |
2234 (princ (format "tabstop (global) \t= %S\n" (default-value 'tab-width))) | |
2235 (princ (format "wrapmargin (local) \t= %S\n" | |
2236 (- (window-width) fill-column))) | |
2237 (princ (format "wrapmargin (global) \t= %S\n" | |
2238 (- (window-width) (default-value 'fill-column)))) | |
2239 (princ (format "shell \t\t\t= %S\n" (if (boundp 'explicit-shell-file-name) | |
2240 explicit-shell-file-name | |
2241 'none))) | |
2242 )) | |
2243 | |
2244 | |
2245 | |
2246 | |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
2247 |
15482
b394c4c8b299
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
2248 ;;; viper-ex.el ends here |