annotate lisp/emulation/viper-ex.el @ 85890:d505125b0b46

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