annotate lisp/emulation/viper-util.el @ 19993:2c30b1fb6409

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