Mercurial > emacs
annotate lisp/emulation/viper-util.el @ 15672:d91ddc424d9a libc-960715
Generalize C90 alternative to all x90 machines.
author | Torbjorn Granlund <tege@swox.com> |
---|---|
date | Sun, 14 Jul 1996 18:09:15 +0000 |
parents | fadc581e380e |
children | fb60ef923bb5 |
rev | line source |
---|---|
10789 | 1 ;;; viper-util.el --- Utilities used by viper.el |
14169 | 2 |
14909
7ff1df13b124
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14588
diff
changeset
|
3 ;; Copyright (C) 1994, 1995, 1996 Free Software Foundation, Inc. |
11288 | 4 |
10789 | 5 ;; This file is part of GNU Emacs. |
6 | |
7 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
8 ;; it under the terms of the GNU General Public License as published by | |
9 ;; the Free Software Foundation; either version 2, or (at your option) | |
10 ;; any later version. | |
11 | |
12 ;; GNU Emacs is distributed in the hope that it will be useful, | |
13 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 ;; GNU General Public License for more details. | |
16 | |
17 ;; You should have received a copy of the GNU General Public License | |
14169 | 18 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
19 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
20 ;; Boston, MA 02111-1307, USA. | |
10789 | 21 |
14909
7ff1df13b124
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14588
diff
changeset
|
22 |
7ff1df13b124
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14588
diff
changeset
|
23 ;; Code |
7ff1df13b124
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14588
diff
changeset
|
24 |
10789 | 25 (require 'ring) |
26 | |
14909
7ff1df13b124
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14588
diff
changeset
|
27 ;; Compiler pacifier |
7ff1df13b124
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14588
diff
changeset
|
28 (defvar vip-overriding-map) |
7ff1df13b124
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14588
diff
changeset
|
29 (defvar pm-color-alist) |
7ff1df13b124
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14588
diff
changeset
|
30 (defvar zmacs-region-stays) |
7ff1df13b124
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14588
diff
changeset
|
31 (defvar vip-search-face) |
7ff1df13b124
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14588
diff
changeset
|
32 (defvar vip-minibuffer-current-face) |
7ff1df13b124
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14588
diff
changeset
|
33 (defvar vip-minibuffer-insert-face) |
7ff1df13b124
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14588
diff
changeset
|
34 (defvar vip-minibuffer-vi-face) |
7ff1df13b124
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14588
diff
changeset
|
35 (defvar vip-minibuffer-emacs-face) |
7ff1df13b124
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14588
diff
changeset
|
36 (defvar vip-replace-overlay-face) |
7ff1df13b124
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14588
diff
changeset
|
37 (defvar vip-minibuffer-overlay) |
7ff1df13b124
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14588
diff
changeset
|
38 (defvar vip-replace-overlay) |
7ff1df13b124
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14588
diff
changeset
|
39 (defvar vip-search-overlay) |
7ff1df13b124
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14588
diff
changeset
|
40 (defvar vip-replace-overlay-cursor-color) |
7ff1df13b124
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14588
diff
changeset
|
41 (defvar vip-intermediate-command) |
7ff1df13b124
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14588
diff
changeset
|
42 (defvar vip-use-replace-region-delimiters) |
7ff1df13b124
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14588
diff
changeset
|
43 (defvar vip-fast-keyseq-timeout) |
7ff1df13b124
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14588
diff
changeset
|
44 (defvar vip-related-files-and-buffers-ring) |
7ff1df13b124
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14588
diff
changeset
|
45 ;; end compiler pacifier |
7ff1df13b124
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14588
diff
changeset
|
46 |
7ff1df13b124
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14588
diff
changeset
|
47 ;; Is it XEmacs? |
12204
a7bd91d4af97
(vip-over-whitespace-line): new function.
Karl Heuer <kwzh@gnu.org>
parents:
12139
diff
changeset
|
48 (defconst vip-xemacs-p (string-match "\\(Lucid\\|XEmacs\\)" emacs-version)) |
14909
7ff1df13b124
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14588
diff
changeset
|
49 ;; Is it Emacs? |
12139
e16c06646396
(vip-event-key): now handles keys 128--255 as meta-chars.
Karl Heuer <kwzh@gnu.org>
parents:
11288
diff
changeset
|
50 (defconst vip-emacs-p (not vip-xemacs-p)) |
e16c06646396
(vip-event-key): now handles keys 128--255 as meta-chars.
Karl Heuer <kwzh@gnu.org>
parents:
11288
diff
changeset
|
51 ;; Tell whether we are running as a window application or on a TTY |
e16c06646396
(vip-event-key): now handles keys 128--255 as meta-chars.
Karl Heuer <kwzh@gnu.org>
parents:
11288
diff
changeset
|
52 (defsubst vip-device-type () |
e16c06646396
(vip-event-key): now handles keys 128--255 as meta-chars.
Karl Heuer <kwzh@gnu.org>
parents:
11288
diff
changeset
|
53 (if vip-emacs-p |
e16c06646396
(vip-event-key): now handles keys 128--255 as meta-chars.
Karl Heuer <kwzh@gnu.org>
parents:
11288
diff
changeset
|
54 window-system |
e16c06646396
(vip-event-key): now handles keys 128--255 as meta-chars.
Karl Heuer <kwzh@gnu.org>
parents:
11288
diff
changeset
|
55 (device-type (selected-device)))) |
e16c06646396
(vip-event-key): now handles keys 128--255 as meta-chars.
Karl Heuer <kwzh@gnu.org>
parents:
11288
diff
changeset
|
56 ;; in XEmacs: device-type is tty on tty and stream in batch. |
14581
4951b11970a1
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14384
diff
changeset
|
57 (defun vip-window-display-p () |
12139
e16c06646396
(vip-event-key): now handles keys 128--255 as meta-chars.
Karl Heuer <kwzh@gnu.org>
parents:
11288
diff
changeset
|
58 (and (vip-device-type) (not (memq (vip-device-type) '(tty stream))))) |
10789 | 59 |
14581
4951b11970a1
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14384
diff
changeset
|
60 (defvar vip-force-faces nil |
4951b11970a1
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14384
diff
changeset
|
61 "If t, Viper will think that it is running on a display that supports faces. |
4951b11970a1
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14384
diff
changeset
|
62 This is provided as a temporary relief for users of face-capable displays |
4951b11970a1
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14384
diff
changeset
|
63 that Viper doesn't know about.") |
4951b11970a1
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14384
diff
changeset
|
64 |
4951b11970a1
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14384
diff
changeset
|
65 (defun vip-has-face-support-p () |
4951b11970a1
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14384
diff
changeset
|
66 (cond ((vip-window-display-p)) |
4951b11970a1
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14384
diff
changeset
|
67 (vip-force-faces) |
4951b11970a1
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14384
diff
changeset
|
68 (vip-emacs-p (memq (vip-device-type) '(pc))) |
4951b11970a1
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14384
diff
changeset
|
69 (vip-xemacs-p (memq (vip-device-type) '(tty pc))))) |
4951b11970a1
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14384
diff
changeset
|
70 |
10789 | 71 |
72 ;;; Macros | |
73 | |
74 (defmacro vip-deflocalvar (var default-value &optional documentation) | |
75 (` (progn | |
76 (defvar (, var) (, default-value) | |
77 (, (format "%s\n\(buffer local\)" documentation))) | |
78 (make-variable-buffer-local '(, var)) | |
79 ))) | |
80 | |
81 (defmacro vip-loop (count body) | |
82 "(vip-loop COUNT BODY) Execute BODY COUNT times." | |
83 (list 'let (list (list 'count count)) | |
84 (list 'while '(> count 0) | |
85 body | |
86 '(setq count (1- count)) | |
87 ))) | |
88 | |
89 (defmacro vip-buffer-live-p (buf) | |
90 (` (and (, buf) (get-buffer (, buf)) (buffer-name (get-buffer (, buf)))))) | |
91 | |
92 ;; return buffer-specific macro definition, given a full macro definition | |
93 (defmacro vip-kbd-buf-alist (macro-elt) | |
94 (` (nth 1 (, macro-elt)))) | |
95 ;; get a pair: (curr-buffer . macro-definition) | |
96 (defmacro vip-kbd-buf-pair (macro-elt) | |
97 (` (assoc (buffer-name) (vip-kbd-buf-alist (, macro-elt))))) | |
98 ;; get macro definition for current buffer | |
99 (defmacro vip-kbd-buf-definition (macro-elt) | |
100 (` (cdr (vip-kbd-buf-pair (, macro-elt))))) | |
101 | |
102 ;; return mode-specific macro definitions, given a full macro definition | |
103 (defmacro vip-kbd-mode-alist (macro-elt) | |
104 (` (nth 2 (, macro-elt)))) | |
105 ;; get a pair: (major-mode . macro-definition) | |
106 (defmacro vip-kbd-mode-pair (macro-elt) | |
107 (` (assoc major-mode (vip-kbd-mode-alist (, macro-elt))))) | |
108 ;; get macro definition for the current major mode | |
109 (defmacro vip-kbd-mode-definition (macro-elt) | |
110 (` (cdr (vip-kbd-mode-pair (, macro-elt))))) | |
111 | |
112 ;; return global macro definition, given a full macro definition | |
113 (defmacro vip-kbd-global-pair (macro-elt) | |
114 (` (nth 3 (, macro-elt)))) | |
115 ;; get global macro definition from an elt of macro-alist | |
116 (defmacro vip-kbd-global-definition (macro-elt) | |
117 (` (cdr (vip-kbd-global-pair (, macro-elt))))) | |
118 | |
119 ;; last elt of a sequence | |
120 (defsubst vip-seq-last-elt (seq) | |
121 (elt seq (1- (length seq)))) | |
122 | |
123 ;; Check if arg is a valid character for register | |
124 ;; TYPE is a list that can contain `letter', `Letter', and `digit'. | |
125 ;; Letter means lowercase letters, Letter means uppercase letters, and | |
126 ;; digit means digits from 1 to 9. | |
127 ;; If TYPE is nil, then down/uppercase letters and digits are allowed. | |
128 (defun vip-valid-register (reg &optional type) | |
129 (or type (setq type '(letter Letter digit))) | |
130 (or (if (memq 'letter type) | |
131 (and (<= ?a reg) (<= reg ?z))) | |
132 (if (memq 'digit type) | |
133 (and (<= ?1 reg) (<= reg ?9))) | |
134 (if (memq 'Letter type) | |
135 (and (<= ?A reg) (<= reg ?Z))) | |
136 )) | |
137 | |
12139
e16c06646396
(vip-event-key): now handles keys 128--255 as meta-chars.
Karl Heuer <kwzh@gnu.org>
parents:
11288
diff
changeset
|
138 ;; checks if object is a marker, has a buffer, and points to within that buffer |
10789 | 139 (defun vip-valid-marker (marker) |
12139
e16c06646396
(vip-event-key): now handles keys 128--255 as meta-chars.
Karl Heuer <kwzh@gnu.org>
parents:
11288
diff
changeset
|
140 (if (and (markerp marker) (marker-buffer marker)) |
10789 | 141 (let ((buf (marker-buffer marker)) |
142 (pos (marker-position marker))) | |
143 (save-excursion | |
144 (set-buffer buf) | |
145 (and (<= pos (point-max)) (<= (point-min) pos)))))) | |
146 | |
147 | |
148 (defvar vip-minibuffer-overlay-priority 300) | |
149 (defvar vip-replace-overlay-priority 400) | |
150 (defvar vip-search-overlay-priority 500) | |
151 | |
152 | |
153 ;;; XEmacs support | |
154 | |
155 (if vip-xemacs-p | |
156 (progn | |
157 (fset 'vip-read-event (symbol-function 'next-command-event)) | |
158 (fset 'vip-make-overlay (symbol-function 'make-extent)) | |
159 (fset 'vip-overlay-start (symbol-function 'extent-start-position)) | |
160 (fset 'vip-overlay-end (symbol-function 'extent-end-position)) | |
161 (fset 'vip-overlay-put (symbol-function 'set-extent-property)) | |
162 (fset 'vip-overlay-p (symbol-function 'extentp)) | |
163 (fset 'vip-overlay-get (symbol-function 'extent-property)) | |
164 (fset 'vip-move-overlay (symbol-function 'set-extent-endpoints)) | |
12139
e16c06646396
(vip-event-key): now handles keys 128--255 as meta-chars.
Karl Heuer <kwzh@gnu.org>
parents:
11288
diff
changeset
|
165 (if (vip-window-display-p) |
e16c06646396
(vip-event-key): now handles keys 128--255 as meta-chars.
Karl Heuer <kwzh@gnu.org>
parents:
11288
diff
changeset
|
166 (fset 'vip-iconify (symbol-function 'iconify-frame))) |
14581
4951b11970a1
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14384
diff
changeset
|
167 (cond ((vip-has-face-support-p) |
10789 | 168 (fset 'vip-get-face (symbol-function 'get-face)) |
169 (fset 'vip-color-defined-p | |
12139
e16c06646396
(vip-event-key): now handles keys 128--255 as meta-chars.
Karl Heuer <kwzh@gnu.org>
parents:
11288
diff
changeset
|
170 (symbol-function 'valid-color-name-p)) |
e16c06646396
(vip-event-key): now handles keys 128--255 as meta-chars.
Karl Heuer <kwzh@gnu.org>
parents:
11288
diff
changeset
|
171 ))) |
10789 | 172 (fset 'vip-read-event (symbol-function 'read-event)) |
173 (fset 'vip-make-overlay (symbol-function 'make-overlay)) | |
174 (fset 'vip-overlay-start (symbol-function 'overlay-start)) | |
175 (fset 'vip-overlay-end (symbol-function 'overlay-end)) | |
176 (fset 'vip-overlay-put (symbol-function 'overlay-put)) | |
177 (fset 'vip-overlay-p (symbol-function 'overlayp)) | |
178 (fset 'vip-overlay-get (symbol-function 'overlay-get)) | |
179 (fset 'vip-move-overlay (symbol-function 'move-overlay)) | |
12139
e16c06646396
(vip-event-key): now handles keys 128--255 as meta-chars.
Karl Heuer <kwzh@gnu.org>
parents:
11288
diff
changeset
|
180 (if (vip-window-display-p) |
10789 | 181 (fset 'vip-iconify (symbol-function 'iconify-or-deiconify-frame))) |
14581
4951b11970a1
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14384
diff
changeset
|
182 (cond ((vip-has-face-support-p) |
10789 | 183 (fset 'vip-get-face (symbol-function 'internal-get-face)) |
184 (fset 'vip-color-defined-p (symbol-function 'x-color-defined-p)) | |
12139
e16c06646396
(vip-event-key): now handles keys 128--255 as meta-chars.
Karl Heuer <kwzh@gnu.org>
parents:
11288
diff
changeset
|
185 ))) |
e16c06646396
(vip-event-key): now handles keys 128--255 as meta-chars.
Karl Heuer <kwzh@gnu.org>
parents:
11288
diff
changeset
|
186 |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
187 (fset 'vip-characterp |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
188 (symbol-function |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
189 (if vip-xemacs-p 'characterp 'integerp))) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
190 |
12139
e16c06646396
(vip-event-key): now handles keys 128--255 as meta-chars.
Karl Heuer <kwzh@gnu.org>
parents:
11288
diff
changeset
|
191 (defsubst vip-color-display-p () |
e16c06646396
(vip-event-key): now handles keys 128--255 as meta-chars.
Karl Heuer <kwzh@gnu.org>
parents:
11288
diff
changeset
|
192 (if vip-emacs-p |
e16c06646396
(vip-event-key): now handles keys 128--255 as meta-chars.
Karl Heuer <kwzh@gnu.org>
parents:
11288
diff
changeset
|
193 (x-display-color-p) |
e16c06646396
(vip-event-key): now handles keys 128--255 as meta-chars.
Karl Heuer <kwzh@gnu.org>
parents:
11288
diff
changeset
|
194 (eq (device-class (selected-device)) 'color))) |
14909
7ff1df13b124
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14588
diff
changeset
|
195 |
7ff1df13b124
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14588
diff
changeset
|
196 (defsubst vip-get-cursor-color () |
15578
fadc581e380e
(vip-read-key): inhibit quit added.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
197 (if vip-emacs-p |
fadc581e380e
(vip-read-key): inhibit quit added.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
198 (cdr (assoc 'cursor-color (frame-parameters))) |
fadc581e380e
(vip-read-key): inhibit quit added.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
199 (color-instance-name (frame-property (selected-frame) 'cursor-color)))) |
fadc581e380e
(vip-read-key): inhibit quit added.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
200 |
10789 | 201 |
202 ;; OS/2 | |
12139
e16c06646396
(vip-event-key): now handles keys 128--255 as meta-chars.
Karl Heuer <kwzh@gnu.org>
parents:
11288
diff
changeset
|
203 (cond ((eq (vip-device-type) 'pm) |
10789 | 204 (fset 'vip-color-defined-p |
205 (function (lambda (color) (assoc color pm-color-alist)))))) | |
206 | |
207 ;; needed to smooth out the difference between Emacs and XEmacs | |
208 (defsubst vip-italicize-face (face) | |
209 (if vip-xemacs-p | |
210 (make-face-italic face) | |
211 (make-face-italic face nil 'noerror))) | |
212 | |
213 ;; test if display is color and the colors are defined | |
214 (defsubst vip-can-use-colors (&rest colors) | |
12139
e16c06646396
(vip-event-key): now handles keys 128--255 as meta-chars.
Karl Heuer <kwzh@gnu.org>
parents:
11288
diff
changeset
|
215 (if (vip-color-display-p) |
10789 | 216 (not (memq nil (mapcar 'vip-color-defined-p colors))) |
217 )) | |
218 | |
14233
396316e5fbe6
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14169
diff
changeset
|
219 (defun vip-hide-face (face) |
14581
4951b11970a1
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14384
diff
changeset
|
220 (if (and (vip-has-face-support-p) vip-emacs-p) |
14233
396316e5fbe6
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14169
diff
changeset
|
221 (add-to-list 'facemenu-unlisted-faces face))) |
396316e5fbe6
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14169
diff
changeset
|
222 |
396316e5fbe6
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14169
diff
changeset
|
223 ;; cursor colors |
10789 | 224 (defun vip-change-cursor-color (new-color) |
12139
e16c06646396
(vip-event-key): now handles keys 128--255 as meta-chars.
Karl Heuer <kwzh@gnu.org>
parents:
11288
diff
changeset
|
225 (if (and (vip-window-display-p) (vip-color-display-p) |
e16c06646396
(vip-event-key): now handles keys 128--255 as meta-chars.
Karl Heuer <kwzh@gnu.org>
parents:
11288
diff
changeset
|
226 (stringp new-color) (vip-color-defined-p new-color) |
e16c06646396
(vip-event-key): now handles keys 128--255 as meta-chars.
Karl Heuer <kwzh@gnu.org>
parents:
11288
diff
changeset
|
227 (not (string= new-color (vip-get-cursor-color)))) |
e16c06646396
(vip-event-key): now handles keys 128--255 as meta-chars.
Karl Heuer <kwzh@gnu.org>
parents:
11288
diff
changeset
|
228 (modify-frame-parameters |
e16c06646396
(vip-event-key): now handles keys 128--255 as meta-chars.
Karl Heuer <kwzh@gnu.org>
parents:
11288
diff
changeset
|
229 (selected-frame) (list (cons 'cursor-color new-color))))) |
10789 | 230 |
231 (defsubst vip-save-cursor-color () | |
12139
e16c06646396
(vip-event-key): now handles keys 128--255 as meta-chars.
Karl Heuer <kwzh@gnu.org>
parents:
11288
diff
changeset
|
232 (if (and (vip-window-display-p) (vip-color-display-p)) |
e16c06646396
(vip-event-key): now handles keys 128--255 as meta-chars.
Karl Heuer <kwzh@gnu.org>
parents:
11288
diff
changeset
|
233 (let ((color (vip-get-cursor-color))) |
10789 | 234 (if (and (stringp color) (vip-color-defined-p color) |
235 (not (string= color vip-replace-overlay-cursor-color))) | |
236 (vip-overlay-put vip-replace-overlay 'vip-cursor-color color))))) | |
237 | |
238 (defsubst vip-restore-cursor-color () | |
239 (vip-change-cursor-color | |
240 (vip-overlay-get vip-replace-overlay 'vip-cursor-color))) | |
241 | |
242 | |
243 ;; Check the current version against the major and minor version numbers | |
244 ;; using op: cur-vers op major.minor If emacs-major-version or | |
245 ;; emacs-minor-version are not defined, we assume that the current version | |
246 ;; is hopelessly outdated. We assume that emacs-major-version and | |
247 ;; emacs-minor-version are defined. Otherwise, for Emacs/XEmacs 19, if the | |
248 ;; current minor version is < 10 (xemacs) or < 23 (emacs) the return value | |
249 ;; will be nil (when op is =, >, or >=) and t (when op is <, <=), which may be | |
250 ;; incorrect. However, this gives correct result in our cases, since we are | |
251 ;; testing for sufficiently high Emacs versions. | |
252 (defun vip-check-version (op major minor &optional type-of-emacs) | |
253 (if (and (boundp 'emacs-major-version) (boundp 'emacs-minor-version)) | |
254 (and (cond ((eq type-of-emacs 'xemacs) vip-xemacs-p) | |
255 ((eq type-of-emacs 'emacs) vip-emacs-p) | |
256 (t t)) | |
257 (cond ((eq op '=) (and (= emacs-minor-version minor) | |
258 (= emacs-major-version major))) | |
259 ((memq op '(> >= < <=)) | |
260 (and (or (funcall op emacs-major-version major) | |
261 (= emacs-major-version major)) | |
262 (if (= emacs-major-version major) | |
263 (funcall op emacs-minor-version minor) | |
264 t))) | |
265 (t | |
266 (error "%S: Invalid op in vip-check-version" op)))) | |
267 (cond ((memq op '(= > >=)) nil) | |
268 ((memq op '(< <=)) t)))) | |
12693
321b2ad48a9c
(vip-add-hook,vip-remove-hook): new functions.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12212
diff
changeset
|
269 |
321b2ad48a9c
(vip-add-hook,vip-remove-hook): new functions.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12212
diff
changeset
|
270 ;;;; warn if it is a wrong version of emacs |
321b2ad48a9c
(vip-add-hook,vip-remove-hook): new functions.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12212
diff
changeset
|
271 ;;(if (or (vip-check-version '< 19 29 'emacs) |
321b2ad48a9c
(vip-add-hook,vip-remove-hook): new functions.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12212
diff
changeset
|
272 ;; (vip-check-version '< 19 12 'xemacs)) |
321b2ad48a9c
(vip-add-hook,vip-remove-hook): new functions.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12212
diff
changeset
|
273 ;; (progn |
321b2ad48a9c
(vip-add-hook,vip-remove-hook): new functions.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12212
diff
changeset
|
274 ;; (with-output-to-temp-buffer " *vip-info*" |
321b2ad48a9c
(vip-add-hook,vip-remove-hook): new functions.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12212
diff
changeset
|
275 ;; (switch-to-buffer " *vip-info*") |
321b2ad48a9c
(vip-add-hook,vip-remove-hook): new functions.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12212
diff
changeset
|
276 ;; (insert |
321b2ad48a9c
(vip-add-hook,vip-remove-hook): new functions.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12212
diff
changeset
|
277 ;; (format " |
321b2ad48a9c
(vip-add-hook,vip-remove-hook): new functions.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12212
diff
changeset
|
278 ;; |
321b2ad48a9c
(vip-add-hook,vip-remove-hook): new functions.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12212
diff
changeset
|
279 ;;This version of Viper requires |
321b2ad48a9c
(vip-add-hook,vip-remove-hook): new functions.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12212
diff
changeset
|
280 ;; |
321b2ad48a9c
(vip-add-hook,vip-remove-hook): new functions.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12212
diff
changeset
|
281 ;;\t Emacs 19.29 and higher |
321b2ad48a9c
(vip-add-hook,vip-remove-hook): new functions.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12212
diff
changeset
|
282 ;;\t OR |
321b2ad48a9c
(vip-add-hook,vip-remove-hook): new functions.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12212
diff
changeset
|
283 ;;\t XEmacs 19.12 and higher |
321b2ad48a9c
(vip-add-hook,vip-remove-hook): new functions.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12212
diff
changeset
|
284 ;; |
321b2ad48a9c
(vip-add-hook,vip-remove-hook): new functions.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12212
diff
changeset
|
285 ;;It is unlikely to work under Emacs version %s |
321b2ad48a9c
(vip-add-hook,vip-remove-hook): new functions.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12212
diff
changeset
|
286 ;;that you are using... " emacs-version)) |
321b2ad48a9c
(vip-add-hook,vip-remove-hook): new functions.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12212
diff
changeset
|
287 ;; |
321b2ad48a9c
(vip-add-hook,vip-remove-hook): new functions.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12212
diff
changeset
|
288 ;; (if noninteractive |
321b2ad48a9c
(vip-add-hook,vip-remove-hook): new functions.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12212
diff
changeset
|
289 ;; () |
321b2ad48a9c
(vip-add-hook,vip-remove-hook): new functions.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12212
diff
changeset
|
290 ;; (beep 1) |
321b2ad48a9c
(vip-add-hook,vip-remove-hook): new functions.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12212
diff
changeset
|
291 ;; (beep 1) |
321b2ad48a9c
(vip-add-hook,vip-remove-hook): new functions.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12212
diff
changeset
|
292 ;; (insert "\n\nType any key to continue... ") |
321b2ad48a9c
(vip-add-hook,vip-remove-hook): new functions.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12212
diff
changeset
|
293 ;; (vip-read-event))) |
321b2ad48a9c
(vip-add-hook,vip-remove-hook): new functions.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12212
diff
changeset
|
294 ;; (kill-buffer " *vip-info*"))) |
10789 | 295 |
296 | |
297 (defun vip-get-visible-buffer-window (wind) | |
298 (if vip-xemacs-p | |
299 (get-buffer-window wind t) | |
300 (get-buffer-window wind 'visible))) | |
301 | |
302 | |
12139
e16c06646396
(vip-event-key): now handles keys 128--255 as meta-chars.
Karl Heuer <kwzh@gnu.org>
parents:
11288
diff
changeset
|
303 ;; Return line position. |
e16c06646396
(vip-event-key): now handles keys 128--255 as meta-chars.
Karl Heuer <kwzh@gnu.org>
parents:
11288
diff
changeset
|
304 ;; If pos is 'start then returns position of line start. |
e16c06646396
(vip-event-key): now handles keys 128--255 as meta-chars.
Karl Heuer <kwzh@gnu.org>
parents:
11288
diff
changeset
|
305 ;; If pos is 'end, returns line end. If pos is 'mid, returns line center. |
e16c06646396
(vip-event-key): now handles keys 128--255 as meta-chars.
Karl Heuer <kwzh@gnu.org>
parents:
11288
diff
changeset
|
306 ;; Pos = 'indent returns beginning of indentation. |
e16c06646396
(vip-event-key): now handles keys 128--255 as meta-chars.
Karl Heuer <kwzh@gnu.org>
parents:
11288
diff
changeset
|
307 ;; Otherwise, returns point. Current point is not moved in any case." |
10789 | 308 (defun vip-line-pos (pos) |
309 (let ((cur-pos (point)) | |
310 (result)) | |
311 (cond | |
312 ((equal pos 'start) | |
313 (beginning-of-line)) | |
314 ((equal pos 'end) | |
315 (end-of-line)) | |
316 ((equal pos 'mid) | |
317 (goto-char (+ (vip-line-pos 'start) (vip-line-pos 'end) 2))) | |
318 ((equal pos 'indent) | |
319 (back-to-indentation)) | |
320 (t nil)) | |
321 (setq result (point)) | |
322 (goto-char cur-pos) | |
323 result)) | |
324 | |
325 | |
12139
e16c06646396
(vip-event-key): now handles keys 128--255 as meta-chars.
Karl Heuer <kwzh@gnu.org>
parents:
11288
diff
changeset
|
326 ;; Like move-marker but creates a virgin marker if arg isn't already a marker. |
e16c06646396
(vip-event-key): now handles keys 128--255 as meta-chars.
Karl Heuer <kwzh@gnu.org>
parents:
11288
diff
changeset
|
327 ;; The first argument must eval to a variable name. |
e16c06646396
(vip-event-key): now handles keys 128--255 as meta-chars.
Karl Heuer <kwzh@gnu.org>
parents:
11288
diff
changeset
|
328 ;; Arguments: (var-name position &optional buffer). |
e16c06646396
(vip-event-key): now handles keys 128--255 as meta-chars.
Karl Heuer <kwzh@gnu.org>
parents:
11288
diff
changeset
|
329 ;; |
e16c06646396
(vip-event-key): now handles keys 128--255 as meta-chars.
Karl Heuer <kwzh@gnu.org>
parents:
11288
diff
changeset
|
330 ;; This is useful for moving markers that are supposed to be local. |
e16c06646396
(vip-event-key): now handles keys 128--255 as meta-chars.
Karl Heuer <kwzh@gnu.org>
parents:
11288
diff
changeset
|
331 ;; For this, VAR-NAME should be made buffer-local with nil as a default. |
e16c06646396
(vip-event-key): now handles keys 128--255 as meta-chars.
Karl Heuer <kwzh@gnu.org>
parents:
11288
diff
changeset
|
332 ;; Then, each time this var is used in `vip-move-marker-locally' in a new |
e16c06646396
(vip-event-key): now handles keys 128--255 as meta-chars.
Karl Heuer <kwzh@gnu.org>
parents:
11288
diff
changeset
|
333 ;; buffer, a new marker will be created. |
10789 | 334 (defun vip-move-marker-locally (var pos &optional buffer) |
335 (if (markerp (eval var)) | |
336 () | |
337 (set var (make-marker))) | |
338 (move-marker (eval var) pos buffer)) | |
339 | |
340 | |
12139
e16c06646396
(vip-event-key): now handles keys 128--255 as meta-chars.
Karl Heuer <kwzh@gnu.org>
parents:
11288
diff
changeset
|
341 ;; Print CONDITIONS as a message. |
10789 | 342 (defun vip-message-conditions (conditions) |
343 (let ((case (car conditions)) (msg (cdr conditions))) | |
344 (if (null msg) | |
345 (message "%s" case) | |
346 (message "%s: %s" case (mapconcat 'prin1-to-string msg " "))) | |
347 (beep 1))) | |
348 | |
12139
e16c06646396
(vip-event-key): now handles keys 128--255 as meta-chars.
Karl Heuer <kwzh@gnu.org>
parents:
11288
diff
changeset
|
349 |
10789 | 350 |
351 ;;; List/alist utilities | |
352 | |
12139
e16c06646396
(vip-event-key): now handles keys 128--255 as meta-chars.
Karl Heuer <kwzh@gnu.org>
parents:
11288
diff
changeset
|
353 ;; Convert LIST to an alist |
10789 | 354 (defun vip-list-to-alist (lst) |
355 (let ((alist)) | |
356 (while lst | |
357 (setq alist (cons (list (car lst)) alist)) | |
358 (setq lst (cdr lst))) | |
359 alist)) | |
360 | |
12139
e16c06646396
(vip-event-key): now handles keys 128--255 as meta-chars.
Karl Heuer <kwzh@gnu.org>
parents:
11288
diff
changeset
|
361 ;; Convert ALIST to a list. |
10789 | 362 (defun vip-alist-to-list (alst) |
363 (let ((lst)) | |
364 (while alst | |
365 (setq lst (cons (car (car alst)) lst)) | |
366 (setq alst (cdr alst))) | |
367 lst)) | |
368 | |
12139
e16c06646396
(vip-event-key): now handles keys 128--255 as meta-chars.
Karl Heuer <kwzh@gnu.org>
parents:
11288
diff
changeset
|
369 ;; Filter ALIST using REGEXP. Return alist whose elements match the regexp. |
10789 | 370 (defun vip-filter-alist (regexp alst) |
371 (interactive "s x") | |
372 (let ((outalst) (inalst alst)) | |
373 (while (car inalst) | |
374 (if (string-match regexp (car (car inalst))) | |
375 (setq outalst (cons (car inalst) outalst))) | |
376 (setq inalst (cdr inalst))) | |
377 outalst)) | |
378 | |
12139
e16c06646396
(vip-event-key): now handles keys 128--255 as meta-chars.
Karl Heuer <kwzh@gnu.org>
parents:
11288
diff
changeset
|
379 ;; Filter LIST using REGEXP. Return list whose elements match the regexp. |
10789 | 380 (defun vip-filter-list (regexp lst) |
381 (interactive "s x") | |
382 (let ((outlst) (inlst lst)) | |
383 (while (car inlst) | |
384 (if (string-match regexp (car inlst)) | |
385 (setq outlst (cons (car inlst) outlst))) | |
386 (setq inlst (cdr inlst))) | |
387 outlst)) | |
388 | |
389 | |
390 ;; Append LIS2 to LIS1, both alists, by side-effect and returns LIS1 | |
391 ;; LIS2 is modified by filtering it: deleting its members of the form | |
392 ;; \(car elt\) such that (car elt') is in LIS1. | |
393 (defun vip-append-filter-alist (lis1 lis2) | |
394 (let ((temp lis1) | |
395 elt) | |
396 | |
397 ;;filter-append the second list | |
398 (while temp | |
399 ;; delete all occurrences | |
400 (while (setq elt (assoc (car (car temp)) lis2)) | |
401 (setq lis2 (delq elt lis2))) | |
402 (setq temp (cdr temp))) | |
403 | |
404 (nconc lis1 lis2))) | |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
405 |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
406 |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
407 ;;; Support for :e and file globbing |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
408 |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
409 (defun vip-ex-nontrivial-find-file-unix (filespec) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
410 "Glob the file spec and visit all files matching the spec. |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
411 This function is designed to work under Unix. It may also work under VMS. |
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 Users who prefer other types of shells should write their own version of this |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
414 function and set the variable `ex-nontrivial-find-file-function' |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
415 appropriately." |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
416 (let ((gshell |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
417 (cond (ex-unix-type-shell shell-file-name) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
418 ((memq system-type '(vax-vms axp-vms)) "*dcl*") ; VAX VMS |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
419 (t "sh"))) ; probably Unix anyway |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
420 (gshell-options |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
421 ;; using cond in anticipation of further additions |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
422 (cond (ex-unix-type-shell-options) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
423 )) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
424 (command (cond (vip-ms-style-os-p (format "\"ls -1 %s\"" filespec)) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
425 (t (format "ls -1 %s" filespec)))) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
426 file-list) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
427 (save-excursion |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
428 (set-buffer (setq tmp-buf (get-buffer-create vip-ex-tmp-buf-name))) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
429 (erase-buffer) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
430 (setq status |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
431 (if gshell-options |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
432 (call-process gshell nil t nil |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
433 gshell-options |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
434 "-c" |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
435 command) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
436 (call-process gshell nil t nil |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
437 "-c" |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
438 command))) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
439 (goto-char (point-min)) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
440 ;; Issue an error, if no match. |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
441 (if (> status 0) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
442 (save-excursion |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
443 (skip-chars-forward " \t\n\j") |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
444 (if (looking-at "ls:") |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
445 (vip-forward-Word 1)) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
446 (error "%s: %s" |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
447 (if (stringp gshell) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
448 gshell |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
449 "shell") |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
450 (buffer-substring (point) (vip-line-pos 'end))) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
451 )) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
452 (goto-char (point-min)) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
453 (setq file-list (vip-get-filenames-from-buffer 'one-per-line))) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
454 |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
455 (mapcar 'find-file file-list) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
456 )) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
457 |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
458 (defun vip-ex-nontrivial-find-file-ms (filespec) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
459 "Glob the file spec and visit all files matching the spec. |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
460 This function is designed to work under MS type systems, such as NT, W95, and |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
461 DOS. It may also work under OS/2. |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
462 |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
463 The users of Unix-type shells should be able to use |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
464 `vip-ex-nontrivial-find-file-unix', making it into the value of the variable |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
465 `ex-nontrivial-find-file-function'. If this doesn't work, the user may have |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
466 to write a custom function, similar to `vip-ex-nontrivial-find-file-unix'." |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
467 (save-excursion |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
468 (set-buffer (setq tmp-buf (get-buffer-create vip-ex-tmp-buf-name))) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
469 (erase-buffer) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
470 (insert filespec) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
471 (goto-char (point-min)) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
472 (mapcar 'find-file |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
473 (vip-glob-ms-windows-files (vip-get-filenames-from-buffer))) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
474 )) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
475 |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
476 |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
477 ;; Interpret the stuff in the buffer as a list of file names |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
478 ;; return a list of file names listed in the buffer beginning at point |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
479 ;; If optional arg is supplied, assume each filename is listed on a separate |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
480 ;; line |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
481 (defun vip-get-filenames-from-buffer (one-per-line) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
482 (let ((skip-chars (if one-per-line "\t\n" " \t\n")) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
483 result fname delim) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
484 (skip-chars-forward skip-chars) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
485 (while (not (eobp)) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
486 (if (cond ((looking-at "\"") |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
487 (setq delim ?\") |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
488 (re-search-forward "[^\"]+" nil t)) ; noerror |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
489 ((looking-at "'") |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
490 (setq delim ?') |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
491 (re-search-forward "[^']+" nil t)) ; noerror |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
492 (t |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
493 (re-search-forward |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
494 (concat "[^" skip-chars "]+") nil t))) ;noerror |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
495 (setq fname |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
496 (buffer-substring (match-beginning 0) (match-end 0)))) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
497 (if delim |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
498 (forward-char 1)) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
499 (skip-chars-forward " \t\n") |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
500 (setq result (cons fname result))) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
501 result)) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
502 |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
503 ;; convert MS-DOS wildcards to regexp |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
504 (defun vip-wildcard-to-regexp (wcard) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
505 (save-excursion |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
506 (set-buffer (setq tmp-buf (get-buffer-create vip-ex-tmp-buf-name))) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
507 (erase-buffer) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
508 (insert wcard) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
509 (goto-char (point-min)) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
510 (while (not (eobp)) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
511 (skip-chars-forward "^*?.\\\\") |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
512 (cond ((eq (char-after (point)) ?*) (insert ".")(forward-char 1)) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
513 ((eq (char-after (point)) ?.) (insert "\\")(forward-char 1)) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
514 ((eq (char-after (point)) ?\\) (insert "\\")(forward-char 1)) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
515 ((eq (char-after (point)) ??) (delete-char 1)(insert "."))) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
516 ) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
517 (buffer-string) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
518 )) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
519 |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
520 |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
521 ;; glob windows files |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
522 ;; LIST is expected to be in reverse order |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
523 (defun vip-glob-ms-windows-files (list) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
524 (let ((tmp list) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
525 (case-fold-search t) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
526 tmp2) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
527 (while tmp |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
528 (setq tmp2 (cons (directory-files |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
529 ;; the directory part |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
530 (or (file-name-directory (car tmp)) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
531 "") |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
532 t ; return full names |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
533 ;; the regexp part: globs the file names |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
534 (concat "^" |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
535 (vip-wildcard-to-regexp |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
536 (file-name-nondirectory (car tmp))) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
537 "$")) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
538 tmp2)) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
539 (setq tmp (cdr tmp))) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
540 (reverse (apply 'append tmp2)))) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
541 |
10789 | 542 |
543 | |
544 | |
545 | |
546 ;;; Insertion ring | |
547 | |
548 ;; Rotate RING's index. DIRection can be positive or negative. | |
549 (defun vip-ring-rotate1 (ring dir) | |
550 (if (and (ring-p ring) (> (ring-length ring) 0)) | |
551 (progn | |
552 (setcar ring (cond ((> dir 0) | |
553 (ring-plus1 (car ring) (ring-length ring))) | |
554 ((< dir 0) | |
555 (ring-minus1 (car ring) (ring-length ring))) | |
556 ;; don't rotate if dir = 0 | |
557 (t (car ring)))) | |
558 (vip-current-ring-item ring) | |
559 ))) | |
560 | |
561 (defun vip-special-ring-rotate1 (ring dir) | |
562 (if (memq vip-intermediate-command | |
563 '(repeating-display-destructive-command | |
564 repeating-insertion-from-ring)) | |
565 (vip-ring-rotate1 ring dir) | |
566 ;; don't rotate otherwise | |
567 (vip-ring-rotate1 ring 0))) | |
568 | |
569 ;; current ring item; if N is given, then so many items back from the | |
570 ;; current | |
571 (defun vip-current-ring-item (ring &optional n) | |
572 (setq n (or n 0)) | |
573 (if (and (ring-p ring) (> (ring-length ring) 0)) | |
574 (aref (cdr (cdr ring)) (mod (- (car ring) 1 n) (ring-length ring))))) | |
575 | |
576 ;; push item onto ring. the second argument is a ring-variable, not value. | |
577 (defun vip-push-onto-ring (item ring-var) | |
578 (or (ring-p (eval ring-var)) | |
579 (set ring-var (make-ring (eval (intern (format "%S-size" ring-var)))))) | |
580 (or (null item) ; don't push nil | |
581 (and (stringp item) (string= item "")) ; or empty strings | |
582 (equal item (vip-current-ring-item (eval ring-var))) ; or old stuff | |
583 ;; Since vip-set-destructive-command checks if we are inside vip-repeat, | |
584 ;; we don't check whether this-command-keys is a `.'. | |
585 ;; The cmd vip-repeat makes a call to the current function only if | |
586 ;; `.' is executing a command from the command history. It doesn't | |
587 ;; call the push-onto-ring function if `.' is simply repeating the | |
588 ;; last destructive command. | |
589 ;; We only check for ESC (which happens when we do insert with a | |
590 ;; prefix argument, or if this-command-keys doesn't give anything | |
591 ;; meaningful (in that case we don't know what to show to the user). | |
592 (and (eq ring-var 'vip-command-ring) | |
593 (string-match "\\([0-9]*\e\\|^[ \t]*$\\|escape\\)" | |
594 (vip-array-to-string (this-command-keys)))) | |
595 (vip-ring-insert (eval ring-var) item)) | |
596 ) | |
597 | |
598 | |
599 ;; removing elts from ring seems to break it | |
600 (defun vip-cleanup-ring (ring) | |
601 (or (< (ring-length ring) 2) | |
602 (null (vip-current-ring-item ring)) | |
603 ;; last and previous equal | |
604 (if (equal (vip-current-ring-item ring) (vip-current-ring-item ring 1)) | |
605 (vip-ring-pop ring)))) | |
606 | |
607 ;; ring-remove seems to be buggy, so we concocted this for our purposes. | |
608 (defun vip-ring-pop (ring) | |
609 (let* ((ln (ring-length ring)) | |
610 (vec (cdr (cdr ring))) | |
611 (veclen (length vec)) | |
612 (hd (car ring)) | |
613 (idx (max 0 (ring-minus1 hd ln))) | |
614 (top-elt (aref vec idx))) | |
615 | |
616 ;; shift elements | |
617 (while (< (1+ idx) veclen) | |
618 (aset vec idx (aref vec (1+ idx))) | |
619 (setq idx (1+ idx))) | |
620 (aset vec idx nil) | |
621 | |
622 (setq hd (max 0 (ring-minus1 hd ln))) | |
623 (if (= hd (1- ln)) (setq hd 0)) | |
624 (setcar ring hd) ; move head | |
625 (setcar (cdr ring) (max 0 (1- ln))) ; adjust length | |
626 top-elt | |
627 )) | |
628 | |
629 (defun vip-ring-insert (ring item) | |
630 (let* ((ln (ring-length ring)) | |
631 (vec (cdr (cdr ring))) | |
632 (veclen (length vec)) | |
633 (hd (car ring)) | |
634 (vecpos-after-hd (if (= hd 0) ln hd)) | |
635 (idx ln)) | |
636 | |
637 (if (= ln veclen) | |
638 (progn | |
639 (aset vec hd item) ; hd is always 1+ the actual head index in vec | |
640 (setcar ring (ring-plus1 hd ln))) | |
641 (setcar (cdr ring) (1+ ln)) | |
642 (setcar ring (ring-plus1 vecpos-after-hd (1+ ln))) | |
643 (while (and (>= idx vecpos-after-hd) (> ln 0)) | |
644 (aset vec idx (aref vec (1- idx))) | |
645 (setq idx (1- idx))) | |
646 (aset vec vecpos-after-hd item)) | |
647 item)) | |
648 | |
649 | |
650 ;;; String utilities | |
651 | |
652 ;; If STRING is longer than MAX-LEN, truncate it and print ...... instead | |
653 ;; PRE-STRING is a string to prepend to the abbrev string. | |
654 ;; POST-STRING is a string to append to the abbrev string. | |
655 ;; ABBREV_SIGN is a string to be inserted before POST-STRING | |
656 ;; if the orig string was truncated. | |
657 (defun vip-abbreviate-string (string max-len | |
658 pre-string post-string abbrev-sign) | |
659 (let (truncated-str) | |
660 (setq truncated-str | |
661 (if (stringp string) | |
662 (substring string 0 (min max-len (length string))))) | |
663 (cond ((null truncated-str) "") | |
664 ((> (length string) max-len) | |
665 (format "%s%s%s%s" | |
666 pre-string truncated-str abbrev-sign post-string)) | |
667 (t (format "%s%s%s" pre-string truncated-str post-string))))) | |
12204
a7bd91d4af97
(vip-over-whitespace-line): new function.
Karl Heuer <kwzh@gnu.org>
parents:
12139
diff
changeset
|
668 |
a7bd91d4af97
(vip-over-whitespace-line): new function.
Karl Heuer <kwzh@gnu.org>
parents:
12139
diff
changeset
|
669 ;; tells if we are over a whitespace-only line |
a7bd91d4af97
(vip-over-whitespace-line): new function.
Karl Heuer <kwzh@gnu.org>
parents:
12139
diff
changeset
|
670 (defsubst vip-over-whitespace-line () |
a7bd91d4af97
(vip-over-whitespace-line): new function.
Karl Heuer <kwzh@gnu.org>
parents:
12139
diff
changeset
|
671 (save-excursion |
a7bd91d4af97
(vip-over-whitespace-line): new function.
Karl Heuer <kwzh@gnu.org>
parents:
12139
diff
changeset
|
672 (beginning-of-line) |
a7bd91d4af97
(vip-over-whitespace-line): new function.
Karl Heuer <kwzh@gnu.org>
parents:
12139
diff
changeset
|
673 (looking-at "^[ \t]*$"))) |
10789 | 674 |
675 | |
676 ;;; Saving settings in custom file | |
677 | |
12139
e16c06646396
(vip-event-key): now handles keys 128--255 as meta-chars.
Karl Heuer <kwzh@gnu.org>
parents:
11288
diff
changeset
|
678 ;; Save the current setting of VAR in CUSTOM-FILE. |
e16c06646396
(vip-event-key): now handles keys 128--255 as meta-chars.
Karl Heuer <kwzh@gnu.org>
parents:
11288
diff
changeset
|
679 ;; If given, MESSAGE is a message to be displayed after that. |
e16c06646396
(vip-event-key): now handles keys 128--255 as meta-chars.
Karl Heuer <kwzh@gnu.org>
parents:
11288
diff
changeset
|
680 ;; This message is erased after 2 secs, if erase-msg is non-nil. |
e16c06646396
(vip-event-key): now handles keys 128--255 as meta-chars.
Karl Heuer <kwzh@gnu.org>
parents:
11288
diff
changeset
|
681 ;; Arguments: var message custom-file &optional erase-message |
10789 | 682 (defun vip-save-setting (var message custom-file &optional erase-msg) |
683 (let* ((var-name (symbol-name var)) | |
684 (var-val (if (boundp var) (eval var))) | |
685 (regexp (format "^[^;]*%s[ \t\n]*[a-zA-Z---_']*[ \t\n)]" var-name)) | |
686 (buf (find-file-noselect (substitute-in-file-name custom-file))) | |
687 ) | |
14384
854325337547
Moved code around to minimize compiler warnings.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14336
diff
changeset
|
688 (message message) |
10789 | 689 (save-excursion |
690 (set-buffer buf) | |
691 (goto-char (point-min)) | |
692 (if (re-search-forward regexp nil t) | |
693 (let ((reg-end (1- (match-end 0)))) | |
694 (search-backward var-name) | |
695 (delete-region (match-beginning 0) reg-end) | |
696 (goto-char (match-beginning 0)) | |
697 (insert (format "%s '%S" var-name var-val))) | |
698 (goto-char (point-max)) | |
699 (if (not (bolp)) (insert "\n")) | |
700 (insert (format "(setq %s '%S)\n" var-name var-val))) | |
701 (save-buffer)) | |
702 (kill-buffer buf) | |
703 (if erase-msg | |
704 (progn | |
705 (sit-for 2) | |
706 (message ""))) | |
707 )) | |
708 | |
709 ;; Save STRING in CUSTOM-FILE. If PATTERN is non-nil, remove strings that | |
710 ;; match this pattern. | |
711 (defun vip-save-string-in-file (string custom-file &optional pattern) | |
712 (let ((buf (find-file-noselect (substitute-in-file-name custom-file)))) | |
713 (save-excursion | |
714 (set-buffer buf) | |
715 (goto-char (point-min)) | |
716 (if pattern (delete-matching-lines pattern)) | |
717 (goto-char (point-max)) | |
718 (if string (insert string)) | |
719 (save-buffer)) | |
720 (kill-buffer buf) | |
721 )) | |
722 | |
723 | |
724 ;;; Overlays | |
725 | |
726 ;; Search | |
727 | |
728 (defun vip-flash-search-pattern () | |
729 (if (vip-overlay-p vip-search-overlay) | |
730 (vip-move-overlay vip-search-overlay (match-beginning 0) (match-end 0)) | |
731 (setq vip-search-overlay | |
732 (vip-make-overlay | |
733 (match-beginning 0) (match-end 0) (current-buffer)))) | |
734 | |
735 (vip-overlay-put vip-search-overlay 'priority vip-search-overlay-priority) | |
14581
4951b11970a1
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14384
diff
changeset
|
736 (if (vip-has-face-support-p) |
10789 | 737 (progn |
738 (vip-overlay-put vip-search-overlay 'face vip-search-face) | |
739 (sit-for 2) | |
740 (vip-overlay-put vip-search-overlay 'face nil)))) | |
741 | |
742 ;; Replace state | |
743 | |
14909
7ff1df13b124
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14588
diff
changeset
|
744 (defsubst vip-move-replace-overlay (beg end) |
7ff1df13b124
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14588
diff
changeset
|
745 (vip-move-overlay vip-replace-overlay beg end)) |
7ff1df13b124
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14588
diff
changeset
|
746 |
10789 | 747 (defun vip-set-replace-overlay (beg end) |
748 (if (vip-overlay-p vip-replace-overlay) | |
749 (vip-move-replace-overlay beg end) | |
750 (setq vip-replace-overlay (vip-make-overlay beg end (current-buffer))) | |
14909
7ff1df13b124
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14588
diff
changeset
|
751 ;; never detach |
7ff1df13b124
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14588
diff
changeset
|
752 (vip-overlay-put |
7ff1df13b124
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14588
diff
changeset
|
753 vip-replace-overlay (if vip-emacs-p 'evaporate 'detachable) nil) |
10789 | 754 (vip-overlay-put |
755 vip-replace-overlay 'priority vip-replace-overlay-priority)) | |
14581
4951b11970a1
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14384
diff
changeset
|
756 (if (vip-has-face-support-p) |
10789 | 757 (vip-overlay-put vip-replace-overlay 'face vip-replace-overlay-face)) |
758 (vip-save-cursor-color) | |
759 (vip-change-cursor-color vip-replace-overlay-cursor-color) | |
760 ) | |
761 | |
12139
e16c06646396
(vip-event-key): now handles keys 128--255 as meta-chars.
Karl Heuer <kwzh@gnu.org>
parents:
11288
diff
changeset
|
762 |
e16c06646396
(vip-event-key): now handles keys 128--255 as meta-chars.
Karl Heuer <kwzh@gnu.org>
parents:
11288
diff
changeset
|
763 (defsubst vip-set-replace-overlay-glyphs (before-glyph after-glyph) |
14581
4951b11970a1
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14384
diff
changeset
|
764 (if (or (not (vip-has-face-support-p)) |
14233
396316e5fbe6
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14169
diff
changeset
|
765 vip-use-replace-region-delimiters) |
12139
e16c06646396
(vip-event-key): now handles keys 128--255 as meta-chars.
Karl Heuer <kwzh@gnu.org>
parents:
11288
diff
changeset
|
766 (let ((before-name (if vip-xemacs-p 'begin-glyph 'before-string)) |
e16c06646396
(vip-event-key): now handles keys 128--255 as meta-chars.
Karl Heuer <kwzh@gnu.org>
parents:
11288
diff
changeset
|
767 (after-name (if vip-xemacs-p 'end-glyph 'after-string))) |
e16c06646396
(vip-event-key): now handles keys 128--255 as meta-chars.
Karl Heuer <kwzh@gnu.org>
parents:
11288
diff
changeset
|
768 (vip-overlay-put vip-replace-overlay before-name before-glyph) |
e16c06646396
(vip-event-key): now handles keys 128--255 as meta-chars.
Karl Heuer <kwzh@gnu.org>
parents:
11288
diff
changeset
|
769 (vip-overlay-put vip-replace-overlay after-name after-glyph)))) |
14909
7ff1df13b124
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14588
diff
changeset
|
770 |
7ff1df13b124
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14588
diff
changeset
|
771 (defsubst vip-hide-replace-overlay () |
7ff1df13b124
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14588
diff
changeset
|
772 (vip-set-replace-overlay-glyphs nil nil) |
7ff1df13b124
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14588
diff
changeset
|
773 (vip-restore-cursor-color) |
7ff1df13b124
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14588
diff
changeset
|
774 (if (vip-has-face-support-p) |
7ff1df13b124
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14588
diff
changeset
|
775 (vip-overlay-put vip-replace-overlay 'face nil))) |
10789 | 776 |
777 | |
778 (defsubst vip-replace-start () | |
14233
396316e5fbe6
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14169
diff
changeset
|
779 (vip-overlay-start vip-replace-overlay)) |
10789 | 780 (defsubst vip-replace-end () |
14233
396316e5fbe6
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14169
diff
changeset
|
781 (vip-overlay-end vip-replace-overlay)) |
10789 | 782 |
783 | |
784 ;; Minibuffer | |
785 | |
786 (defun vip-set-minibuffer-overlay () | |
787 (vip-check-minibuffer-overlay) | |
14581
4951b11970a1
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14384
diff
changeset
|
788 (if (vip-has-face-support-p) |
10789 | 789 (progn |
790 (vip-overlay-put | |
791 vip-minibuffer-overlay 'face vip-minibuffer-current-face) | |
792 (vip-overlay-put | |
14233
396316e5fbe6
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14169
diff
changeset
|
793 vip-minibuffer-overlay 'priority vip-minibuffer-overlay-priority) |
14909
7ff1df13b124
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14588
diff
changeset
|
794 ;; never detach |
7ff1df13b124
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14588
diff
changeset
|
795 (vip-overlay-put |
7ff1df13b124
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14588
diff
changeset
|
796 vip-minibuffer-overlay (if vip-emacs-p 'evaporate 'detachable) nil) |
7ff1df13b124
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14588
diff
changeset
|
797 ;; make vip-minibuffer-overlay open-ended |
14233
396316e5fbe6
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14169
diff
changeset
|
798 ;; In emacs, it is made open ended at creation time |
14909
7ff1df13b124
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14588
diff
changeset
|
799 (if vip-xemacs-p |
7ff1df13b124
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14588
diff
changeset
|
800 (progn |
7ff1df13b124
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14588
diff
changeset
|
801 (vip-overlay-put vip-minibuffer-overlay 'start-open nil) |
7ff1df13b124
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14588
diff
changeset
|
802 (vip-overlay-put vip-minibuffer-overlay 'end-open nil))) |
14233
396316e5fbe6
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14169
diff
changeset
|
803 ))) |
10789 | 804 |
805 (defun vip-check-minibuffer-overlay () | |
14233
396316e5fbe6
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14169
diff
changeset
|
806 (or (vip-overlay-p vip-minibuffer-overlay) |
396316e5fbe6
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14169
diff
changeset
|
807 (setq vip-minibuffer-overlay |
396316e5fbe6
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14169
diff
changeset
|
808 (if vip-xemacs-p |
396316e5fbe6
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14169
diff
changeset
|
809 (vip-make-overlay 1 (1+ (buffer-size)) (current-buffer)) |
14909
7ff1df13b124
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14588
diff
changeset
|
810 ;; make overlay open-ended |
7ff1df13b124
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14588
diff
changeset
|
811 (vip-make-overlay |
7ff1df13b124
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14588
diff
changeset
|
812 1 (1+ (buffer-size)) (current-buffer) nil 'rear-advance))) |
14233
396316e5fbe6
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14169
diff
changeset
|
813 )) |
10789 | 814 |
815 | |
816 (defsubst vip-is-in-minibuffer () | |
817 (string-match "\*Minibuf-" (buffer-name))) | |
818 | |
819 | |
820 | |
821 ;;; XEmacs compatibility | |
14581
4951b11970a1
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14384
diff
changeset
|
822 |
4951b11970a1
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14384
diff
changeset
|
823 (defun vip-abbreviate-file-name (file) |
4951b11970a1
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14384
diff
changeset
|
824 (if vip-emacs-p |
4951b11970a1
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14384
diff
changeset
|
825 (abbreviate-file-name file) |
4951b11970a1
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14384
diff
changeset
|
826 ;; XEmacs requires addl argument |
4951b11970a1
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14384
diff
changeset
|
827 (abbreviate-file-name file t))) |
10789 | 828 |
12899
e0dfd3c3837e
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12693
diff
changeset
|
829 ;; Sit for VAL milliseconds. XEmacs doesn't support the millisecond arg |
12139
e16c06646396
(vip-event-key): now handles keys 128--255 as meta-chars.
Karl Heuer <kwzh@gnu.org>
parents:
11288
diff
changeset
|
830 ;; in sit-for, so this function smoothes out the differences. |
10789 | 831 (defsubst vip-sit-for-short (val &optional nodisp) |
832 (if vip-xemacs-p | |
833 (sit-for (/ val 1000.0) nodisp) | |
834 (sit-for 0 val nodisp))) | |
835 | |
836 ;; EVENT may be a single event of a sequence of events | |
837 (defsubst vip-ESC-event-p (event) | |
838 (let ((ESC-keys '(?\e (control \[) escape)) | |
839 (key (vip-event-key event))) | |
840 (member key ESC-keys))) | |
841 | |
14909
7ff1df13b124
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14588
diff
changeset
|
842 |
7ff1df13b124
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14588
diff
changeset
|
843 (defsubst vip-mark-marker () |
7ff1df13b124
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14588
diff
changeset
|
844 (if vip-xemacs-p |
7ff1df13b124
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14588
diff
changeset
|
845 (mark-marker t) |
7ff1df13b124
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14588
diff
changeset
|
846 (mark-marker))) |
7ff1df13b124
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14588
diff
changeset
|
847 |
10789 | 848 ;; like (set-mark-command nil) but doesn't push twice, if (car mark-ring) |
849 ;; is the same as (mark t). | |
850 (defsubst vip-set-mark-if-necessary () | |
851 (setq mark-ring (delete (vip-mark-marker) mark-ring)) | |
852 (set-mark-command nil)) | |
853 | |
854 ;; In transient mark mode (zmacs mode), it is annoying when regions become | |
855 ;; highlighted due to Viper's pushing marks. So, we deactivate marks, unless | |
856 ;; the user explicitly wants highlighting, e.g., by hitting '' or `` | |
857 (defun vip-deactivate-mark () | |
858 (if vip-xemacs-p | |
859 (zmacs-deactivate-region) | |
860 (deactivate-mark))) | |
861 | |
12899
e0dfd3c3837e
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12693
diff
changeset
|
862 (defsubst vip-leave-region-active () |
e0dfd3c3837e
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12693
diff
changeset
|
863 (if vip-xemacs-p |
e0dfd3c3837e
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12693
diff
changeset
|
864 (setq zmacs-region-stays t))) |
e0dfd3c3837e
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12693
diff
changeset
|
865 |
10789 | 866 |
867 (defsubst vip-events-to-keys (events) | |
868 (cond (vip-xemacs-p (events-to-keys events)) | |
869 (t events))) | |
870 | |
871 | |
872 (defun vip-eval-after-load (file form) | |
873 (if vip-emacs-p | |
874 (eval-after-load file form) | |
875 (or (assoc file after-load-alist) | |
876 (setq after-load-alist (cons (list file) after-load-alist))) | |
877 (let ((elt (assoc file after-load-alist))) | |
878 (or (member form (cdr elt)) | |
879 (setq elt (nconc elt (list form))))) | |
880 form | |
881 )) | |
12693
321b2ad48a9c
(vip-add-hook,vip-remove-hook): new functions.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12212
diff
changeset
|
882 |
321b2ad48a9c
(vip-add-hook,vip-remove-hook): new functions.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12212
diff
changeset
|
883 ;; This is here because Emacs changed the way local hooks work. |
321b2ad48a9c
(vip-add-hook,vip-remove-hook): new functions.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12212
diff
changeset
|
884 ;; |
321b2ad48a9c
(vip-add-hook,vip-remove-hook): new functions.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12212
diff
changeset
|
885 ;;Add to the value of HOOK the function FUNCTION. |
321b2ad48a9c
(vip-add-hook,vip-remove-hook): new functions.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12212
diff
changeset
|
886 ;;FUNCTION is not added if already present. |
321b2ad48a9c
(vip-add-hook,vip-remove-hook): new functions.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12212
diff
changeset
|
887 ;;FUNCTION is added (if necessary) at the beginning of the hook list |
321b2ad48a9c
(vip-add-hook,vip-remove-hook): new functions.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12212
diff
changeset
|
888 ;;unless the optional argument APPEND is non-nil, in which case |
321b2ad48a9c
(vip-add-hook,vip-remove-hook): new functions.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12212
diff
changeset
|
889 ;;FUNCTION is added at the end. |
321b2ad48a9c
(vip-add-hook,vip-remove-hook): new functions.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12212
diff
changeset
|
890 ;; |
321b2ad48a9c
(vip-add-hook,vip-remove-hook): new functions.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12212
diff
changeset
|
891 ;;HOOK should be a symbol, and FUNCTION may be any valid function. If |
321b2ad48a9c
(vip-add-hook,vip-remove-hook): new functions.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12212
diff
changeset
|
892 ;;HOOK is void, it is first set to nil. If HOOK's value is a single |
321b2ad48a9c
(vip-add-hook,vip-remove-hook): new functions.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12212
diff
changeset
|
893 ;;function, it is changed to a list of functions." |
321b2ad48a9c
(vip-add-hook,vip-remove-hook): new functions.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12212
diff
changeset
|
894 (defun vip-add-hook (hook function &optional append) |
321b2ad48a9c
(vip-add-hook,vip-remove-hook): new functions.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12212
diff
changeset
|
895 (if (not (boundp hook)) (set hook nil)) |
321b2ad48a9c
(vip-add-hook,vip-remove-hook): new functions.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12212
diff
changeset
|
896 ;; If the hook value is a single function, turn it into a list. |
321b2ad48a9c
(vip-add-hook,vip-remove-hook): new functions.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12212
diff
changeset
|
897 (let ((old (symbol-value hook))) |
321b2ad48a9c
(vip-add-hook,vip-remove-hook): new functions.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12212
diff
changeset
|
898 (if (or (not (listp old)) (eq (car old) 'lambda)) |
321b2ad48a9c
(vip-add-hook,vip-remove-hook): new functions.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12212
diff
changeset
|
899 (setq old (list old))) |
321b2ad48a9c
(vip-add-hook,vip-remove-hook): new functions.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12212
diff
changeset
|
900 (if (member function old) |
321b2ad48a9c
(vip-add-hook,vip-remove-hook): new functions.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12212
diff
changeset
|
901 nil |
321b2ad48a9c
(vip-add-hook,vip-remove-hook): new functions.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12212
diff
changeset
|
902 (set hook (if append |
321b2ad48a9c
(vip-add-hook,vip-remove-hook): new functions.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12212
diff
changeset
|
903 (append old (list function)) ; don't nconc |
321b2ad48a9c
(vip-add-hook,vip-remove-hook): new functions.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12212
diff
changeset
|
904 (cons function old)))))) |
321b2ad48a9c
(vip-add-hook,vip-remove-hook): new functions.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12212
diff
changeset
|
905 |
321b2ad48a9c
(vip-add-hook,vip-remove-hook): new functions.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12212
diff
changeset
|
906 ;; This is here because of Emacs's changes in the semantics of add/remove-hooks |
321b2ad48a9c
(vip-add-hook,vip-remove-hook): new functions.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12212
diff
changeset
|
907 ;; and due to the bugs they introduced. |
321b2ad48a9c
(vip-add-hook,vip-remove-hook): new functions.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12212
diff
changeset
|
908 ;; |
321b2ad48a9c
(vip-add-hook,vip-remove-hook): new functions.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12212
diff
changeset
|
909 ;; Remove from the value of HOOK the function FUNCTION. |
321b2ad48a9c
(vip-add-hook,vip-remove-hook): new functions.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12212
diff
changeset
|
910 ;; HOOK should be a symbol, and FUNCTION may be any valid function. If |
321b2ad48a9c
(vip-add-hook,vip-remove-hook): new functions.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12212
diff
changeset
|
911 ;; FUNCTION isn't the value of HOOK, or, if FUNCTION doesn't appear in the |
321b2ad48a9c
(vip-add-hook,vip-remove-hook): new functions.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12212
diff
changeset
|
912 ;; list of hooks to run in HOOK, then nothing is done. See `vip-add-hook'." |
321b2ad48a9c
(vip-add-hook,vip-remove-hook): new functions.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12212
diff
changeset
|
913 (defun vip-remove-hook (hook function) |
321b2ad48a9c
(vip-add-hook,vip-remove-hook): new functions.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12212
diff
changeset
|
914 (if (or (not (boundp hook)) ;unbound symbol, or |
321b2ad48a9c
(vip-add-hook,vip-remove-hook): new functions.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12212
diff
changeset
|
915 (null (symbol-value hook)) ;value is nil, or |
321b2ad48a9c
(vip-add-hook,vip-remove-hook): new functions.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12212
diff
changeset
|
916 (null function)) ;function is nil, then |
321b2ad48a9c
(vip-add-hook,vip-remove-hook): new functions.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12212
diff
changeset
|
917 nil ;Do nothing. |
321b2ad48a9c
(vip-add-hook,vip-remove-hook): new functions.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12212
diff
changeset
|
918 (let ((hook-value (symbol-value hook))) |
321b2ad48a9c
(vip-add-hook,vip-remove-hook): new functions.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12212
diff
changeset
|
919 (if (consp hook-value) |
321b2ad48a9c
(vip-add-hook,vip-remove-hook): new functions.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12212
diff
changeset
|
920 ;; don't side-effect the list |
321b2ad48a9c
(vip-add-hook,vip-remove-hook): new functions.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12212
diff
changeset
|
921 (setq hook-value (delete function (copy-sequence hook-value))) |
321b2ad48a9c
(vip-add-hook,vip-remove-hook): new functions.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12212
diff
changeset
|
922 (if (equal hook-value function) |
321b2ad48a9c
(vip-add-hook,vip-remove-hook): new functions.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12212
diff
changeset
|
923 (setq hook-value nil))) |
321b2ad48a9c
(vip-add-hook,vip-remove-hook): new functions.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12212
diff
changeset
|
924 (set hook hook-value)))) |
321b2ad48a9c
(vip-add-hook,vip-remove-hook): new functions.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12212
diff
changeset
|
925 |
10789 | 926 |
927 | |
928 ;; like read-event, but in XEmacs also try to convert to char, if possible | |
929 (defun vip-read-event-convert-to-char () | |
930 (let (event) | |
931 (if vip-emacs-p | |
932 (read-event) | |
933 (setq event (next-command-event)) | |
934 (or (event-to-character event) | |
935 event)) | |
936 )) | |
937 | |
12693
321b2ad48a9c
(vip-add-hook,vip-remove-hook): new functions.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12212
diff
changeset
|
938 ;; This function lets function-key-map convert key sequences into logical |
321b2ad48a9c
(vip-add-hook,vip-remove-hook): new functions.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12212
diff
changeset
|
939 ;; keys. This does a better job than vip-read-event when it comes to kbd |
15578
fadc581e380e
(vip-read-key): inhibit quit added.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
940 ;; macros, since it enables certain macros to be shared between X and TTY modes |
fadc581e380e
(vip-read-key): inhibit quit added.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
941 ;; by correctly mapping key sequences for Left/Right/... (one an ascii |
fadc581e380e
(vip-read-key): inhibit quit added.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
942 ;; terminal) into logical keys left, right, etc. |
12693
321b2ad48a9c
(vip-add-hook,vip-remove-hook): new functions.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12212
diff
changeset
|
943 (defun vip-read-key () |
321b2ad48a9c
(vip-add-hook,vip-remove-hook): new functions.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12212
diff
changeset
|
944 (let ((overriding-local-map vip-overriding-map) |
15578
fadc581e380e
(vip-read-key): inhibit quit added.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
945 (inhibit-quit t) |
12693
321b2ad48a9c
(vip-add-hook,vip-remove-hook): new functions.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12212
diff
changeset
|
946 key) |
321b2ad48a9c
(vip-add-hook,vip-remove-hook): new functions.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12212
diff
changeset
|
947 (use-global-map vip-overriding-map) |
321b2ad48a9c
(vip-add-hook,vip-remove-hook): new functions.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12212
diff
changeset
|
948 (setq key (elt (read-key-sequence nil) 0)) |
321b2ad48a9c
(vip-add-hook,vip-remove-hook): new functions.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12212
diff
changeset
|
949 (use-global-map global-map) |
15578
fadc581e380e
(vip-read-key): inhibit quit added.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
950 key)) |
12693
321b2ad48a9c
(vip-add-hook,vip-remove-hook): new functions.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12212
diff
changeset
|
951 |
10789 | 952 |
12139
e16c06646396
(vip-event-key): now handles keys 128--255 as meta-chars.
Karl Heuer <kwzh@gnu.org>
parents:
11288
diff
changeset
|
953 ;; Emacs has a bug in eventp, which causes (eventp nil) to return (nil) |
14584
6674e3119d9e
(vip-event-key): ignore consp events.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14581
diff
changeset
|
954 ;; instead of nil, if '(nil) was previously inadvertently assigned to |
10789 | 955 ;; unread-command-events |
956 (defun vip-event-key (event) | |
957 (or (and event (eventp event)) | |
958 (error "vip-event-key: Wrong type argument, eventp, %S" event)) | |
959 (let ((mod (event-modifiers event)) | |
960 basis) | |
961 (setq basis | |
962 (cond | |
963 (vip-xemacs-p | |
964 (cond ((key-press-event-p event) | |
965 (event-key event)) | |
966 ((button-event-p event) | |
12139
e16c06646396
(vip-event-key): now handles keys 128--255 as meta-chars.
Karl Heuer <kwzh@gnu.org>
parents:
11288
diff
changeset
|
967 (concat "mouse-" (prin1-to-string (event-button event)))) |
10789 | 968 (t |
969 (error "vip-event-key: Unknown event, %S" event)))) | |
970 (t | |
971 ;; Emacs doesn't handle capital letters correctly, since | |
972 ;; \S-a isn't considered the same as A (it behaves as | |
973 ;; plain `a' instead). So we take care of this here | |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
974 (cond ((and (vip-characterp event) (<= ?A event) (<= event ?Z)) |
12139
e16c06646396
(vip-event-key): now handles keys 128--255 as meta-chars.
Karl Heuer <kwzh@gnu.org>
parents:
11288
diff
changeset
|
975 (setq mod nil |
e16c06646396
(vip-event-key): now handles keys 128--255 as meta-chars.
Karl Heuer <kwzh@gnu.org>
parents:
11288
diff
changeset
|
976 event event)) |
e16c06646396
(vip-event-key): now handles keys 128--255 as meta-chars.
Karl Heuer <kwzh@gnu.org>
parents:
11288
diff
changeset
|
977 ;; Emacs has the oddity whereby characters 128+char |
e16c06646396
(vip-event-key): now handles keys 128--255 as meta-chars.
Karl Heuer <kwzh@gnu.org>
parents:
11288
diff
changeset
|
978 ;; represent M-char *if* this appears inside a string. |
14584
6674e3119d9e
(vip-event-key): ignore consp events.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14581
diff
changeset
|
979 ;; So, we convert them manually to (meta char). |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
980 ((and (vip-characterp event) (< ?\C-? event) (<= event 255)) |
12139
e16c06646396
(vip-event-key): now handles keys 128--255 as meta-chars.
Karl Heuer <kwzh@gnu.org>
parents:
11288
diff
changeset
|
981 (setq mod '(meta) |
e16c06646396
(vip-event-key): now handles keys 128--255 as meta-chars.
Karl Heuer <kwzh@gnu.org>
parents:
11288
diff
changeset
|
982 event (- event ?\C-? 1))) |
e16c06646396
(vip-event-key): now handles keys 128--255 as meta-chars.
Karl Heuer <kwzh@gnu.org>
parents:
11288
diff
changeset
|
983 (t (event-basic-type event))) |
e16c06646396
(vip-event-key): now handles keys 128--255 as meta-chars.
Karl Heuer <kwzh@gnu.org>
parents:
11288
diff
changeset
|
984 ))) |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
985 (if (vip-characterp basis) |
10789 | 986 (setq basis |
987 (if (= basis ?\C-?) | |
988 (list 'control '\?) ; taking care of an emacs bug | |
989 (intern (char-to-string basis))))) | |
990 (if mod | |
991 (append mod (list basis)) | |
14588
cf9a69c6ffdd
(vip-event-key): previous change undone.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14584
diff
changeset
|
992 basis))) |
10789 | 993 |
994 (defun vip-key-to-emacs-key (key) | |
995 (let (key-name char-p modifiers mod-char-list base-key base-key-name) | |
996 (cond (vip-xemacs-p key) | |
997 ((symbolp key) | |
998 (setq key-name (symbol-name key)) | |
999 (if (= (length key-name) 1) ; character event | |
1000 (string-to-char key-name) | |
1001 key)) | |
1002 ((listp key) | |
1003 (setq modifiers (subseq key 0 (1- (length key))) | |
1004 base-key (vip-seq-last-elt key) | |
1005 base-key-name (symbol-name base-key) | |
1006 char-p (= (length base-key-name) 1)) | |
1007 (setq mod-char-list | |
1008 (mapcar | |
1009 '(lambda (elt) (upcase (substring (symbol-name elt) 0 1))) | |
1010 modifiers)) | |
1011 (if char-p | |
1012 (setq key-name | |
1013 (car (read-from-string | |
1014 (concat | |
1015 "?\\" | |
1016 (mapconcat 'identity mod-char-list "-\\") | |
1017 "-" | |
1018 base-key-name)))) | |
1019 (setq key-name | |
1020 (intern | |
1021 (concat | |
1022 (mapconcat 'identity mod-char-list "-") | |
1023 "-" | |
1024 base-key-name)))))) | |
1025 )) | |
1026 | |
1027 | |
1028 ;; Args can be a sequence of events, a string, or a Viper macro. Will try to | |
1029 ;; convert events to keys and, if all keys are regular printable | |
1030 ;; characters, will return a string. Otherwise, will return a string | |
1031 ;; representing a vector of converted events. If the input was a Viper macro, | |
1032 ;; will return a string that represents this macro as a vector. | |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
1033 (defun vip-array-to-string (event-seq) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
1034 (let (temp temp2) |
10789 | 1035 (cond ((stringp event-seq) event-seq) |
1036 ((vip-event-vector-p event-seq) | |
1037 (setq temp (mapcar 'vip-event-key event-seq)) | |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
1038 (cond ((vip-char-symbol-sequence-p temp) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
1039 (mapconcat 'symbol-name temp "")) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
1040 ((and (vip-char-array-p |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
1041 (setq temp2 (mapcar 'vip-key-to-character temp)))) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
1042 (mapconcat 'char-to-string temp2 "")) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
1043 (t (prin1-to-string (vconcat temp))))) |
10789 | 1044 ((vip-char-symbol-sequence-p event-seq) |
1045 (mapconcat 'symbol-name event-seq "")) | |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
1046 ((and (vectorp event-seq) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
1047 (vip-char-array-p |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
1048 (setq temp (mapcar 'vip-key-to-character event-seq)))) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
1049 (mapconcat 'char-to-string temp "")) |
10789 | 1050 (t (prin1-to-string event-seq))))) |
13213
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1051 |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1052 (defun vip-key-press-events-to-chars (events) |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1053 (mapconcat (if vip-emacs-p |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1054 'char-to-string |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1055 (function |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1056 (lambda (elt) (char-to-string (event-to-character elt))))) |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1057 events |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1058 "")) |
10789 | 1059 |
1060 | |
1061 (defsubst vip-fast-keysequence-p () | |
1062 (not (vip-sit-for-short vip-fast-keyseq-timeout t))) | |
1063 | |
1064 (defun vip-read-char-exclusive () | |
1065 (let (char | |
1066 (echo-keystrokes 1)) | |
1067 (while (null char) | |
1068 (condition-case nil | |
1069 (setq char (read-char)) | |
1070 (error | |
1071 ;; skip event if not char | |
1072 (vip-read-event)))) | |
1073 char)) | |
1074 | |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
1075 ;; key is supposed to be in viper's representation, e.g., (control l), a |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
1076 ;; character, etc. |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
1077 (defun vip-key-to-character (key) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
1078 (cond ((eq key 'space) ?\ ) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
1079 ((eq key 'delete) ?\C-?) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
1080 ((eq key 'backspace) ?\C-h) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
1081 ((and (symbolp key) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
1082 (= 1 (length (symbol-name key)))) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
1083 (string-to-char (symbol-name key))) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
1084 ((and (listp key) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
1085 (eq (car key) 'control) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
1086 (symbol-name (nth 1 key)) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
1087 (= 1 (length (symbol-name (nth 1 key))))) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
1088 (read (format "?\\C-%s" (symbol-name (nth 1 key))))) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
1089 (t key))) |
10789 | 1090 |
1091 | |
1092 (defun vip-setup-master-buffer (&rest other-files-or-buffers) | |
1093 "Set up the current buffer as a master buffer. | |
1094 Arguments become related buffers. This function should normally be used in | |
1095 the `Local variables' section of a file." | |
1096 (setq vip-related-files-and-buffers-ring | |
1097 (make-ring (1+ (length other-files-or-buffers)))) | |
1098 (mapcar '(lambda (elt) | |
1099 (vip-ring-insert vip-related-files-and-buffers-ring elt)) | |
1100 other-files-or-buffers) | |
1101 (vip-ring-insert vip-related-files-and-buffers-ring (buffer-name)) | |
1102 ) | |
13213
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1103 |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1104 ;;; Movement utilities |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1105 |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1106 (defvar vip-syntax-preference 'strict-vi |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1107 "*Syntax type characterizing Viper's alphanumeric symbols. |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1108 `emacs' means only word constituents are considered to be alphanumeric. |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1109 Word constituents are symbols specified as word constituents by the current |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1110 syntax table. |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1111 `extended' means word and symbol constituents. |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1112 `reformed-vi' means Vi-ish behavior: word constituents and the symbol `_'. |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1113 However, word constituents are determined according to Emacs syntax tables, |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1114 which may be different from Vi in some major modes. |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1115 `strict-vi' means Viper words are exactly as in Vi.") |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1116 |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1117 (vip-deflocalvar vip-ALPHA-char-class "w" |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1118 "String of syntax classes characterizing Viper's alphanumeric symbols. |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1119 In addition, the symbol `_' may be considered alphanumeric if |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1120 `vip-syntax-preference'is `reformed-vi'.") |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1121 |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1122 (vip-deflocalvar vip-strict-ALPHA-chars "a-zA-Z0-9_" |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1123 "Regexp matching the set of alphanumeric characters acceptable to strict |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1124 Vi.") |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1125 (vip-deflocalvar vip-strict-SEP-chars " \t\n" |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1126 "Regexp matching the set of alphanumeric characters acceptable to strict |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1127 Vi.") |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1128 |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1129 (vip-deflocalvar vip-SEP-char-class " -" |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1130 "String of syntax classes for Vi separators. |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1131 Usually contains ` ', linefeed, TAB or formfeed.") |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1132 |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1133 (defun vip-update-alphanumeric-class () |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1134 "Set the syntactic class of Viper alphanumeric symbols according to |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1135 the variable `vip-ALPHA-char-class'. Should be called in order for changes to |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1136 `vip-ALPHA-char-class' to take effect." |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1137 (interactive) |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1138 (setq-default |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1139 vip-ALPHA-char-class |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1140 (cond ((eq vip-syntax-preference 'emacs) "w") ; only word constituents |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1141 ((eq vip-syntax-preference 'extended) "w_") ; word & symbol chars |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1142 (t "w")))) ; vi syntax: word constituents and the symbol `_' |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1143 |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1144 ;; addl-chars are characters to be temporarily considered as alphanumerical |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1145 (defun vip-looking-at-alpha (&optional addl-chars) |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1146 (or (stringp addl-chars) (setq addl-chars "")) |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1147 (if (eq vip-syntax-preference 'reformed-vi) |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1148 (setq addl-chars (concat addl-chars "_"))) |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1149 (let ((char (char-after (point)))) |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1150 (if char |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1151 (if (eq vip-syntax-preference 'strict-vi) |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1152 (looking-at (concat "[" vip-strict-ALPHA-chars addl-chars "]")) |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1153 (or (memq char |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1154 ;; convert string to list |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1155 (append (vconcat addl-chars) nil)) |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1156 (memq (char-syntax char) |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1157 (append (vconcat vip-ALPHA-char-class) nil))))) |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1158 )) |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1159 |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1160 (defsubst vip-looking-at-separator () |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1161 (let ((char (char-after (point)))) |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1162 (if char |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1163 (or (eq char ?\n) ; RET is always a separator in Vi |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1164 (memq (char-syntax char) |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1165 (append (vconcat vip-SEP-char-class) nil)))))) |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1166 |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1167 (defsubst vip-looking-at-alphasep (&optional addl-chars) |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1168 (or (vip-looking-at-separator) (vip-looking-at-alpha addl-chars))) |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1169 |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1170 (defsubst vip-skip-alpha-forward (&optional addl-chars) |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1171 (or (stringp addl-chars) (setq addl-chars "")) |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1172 (vip-skip-syntax |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1173 'forward |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1174 (cond ((eq vip-syntax-preference 'strict-vi) |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1175 "") |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1176 (t vip-ALPHA-char-class )) |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1177 (cond ((eq vip-syntax-preference 'strict-vi) |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1178 (concat vip-strict-ALPHA-chars addl-chars)) |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1179 (t addl-chars)))) |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1180 |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1181 (defsubst vip-skip-alpha-backward (&optional addl-chars) |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1182 (or (stringp addl-chars) (setq addl-chars "")) |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1183 (vip-skip-syntax |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1184 'backward |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1185 (cond ((eq vip-syntax-preference 'strict-vi) |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1186 "") |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1187 (t vip-ALPHA-char-class )) |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1188 (cond ((eq vip-syntax-preference 'strict-vi) |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1189 (concat vip-strict-ALPHA-chars addl-chars)) |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1190 (t addl-chars)))) |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1191 |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1192 ;; weird syntax tables may confuse strict-vi style |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1193 (defsubst vip-skip-all-separators-forward (&optional within-line) |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1194 (vip-skip-syntax 'forward |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1195 vip-SEP-char-class |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1196 (or within-line "\n") |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1197 (if within-line (vip-line-pos 'end)))) |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1198 (defsubst vip-skip-all-separators-backward (&optional within-line) |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1199 (vip-skip-syntax 'backward |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1200 vip-SEP-char-class |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1201 (or within-line "\n") |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1202 (if within-line (vip-line-pos 'start)))) |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1203 (defun vip-skip-nonseparators (direction) |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1204 (let ((func (intern (format "skip-syntax-%S" direction)))) |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1205 (funcall func (concat "^" vip-SEP-char-class) |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1206 (vip-line-pos (if (eq direction 'forward) 'end 'start))))) |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1207 |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1208 (defsubst vip-skip-nonalphasep-forward () |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1209 (if (eq vip-syntax-preference 'strict-vi) |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1210 (skip-chars-forward |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1211 (concat "^" vip-strict-SEP-chars vip-strict-ALPHA-chars)) |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1212 (skip-syntax-forward |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1213 (concat |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1214 "^" vip-ALPHA-char-class vip-SEP-char-class) (vip-line-pos 'end)))) |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1215 (defsubst vip-skip-nonalphasep-backward () |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1216 (if (eq vip-syntax-preference 'strict-vi) |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1217 (skip-chars-backward |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1218 (concat "^" vip-strict-SEP-chars vip-strict-ALPHA-chars)) |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1219 (skip-syntax-backward |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1220 (concat |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1221 "^" vip-ALPHA-char-class vip-SEP-char-class) (vip-line-pos 'start)))) |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1222 |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1223 ;; Skip SYNTAX like skip-syntax-* and ADDL-CHARS like skip-chars-* |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1224 ;; Return the number of chars traveled. |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1225 ;; Either SYNTAX or ADDL-CHARS can be nil, in which case they are interpreted |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1226 ;; as an empty string. |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1227 (defun vip-skip-syntax (direction syntax addl-chars &optional limit) |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1228 (let ((total 0) |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1229 (local 1) |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1230 (skip-chars-func (intern (format "skip-chars-%S" direction))) |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1231 (skip-syntax-func (intern (format "skip-syntax-%S" direction)))) |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1232 (or (stringp addl-chars) (setq addl-chars "")) |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1233 (or (stringp syntax) (setq syntax "")) |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1234 (while (and (not (= local 0)) (not (eobp))) |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1235 (setq local |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1236 (+ (funcall skip-syntax-func syntax limit) |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1237 (funcall skip-chars-func addl-chars limit))) |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1238 (setq total (+ total local))) |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1239 total |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1240 )) |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1241 |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1242 |
10789 | 1243 |
1244 | |
1245 (provide 'viper-util) | |
1246 | |
1247 ;;; viper-util.el ends here |