annotate lisp/viper/viper-ex.el @ 180:add28d59e586

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