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