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