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