Mercurial > emacs
annotate lisp/emulation/viper-util.el @ 107062:bb5cb7ece094
* nsterm.m (ns_defined_color): Block input. Suggested by Mike
<deactivated@gmail.com> (Bug#3605).
author | Chong Yidong <cyd@stupidchicken.com> |
---|---|
date | Sun, 31 Jan 2010 00:23:09 -0500 |
parents | 1d1d5d9bd884 |
children | 280c8ae2476d 376148b31b5e |
rev | line source |
---|---|
38514
10482dd382e7
* viper-ex.el (ex-token-list,ex-cmd-execute): Revamped, courtesy
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
38414
diff
changeset
|
1 ;;; viper-util.el --- Utilities used by viper.el |
14169 | 2 |
64701
34bd8e434dd7
Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
64215
diff
changeset
|
3 ;; Copyright (C) 1994, 1995, 1996, 1997, 1999, 2000, 2001, 2002, 2003, |
106815 | 4 ;; 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. |
11288 | 5 |
42602
633233bf2bbf
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
39215
diff
changeset
|
6 ;; Author: Michael Kifer <kifer@cs.stonybrook.edu> |
39215
8dccf2552307
2001-09-09 Michael Kifer <kifer@cs.sunysb.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
38723
diff
changeset
|
7 |
10789 | 8 ;; This file is part of GNU Emacs. |
9 | |
94658
eb7b2376cae5
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
10 ;; GNU Emacs is free software: you can redistribute it and/or modify |
10789 | 11 ;; it under the terms of the GNU General Public License as published by |
94658
eb7b2376cae5
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
12 ;; the Free Software Foundation, either version 3 of the License, or |
eb7b2376cae5
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
13 ;; (at your option) any later version. |
10789 | 14 |
15 ;; GNU Emacs is distributed in the hope that it will be useful, | |
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 ;; GNU General Public License for more details. | |
19 | |
20 ;; You should have received a copy of the GNU General Public License | |
94658
eb7b2376cae5
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
21 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
10789 | 22 |
38414
67b464da13ec
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
36857
diff
changeset
|
23 ;;; Commentary: |
14909
7ff1df13b124
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14588
diff
changeset
|
24 |
38414
67b464da13ec
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
36857
diff
changeset
|
25 ;;; Code: |
14909
7ff1df13b124
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14588
diff
changeset
|
26 |
93652
6523ed37006c
2008-04-04 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
93615
diff
changeset
|
27 (provide 'viper-util) |
6523ed37006c
2008-04-04 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
93615
diff
changeset
|
28 |
6523ed37006c
2008-04-04 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
93615
diff
changeset
|
29 |
14909
7ff1df13b124
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14588
diff
changeset
|
30 ;; Compiler pacifier |
19079 | 31 (defvar viper-overriding-map) |
14909
7ff1df13b124
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14588
diff
changeset
|
32 (defvar pm-color-alist) |
19079 | 33 (defvar viper-minibuffer-current-face) |
34 (defvar viper-minibuffer-insert-face) | |
35 (defvar viper-minibuffer-vi-face) | |
36 (defvar viper-minibuffer-emacs-face) | |
37 (defvar viper-replace-overlay-face) | |
38 (defvar viper-fast-keyseq-timeout) | |
18047 | 39 (defvar ex-unix-type-shell) |
40 (defvar ex-unix-type-shell-options) | |
19079 | 41 (defvar viper-ex-tmp-buf-name) |
19462 | 42 (defvar viper-syntax-preference) |
42602
633233bf2bbf
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
39215
diff
changeset
|
43 (defvar viper-saved-mark) |
18047 | 44 |
45 (require 'ring) | |
14909
7ff1df13b124
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14588
diff
changeset
|
46 |
87691
f2c8fd594360
2008-01-10 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
87678
diff
changeset
|
47 (eval-and-compile |
f2c8fd594360
2008-01-10 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
87678
diff
changeset
|
48 (unless (fboundp 'declare-function) (defmacro declare-function (&rest r)))) |
f2c8fd594360
2008-01-10 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
87678
diff
changeset
|
49 |
18047 | 50 ;; end pacifier |
10789 | 51 |
18047 | 52 (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
|
53 |
14581
4951b11970a1
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14384
diff
changeset
|
54 |
10789 | 55 |
92380
8ee8aa679c74
(zmacs-region-stays): No need to define for compiler.
Glenn Morris <rgm@gnu.org>
parents:
87691
diff
changeset
|
56 (defalias 'viper-overlay-p |
85972
51aa47312c4b
* ediff-init.el (ediff-xemacs-p, ediff-emacs-p): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
84908
diff
changeset
|
57 (if (featurep 'xemacs) 'extentp 'overlayp)) |
92380
8ee8aa679c74
(zmacs-region-stays): No need to define for compiler.
Glenn Morris <rgm@gnu.org>
parents:
87691
diff
changeset
|
58 (defalias 'viper-make-overlay |
85972
51aa47312c4b
* ediff-init.el (ediff-xemacs-p, ediff-emacs-p): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
84908
diff
changeset
|
59 (if (featurep 'xemacs) 'make-extent 'make-overlay)) |
92380
8ee8aa679c74
(zmacs-region-stays): No need to define for compiler.
Glenn Morris <rgm@gnu.org>
parents:
87691
diff
changeset
|
60 (defalias 'viper-overlay-live-p |
85972
51aa47312c4b
* ediff-init.el (ediff-xemacs-p, ediff-emacs-p): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
84908
diff
changeset
|
61 (if (featurep 'xemacs) 'extent-live-p 'overlayp)) |
92380
8ee8aa679c74
(zmacs-region-stays): No need to define for compiler.
Glenn Morris <rgm@gnu.org>
parents:
87691
diff
changeset
|
62 (defalias 'viper-move-overlay |
85972
51aa47312c4b
* ediff-init.el (ediff-xemacs-p, ediff-emacs-p): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
84908
diff
changeset
|
63 (if (featurep 'xemacs) 'set-extent-endpoints 'move-overlay)) |
92380
8ee8aa679c74
(zmacs-region-stays): No need to define for compiler.
Glenn Morris <rgm@gnu.org>
parents:
87691
diff
changeset
|
64 (defalias 'viper-overlay-start |
85972
51aa47312c4b
* ediff-init.el (ediff-xemacs-p, ediff-emacs-p): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
84908
diff
changeset
|
65 (if (featurep 'xemacs) 'extent-start-position 'overlay-start)) |
92380
8ee8aa679c74
(zmacs-region-stays): No need to define for compiler.
Glenn Morris <rgm@gnu.org>
parents:
87691
diff
changeset
|
66 (defalias 'viper-overlay-end |
85972
51aa47312c4b
* ediff-init.el (ediff-xemacs-p, ediff-emacs-p): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
84908
diff
changeset
|
67 (if (featurep 'xemacs) 'extent-end-position 'overlay-end)) |
92380
8ee8aa679c74
(zmacs-region-stays): No need to define for compiler.
Glenn Morris <rgm@gnu.org>
parents:
87691
diff
changeset
|
68 (defalias 'viper-overlay-get |
85972
51aa47312c4b
* ediff-init.el (ediff-xemacs-p, ediff-emacs-p): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
84908
diff
changeset
|
69 (if (featurep 'xemacs) 'extent-property 'overlay-get)) |
92380
8ee8aa679c74
(zmacs-region-stays): No need to define for compiler.
Glenn Morris <rgm@gnu.org>
parents:
87691
diff
changeset
|
70 (defalias 'viper-overlay-put |
85972
51aa47312c4b
* ediff-init.el (ediff-xemacs-p, ediff-emacs-p): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
84908
diff
changeset
|
71 (if (featurep 'xemacs) 'set-extent-property 'overlay-put)) |
92380
8ee8aa679c74
(zmacs-region-stays): No need to define for compiler.
Glenn Morris <rgm@gnu.org>
parents:
87691
diff
changeset
|
72 (defalias 'viper-read-event |
85972
51aa47312c4b
* ediff-init.el (ediff-xemacs-p, ediff-emacs-p): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
84908
diff
changeset
|
73 (if (featurep 'xemacs) 'next-command-event 'read-event)) |
92380
8ee8aa679c74
(zmacs-region-stays): No need to define for compiler.
Glenn Morris <rgm@gnu.org>
parents:
87691
diff
changeset
|
74 (defalias 'viper-characterp |
85972
51aa47312c4b
* ediff-init.el (ediff-xemacs-p, ediff-emacs-p): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
84908
diff
changeset
|
75 (if (featurep 'xemacs) 'characterp 'integerp)) |
92380
8ee8aa679c74
(zmacs-region-stays): No need to define for compiler.
Glenn Morris <rgm@gnu.org>
parents:
87691
diff
changeset
|
76 (defalias 'viper-int-to-char |
85972
51aa47312c4b
* ediff-init.el (ediff-xemacs-p, ediff-emacs-p): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
84908
diff
changeset
|
77 (if (featurep 'xemacs) 'int-to-char 'identity)) |
92380
8ee8aa679c74
(zmacs-region-stays): No need to define for compiler.
Glenn Morris <rgm@gnu.org>
parents:
87691
diff
changeset
|
78 (defalias 'viper-get-face |
85972
51aa47312c4b
* ediff-init.el (ediff-xemacs-p, ediff-emacs-p): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
84908
diff
changeset
|
79 (if (featurep 'xemacs) 'get-face 'internal-get-face)) |
92380
8ee8aa679c74
(zmacs-region-stays): No need to define for compiler.
Glenn Morris <rgm@gnu.org>
parents:
87691
diff
changeset
|
80 (defalias 'viper-color-defined-p |
85972
51aa47312c4b
* ediff-init.el (ediff-xemacs-p, ediff-emacs-p): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
84908
diff
changeset
|
81 (if (featurep 'xemacs) 'valid-color-name-p 'x-color-defined-p)) |
51aa47312c4b
* ediff-init.el (ediff-xemacs-p, ediff-emacs-p): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
84908
diff
changeset
|
82 (defalias 'viper-iconify |
51aa47312c4b
* ediff-init.el (ediff-xemacs-p, ediff-emacs-p): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
84908
diff
changeset
|
83 (if (featurep 'xemacs) 'iconify-frame 'iconify-or-deiconify-frame)) |
18047 | 84 |
38514
10482dd382e7
* viper-ex.el (ex-token-list,ex-cmd-execute): Revamped, courtesy
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
38414
diff
changeset
|
85 |
33842
f6a67d77484a
* ediff-diff.el: Moved variables around to have it compile under NT.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
33742
diff
changeset
|
86 ;; CHAR is supposed to be a char or an integer (positive or negative) |
f6a67d77484a
* ediff-diff.el: Moved variables around to have it compile under NT.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
33742
diff
changeset
|
87 ;; LIST is a list of chars, nil, and negative numbers |
38514
10482dd382e7
* viper-ex.el (ex-token-list,ex-cmd-execute): Revamped, courtesy
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
38414
diff
changeset
|
88 ;; Check if CHAR is a member by trying to convert in characters, if necessary. |
33842
f6a67d77484a
* ediff-diff.el: Moved variables around to have it compile under NT.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
33742
diff
changeset
|
89 ;; Introduced for compatibility with XEmacs, where integers are not the same as |
f6a67d77484a
* ediff-diff.el: Moved variables around to have it compile under NT.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
33742
diff
changeset
|
90 ;; chars. |
33019
6306740f6938
2000-10-29 Michael Kifer <kifer@cs.sunysb.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
28510
diff
changeset
|
91 (defun viper-memq-char (char list) |
38514
10482dd382e7
* viper-ex.el (ex-token-list,ex-cmd-execute): Revamped, courtesy
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
38414
diff
changeset
|
92 (cond ((and (integerp char) (>= char 0)) |
10482dd382e7
* viper-ex.el (ex-token-list,ex-cmd-execute): Revamped, courtesy
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
38414
diff
changeset
|
93 (memq (viper-int-to-char char) list)) |
33842
f6a67d77484a
* ediff-diff.el: Moved variables around to have it compile under NT.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
33742
diff
changeset
|
94 ((memq char list)))) |
33019
6306740f6938
2000-10-29 Michael Kifer <kifer@cs.sunysb.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
28510
diff
changeset
|
95 |
38514
10482dd382e7
* viper-ex.el (ex-token-list,ex-cmd-execute): Revamped, courtesy
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
38414
diff
changeset
|
96 ;; Check if char-or-int and char are the same as characters |
10482dd382e7
* viper-ex.el (ex-token-list,ex-cmd-execute): Revamped, courtesy
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
38414
diff
changeset
|
97 (defun viper-char-equal (char-or-int char) |
10482dd382e7
* viper-ex.el (ex-token-list,ex-cmd-execute): Revamped, courtesy
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
38414
diff
changeset
|
98 (cond ((and (integerp char-or-int) (>= char-or-int 0)) |
10482dd382e7
* viper-ex.el (ex-token-list,ex-cmd-execute): Revamped, courtesy
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
38414
diff
changeset
|
99 (= (viper-int-to-char char-or-int) char)) |
10482dd382e7
* viper-ex.el (ex-token-list,ex-cmd-execute): Revamped, courtesy
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
38414
diff
changeset
|
100 ((eq char-or-int char)))) |
10482dd382e7
* viper-ex.el (ex-token-list,ex-cmd-execute): Revamped, courtesy
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
38414
diff
changeset
|
101 |
33019
6306740f6938
2000-10-29 Michael Kifer <kifer@cs.sunysb.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
28510
diff
changeset
|
102 ;; Like =, but accommodates null and also is t for eq-objects |
6306740f6938
2000-10-29 Michael Kifer <kifer@cs.sunysb.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
28510
diff
changeset
|
103 (defun viper= (char char1) |
6306740f6938
2000-10-29 Michael Kifer <kifer@cs.sunysb.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
28510
diff
changeset
|
104 (cond ((eq char char1) t) |
6306740f6938
2000-10-29 Michael Kifer <kifer@cs.sunysb.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
28510
diff
changeset
|
105 ((and (viper-characterp char) (viper-characterp char1)) |
6306740f6938
2000-10-29 Michael Kifer <kifer@cs.sunysb.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
28510
diff
changeset
|
106 (= char char1)) |
6306740f6938
2000-10-29 Michael Kifer <kifer@cs.sunysb.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
28510
diff
changeset
|
107 (t nil))) |
6306740f6938
2000-10-29 Michael Kifer <kifer@cs.sunysb.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
28510
diff
changeset
|
108 |
19079 | 109 (defsubst viper-color-display-p () |
92380
8ee8aa679c74
(zmacs-region-stays): No need to define for compiler.
Glenn Morris <rgm@gnu.org>
parents:
87691
diff
changeset
|
110 (if (featurep 'xemacs) (eq (device-class (selected-device)) 'color) |
8ee8aa679c74
(zmacs-region-stays): No need to define for compiler.
Glenn Morris <rgm@gnu.org>
parents:
87691
diff
changeset
|
111 (x-display-color-p))) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47520
diff
changeset
|
112 |
72516
aba79a1f03ed
2006-08-25 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
71382
diff
changeset
|
113 (defun viper-get-cursor-color (&optional frame) |
92380
8ee8aa679c74
(zmacs-region-stays): No need to define for compiler.
Glenn Morris <rgm@gnu.org>
parents:
87691
diff
changeset
|
114 (if (featurep 'xemacs) |
8ee8aa679c74
(zmacs-region-stays): No need to define for compiler.
Glenn Morris <rgm@gnu.org>
parents:
87691
diff
changeset
|
115 (color-instance-name |
8ee8aa679c74
(zmacs-region-stays): No need to define for compiler.
Glenn Morris <rgm@gnu.org>
parents:
87691
diff
changeset
|
116 (frame-property (or frame (selected-frame)) 'cursor-color)) |
8ee8aa679c74
(zmacs-region-stays): No need to define for compiler.
Glenn Morris <rgm@gnu.org>
parents:
87691
diff
changeset
|
117 (cdr (assoc 'cursor-color (frame-parameters))))) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47520
diff
changeset
|
118 |
92380
8ee8aa679c74
(zmacs-region-stays): No need to define for compiler.
Glenn Morris <rgm@gnu.org>
parents:
87691
diff
changeset
|
119 (defmacro viper-frame-value (variable) |
8ee8aa679c74
(zmacs-region-stays): No need to define for compiler.
Glenn Morris <rgm@gnu.org>
parents:
87691
diff
changeset
|
120 "Return the value of VARIABLE local to the current frame, if there is one. |
8ee8aa679c74
(zmacs-region-stays): No need to define for compiler.
Glenn Morris <rgm@gnu.org>
parents:
87691
diff
changeset
|
121 Otherwise return the normal value." |
8ee8aa679c74
(zmacs-region-stays): No need to define for compiler.
Glenn Morris <rgm@gnu.org>
parents:
87691
diff
changeset
|
122 `(if (featurep 'xemacs) |
8ee8aa679c74
(zmacs-region-stays): No need to define for compiler.
Glenn Morris <rgm@gnu.org>
parents:
87691
diff
changeset
|
123 ,variable |
8ee8aa679c74
(zmacs-region-stays): No need to define for compiler.
Glenn Morris <rgm@gnu.org>
parents:
87691
diff
changeset
|
124 ;; Frame-local variables are obsolete from Emacs 22.2 onwards, |
8ee8aa679c74
(zmacs-region-stays): No need to define for compiler.
Glenn Morris <rgm@gnu.org>
parents:
87691
diff
changeset
|
125 ;; so we do it by hand instead. |
92422
f3c93a3ef0d5
(viper-frame-value): Prefer buffer-local value, if set, over frame value.
Glenn Morris <rgm@gnu.org>
parents:
92380
diff
changeset
|
126 ;; Buffer-local values take precedence over frame-local ones. |
f3c93a3ef0d5
(viper-frame-value): Prefer buffer-local value, if set, over frame value.
Glenn Morris <rgm@gnu.org>
parents:
92380
diff
changeset
|
127 (if (local-variable-p ',variable) |
f3c93a3ef0d5
(viper-frame-value): Prefer buffer-local value, if set, over frame value.
Glenn Morris <rgm@gnu.org>
parents:
92380
diff
changeset
|
128 ,variable |
f3c93a3ef0d5
(viper-frame-value): Prefer buffer-local value, if set, over frame value.
Glenn Morris <rgm@gnu.org>
parents:
92380
diff
changeset
|
129 ;; Distinguish between no frame parameter and a frame parameter |
f3c93a3ef0d5
(viper-frame-value): Prefer buffer-local value, if set, over frame value.
Glenn Morris <rgm@gnu.org>
parents:
92380
diff
changeset
|
130 ;; with a value of nil. |
f3c93a3ef0d5
(viper-frame-value): Prefer buffer-local value, if set, over frame value.
Glenn Morris <rgm@gnu.org>
parents:
92380
diff
changeset
|
131 (let ((fp (assoc ',variable (frame-parameters)))) |
f3c93a3ef0d5
(viper-frame-value): Prefer buffer-local value, if set, over frame value.
Glenn Morris <rgm@gnu.org>
parents:
92380
diff
changeset
|
132 (if fp (cdr fp) |
f3c93a3ef0d5
(viper-frame-value): Prefer buffer-local value, if set, over frame value.
Glenn Morris <rgm@gnu.org>
parents:
92380
diff
changeset
|
133 ,variable))))) |
16136
de1340e6ddb4
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15747
diff
changeset
|
134 |
10789 | 135 ;; OS/2 |
19079 | 136 (cond ((eq (viper-device-type) 'pm) |
137 (fset 'viper-color-defined-p | |
26263
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
22284
diff
changeset
|
138 (lambda (color) (assoc color pm-color-alist))))) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47520
diff
changeset
|
139 |
14233
396316e5fbe6
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14169
diff
changeset
|
140 |
396316e5fbe6
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14169
diff
changeset
|
141 ;; cursor colors |
72516
aba79a1f03ed
2006-08-25 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
71382
diff
changeset
|
142 (defun viper-change-cursor-color (new-color &optional frame) |
19079 | 143 (if (and (viper-window-display-p) (viper-color-display-p) |
144 (stringp new-color) (viper-color-defined-p new-color) | |
145 (not (string= new-color (viper-get-cursor-color)))) | |
92380
8ee8aa679c74
(zmacs-region-stays): No need to define for compiler.
Glenn Morris <rgm@gnu.org>
parents:
87691
diff
changeset
|
146 (if (featurep 'xemacs) |
8ee8aa679c74
(zmacs-region-stays): No need to define for compiler.
Glenn Morris <rgm@gnu.org>
parents:
87691
diff
changeset
|
147 (set-frame-property |
8ee8aa679c74
(zmacs-region-stays): No need to define for compiler.
Glenn Morris <rgm@gnu.org>
parents:
87691
diff
changeset
|
148 (or frame (selected-frame)) |
8ee8aa679c74
(zmacs-region-stays): No need to define for compiler.
Glenn Morris <rgm@gnu.org>
parents:
87691
diff
changeset
|
149 'cursor-color (make-color-instance new-color)) |
8ee8aa679c74
(zmacs-region-stays): No need to define for compiler.
Glenn Morris <rgm@gnu.org>
parents:
87691
diff
changeset
|
150 (modify-frame-parameters |
8ee8aa679c74
(zmacs-region-stays): No need to define for compiler.
Glenn Morris <rgm@gnu.org>
parents:
87691
diff
changeset
|
151 (or frame (selected-frame)) |
8ee8aa679c74
(zmacs-region-stays): No need to define for compiler.
Glenn Morris <rgm@gnu.org>
parents:
87691
diff
changeset
|
152 (list (cons 'cursor-color new-color)))))) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47520
diff
changeset
|
153 |
92380
8ee8aa679c74
(zmacs-region-stays): No need to define for compiler.
Glenn Morris <rgm@gnu.org>
parents:
87691
diff
changeset
|
154 ;; Note that the colors this function uses might not be those |
8ee8aa679c74
(zmacs-region-stays): No need to define for compiler.
Glenn Morris <rgm@gnu.org>
parents:
87691
diff
changeset
|
155 ;; associated with FRAME, if there are frame-local values. |
8ee8aa679c74
(zmacs-region-stays): No need to define for compiler.
Glenn Morris <rgm@gnu.org>
parents:
87691
diff
changeset
|
156 ;; This was equally true before the advent of viper-frame-value. |
8ee8aa679c74
(zmacs-region-stays): No need to define for compiler.
Glenn Morris <rgm@gnu.org>
parents:
87691
diff
changeset
|
157 ;; Now it could be changed by passing frame to v-f-v. |
72516
aba79a1f03ed
2006-08-25 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
71382
diff
changeset
|
158 (defun viper-set-cursor-color-according-to-state (&optional frame) |
aba79a1f03ed
2006-08-25 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
71382
diff
changeset
|
159 (cond ((eq viper-current-state 'replace-state) |
92380
8ee8aa679c74
(zmacs-region-stays): No need to define for compiler.
Glenn Morris <rgm@gnu.org>
parents:
87691
diff
changeset
|
160 (viper-change-cursor-color |
8ee8aa679c74
(zmacs-region-stays): No need to define for compiler.
Glenn Morris <rgm@gnu.org>
parents:
87691
diff
changeset
|
161 (viper-frame-value viper-replace-overlay-cursor-color) |
8ee8aa679c74
(zmacs-region-stays): No need to define for compiler.
Glenn Morris <rgm@gnu.org>
parents:
87691
diff
changeset
|
162 frame)) |
72516
aba79a1f03ed
2006-08-25 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
71382
diff
changeset
|
163 ((and (eq viper-current-state 'emacs-state) |
92380
8ee8aa679c74
(zmacs-region-stays): No need to define for compiler.
Glenn Morris <rgm@gnu.org>
parents:
87691
diff
changeset
|
164 (viper-frame-value viper-emacs-state-cursor-color)) |
8ee8aa679c74
(zmacs-region-stays): No need to define for compiler.
Glenn Morris <rgm@gnu.org>
parents:
87691
diff
changeset
|
165 (viper-change-cursor-color |
8ee8aa679c74
(zmacs-region-stays): No need to define for compiler.
Glenn Morris <rgm@gnu.org>
parents:
87691
diff
changeset
|
166 (viper-frame-value viper-emacs-state-cursor-color) |
8ee8aa679c74
(zmacs-region-stays): No need to define for compiler.
Glenn Morris <rgm@gnu.org>
parents:
87691
diff
changeset
|
167 frame)) |
72516
aba79a1f03ed
2006-08-25 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
71382
diff
changeset
|
168 ((eq viper-current-state 'insert-state) |
92380
8ee8aa679c74
(zmacs-region-stays): No need to define for compiler.
Glenn Morris <rgm@gnu.org>
parents:
87691
diff
changeset
|
169 (viper-change-cursor-color |
8ee8aa679c74
(zmacs-region-stays): No need to define for compiler.
Glenn Morris <rgm@gnu.org>
parents:
87691
diff
changeset
|
170 (viper-frame-value viper-insert-state-cursor-color) |
8ee8aa679c74
(zmacs-region-stays): No need to define for compiler.
Glenn Morris <rgm@gnu.org>
parents:
87691
diff
changeset
|
171 frame)) |
72516
aba79a1f03ed
2006-08-25 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
71382
diff
changeset
|
172 (t |
92380
8ee8aa679c74
(zmacs-region-stays): No need to define for compiler.
Glenn Morris <rgm@gnu.org>
parents:
87691
diff
changeset
|
173 (viper-change-cursor-color |
8ee8aa679c74
(zmacs-region-stays): No need to define for compiler.
Glenn Morris <rgm@gnu.org>
parents:
87691
diff
changeset
|
174 (viper-frame-value viper-vi-state-cursor-color) |
8ee8aa679c74
(zmacs-region-stays): No need to define for compiler.
Glenn Morris <rgm@gnu.org>
parents:
87691
diff
changeset
|
175 frame)))) |
72516
aba79a1f03ed
2006-08-25 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
71382
diff
changeset
|
176 |
106192
a2ee981efbec
2009-11-22 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
105829
diff
changeset
|
177 ;; By default, saves current frame cursor color before changing viper state |
26263
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
22284
diff
changeset
|
178 (defun viper-save-cursor-color (before-which-mode) |
19079 | 179 (if (and (viper-window-display-p) (viper-color-display-p)) |
180 (let ((color (viper-get-cursor-color))) | |
181 (if (and (stringp color) (viper-color-defined-p color) | |
106192
a2ee981efbec
2009-11-22 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
105829
diff
changeset
|
182 ;; there is something fishy in that the color is not saved if |
a2ee981efbec
2009-11-22 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
105829
diff
changeset
|
183 ;; it is the same as frames default cursor color. need to be |
a2ee981efbec
2009-11-22 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
105829
diff
changeset
|
184 ;; checked. |
92380
8ee8aa679c74
(zmacs-region-stays): No need to define for compiler.
Glenn Morris <rgm@gnu.org>
parents:
87691
diff
changeset
|
185 (not (string= color |
8ee8aa679c74
(zmacs-region-stays): No need to define for compiler.
Glenn Morris <rgm@gnu.org>
parents:
87691
diff
changeset
|
186 (viper-frame-value |
8ee8aa679c74
(zmacs-region-stays): No need to define for compiler.
Glenn Morris <rgm@gnu.org>
parents:
87691
diff
changeset
|
187 viper-replace-overlay-cursor-color)))) |
26263
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
22284
diff
changeset
|
188 (modify-frame-parameters |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
22284
diff
changeset
|
189 (selected-frame) |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
22284
diff
changeset
|
190 (list |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
22284
diff
changeset
|
191 (cons |
68997
6169b51037af
2006-02-19 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
68648
diff
changeset
|
192 (cond ((eq before-which-mode 'before-replace-mode) |
6169b51037af
2006-02-19 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
68648
diff
changeset
|
193 'viper-saved-cursor-color-in-replace-mode) |
6169b51037af
2006-02-19 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
68648
diff
changeset
|
194 ((eq before-which-mode 'before-emacs-mode) |
6169b51037af
2006-02-19 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
68648
diff
changeset
|
195 'viper-saved-cursor-color-in-emacs-mode) |
6169b51037af
2006-02-19 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
68648
diff
changeset
|
196 (t |
6169b51037af
2006-02-19 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
68648
diff
changeset
|
197 'viper-saved-cursor-color-in-insert-mode)) |
92380
8ee8aa679c74
(zmacs-region-stays): No need to define for compiler.
Glenn Morris <rgm@gnu.org>
parents:
87691
diff
changeset
|
198 color))))))) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47520
diff
changeset
|
199 |
26263
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
22284
diff
changeset
|
200 |
99595
eb7532b56b78
2008-11-16 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
97142
diff
changeset
|
201 (defun viper-get-saved-cursor-color-in-replace-mode () |
26263
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
22284
diff
changeset
|
202 (or |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
22284
diff
changeset
|
203 (funcall |
85972
51aa47312c4b
* ediff-init.el (ediff-xemacs-p, ediff-emacs-p): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
84908
diff
changeset
|
204 (if (featurep 'emacs) 'frame-parameter 'frame-property) |
26263
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
22284
diff
changeset
|
205 (selected-frame) |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
22284
diff
changeset
|
206 'viper-saved-cursor-color-in-replace-mode) |
93615
34417c118a39
2008-04-03 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
92766
diff
changeset
|
207 (or (and (eq viper-current-state 'emacs-mode) |
34417c118a39
2008-04-03 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
92766
diff
changeset
|
208 (viper-frame-value viper-emacs-state-cursor-color)) |
34417c118a39
2008-04-03 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
92766
diff
changeset
|
209 (viper-frame-value viper-vi-state-cursor-color)))) |
26263
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
22284
diff
changeset
|
210 |
99595
eb7532b56b78
2008-11-16 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
97142
diff
changeset
|
211 (defun viper-get-saved-cursor-color-in-insert-mode () |
26263
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
22284
diff
changeset
|
212 (or |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
22284
diff
changeset
|
213 (funcall |
85972
51aa47312c4b
* ediff-init.el (ediff-xemacs-p, ediff-emacs-p): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
84908
diff
changeset
|
214 (if (featurep 'emacs) 'frame-parameter 'frame-property) |
26263
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
22284
diff
changeset
|
215 (selected-frame) |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
22284
diff
changeset
|
216 'viper-saved-cursor-color-in-insert-mode) |
93615
34417c118a39
2008-04-03 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
92766
diff
changeset
|
217 (or (and (eq viper-current-state 'emacs-mode) |
34417c118a39
2008-04-03 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
92766
diff
changeset
|
218 (viper-frame-value viper-emacs-state-cursor-color)) |
34417c118a39
2008-04-03 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
92766
diff
changeset
|
219 (viper-frame-value viper-vi-state-cursor-color)))) |
68997
6169b51037af
2006-02-19 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
68648
diff
changeset
|
220 |
99595
eb7532b56b78
2008-11-16 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
97142
diff
changeset
|
221 (defun viper-get-saved-cursor-color-in-emacs-mode () |
68997
6169b51037af
2006-02-19 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
68648
diff
changeset
|
222 (or |
6169b51037af
2006-02-19 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
68648
diff
changeset
|
223 (funcall |
85972
51aa47312c4b
* ediff-init.el (ediff-xemacs-p, ediff-emacs-p): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
84908
diff
changeset
|
224 (if (featurep 'emacs) 'frame-parameter 'frame-property) |
68997
6169b51037af
2006-02-19 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
68648
diff
changeset
|
225 (selected-frame) |
6169b51037af
2006-02-19 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
68648
diff
changeset
|
226 'viper-saved-cursor-color-in-emacs-mode) |
92380
8ee8aa679c74
(zmacs-region-stays): No need to define for compiler.
Glenn Morris <rgm@gnu.org>
parents:
87691
diff
changeset
|
227 (viper-frame-value viper-vi-state-cursor-color))) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47520
diff
changeset
|
228 |
16766
beb94a5271e2
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
16329
diff
changeset
|
229 ;; restore cursor color from replace overlay |
26263
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
22284
diff
changeset
|
230 (defun viper-restore-cursor-color(after-which-mode) |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
22284
diff
changeset
|
231 (if (viper-overlay-p viper-replace-overlay) |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
22284
diff
changeset
|
232 (viper-change-cursor-color |
68997
6169b51037af
2006-02-19 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
68648
diff
changeset
|
233 (cond ((eq after-which-mode 'after-replace-mode) |
6169b51037af
2006-02-19 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
68648
diff
changeset
|
234 (viper-get-saved-cursor-color-in-replace-mode)) |
6169b51037af
2006-02-19 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
68648
diff
changeset
|
235 ((eq after-which-mode 'after-emacs-mode) |
6169b51037af
2006-02-19 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
68648
diff
changeset
|
236 (viper-get-saved-cursor-color-in-emacs-mode)) |
6169b51037af
2006-02-19 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
68648
diff
changeset
|
237 (t (viper-get-saved-cursor-color-in-insert-mode))) |
26263
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
22284
diff
changeset
|
238 ))) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47520
diff
changeset
|
239 |
18047 | 240 |
10789 | 241 ;; Check the current version against the major and minor version numbers |
242 ;; using op: cur-vers op major.minor If emacs-major-version or | |
243 ;; emacs-minor-version are not defined, we assume that the current version | |
244 ;; is hopelessly outdated. We assume that emacs-major-version and | |
245 ;; emacs-minor-version are defined. Otherwise, for Emacs/XEmacs 19, if the | |
246 ;; current minor version is < 10 (xemacs) or < 23 (emacs) the return value | |
247 ;; will be nil (when op is =, >, or >=) and t (when op is <, <=), which may be | |
26263
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
22284
diff
changeset
|
248 ;; incorrect. However, this gives correct result in our cases, since we are |
10789 | 249 ;; testing for sufficiently high Emacs versions. |
19079 | 250 (defun viper-check-version (op major minor &optional type-of-emacs) |
10789 | 251 (if (and (boundp 'emacs-major-version) (boundp 'emacs-minor-version)) |
85972
51aa47312c4b
* ediff-init.el (ediff-xemacs-p, ediff-emacs-p): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
84908
diff
changeset
|
252 (and (cond ((eq type-of-emacs 'xemacs) (featurep 'xemacs)) |
51aa47312c4b
* ediff-init.el (ediff-xemacs-p, ediff-emacs-p): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
84908
diff
changeset
|
253 ((eq type-of-emacs 'emacs) (featurep 'emacs)) |
10789 | 254 (t t)) |
255 (cond ((eq op '=) (and (= emacs-minor-version minor) | |
256 (= emacs-major-version major))) | |
257 ((memq op '(> >= < <=)) | |
258 (and (or (funcall op emacs-major-version major) | |
259 (= emacs-major-version major)) | |
260 (if (= emacs-major-version major) | |
261 (funcall op emacs-minor-version minor) | |
262 t))) | |
263 (t | |
19079 | 264 (error "%S: Invalid op in viper-check-version" op)))) |
10789 | 265 (cond ((memq op '(= > >=)) nil) |
266 ((memq op '(< <=)) t)))) | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47520
diff
changeset
|
267 |
10789 | 268 |
19079 | 269 (defun viper-get-visible-buffer-window (wind) |
85972
51aa47312c4b
* ediff-init.el (ediff-xemacs-p, ediff-emacs-p): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
84908
diff
changeset
|
270 (if (featurep 'xemacs) |
10789 | 271 (get-buffer-window wind t) |
272 (get-buffer-window wind 'visible))) | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47520
diff
changeset
|
273 |
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47520
diff
changeset
|
274 |
12139
e16c06646396
(vip-event-key): now handles keys 128--255 as meta-chars.
Karl Heuer <kwzh@gnu.org>
parents:
11288
diff
changeset
|
275 ;; Return line position. |
e16c06646396
(vip-event-key): now handles keys 128--255 as meta-chars.
Karl Heuer <kwzh@gnu.org>
parents:
11288
diff
changeset
|
276 ;; If pos is 'start then returns position of line start. |
26263
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
22284
diff
changeset
|
277 ;; If pos is 'end, returns line end. If pos is 'mid, returns line center. |
12139
e16c06646396
(vip-event-key): now handles keys 128--255 as meta-chars.
Karl Heuer <kwzh@gnu.org>
parents:
11288
diff
changeset
|
278 ;; Pos = 'indent returns beginning of indentation. |
26263
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
22284
diff
changeset
|
279 ;; Otherwise, returns point. Current point is not moved in any case." |
19079 | 280 (defun viper-line-pos (pos) |
10789 | 281 (let ((cur-pos (point)) |
282 (result)) | |
283 (cond | |
284 ((equal pos 'start) | |
285 (beginning-of-line)) | |
286 ((equal pos 'end) | |
287 (end-of-line)) | |
288 ((equal pos 'mid) | |
19079 | 289 (goto-char (+ (viper-line-pos 'start) (viper-line-pos 'end) 2))) |
10789 | 290 ((equal pos 'indent) |
291 (back-to-indentation)) | |
292 (t nil)) | |
293 (setq result (point)) | |
294 (goto-char cur-pos) | |
295 result)) | |
296 | |
47520
a37b476e1aec
2002-09-18 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
43220
diff
changeset
|
297 ;; Emacs used to count each multibyte character as several positions in the buffer, |
a37b476e1aec
2002-09-18 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
43220
diff
changeset
|
298 ;; so we had to use Emacs' chars-in-region to count characters. Since 20.3, |
a37b476e1aec
2002-09-18 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
43220
diff
changeset
|
299 ;; Emacs counts multibyte characters as 1 position. XEmacs has always been |
a37b476e1aec
2002-09-18 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
43220
diff
changeset
|
300 ;; counting each char as just one pos. So, now we can simply subtract beg from |
a37b476e1aec
2002-09-18 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
43220
diff
changeset
|
301 ;; end to determine the number of characters in a region. |
19462 | 302 (defun viper-chars-in-region (beg end &optional preserve-sign) |
47520
a37b476e1aec
2002-09-18 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
43220
diff
changeset
|
303 ;;(let ((count (abs (if (fboundp 'chars-in-region) |
a37b476e1aec
2002-09-18 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
43220
diff
changeset
|
304 ;; (chars-in-region beg end) |
a37b476e1aec
2002-09-18 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
43220
diff
changeset
|
305 ;; (- end beg))))) |
a37b476e1aec
2002-09-18 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
43220
diff
changeset
|
306 (let ((count (abs (- end beg)))) |
19462 | 307 (if (and (< end beg) preserve-sign) |
308 (- count) | |
309 count))) | |
310 | |
311 ;; Test if POS is between BEG and END | |
312 (defsubst viper-pos-within-region (pos beg end) | |
313 (and (>= pos (min beg end)) (>= (max beg end) pos))) | |
314 | |
10789 | 315 |
12139
e16c06646396
(vip-event-key): now handles keys 128--255 as meta-chars.
Karl Heuer <kwzh@gnu.org>
parents:
11288
diff
changeset
|
316 ;; 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
|
317 ;; 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
|
318 ;; Arguments: (var-name position &optional buffer). |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47520
diff
changeset
|
319 ;; |
12139
e16c06646396
(vip-event-key): now handles keys 128--255 as meta-chars.
Karl Heuer <kwzh@gnu.org>
parents:
11288
diff
changeset
|
320 ;; 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
|
321 ;; For this, VAR-NAME should be made buffer-local with nil as a default. |
19079 | 322 ;; 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
|
323 ;; buffer, a new marker will be created. |
19079 | 324 (defun viper-move-marker-locally (var pos &optional buffer) |
10789 | 325 (if (markerp (eval var)) |
326 () | |
327 (set var (make-marker))) | |
328 (move-marker (eval var) pos buffer)) | |
329 | |
330 | |
12139
e16c06646396
(vip-event-key): now handles keys 128--255 as meta-chars.
Karl Heuer <kwzh@gnu.org>
parents:
11288
diff
changeset
|
331 ;; Print CONDITIONS as a message. |
19079 | 332 (defun viper-message-conditions (conditions) |
10789 | 333 (let ((case (car conditions)) (msg (cdr conditions))) |
334 (if (null msg) | |
335 (message "%s" case) | |
336 (message "%s: %s" case (mapconcat 'prin1-to-string msg " "))) | |
337 (beep 1))) | |
338 | |
12139
e16c06646396
(vip-event-key): now handles keys 128--255 as meta-chars.
Karl Heuer <kwzh@gnu.org>
parents:
11288
diff
changeset
|
339 |
10789 | 340 |
341 ;;; List/alist utilities | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47520
diff
changeset
|
342 |
12139
e16c06646396
(vip-event-key): now handles keys 128--255 as meta-chars.
Karl Heuer <kwzh@gnu.org>
parents:
11288
diff
changeset
|
343 ;; Convert LIST to an alist |
19079 | 344 (defun viper-list-to-alist (lst) |
10789 | 345 (let ((alist)) |
346 (while lst | |
347 (setq alist (cons (list (car lst)) alist)) | |
348 (setq lst (cdr lst))) | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47520
diff
changeset
|
349 alist)) |
10789 | 350 |
12139
e16c06646396
(vip-event-key): now handles keys 128--255 as meta-chars.
Karl Heuer <kwzh@gnu.org>
parents:
11288
diff
changeset
|
351 ;; Convert ALIST to a list. |
19079 | 352 (defun viper-alist-to-list (alst) |
10789 | 353 (let ((lst)) |
354 (while alst | |
355 (setq lst (cons (car (car alst)) lst)) | |
356 (setq alst (cdr alst))) | |
357 lst)) | |
358 | |
26263
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
22284
diff
changeset
|
359 ;; Filter ALIST using REGEXP. Return alist whose elements match the regexp. |
19079 | 360 (defun viper-filter-alist (regexp alst) |
10789 | 361 (interactive "s x") |
362 (let ((outalst) (inalst alst)) | |
363 (while (car inalst) | |
364 (if (string-match regexp (car (car inalst))) | |
365 (setq outalst (cons (car inalst) outalst))) | |
366 (setq inalst (cdr inalst))) | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47520
diff
changeset
|
367 outalst)) |
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47520
diff
changeset
|
368 |
26263
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
22284
diff
changeset
|
369 ;; Filter LIST using REGEXP. Return list whose elements match the regexp. |
19079 | 370 (defun viper-filter-list (regexp lst) |
10789 | 371 (interactive "s x") |
372 (let ((outlst) (inlst lst)) | |
373 (while (car inlst) | |
374 (if (string-match regexp (car inlst)) | |
375 (setq outlst (cons (car inlst) outlst))) | |
376 (setq inlst (cdr inlst))) | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47520
diff
changeset
|
377 outlst)) |
10789 | 378 |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47520
diff
changeset
|
379 |
10789 | 380 ;; Append LIS2 to LIS1, both alists, by side-effect and returns LIS1 |
381 ;; LIS2 is modified by filtering it: deleting its members of the form | |
382 ;; \(car elt\) such that (car elt') is in LIS1. | |
19079 | 383 (defun viper-append-filter-alist (lis1 lis2) |
10789 | 384 (let ((temp lis1) |
385 elt) | |
386 ;;filter-append the second list | |
387 (while temp | |
388 ;; delete all occurrences | |
389 (while (setq elt (assoc (car (car temp)) lis2)) | |
390 (setq lis2 (delq elt lis2))) | |
391 (setq temp (cdr temp))) | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47520
diff
changeset
|
392 |
64750
fbdb9482b6fc
2005-08-06 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
64701
diff
changeset
|
393 (append lis1 lis2))) |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
394 |
36857
f6386773ce30
2001-03-17 Michael Kifer <kifer@cs.sunysb.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
33842
diff
changeset
|
395 |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
396 |
87691
f2c8fd594360
2008-01-10 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
87678
diff
changeset
|
397 (declare-function viper-forward-Word "viper-cmd" (arg)) |
86243
4d615a83cee2
* progmodes/idlw-help.el: Require browse-url unconditionally, it
Dan Nicolaescu <dann@ics.uci.edu>
parents:
85972
diff
changeset
|
398 |
26263
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
22284
diff
changeset
|
399 ;;; Support for :e, :r, :w file globbing |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
400 |
26263
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
22284
diff
changeset
|
401 ;; Glob the file spec. |
97142 | 402 ;; This function is designed to work under Unix. |
26263
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
22284
diff
changeset
|
403 (defun viper-glob-unix-files (filespec) |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
404 (let ((gshell |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
405 (cond (ex-unix-type-shell shell-file-name) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
406 (t "sh"))) ; probably Unix anyway |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
407 (gshell-options |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
408 ;; using cond in anticipation of further additions |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
409 (cond (ex-unix-type-shell-options) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
410 )) |
19079 | 411 (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
|
412 (t (format "ls -1 -d %s" filespec)))) |
26263
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
22284
diff
changeset
|
413 status) |
105829
328150f0cf76
* url-util.el (url-insert-entities-in-string):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
101721
diff
changeset
|
414 (with-current-buffer (get-buffer-create viper-ex-tmp-buf-name) |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
415 (erase-buffer) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
416 (setq status |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
417 (if gshell-options |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
418 (call-process gshell nil t nil |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
419 gshell-options |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
420 "-c" |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
421 command) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
422 (call-process gshell nil t nil |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
423 "-c" |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
424 command))) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
425 (goto-char (point-min)) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
426 ;; Issue an error, if no match. |
53477
79093b308520
* progmodes/idlwave.el (idlwave-make-tags):
Eli Zaretskii <eliz@is.elta.co.il>
parents:
52401
diff
changeset
|
427 (unless (eq 0 status) |
79093b308520
* progmodes/idlwave.el (idlwave-make-tags):
Eli Zaretskii <eliz@is.elta.co.il>
parents:
52401
diff
changeset
|
428 (save-excursion |
79093b308520
* progmodes/idlwave.el (idlwave-make-tags):
Eli Zaretskii <eliz@is.elta.co.il>
parents:
52401
diff
changeset
|
429 (skip-chars-forward " \t\n\j") |
79093b308520
* progmodes/idlwave.el (idlwave-make-tags):
Eli Zaretskii <eliz@is.elta.co.il>
parents:
52401
diff
changeset
|
430 (if (looking-at "ls:") |
79093b308520
* progmodes/idlwave.el (idlwave-make-tags):
Eli Zaretskii <eliz@is.elta.co.il>
parents:
52401
diff
changeset
|
431 (viper-forward-Word 1)) |
79093b308520
* progmodes/idlwave.el (idlwave-make-tags):
Eli Zaretskii <eliz@is.elta.co.il>
parents:
52401
diff
changeset
|
432 (error "%s: %s" |
79093b308520
* progmodes/idlwave.el (idlwave-make-tags):
Eli Zaretskii <eliz@is.elta.co.il>
parents:
52401
diff
changeset
|
433 (if (stringp gshell) |
79093b308520
* progmodes/idlwave.el (idlwave-make-tags):
Eli Zaretskii <eliz@is.elta.co.il>
parents:
52401
diff
changeset
|
434 gshell |
79093b308520
* progmodes/idlwave.el (idlwave-make-tags):
Eli Zaretskii <eliz@is.elta.co.il>
parents:
52401
diff
changeset
|
435 "shell") |
79093b308520
* progmodes/idlwave.el (idlwave-make-tags):
Eli Zaretskii <eliz@is.elta.co.il>
parents:
52401
diff
changeset
|
436 (buffer-substring (point) (viper-line-pos 'end))) |
79093b308520
* progmodes/idlwave.el (idlwave-make-tags):
Eli Zaretskii <eliz@is.elta.co.il>
parents:
52401
diff
changeset
|
437 )) |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
438 (goto-char (point-min)) |
26263
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
22284
diff
changeset
|
439 (viper-get-filenames-from-buffer 'one-per-line)) |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
440 )) |
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 |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
443 ;; 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
|
444 ;; 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
|
445 ;; 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
|
446 ;; line |
19079 | 447 (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
|
448 (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
|
449 result fname delim) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
450 (skip-chars-forward skip-chars) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
451 (while (not (eobp)) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
452 (if (cond ((looking-at "\"") |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
453 (setq delim ?\") |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
454 (re-search-forward "[^\"]+" nil t)) ; noerror |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
455 ((looking-at "'") |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
456 (setq delim ?') |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
457 (re-search-forward "[^']+" nil t)) ; noerror |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47520
diff
changeset
|
458 (t |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
459 (re-search-forward |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
460 (concat "[^" skip-chars "]+") nil t))) ;noerror |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
461 (setq fname |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
462 (buffer-substring (match-beginning 0) (match-end 0)))) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
463 (if delim |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
464 (forward-char 1)) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
465 (skip-chars-forward " \t\n") |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
466 (setq result (cons fname result))) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
467 result)) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
468 |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
469 ;; convert MS-DOS wildcards to regexp |
19079 | 470 (defun viper-wildcard-to-regexp (wcard) |
105829
328150f0cf76
* url-util.el (url-insert-entities-in-string):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
101721
diff
changeset
|
471 (with-current-buffer (get-buffer-create viper-ex-tmp-buf-name) |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
472 (erase-buffer) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
473 (insert wcard) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
474 (goto-char (point-min)) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
475 (while (not (eobp)) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
476 (skip-chars-forward "^*?.\\\\") |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
477 (cond ((eq (char-after (point)) ?*) (insert ".")(forward-char 1)) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
478 ((eq (char-after (point)) ?.) (insert "\\")(forward-char 1)) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
479 ((eq (char-after (point)) ?\\) (insert "\\")(forward-char 1)) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
480 ((eq (char-after (point)) ??) (delete-char 1)(insert "."))) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
481 ) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
482 (buffer-string) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
483 )) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
484 |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
485 |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
486 ;; glob windows files |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
487 ;; LIST is expected to be in reverse order |
26263
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
22284
diff
changeset
|
488 (defun viper-glob-mswindows-files (filespec) |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
22284
diff
changeset
|
489 (let ((case-fold-search t) |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
22284
diff
changeset
|
490 tmp tmp2) |
105829
328150f0cf76
* url-util.el (url-insert-entities-in-string):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
101721
diff
changeset
|
491 (with-current-buffer (get-buffer-create viper-ex-tmp-buf-name) |
26263
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
22284
diff
changeset
|
492 (erase-buffer) |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
22284
diff
changeset
|
493 (insert filespec) |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
22284
diff
changeset
|
494 (goto-char (point-min)) |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
22284
diff
changeset
|
495 (setq tmp (viper-get-filenames-from-buffer)) |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
22284
diff
changeset
|
496 (while tmp |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47520
diff
changeset
|
497 (setq tmp2 (cons (directory-files |
26263
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
22284
diff
changeset
|
498 ;; the directory part |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
22284
diff
changeset
|
499 (or (file-name-directory (car tmp)) |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
22284
diff
changeset
|
500 "") |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
22284
diff
changeset
|
501 t ; return full names |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
22284
diff
changeset
|
502 ;; the regexp part: globs the file names |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
22284
diff
changeset
|
503 (concat "^" |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
22284
diff
changeset
|
504 (viper-wildcard-to-regexp |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
22284
diff
changeset
|
505 (file-name-nondirectory (car tmp))) |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
22284
diff
changeset
|
506 "$")) |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
22284
diff
changeset
|
507 tmp2)) |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
22284
diff
changeset
|
508 (setq tmp (cdr tmp))) |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
22284
diff
changeset
|
509 (reverse (apply 'append tmp2))))) |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
510 |
10789 | 511 |
512 ;;; Insertion ring | |
513 | |
26263
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
22284
diff
changeset
|
514 ;; Rotate RING's index. DIRection can be positive or negative. |
19079 | 515 (defun viper-ring-rotate1 (ring dir) |
10789 | 516 (if (and (ring-p ring) (> (ring-length ring) 0)) |
517 (progn | |
518 (setcar ring (cond ((> dir 0) | |
519 (ring-plus1 (car ring) (ring-length ring))) | |
520 ((< dir 0) | |
521 (ring-minus1 (car ring) (ring-length ring))) | |
522 ;; don't rotate if dir = 0 | |
523 (t (car ring)))) | |
19079 | 524 (viper-current-ring-item ring) |
10789 | 525 ))) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47520
diff
changeset
|
526 |
19079 | 527 (defun viper-special-ring-rotate1 (ring dir) |
528 (if (memq viper-intermediate-command | |
10789 | 529 '(repeating-display-destructive-command |
530 repeating-insertion-from-ring)) | |
19079 | 531 (viper-ring-rotate1 ring dir) |
10789 | 532 ;; don't rotate otherwise |
19079 | 533 (viper-ring-rotate1 ring 0))) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47520
diff
changeset
|
534 |
10789 | 535 ;; current ring item; if N is given, then so many items back from the |
536 ;; current | |
19079 | 537 (defun viper-current-ring-item (ring &optional n) |
10789 | 538 (setq n (or n 0)) |
539 (if (and (ring-p ring) (> (ring-length ring) 0)) | |
540 (aref (cdr (cdr ring)) (mod (- (car ring) 1 n) (ring-length ring))))) | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47520
diff
changeset
|
541 |
26263
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
22284
diff
changeset
|
542 ;; Push item onto ring. The second argument is a ring-variable, not value. |
19079 | 543 (defun viper-push-onto-ring (item ring-var) |
10789 | 544 (or (ring-p (eval ring-var)) |
545 (set ring-var (make-ring (eval (intern (format "%S-size" ring-var)))))) | |
546 (or (null item) ; don't push nil | |
547 (and (stringp item) (string= item "")) ; or empty strings | |
19079 | 548 (equal item (viper-current-ring-item (eval ring-var))) ; or old stuff |
549 ;; Since viper-set-destructive-command checks if we are inside | |
550 ;; viper-repeat, we don't check whether this-command-keys is a `.'. The | |
551 ;; cmd viper-repeat makes a call to the current function only if `.' is | |
26263
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
22284
diff
changeset
|
552 ;; executing a command from the command history. It doesn't call the |
19079 | 553 ;; push-onto-ring function if `.' is simply repeating the last |
554 ;; destructive command. We only check for ESC (which happens when we do | |
555 ;; insert with a prefix argument, or if this-command-keys doesn't give | |
556 ;; anything meaningful (in that case we don't know what to show to the | |
557 ;; user). | |
558 (and (eq ring-var 'viper-command-ring) | |
10789 | 559 (string-match "\\([0-9]*\e\\|^[ \t]*$\\|escape\\)" |
19079 | 560 (viper-array-to-string (this-command-keys)))) |
561 (viper-ring-insert (eval ring-var) item)) | |
10789 | 562 ) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47520
diff
changeset
|
563 |
10789 | 564 |
565 ;; removing elts from ring seems to break it | |
19079 | 566 (defun viper-cleanup-ring (ring) |
10789 | 567 (or (< (ring-length ring) 2) |
19079 | 568 (null (viper-current-ring-item ring)) |
10789 | 569 ;; last and previous equal |
19079 | 570 (if (equal (viper-current-ring-item ring) |
571 (viper-current-ring-item ring 1)) | |
572 (viper-ring-pop ring)))) | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47520
diff
changeset
|
573 |
10789 | 574 ;; ring-remove seems to be buggy, so we concocted this for our purposes. |
19079 | 575 (defun viper-ring-pop (ring) |
10789 | 576 (let* ((ln (ring-length ring)) |
577 (vec (cdr (cdr ring))) | |
578 (veclen (length vec)) | |
579 (hd (car ring)) | |
580 (idx (max 0 (ring-minus1 hd ln))) | |
581 (top-elt (aref vec idx))) | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47520
diff
changeset
|
582 |
10789 | 583 ;; shift elements |
584 (while (< (1+ idx) veclen) | |
585 (aset vec idx (aref vec (1+ idx))) | |
586 (setq idx (1+ idx))) | |
587 (aset vec idx nil) | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47520
diff
changeset
|
588 |
10789 | 589 (setq hd (max 0 (ring-minus1 hd ln))) |
590 (if (= hd (1- ln)) (setq hd 0)) | |
591 (setcar ring hd) ; move head | |
592 (setcar (cdr ring) (max 0 (1- ln))) ; adjust length | |
593 top-elt | |
594 )) | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47520
diff
changeset
|
595 |
19079 | 596 (defun viper-ring-insert (ring item) |
10789 | 597 (let* ((ln (ring-length ring)) |
598 (vec (cdr (cdr ring))) | |
599 (veclen (length vec)) | |
600 (hd (car ring)) | |
601 (vecpos-after-hd (if (= hd 0) ln hd)) | |
602 (idx ln)) | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47520
diff
changeset
|
603 |
10789 | 604 (if (= ln veclen) |
605 (progn | |
606 (aset vec hd item) ; hd is always 1+ the actual head index in vec | |
607 (setcar ring (ring-plus1 hd ln))) | |
608 (setcar (cdr ring) (1+ ln)) | |
609 (setcar ring (ring-plus1 vecpos-after-hd (1+ ln))) | |
610 (while (and (>= idx vecpos-after-hd) (> ln 0)) | |
611 (aset vec idx (aref vec (1- idx))) | |
612 (setq idx (1- idx))) | |
613 (aset vec vecpos-after-hd item)) | |
614 item)) | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47520
diff
changeset
|
615 |
10789 | 616 |
617 ;;; String utilities | |
618 | |
619 ;; If STRING is longer than MAX-LEN, truncate it and print ...... instead | |
620 ;; PRE-STRING is a string to prepend to the abbrev string. | |
621 ;; POST-STRING is a string to append to the abbrev string. | |
622 ;; ABBREV_SIGN is a string to be inserted before POST-STRING | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47520
diff
changeset
|
623 ;; if the orig string was truncated. |
19079 | 624 (defun viper-abbreviate-string (string max-len |
10789 | 625 pre-string post-string abbrev-sign) |
626 (let (truncated-str) | |
627 (setq truncated-str | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47520
diff
changeset
|
628 (if (stringp string) |
10789 | 629 (substring string 0 (min max-len (length string))))) |
630 (cond ((null truncated-str) "") | |
631 ((> (length string) max-len) | |
632 (format "%s%s%s%s" | |
633 pre-string truncated-str abbrev-sign post-string)) | |
634 (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
|
635 |
a7bd91d4af97
(vip-over-whitespace-line): new function.
Karl Heuer <kwzh@gnu.org>
parents:
12139
diff
changeset
|
636 ;; tells if we are over a whitespace-only line |
19079 | 637 (defsubst viper-over-whitespace-line () |
12204
a7bd91d4af97
(vip-over-whitespace-line): new function.
Karl Heuer <kwzh@gnu.org>
parents:
12139
diff
changeset
|
638 (save-excursion |
a7bd91d4af97
(vip-over-whitespace-line): new function.
Karl Heuer <kwzh@gnu.org>
parents:
12139
diff
changeset
|
639 (beginning-of-line) |
a7bd91d4af97
(vip-over-whitespace-line): new function.
Karl Heuer <kwzh@gnu.org>
parents:
12139
diff
changeset
|
640 (looking-at "^[ \t]*$"))) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47520
diff
changeset
|
641 |
10789 | 642 |
643 ;;; Saving settings in custom file | |
644 | |
12139
e16c06646396
(vip-event-key): now handles keys 128--255 as meta-chars.
Karl Heuer <kwzh@gnu.org>
parents:
11288
diff
changeset
|
645 ;; 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
|
646 ;; 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
|
647 ;; 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
|
648 ;; Arguments: var message custom-file &optional erase-message |
19079 | 649 (defun viper-save-setting (var message custom-file &optional erase-msg) |
10789 | 650 (let* ((var-name (symbol-name var)) |
651 (var-val (if (boundp var) (eval var))) | |
652 (regexp (format "^[^;]*%s[ \t\n]*[a-zA-Z---_']*[ \t\n)]" var-name)) | |
653 (buf (find-file-noselect (substitute-in-file-name custom-file))) | |
654 ) | |
87170
e50a2e215441
* erc-stamp.el (erc-echo-timestamp):
David Kastrup <dak@gnu.org>
parents:
86977
diff
changeset
|
655 (message "%s" (or message "")) |
105829
328150f0cf76
* url-util.el (url-insert-entities-in-string):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
101721
diff
changeset
|
656 (with-current-buffer buf |
10789 | 657 (goto-char (point-min)) |
658 (if (re-search-forward regexp nil t) | |
659 (let ((reg-end (1- (match-end 0)))) | |
660 (search-backward var-name) | |
661 (delete-region (match-beginning 0) reg-end) | |
662 (goto-char (match-beginning 0)) | |
663 (insert (format "%s '%S" var-name var-val))) | |
664 (goto-char (point-max)) | |
665 (if (not (bolp)) (insert "\n")) | |
666 (insert (format "(setq %s '%S)\n" var-name var-val))) | |
667 (save-buffer)) | |
668 (kill-buffer buf) | |
669 (if erase-msg | |
670 (progn | |
671 (sit-for 2) | |
672 (message ""))) | |
673 )) | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47520
diff
changeset
|
674 |
26263
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
22284
diff
changeset
|
675 ;; Save STRING in CUSTOM-FILE. If PATTERN is non-nil, remove strings that |
10789 | 676 ;; match this pattern. |
19079 | 677 (defun viper-save-string-in-file (string custom-file &optional pattern) |
10789 | 678 (let ((buf (find-file-noselect (substitute-in-file-name custom-file)))) |
105829
328150f0cf76
* url-util.el (url-insert-entities-in-string):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
101721
diff
changeset
|
679 (with-current-buffer buf |
21940 | 680 (let (buffer-read-only) |
681 (goto-char (point-min)) | |
682 (if pattern (delete-matching-lines pattern)) | |
683 (goto-char (point-max)) | |
684 (if string (insert string)) | |
685 (save-buffer))) | |
10789 | 686 (kill-buffer buf) |
687 )) | |
21940 | 688 |
689 | |
690 ;; This is a simple-minded check for whether a file is under version control. | |
691 ;; If file,v exists but file doesn't, this file is considered to be not checked | |
692 ;; in and not checked out for the purpose of patching (since patch won't be | |
693 ;; able to read such a file anyway). | |
694 ;; FILE is a string representing file name | |
695 ;;(defun viper-file-under-version-control (file) | |
696 ;; (let* ((filedir (file-name-directory file)) | |
697 ;; (file-nondir (file-name-nondirectory file)) | |
698 ;; (trial (concat file-nondir ",v")) | |
699 ;; (full-trial (concat filedir trial)) | |
700 ;; (full-rcs-trial (concat filedir "RCS/" trial))) | |
701 ;; (and (stringp file) | |
702 ;; (file-exists-p file) | |
703 ;; (or | |
704 ;; (and | |
705 ;; (file-exists-p full-trial) | |
706 ;; ;; in FAT FS, `file,v' and `file' may turn out to be the same! | |
707 ;; ;; don't be fooled by this! | |
708 ;; (not (equal (file-attributes file) | |
709 ;; (file-attributes full-trial)))) | |
710 ;; ;; check if a version is in RCS/ directory | |
711 ;; (file-exists-p full-rcs-trial))) | |
712 ;; )) | |
713 | |
714 | |
715 (defsubst viper-file-checked-in-p (file) | |
26263
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
22284
diff
changeset
|
716 (and (featurep 'vc-hooks) |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
22284
diff
changeset
|
717 ;; CVS files are considered not checked in |
85972
51aa47312c4b
* ediff-init.el (ediff-xemacs-p, ediff-emacs-p): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
84908
diff
changeset
|
718 ;; FIXME: Should this deal with more than CVS? |
26263
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
22284
diff
changeset
|
719 (not (memq (vc-backend file) '(nil CVS))) |
38514
10482dd382e7
* viper-ex.el (ex-token-list,ex-cmd-execute): Revamped, courtesy
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
38414
diff
changeset
|
720 (if (fboundp 'vc-state) |
38723
3a1c2213b3d2
(viper-file-checked-in-p): Use `and'
Gerd Moellmann <gerd@gnu.org>
parents:
38514
diff
changeset
|
721 (and |
38514
10482dd382e7
* viper-ex.el (ex-token-list,ex-cmd-execute): Revamped, courtesy
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
38414
diff
changeset
|
722 (not (memq (vc-state file) '(edited needs-merge))) |
10482dd382e7
* viper-ex.el (ex-token-list,ex-cmd-execute): Revamped, courtesy
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
38414
diff
changeset
|
723 (not (stringp (vc-state file)))) |
10482dd382e7
* viper-ex.el (ex-token-list,ex-cmd-execute): Revamped, courtesy
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
38414
diff
changeset
|
724 ;; XEmacs has no vc-state |
92380
8ee8aa679c74
(zmacs-region-stays): No need to define for compiler.
Glenn Morris <rgm@gnu.org>
parents:
87691
diff
changeset
|
725 (if (featurep 'xemacs) (not (vc-locking-user file)))))) |
26263
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
22284
diff
changeset
|
726 |
21940 | 727 ;; checkout if visited file is checked in |
728 (defun viper-maybe-checkout (buf) | |
729 (let ((file (expand-file-name (buffer-file-name buf))) | |
730 (checkout-function (key-binding "\C-x\C-q"))) | |
731 (if (and (viper-file-checked-in-p file) | |
732 (or (beep 1) t) | |
733 (y-or-n-p | |
734 (format | |
26263
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
22284
diff
changeset
|
735 "File %s is checked in. Check it out? " |
21940 | 736 (viper-abbreviate-file-name file)))) |
737 (with-current-buffer buf | |
738 (command-execute checkout-function))))) | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47520
diff
changeset
|
739 |
21940 | 740 |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47520
diff
changeset
|
741 |
10789 | 742 |
743 ;;; Overlays | |
28510
6fb7a3864791
2000-04-07 Mikio Nakajima <minakaji@osaka.email.ne.jp>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
27899
diff
changeset
|
744 (defun viper-put-on-search-overlay (beg end) |
6fb7a3864791
2000-04-07 Mikio Nakajima <minakaji@osaka.email.ne.jp>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
27899
diff
changeset
|
745 (if (viper-overlay-p viper-search-overlay) |
6fb7a3864791
2000-04-07 Mikio Nakajima <minakaji@osaka.email.ne.jp>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
27899
diff
changeset
|
746 (viper-move-overlay viper-search-overlay beg end) |
6fb7a3864791
2000-04-07 Mikio Nakajima <minakaji@osaka.email.ne.jp>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
27899
diff
changeset
|
747 (setq viper-search-overlay (viper-make-overlay beg end (current-buffer))) |
6fb7a3864791
2000-04-07 Mikio Nakajima <minakaji@osaka.email.ne.jp>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
27899
diff
changeset
|
748 (viper-overlay-put |
6fb7a3864791
2000-04-07 Mikio Nakajima <minakaji@osaka.email.ne.jp>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
27899
diff
changeset
|
749 viper-search-overlay 'priority viper-search-overlay-priority)) |
6fb7a3864791
2000-04-07 Mikio Nakajima <minakaji@osaka.email.ne.jp>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
27899
diff
changeset
|
750 (viper-overlay-put viper-search-overlay 'face viper-search-face)) |
10789 | 751 |
752 ;; Search | |
753 | |
19079 | 754 (defun viper-flash-search-pattern () |
28510
6fb7a3864791
2000-04-07 Mikio Nakajima <minakaji@osaka.email.ne.jp>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
27899
diff
changeset
|
755 (if (not (viper-has-face-support-p)) |
6fb7a3864791
2000-04-07 Mikio Nakajima <minakaji@osaka.email.ne.jp>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
27899
diff
changeset
|
756 nil |
6fb7a3864791
2000-04-07 Mikio Nakajima <minakaji@osaka.email.ne.jp>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
27899
diff
changeset
|
757 (viper-put-on-search-overlay (match-beginning 0) (match-end 0)) |
6fb7a3864791
2000-04-07 Mikio Nakajima <minakaji@osaka.email.ne.jp>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
27899
diff
changeset
|
758 (sit-for 2) |
6fb7a3864791
2000-04-07 Mikio Nakajima <minakaji@osaka.email.ne.jp>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
27899
diff
changeset
|
759 (viper-overlay-put viper-search-overlay 'face nil))) |
6fb7a3864791
2000-04-07 Mikio Nakajima <minakaji@osaka.email.ne.jp>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
27899
diff
changeset
|
760 |
6fb7a3864791
2000-04-07 Mikio Nakajima <minakaji@osaka.email.ne.jp>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
27899
diff
changeset
|
761 (defun viper-hide-search-overlay () |
6fb7a3864791
2000-04-07 Mikio Nakajima <minakaji@osaka.email.ne.jp>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
27899
diff
changeset
|
762 (if (not (viper-overlay-p viper-search-overlay)) |
10789 | 763 (progn |
28510
6fb7a3864791
2000-04-07 Mikio Nakajima <minakaji@osaka.email.ne.jp>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
27899
diff
changeset
|
764 (setq viper-search-overlay |
33019
6306740f6938
2000-10-29 Michael Kifer <kifer@cs.sunysb.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
28510
diff
changeset
|
765 (viper-make-overlay (point-min) (point-min) (current-buffer))) |
28510
6fb7a3864791
2000-04-07 Mikio Nakajima <minakaji@osaka.email.ne.jp>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
27899
diff
changeset
|
766 (viper-overlay-put |
6fb7a3864791
2000-04-07 Mikio Nakajima <minakaji@osaka.email.ne.jp>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
27899
diff
changeset
|
767 viper-search-overlay 'priority viper-search-overlay-priority))) |
6fb7a3864791
2000-04-07 Mikio Nakajima <minakaji@osaka.email.ne.jp>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
27899
diff
changeset
|
768 (viper-overlay-put viper-search-overlay 'face nil)) |
16136
de1340e6ddb4
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15747
diff
changeset
|
769 |
10789 | 770 ;; Replace state |
771 | |
19079 | 772 (defsubst viper-move-replace-overlay (beg end) |
773 (viper-move-overlay viper-replace-overlay beg end)) | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47520
diff
changeset
|
774 |
19079 | 775 (defun viper-set-replace-overlay (beg end) |
27899
42f9a58e0fc4
* viper-cmd.el (viper-envelop-ESC-key): added the option to
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
26263
diff
changeset
|
776 (if (viper-overlay-live-p viper-replace-overlay) |
19079 | 777 (viper-move-replace-overlay beg end) |
778 (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
|
779 ;; never detach |
19079 | 780 (viper-overlay-put |
85972
51aa47312c4b
* ediff-init.el (ediff-xemacs-p, ediff-emacs-p): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
84908
diff
changeset
|
781 viper-replace-overlay (if (featurep 'emacs) 'evaporate 'detachable) nil) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47520
diff
changeset
|
782 (viper-overlay-put |
19079 | 783 viper-replace-overlay 'priority viper-replace-overlay-priority) |
18047 | 784 ;; If Emacs will start supporting overlay maps, as it currently supports |
19079 | 785 ;; text-property maps, we could do away with viper-replace-minor-mode and |
18047 | 786 ;; just have keymap attached to replace overlay. |
19079 | 787 ;;(viper-overlay-put |
788 ;; viper-replace-overlay | |
85972
51aa47312c4b
* ediff-init.el (ediff-xemacs-p, ediff-emacs-p): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
84908
diff
changeset
|
789 ;; (if (featurep 'xemacs) 'keymap 'local-map) |
19079 | 790 ;; viper-replace-map) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47520
diff
changeset
|
791 ) |
19079 | 792 (if (viper-has-face-support-p) |
793 (viper-overlay-put | |
794 viper-replace-overlay 'face viper-replace-overlay-face)) | |
26263
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
22284
diff
changeset
|
795 (viper-save-cursor-color 'before-replace-mode) |
92380
8ee8aa679c74
(zmacs-region-stays): No need to define for compiler.
Glenn Morris <rgm@gnu.org>
parents:
87691
diff
changeset
|
796 (viper-change-cursor-color |
8ee8aa679c74
(zmacs-region-stays): No need to define for compiler.
Glenn Morris <rgm@gnu.org>
parents:
87691
diff
changeset
|
797 (viper-frame-value viper-replace-overlay-cursor-color))) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47520
diff
changeset
|
798 |
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47520
diff
changeset
|
799 |
19079 | 800 (defun viper-set-replace-overlay-glyphs (before-glyph after-glyph) |
27899
42f9a58e0fc4
* viper-cmd.el (viper-envelop-ESC-key): added the option to
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
26263
diff
changeset
|
801 (or (viper-overlay-live-p viper-replace-overlay) |
42f9a58e0fc4
* viper-cmd.el (viper-envelop-ESC-key): added the option to
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
26263
diff
changeset
|
802 (viper-set-replace-overlay (point-min) (point-min))) |
19079 | 803 (if (or (not (viper-has-face-support-p)) |
804 viper-use-replace-region-delimiters) | |
85972
51aa47312c4b
* ediff-init.el (ediff-xemacs-p, ediff-emacs-p): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
84908
diff
changeset
|
805 (let ((before-name (if (featurep 'xemacs) 'begin-glyph 'before-string)) |
51aa47312c4b
* ediff-init.el (ediff-xemacs-p, ediff-emacs-p): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
84908
diff
changeset
|
806 (after-name (if (featurep 'xemacs) 'end-glyph 'after-string))) |
19079 | 807 (viper-overlay-put viper-replace-overlay before-name before-glyph) |
808 (viper-overlay-put viper-replace-overlay after-name after-glyph)))) | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47520
diff
changeset
|
809 |
19079 | 810 (defun viper-hide-replace-overlay () |
811 (viper-set-replace-overlay-glyphs nil nil) | |
26263
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
22284
diff
changeset
|
812 (viper-restore-cursor-color 'after-replace-mode) |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
22284
diff
changeset
|
813 (viper-restore-cursor-color 'after-insert-mode) |
19079 | 814 (if (viper-has-face-support-p) |
815 (viper-overlay-put viper-replace-overlay 'face nil))) | |
10789 | 816 |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47520
diff
changeset
|
817 |
19079 | 818 (defsubst viper-replace-start () |
819 (viper-overlay-start viper-replace-overlay)) | |
820 (defsubst viper-replace-end () | |
821 (viper-overlay-end viper-replace-overlay)) | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47520
diff
changeset
|
822 |
10789 | 823 |
824 ;; Minibuffer | |
825 | |
19079 | 826 (defun viper-set-minibuffer-overlay () |
827 (viper-check-minibuffer-overlay) | |
92380
8ee8aa679c74
(zmacs-region-stays): No need to define for compiler.
Glenn Morris <rgm@gnu.org>
parents:
87691
diff
changeset
|
828 (when (viper-has-face-support-p) |
8ee8aa679c74
(zmacs-region-stays): No need to define for compiler.
Glenn Morris <rgm@gnu.org>
parents:
87691
diff
changeset
|
829 (viper-overlay-put |
8ee8aa679c74
(zmacs-region-stays): No need to define for compiler.
Glenn Morris <rgm@gnu.org>
parents:
87691
diff
changeset
|
830 viper-minibuffer-overlay 'face viper-minibuffer-current-face) |
8ee8aa679c74
(zmacs-region-stays): No need to define for compiler.
Glenn Morris <rgm@gnu.org>
parents:
87691
diff
changeset
|
831 (viper-overlay-put |
8ee8aa679c74
(zmacs-region-stays): No need to define for compiler.
Glenn Morris <rgm@gnu.org>
parents:
87691
diff
changeset
|
832 viper-minibuffer-overlay 'priority viper-minibuffer-overlay-priority) |
8ee8aa679c74
(zmacs-region-stays): No need to define for compiler.
Glenn Morris <rgm@gnu.org>
parents:
87691
diff
changeset
|
833 ;; never detach |
8ee8aa679c74
(zmacs-region-stays): No need to define for compiler.
Glenn Morris <rgm@gnu.org>
parents:
87691
diff
changeset
|
834 (viper-overlay-put |
8ee8aa679c74
(zmacs-region-stays): No need to define for compiler.
Glenn Morris <rgm@gnu.org>
parents:
87691
diff
changeset
|
835 viper-minibuffer-overlay |
8ee8aa679c74
(zmacs-region-stays): No need to define for compiler.
Glenn Morris <rgm@gnu.org>
parents:
87691
diff
changeset
|
836 (if (featurep 'emacs) 'evaporate 'detachable) |
8ee8aa679c74
(zmacs-region-stays): No need to define for compiler.
Glenn Morris <rgm@gnu.org>
parents:
87691
diff
changeset
|
837 nil) |
8ee8aa679c74
(zmacs-region-stays): No need to define for compiler.
Glenn Morris <rgm@gnu.org>
parents:
87691
diff
changeset
|
838 ;; make viper-minibuffer-overlay open-ended |
8ee8aa679c74
(zmacs-region-stays): No need to define for compiler.
Glenn Morris <rgm@gnu.org>
parents:
87691
diff
changeset
|
839 ;; In emacs, it is made open ended at creation time |
8ee8aa679c74
(zmacs-region-stays): No need to define for compiler.
Glenn Morris <rgm@gnu.org>
parents:
87691
diff
changeset
|
840 (when (featurep 'xemacs) |
8ee8aa679c74
(zmacs-region-stays): No need to define for compiler.
Glenn Morris <rgm@gnu.org>
parents:
87691
diff
changeset
|
841 (viper-overlay-put viper-minibuffer-overlay 'start-open nil) |
8ee8aa679c74
(zmacs-region-stays): No need to define for compiler.
Glenn Morris <rgm@gnu.org>
parents:
87691
diff
changeset
|
842 (viper-overlay-put viper-minibuffer-overlay 'end-open nil)))) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47520
diff
changeset
|
843 |
19079 | 844 (defun viper-check-minibuffer-overlay () |
42602
633233bf2bbf
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
39215
diff
changeset
|
845 (if (viper-overlay-live-p viper-minibuffer-overlay) |
633233bf2bbf
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
39215
diff
changeset
|
846 (viper-move-overlay |
633233bf2bbf
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
39215
diff
changeset
|
847 viper-minibuffer-overlay |
633233bf2bbf
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
39215
diff
changeset
|
848 (if (fboundp 'minibuffer-prompt-end) (minibuffer-prompt-end) 1) |
633233bf2bbf
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
39215
diff
changeset
|
849 (1+ (buffer-size))) |
633233bf2bbf
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
39215
diff
changeset
|
850 (setq viper-minibuffer-overlay |
85972
51aa47312c4b
* ediff-init.el (ediff-xemacs-p, ediff-emacs-p): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
84908
diff
changeset
|
851 (if (featurep 'xemacs) |
42602
633233bf2bbf
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
39215
diff
changeset
|
852 (viper-make-overlay 1 (1+ (buffer-size)) (current-buffer)) |
633233bf2bbf
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
39215
diff
changeset
|
853 ;; make overlay open-ended |
633233bf2bbf
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
39215
diff
changeset
|
854 (viper-make-overlay |
633233bf2bbf
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
39215
diff
changeset
|
855 (if (fboundp 'minibuffer-prompt-end) (minibuffer-prompt-end) 1) |
633233bf2bbf
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
39215
diff
changeset
|
856 (1+ (buffer-size)) |
92380
8ee8aa679c74
(zmacs-region-stays): No need to define for compiler.
Glenn Morris <rgm@gnu.org>
parents:
87691
diff
changeset
|
857 (current-buffer) nil 'rear-advance))))) |
10789 | 858 |
859 | |
19079 | 860 (defsubst viper-is-in-minibuffer () |
21940 | 861 (save-match-data |
862 (string-match "\*Minibuf-" (buffer-name)))) | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47520
diff
changeset
|
863 |
10789 | 864 |
865 | |
866 ;;; XEmacs compatibility | |
14581
4951b11970a1
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14384
diff
changeset
|
867 |
19079 | 868 (defun viper-abbreviate-file-name (file) |
92380
8ee8aa679c74
(zmacs-region-stays): No need to define for compiler.
Glenn Morris <rgm@gnu.org>
parents:
87691
diff
changeset
|
869 (if (featurep 'xemacs) |
8ee8aa679c74
(zmacs-region-stays): No need to define for compiler.
Glenn Morris <rgm@gnu.org>
parents:
87691
diff
changeset
|
870 (abbreviate-file-name file t) ; XEmacs requires addl argument |
8ee8aa679c74
(zmacs-region-stays): No need to define for compiler.
Glenn Morris <rgm@gnu.org>
parents:
87691
diff
changeset
|
871 (abbreviate-file-name file))) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47520
diff
changeset
|
872 |
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47520
diff
changeset
|
873 ;; 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
|
874 ;; in sit-for, so this function smoothes out the differences. |
19079 | 875 (defsubst viper-sit-for-short (val &optional nodisp) |
81331
c3779fe5830e
2007-06-12 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
75346
diff
changeset
|
876 (sit-for (/ val 1000.0) nodisp)) |
10789 | 877 |
878 ;; EVENT may be a single event of a sequence of events | |
19079 | 879 (defsubst viper-ESC-event-p (event) |
10789 | 880 (let ((ESC-keys '(?\e (control \[) escape)) |
19079 | 881 (key (viper-event-key event))) |
10789 | 882 (member key ESC-keys))) |
18047 | 883 |
884 ;; checks if object is a marker, has a buffer, and points to within that buffer | |
19079 | 885 (defun viper-valid-marker (marker) |
18047 | 886 (if (and (markerp marker) (marker-buffer marker)) |
887 (let ((buf (marker-buffer marker)) | |
888 (pos (marker-position marker))) | |
105829
328150f0cf76
* url-util.el (url-insert-entities-in-string):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
101721
diff
changeset
|
889 (with-current-buffer buf |
18047 | 890 (and (<= pos (point-max)) (<= (point-min) pos)))))) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47520
diff
changeset
|
891 |
19079 | 892 (defsubst viper-mark-marker () |
92380
8ee8aa679c74
(zmacs-region-stays): No need to define for compiler.
Glenn Morris <rgm@gnu.org>
parents:
87691
diff
changeset
|
893 (if (featurep 'xemacs) (mark-marker t) |
8ee8aa679c74
(zmacs-region-stays): No need to define for compiler.
Glenn Morris <rgm@gnu.org>
parents:
87691
diff
changeset
|
894 (mark-marker))) |
14909
7ff1df13b124
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14588
diff
changeset
|
895 |
10789 | 896 ;; like (set-mark-command nil) but doesn't push twice, if (car mark-ring) |
897 ;; is the same as (mark t). | |
19079 | 898 (defsubst viper-set-mark-if-necessary () |
899 (setq mark-ring (delete (viper-mark-marker) mark-ring)) | |
26263
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
22284
diff
changeset
|
900 (set-mark-command nil) |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
22284
diff
changeset
|
901 (setq viper-saved-mark (point))) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47520
diff
changeset
|
902 |
10789 | 903 ;; In transient mark mode (zmacs mode), it is annoying when regions become |
26263
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
22284
diff
changeset
|
904 ;; highlighted due to Viper's pushing marks. So, we deactivate marks, unless |
10789 | 905 ;; the user explicitly wants highlighting, e.g., by hitting '' or `` |
19079 | 906 (defun viper-deactivate-mark () |
92380
8ee8aa679c74
(zmacs-region-stays): No need to define for compiler.
Glenn Morris <rgm@gnu.org>
parents:
87691
diff
changeset
|
907 (if (featurep 'xemacs) |
8ee8aa679c74
(zmacs-region-stays): No need to define for compiler.
Glenn Morris <rgm@gnu.org>
parents:
87691
diff
changeset
|
908 (zmacs-deactivate-region) |
8ee8aa679c74
(zmacs-region-stays): No need to define for compiler.
Glenn Morris <rgm@gnu.org>
parents:
87691
diff
changeset
|
909 (deactivate-mark))) |
10789 | 910 |
19079 | 911 (defsubst viper-leave-region-active () |
92380
8ee8aa679c74
(zmacs-region-stays): No need to define for compiler.
Glenn Morris <rgm@gnu.org>
parents:
87691
diff
changeset
|
912 (if (featurep 'xemacs) (setq zmacs-region-stays t))) |
12899
e0dfd3c3837e
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12693
diff
changeset
|
913 |
18047 | 914 ;; Check if arg is a valid character for register |
915 ;; TYPE is a list that can contain `letter', `Letter', and `digit'. | |
916 ;; Letter means lowercase letters, Letter means uppercase letters, and | |
917 ;; digit means digits from 1 to 9. | |
918 ;; If TYPE is nil, then down/uppercase letters and digits are allowed. | |
19079 | 919 (defun viper-valid-register (reg &optional type) |
18047 | 920 (or type (setq type '(letter Letter digit))) |
921 (or (if (memq 'letter type) | |
922 (and (<= ?a reg) (<= reg ?z))) | |
923 (if (memq 'digit type) | |
924 (and (<= ?1 reg) (<= reg ?9))) | |
925 (if (memq 'Letter type) | |
926 (and (<= ?A reg) (<= reg ?Z))) | |
927 )) | |
928 | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47520
diff
changeset
|
929 |
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47520
diff
changeset
|
930 |
18047 | 931 ;; it is suggested that an event must be copied before it is assigned to |
932 ;; last-command-event in XEmacs | |
19079 | 933 (defun viper-copy-event (event) |
92380
8ee8aa679c74
(zmacs-region-stays): No need to define for compiler.
Glenn Morris <rgm@gnu.org>
parents:
87691
diff
changeset
|
934 (if (featurep 'xemacs) (copy-event event) |
8ee8aa679c74
(zmacs-region-stays): No need to define for compiler.
Glenn Morris <rgm@gnu.org>
parents:
87691
diff
changeset
|
935 event)) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47520
diff
changeset
|
936 |
42602
633233bf2bbf
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
39215
diff
changeset
|
937 ;; Uses different timeouts for ESC-sequences and others |
99595
eb7532b56b78
2008-11-16 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
97142
diff
changeset
|
938 (defun viper-fast-keysequence-p () |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47520
diff
changeset
|
939 (not (viper-sit-for-short |
42602
633233bf2bbf
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
39215
diff
changeset
|
940 (if (viper-ESC-event-p last-input-event) |
99595
eb7532b56b78
2008-11-16 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
97142
diff
changeset
|
941 (viper-ESC-keyseq-timeout) |
42602
633233bf2bbf
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
39215
diff
changeset
|
942 viper-fast-keyseq-timeout) |
633233bf2bbf
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
39215
diff
changeset
|
943 t))) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47520
diff
changeset
|
944 |
10789 | 945 ;; like read-event, but in XEmacs also try to convert to char, if possible |
19079 | 946 (defun viper-read-event-convert-to-char () |
10789 | 947 (let (event) |
92380
8ee8aa679c74
(zmacs-region-stays): No need to define for compiler.
Glenn Morris <rgm@gnu.org>
parents:
87691
diff
changeset
|
948 (if (featurep 'xemacs) |
8ee8aa679c74
(zmacs-region-stays): No need to define for compiler.
Glenn Morris <rgm@gnu.org>
parents:
87691
diff
changeset
|
949 (progn |
8ee8aa679c74
(zmacs-region-stays): No need to define for compiler.
Glenn Morris <rgm@gnu.org>
parents:
87691
diff
changeset
|
950 (setq event (next-command-event)) |
8ee8aa679c74
(zmacs-region-stays): No need to define for compiler.
Glenn Morris <rgm@gnu.org>
parents:
87691
diff
changeset
|
951 (or (event-to-character event) |
8ee8aa679c74
(zmacs-region-stays): No need to define for compiler.
Glenn Morris <rgm@gnu.org>
parents:
87691
diff
changeset
|
952 event)) |
8ee8aa679c74
(zmacs-region-stays): No need to define for compiler.
Glenn Morris <rgm@gnu.org>
parents:
87691
diff
changeset
|
953 (read-event)))) |
10789 | 954 |
42602
633233bf2bbf
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
39215
diff
changeset
|
955 ;; Viperized read-key-sequence |
633233bf2bbf
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
39215
diff
changeset
|
956 (defun viper-read-key-sequence (prompt &optional continue-echo) |
633233bf2bbf
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
39215
diff
changeset
|
957 (let (inhibit-quit event keyseq) |
633233bf2bbf
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
39215
diff
changeset
|
958 (setq keyseq (read-key-sequence prompt continue-echo)) |
85972
51aa47312c4b
* ediff-init.el (ediff-xemacs-p, ediff-emacs-p): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
84908
diff
changeset
|
959 (setq event (if (featurep 'xemacs) |
42602
633233bf2bbf
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
39215
diff
changeset
|
960 (elt keyseq 0) ; XEmacs returns vector of events |
633233bf2bbf
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
39215
diff
changeset
|
961 (elt (listify-key-sequence keyseq) 0))) |
633233bf2bbf
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
39215
diff
changeset
|
962 (if (viper-ESC-event-p event) |
633233bf2bbf
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
39215
diff
changeset
|
963 (let (unread-command-events) |
633233bf2bbf
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
39215
diff
changeset
|
964 (if (viper-fast-keysequence-p) |
633233bf2bbf
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
39215
diff
changeset
|
965 (let ((viper-vi-global-user-minor-mode nil) |
633233bf2bbf
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
39215
diff
changeset
|
966 (viper-vi-local-user-minor-mode nil) |
43220
69c91aaa067a
2002-02-10 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
42602
diff
changeset
|
967 (viper-vi-intercept-minor-mode nil) |
69c91aaa067a
2002-02-10 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
42602
diff
changeset
|
968 (viper-insert-intercept-minor-mode nil) |
42602
633233bf2bbf
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
39215
diff
changeset
|
969 (viper-replace-minor-mode nil) ; actually unnecessary |
633233bf2bbf
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
39215
diff
changeset
|
970 (viper-insert-global-user-minor-mode nil) |
633233bf2bbf
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
39215
diff
changeset
|
971 (viper-insert-local-user-minor-mode nil)) |
43220
69c91aaa067a
2002-02-10 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
42602
diff
changeset
|
972 ;; Note: set unread-command-events only after testing for fast |
69c91aaa067a
2002-02-10 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
42602
diff
changeset
|
973 ;; keysequence. Otherwise, viper-fast-keysequence-p will be |
69c91aaa067a
2002-02-10 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
42602
diff
changeset
|
974 ;; always t -- whether there is anything after ESC or not |
69c91aaa067a
2002-02-10 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
42602
diff
changeset
|
975 (viper-set-unread-command-events keyseq) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47520
diff
changeset
|
976 (setq keyseq (read-key-sequence nil))) |
43220
69c91aaa067a
2002-02-10 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
42602
diff
changeset
|
977 (viper-set-unread-command-events keyseq) |
69c91aaa067a
2002-02-10 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
42602
diff
changeset
|
978 (setq keyseq (read-key-sequence nil))))) |
42602
633233bf2bbf
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
39215
diff
changeset
|
979 keyseq)) |
633233bf2bbf
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
39215
diff
changeset
|
980 |
633233bf2bbf
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
39215
diff
changeset
|
981 |
12693
321b2ad48a9c
(vip-add-hook,vip-remove-hook): new functions.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12212
diff
changeset
|
982 ;; This function lets function-key-map convert key sequences into logical |
26263
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
22284
diff
changeset
|
983 ;; 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
|
984 ;; macros, since it enables certain macros to be shared between X and TTY modes |
93615
34417c118a39
2008-04-03 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
92766
diff
changeset
|
985 ;; by correctly mapping key sequences for Left/Right/... (on an ascii |
15578
fadc581e380e
(vip-read-key): inhibit quit added.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
986 ;; terminal) into logical keys left, right, etc. |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47520
diff
changeset
|
987 (defun viper-read-key () |
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47520
diff
changeset
|
988 (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
|
989 (inhibit-quit t) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47520
diff
changeset
|
990 help-char key) |
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47520
diff
changeset
|
991 (use-global-map viper-overriding-map) |
19203 | 992 (unwind-protect |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47520
diff
changeset
|
993 (setq key (elt (viper-read-key-sequence nil) 0)) |
19203 | 994 (use-global-map global-map)) |
15578
fadc581e380e
(vip-read-key): inhibit quit added.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
995 key)) |
12693
321b2ad48a9c
(vip-add-hook,vip-remove-hook): new functions.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12212
diff
changeset
|
996 |
10789 | 997 |
12139
e16c06646396
(vip-event-key): now handles keys 128--255 as meta-chars.
Karl Heuer <kwzh@gnu.org>
parents:
11288
diff
changeset
|
998 ;; 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
|
999 ;; instead of nil, if '(nil) was previously inadvertently assigned to |
10789 | 1000 ;; unread-command-events |
19079 | 1001 (defun viper-event-key (event) |
10789 | 1002 (or (and event (eventp event)) |
19079 | 1003 (error "viper-event-key: Wrong type argument, eventp, %S" event)) |
92380
8ee8aa679c74
(zmacs-region-stays): No need to define for compiler.
Glenn Morris <rgm@gnu.org>
parents:
87691
diff
changeset
|
1004 (when (if (featurep 'xemacs) |
42602
633233bf2bbf
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
39215
diff
changeset
|
1005 (or (key-press-event-p event) (mouse-event-p event)) ; xemacs |
633233bf2bbf
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
39215
diff
changeset
|
1006 t ; emacs |
633233bf2bbf
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
39215
diff
changeset
|
1007 ) |
18047 | 1008 (let ((mod (event-modifiers event)) |
1009 basis) | |
1010 (setq basis | |
92380
8ee8aa679c74
(zmacs-region-stays): No need to define for compiler.
Glenn Morris <rgm@gnu.org>
parents:
87691
diff
changeset
|
1011 (if (featurep 'xemacs) |
42602
633233bf2bbf
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
39215
diff
changeset
|
1012 ;; XEmacs |
633233bf2bbf
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
39215
diff
changeset
|
1013 (cond ((key-press-event-p event) |
633233bf2bbf
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
39215
diff
changeset
|
1014 (event-key event)) |
633233bf2bbf
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
39215
diff
changeset
|
1015 ((button-event-p event) |
633233bf2bbf
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
39215
diff
changeset
|
1016 (concat "mouse-" (prin1-to-string (event-button event)))) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47520
diff
changeset
|
1017 (t |
42602
633233bf2bbf
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
39215
diff
changeset
|
1018 (error "viper-event-key: Unknown event, %S" event))) |
633233bf2bbf
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
39215
diff
changeset
|
1019 ;; Emacs doesn't handle capital letters correctly, since |
633233bf2bbf
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
39215
diff
changeset
|
1020 ;; \S-a isn't considered the same as A (it behaves as |
633233bf2bbf
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
39215
diff
changeset
|
1021 ;; plain `a' instead). So we take care of this here |
633233bf2bbf
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
39215
diff
changeset
|
1022 (cond ((and (viper-characterp event) (<= ?A event) (<= event ?Z)) |
633233bf2bbf
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
39215
diff
changeset
|
1023 (setq mod nil |
633233bf2bbf
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
39215
diff
changeset
|
1024 event event)) |
633233bf2bbf
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
39215
diff
changeset
|
1025 ;; Emacs has the oddity whereby characters 128+char |
633233bf2bbf
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
39215
diff
changeset
|
1026 ;; represent M-char *if* this appears inside a string. |
633233bf2bbf
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
39215
diff
changeset
|
1027 ;; So, we convert them manually to (meta char). |
633233bf2bbf
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
39215
diff
changeset
|
1028 ((and (viper-characterp event) |
633233bf2bbf
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
39215
diff
changeset
|
1029 (< ?\C-? event) (<= event 255)) |
633233bf2bbf
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
39215
diff
changeset
|
1030 (setq mod '(meta) |
633233bf2bbf
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
39215
diff
changeset
|
1031 event (- event ?\C-? 1))) |
633233bf2bbf
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
39215
diff
changeset
|
1032 ((and (null mod) (eq event 'return)) |
633233bf2bbf
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
39215
diff
changeset
|
1033 (setq event ?\C-m)) |
633233bf2bbf
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
39215
diff
changeset
|
1034 ((and (null mod) (eq event 'space)) |
633233bf2bbf
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
39215
diff
changeset
|
1035 (setq event ?\ )) |
633233bf2bbf
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
39215
diff
changeset
|
1036 ((and (null mod) (eq event 'delete)) |
633233bf2bbf
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
39215
diff
changeset
|
1037 (setq event ?\C-?)) |
633233bf2bbf
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
39215
diff
changeset
|
1038 ((and (null mod) (eq event 'backspace)) |
633233bf2bbf
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
39215
diff
changeset
|
1039 (setq event ?\C-h)) |
633233bf2bbf
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
39215
diff
changeset
|
1040 (t (event-basic-type event))) |
92380
8ee8aa679c74
(zmacs-region-stays): No need to define for compiler.
Glenn Morris <rgm@gnu.org>
parents:
87691
diff
changeset
|
1041 ) ; (featurep 'xemacs) |
42602
633233bf2bbf
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
39215
diff
changeset
|
1042 ) |
19079 | 1043 (if (viper-characterp basis) |
18047 | 1044 (setq basis |
33019
6306740f6938
2000-10-29 Michael Kifer <kifer@cs.sunysb.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
28510
diff
changeset
|
1045 (if (viper= basis ?\C-?) |
18047 | 1046 (list 'control '\?) ; taking care of an emacs bug |
1047 (intern (char-to-string basis))))) | |
1048 (if mod | |
1049 (append mod (list basis)) | |
1050 basis)))) | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47520
diff
changeset
|
1051 |
106192
a2ee981efbec
2009-11-22 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
105829
diff
changeset
|
1052 (defun viper-last-command-char () |
a2ee981efbec
2009-11-22 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
105829
diff
changeset
|
1053 (if (featurep 'xemacs) |
a2ee981efbec
2009-11-22 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
105829
diff
changeset
|
1054 (event-to-character last-command-event) |
a2ee981efbec
2009-11-22 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
105829
diff
changeset
|
1055 last-command-event)) |
a2ee981efbec
2009-11-22 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
105829
diff
changeset
|
1056 |
19079 | 1057 (defun viper-key-to-emacs-key (key) |
10789 | 1058 (let (key-name char-p modifiers mod-char-list base-key base-key-name) |
85972
51aa47312c4b
* ediff-init.el (ediff-xemacs-p, ediff-emacs-p): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
84908
diff
changeset
|
1059 (cond ((featurep 'xemacs) key) |
18839 | 1060 |
10789 | 1061 ((symbolp key) |
1062 (setq key-name (symbol-name key)) | |
18839 | 1063 (cond ((= (length key-name) 1) ; character event |
1064 (string-to-char key-name)) | |
1065 ;; Emacs doesn't recognize `return' and `escape' as events on | |
1066 ;; dumb terminals, so we translate them into characters | |
85972
51aa47312c4b
* ediff-init.el (ediff-xemacs-p, ediff-emacs-p): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
84908
diff
changeset
|
1067 ((and (featurep 'emacs) (not (viper-window-display-p)) |
18839 | 1068 (string= key-name "return")) |
1069 ?\C-m) | |
85972
51aa47312c4b
* ediff-init.el (ediff-xemacs-p, ediff-emacs-p): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
84908
diff
changeset
|
1070 ((and (featurep 'emacs) (not (viper-window-display-p)) |
18839 | 1071 (string= key-name "escape")) |
1072 ?\e) | |
1073 ;; pass symbol-event as is | |
1074 (t key))) | |
1075 | |
10789 | 1076 ((listp key) |
64215
a4c59075cac8
* viper-cmd.el (viper--key-maps): new variable.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
64085
diff
changeset
|
1077 (setq modifiers (viper-subseq key 0 (1- (length key))) |
19079 | 1078 base-key (viper-seq-last-elt key) |
10789 | 1079 base-key-name (symbol-name base-key) |
1080 char-p (= (length base-key-name) 1)) | |
1081 (setq mod-char-list | |
1082 (mapcar | |
1083 '(lambda (elt) (upcase (substring (symbol-name elt) 0 1))) | |
1084 modifiers)) | |
1085 (if char-p | |
1086 (setq key-name | |
1087 (car (read-from-string | |
1088 (concat | |
1089 "?\\" | |
1090 (mapconcat 'identity mod-char-list "-\\") | |
1091 "-" | |
1092 base-key-name)))) | |
1093 (setq key-name | |
1094 (intern | |
1095 (concat | |
1096 (mapconcat 'identity mod-char-list "-") | |
1097 "-" | |
1098 base-key-name)))))) | |
1099 )) | |
1100 | |
1101 | |
42602
633233bf2bbf
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
39215
diff
changeset
|
1102 ;; LIS is assumed to be a list of events of characters |
633233bf2bbf
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
39215
diff
changeset
|
1103 (defun viper-eventify-list-xemacs (lis) |
85972
51aa47312c4b
* ediff-init.el (ediff-xemacs-p, ediff-emacs-p): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
84908
diff
changeset
|
1104 (if (featurep 'xemacs) |
51aa47312c4b
* ediff-init.el (ediff-xemacs-p, ediff-emacs-p): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
84908
diff
changeset
|
1105 (mapcar |
51aa47312c4b
* ediff-init.el (ediff-xemacs-p, ediff-emacs-p): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
84908
diff
changeset
|
1106 (lambda (elt) |
51aa47312c4b
* ediff-init.el (ediff-xemacs-p, ediff-emacs-p): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
84908
diff
changeset
|
1107 (cond ((viper-characterp elt) (character-to-event elt)) |
51aa47312c4b
* ediff-init.el (ediff-xemacs-p, ediff-emacs-p): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
84908
diff
changeset
|
1108 ((eventp elt) elt) |
51aa47312c4b
* ediff-init.el (ediff-xemacs-p, ediff-emacs-p): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
84908
diff
changeset
|
1109 (t (error |
51aa47312c4b
* ediff-init.el (ediff-xemacs-p, ediff-emacs-p): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
84908
diff
changeset
|
1110 "viper-eventify-list-xemacs: can't convert to event, %S" |
51aa47312c4b
* ediff-init.el (ediff-xemacs-p, ediff-emacs-p): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
84908
diff
changeset
|
1111 elt)))) |
51aa47312c4b
* ediff-init.el (ediff-xemacs-p, ediff-emacs-p): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
84908
diff
changeset
|
1112 lis))) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47520
diff
changeset
|
1113 |
42602
633233bf2bbf
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
39215
diff
changeset
|
1114 |
633233bf2bbf
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
39215
diff
changeset
|
1115 ;; Smoothes out the difference between Emacs' unread-command-events |
633233bf2bbf
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
39215
diff
changeset
|
1116 ;; and XEmacs unread-command-event. Arg is a character, an event, a list of |
633233bf2bbf
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
39215
diff
changeset
|
1117 ;; events or a sequence of keys. |
633233bf2bbf
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
39215
diff
changeset
|
1118 ;; |
633233bf2bbf
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
39215
diff
changeset
|
1119 ;; Due to the way unread-command-events in Emacs (not XEmacs), a non-event |
633233bf2bbf
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
39215
diff
changeset
|
1120 ;; symbol in unread-command-events list may cause Emacs to turn this symbol |
633233bf2bbf
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
39215
diff
changeset
|
1121 ;; into an event. Below, we delete nil from event lists, since nil is the most |
633233bf2bbf
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
39215
diff
changeset
|
1122 ;; common symbol that might appear in this wrong context. |
633233bf2bbf
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
39215
diff
changeset
|
1123 (defun viper-set-unread-command-events (arg) |
85972
51aa47312c4b
* ediff-init.el (ediff-xemacs-p, ediff-emacs-p): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
84908
diff
changeset
|
1124 (if (featurep 'emacs) |
42602
633233bf2bbf
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
39215
diff
changeset
|
1125 (setq |
633233bf2bbf
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
39215
diff
changeset
|
1126 unread-command-events |
633233bf2bbf
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
39215
diff
changeset
|
1127 (let ((new-events |
633233bf2bbf
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
39215
diff
changeset
|
1128 (cond ((eventp arg) (list arg)) |
633233bf2bbf
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
39215
diff
changeset
|
1129 ((listp arg) arg) |
633233bf2bbf
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
39215
diff
changeset
|
1130 ((sequencep arg) |
633233bf2bbf
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
39215
diff
changeset
|
1131 (listify-key-sequence arg)) |
633233bf2bbf
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
39215
diff
changeset
|
1132 (t (error |
633233bf2bbf
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
39215
diff
changeset
|
1133 "viper-set-unread-command-events: Invalid argument, %S" |
633233bf2bbf
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
39215
diff
changeset
|
1134 arg))))) |
633233bf2bbf
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
39215
diff
changeset
|
1135 (if (not (eventp nil)) |
633233bf2bbf
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
39215
diff
changeset
|
1136 (setq new-events (delq nil new-events))) |
633233bf2bbf
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
39215
diff
changeset
|
1137 (append new-events unread-command-events))) |
633233bf2bbf
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
39215
diff
changeset
|
1138 ;; XEmacs |
633233bf2bbf
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
39215
diff
changeset
|
1139 (setq |
633233bf2bbf
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
39215
diff
changeset
|
1140 unread-command-events |
633233bf2bbf
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
39215
diff
changeset
|
1141 (append |
633233bf2bbf
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
39215
diff
changeset
|
1142 (cond ((viper-characterp arg) (list (character-to-event arg))) |
633233bf2bbf
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
39215
diff
changeset
|
1143 ((eventp arg) (list arg)) |
633233bf2bbf
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
39215
diff
changeset
|
1144 ((stringp arg) (mapcar 'character-to-event arg)) |
633233bf2bbf
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
39215
diff
changeset
|
1145 ((vectorp arg) (append arg nil)) ; turn into list |
633233bf2bbf
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
39215
diff
changeset
|
1146 ((listp arg) (viper-eventify-list-xemacs arg)) |
633233bf2bbf
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
39215
diff
changeset
|
1147 (t (error |
633233bf2bbf
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
39215
diff
changeset
|
1148 "viper-set-unread-command-events: Invalid argument, %S" arg))) |
633233bf2bbf
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
39215
diff
changeset
|
1149 unread-command-events)))) |
633233bf2bbf
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
39215
diff
changeset
|
1150 |
633233bf2bbf
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
39215
diff
changeset
|
1151 |
633233bf2bbf
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
39215
diff
changeset
|
1152 ;; Check if vec is a vector of key-press events representing characters |
633233bf2bbf
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
39215
diff
changeset
|
1153 ;; XEmacs only |
633233bf2bbf
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
39215
diff
changeset
|
1154 (defun viper-event-vector-p (vec) |
633233bf2bbf
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
39215
diff
changeset
|
1155 (and (vectorp vec) |
633233bf2bbf
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
39215
diff
changeset
|
1156 (eval (cons 'and (mapcar '(lambda (elt) (if (eventp elt) t)) vec))))) |
633233bf2bbf
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
39215
diff
changeset
|
1157 |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47520
diff
changeset
|
1158 |
42602
633233bf2bbf
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
39215
diff
changeset
|
1159 ;; check if vec is a vector of character symbols |
633233bf2bbf
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
39215
diff
changeset
|
1160 (defun viper-char-symbol-sequence-p (vec) |
633233bf2bbf
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
39215
diff
changeset
|
1161 (and |
633233bf2bbf
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
39215
diff
changeset
|
1162 (sequencep vec) |
633233bf2bbf
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
39215
diff
changeset
|
1163 (eval |
633233bf2bbf
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
39215
diff
changeset
|
1164 (cons 'and |
633233bf2bbf
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
39215
diff
changeset
|
1165 (mapcar (lambda (elt) |
633233bf2bbf
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
39215
diff
changeset
|
1166 (and (symbolp elt) (= (length (symbol-name elt)) 1))) |
633233bf2bbf
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
39215
diff
changeset
|
1167 vec))))) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47520
diff
changeset
|
1168 |
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47520
diff
changeset
|
1169 |
42602
633233bf2bbf
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
39215
diff
changeset
|
1170 (defun viper-char-array-p (array) |
633233bf2bbf
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
39215
diff
changeset
|
1171 (eval (cons 'and (mapcar 'viper-characterp array)))) |
633233bf2bbf
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
39215
diff
changeset
|
1172 |
633233bf2bbf
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
39215
diff
changeset
|
1173 |
10789 | 1174 ;; Args can be a sequence of events, a string, or a Viper macro. Will try to |
1175 ;; convert events to keys and, if all keys are regular printable | |
26263
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
22284
diff
changeset
|
1176 ;; characters, will return a string. Otherwise, will return a string |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
22284
diff
changeset
|
1177 ;; representing a vector of converted events. If the input was a Viper macro, |
10789 | 1178 ;; will return a string that represents this macro as a vector. |
19079 | 1179 (defun viper-array-to-string (event-seq) |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
1180 (let (temp temp2) |
10789 | 1181 (cond ((stringp event-seq) event-seq) |
19079 | 1182 ((viper-event-vector-p event-seq) |
1183 (setq temp (mapcar 'viper-event-key event-seq)) | |
1184 (cond ((viper-char-symbol-sequence-p temp) | |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
1185 (mapconcat 'symbol-name temp "")) |
19079 | 1186 ((and (viper-char-array-p |
1187 (setq temp2 (mapcar 'viper-key-to-character temp)))) | |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
1188 (mapconcat 'char-to-string temp2 "")) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
1189 (t (prin1-to-string (vconcat temp))))) |
19079 | 1190 ((viper-char-symbol-sequence-p event-seq) |
10789 | 1191 (mapconcat 'symbol-name event-seq "")) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47520
diff
changeset
|
1192 ((and (vectorp event-seq) |
19079 | 1193 (viper-char-array-p |
1194 (setq temp (mapcar 'viper-key-to-character event-seq)))) | |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
1195 (mapconcat 'char-to-string temp "")) |
10789 | 1196 (t (prin1-to-string event-seq))))) |
13213
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1197 |
19079 | 1198 (defun viper-key-press-events-to-chars (events) |
92380
8ee8aa679c74
(zmacs-region-stays): No need to define for compiler.
Glenn Morris <rgm@gnu.org>
parents:
87691
diff
changeset
|
1199 (mapconcat (if (featurep 'xemacs) |
93615
34417c118a39
2008-04-03 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
92766
diff
changeset
|
1200 (lambda (elt) (char-to-string (event-to-character elt))) ; xemacs |
34417c118a39
2008-04-03 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
92766
diff
changeset
|
1201 'char-to-string ; emacs |
34417c118a39
2008-04-03 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
92766
diff
changeset
|
1202 ) |
13213
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1203 events |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1204 "")) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47520
diff
changeset
|
1205 |
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47520
diff
changeset
|
1206 |
19079 | 1207 (defun viper-read-char-exclusive () |
10789 | 1208 (let (char |
1209 (echo-keystrokes 1)) | |
1210 (while (null char) | |
1211 (condition-case nil | |
1212 (setq char (read-char)) | |
1213 (error | |
1214 ;; skip event if not char | |
19079 | 1215 (viper-read-event)))) |
10789 | 1216 char)) |
1217 | |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
1218 ;; 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
|
1219 ;; character, etc. |
19079 | 1220 (defun viper-key-to-character (key) |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
1221 (cond ((eq key 'space) ?\ ) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
1222 ((eq key 'delete) ?\C-?) |
19079 | 1223 ((eq key 'return) ?\C-m) |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
1224 ((eq key 'backspace) ?\C-h) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
1225 ((and (symbolp key) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
1226 (= 1 (length (symbol-name key)))) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
1227 (string-to-char (symbol-name key))) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
1228 ((and (listp key) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
1229 (eq (car key) 'control) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
1230 (symbol-name (nth 1 key)) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
1231 (= 1 (length (symbol-name (nth 1 key))))) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
1232 (read (format "?\\C-%s" (symbol-name (nth 1 key))))) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14909
diff
changeset
|
1233 (t key))) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47520
diff
changeset
|
1234 |
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47520
diff
changeset
|
1235 |
19079 | 1236 (defun viper-setup-master-buffer (&rest other-files-or-buffers) |
10789 | 1237 "Set up the current buffer as a master buffer. |
26263
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
22284
diff
changeset
|
1238 Arguments become related buffers. This function should normally be used in |
10789 | 1239 the `Local variables' section of a file." |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47520
diff
changeset
|
1240 (setq viper-related-files-and-buffers-ring |
10789 | 1241 (make-ring (1+ (length other-files-or-buffers)))) |
84908
862e65546389
(viper-setup-master-buffer): Use `mapc' rather than `mapcar'.
Juanma Barranquero <lekktu@gmail.com>
parents:
82140
diff
changeset
|
1242 (mapc '(lambda (elt) |
862e65546389
(viper-setup-master-buffer): Use `mapc' rather than `mapcar'.
Juanma Barranquero <lekktu@gmail.com>
parents:
82140
diff
changeset
|
1243 (viper-ring-insert viper-related-files-and-buffers-ring elt)) |
862e65546389
(viper-setup-master-buffer): Use `mapc' rather than `mapcar'.
Juanma Barranquero <lekktu@gmail.com>
parents:
82140
diff
changeset
|
1244 other-files-or-buffers) |
19079 | 1245 (viper-ring-insert viper-related-files-and-buffers-ring (buffer-name)) |
10789 | 1246 ) |
13213
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1247 |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1248 ;;; Movement utilities |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1249 |
19462 | 1250 ;; Characters that should not be considered as part of the word, in reformed-vi |
1251 ;; syntax mode. | |
66893
7c76da84383b
2005-11-15 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
65627
diff
changeset
|
1252 ;; Note: \\ (quoted \) must appear before `-' because this string is listified |
7c76da84383b
2005-11-15 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
65627
diff
changeset
|
1253 ;; into characters at some point and then put back to string. The result is |
7c76da84383b
2005-11-15 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
65627
diff
changeset
|
1254 ;; used in skip-chars-forward, which treats - specially. Here we achieve the |
7c76da84383b
2005-11-15 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
65627
diff
changeset
|
1255 ;; effect of quoting - and preventing it from being special. |
19462 | 1256 (defconst viper-non-word-characters-reformed-vi |
66893
7c76da84383b
2005-11-15 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
65627
diff
changeset
|
1257 "!@#$%^&*()\\-+=|\\~`{}[];:'\",<.>/?") |
19462 | 1258 ;; These are characters that are not to be considered as parts of a word in |
1259 ;; Viper. | |
1260 ;; Set each time state changes and at loading time | |
1261 (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
|
1262 |
19462 | 1263 ;; must be buffer-local |
19079 | 1264 (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
|
1265 "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
|
1266 In addition, the symbol `_' may be considered alphanumeric if |
19462 | 1267 `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
|
1268 |
19462 | 1269 (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
|
1270 "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
|
1271 Vi.") |
19462 | 1272 (defconst viper-strict-SEP-chars " \t\n" |
1273 "Regexp matching the set of alphanumeric characters acceptable to strict | |
1274 Vi.") | |
1275 (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
|
1276 "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
|
1277 Vi.") |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1278 |
19462 | 1279 (defconst viper-SEP-char-class " -" |
13213
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1280 "String of syntax classes for Vi separators. |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1281 Usually contains ` ', linefeed, TAB or formfeed.") |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1282 |
19462 | 1283 |
1284 ;; Set Viper syntax classes and related variables according to | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47520
diff
changeset
|
1285 ;; `viper-syntax-preference'. |
19462 | 1286 (defun viper-update-syntax-classes (&optional set-default) |
1287 (let ((preference (cond ((eq viper-syntax-preference 'emacs) | |
1288 "w") ; Viper words have only Emacs word chars | |
1289 ((eq viper-syntax-preference 'extended) | |
1290 "w_") ; Viper words have Emacs word & symbol chars | |
1291 (t "w"))) ; Viper words are Emacs words plus `_' | |
1292 (non-word-chars (cond ((eq viper-syntax-preference 'reformed-vi) | |
1293 (viper-string-to-list | |
1294 viper-non-word-characters-reformed-vi)) | |
1295 (t nil)))) | |
1296 (if set-default | |
1297 (setq-default viper-ALPHA-char-class preference | |
1298 viper-non-word-characters non-word-chars) | |
1299 (setq viper-ALPHA-char-class preference | |
1300 viper-non-word-characters non-word-chars)) | |
1301 )) | |
1302 | |
1303 ;; SYMBOL is used because customize requires it, but it is ignored, unless it | |
26263
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
22284
diff
changeset
|
1304 ;; is `nil'. If nil, use setq. |
19462 | 1305 (defun viper-set-syntax-preference (&optional symbol value) |
1306 "Set Viper syntax preference. | |
1307 If called interactively or if SYMBOL is nil, sets syntax preference in current | |
26263
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
22284
diff
changeset
|
1308 buffer. If called non-interactively, preferably via the customization widget, |
19462 | 1309 sets the default value." |
13213
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1310 (interactive) |
19462 | 1311 (or value |
1312 (setq value | |
1313 (completing-read | |
1314 "Viper syntax preference: " | |
1315 '(("strict-vi") ("reformed-vi") ("extended") ("emacs")) | |
1316 nil 'require-match))) | |
1317 (if (stringp value) (setq value (intern value))) | |
1318 (or (memq value '(strict-vi reformed-vi extended emacs)) | |
1319 (error "Invalid Viper syntax preference, %S" value)) | |
1320 (if symbol | |
1321 (setq-default viper-syntax-preference value) | |
1322 (setq viper-syntax-preference value)) | |
1323 (viper-update-syntax-classes)) | |
1324 | |
1325 (defcustom viper-syntax-preference 'reformed-vi | |
1326 "*Syntax type characterizing Viper's alphanumeric symbols. | |
1327 Affects movement and change commands that deal with Vi-style words. | |
1328 Works best when set in the hooks to various major modes. | |
1329 | |
1330 `strict-vi' means Viper words are (hopefully) exactly as in Vi. | |
1331 | |
1332 `reformed-vi' means Viper words are like Emacs words \(as determined using | |
1333 Emacs syntax tables, which are different for different major modes\) with two | |
1334 exceptions: the symbol `_' is always part of a word and typical Vi non-word | |
1335 symbols, such as `,',:,\",),{, etc., are excluded. | |
1336 This behaves very close to `strict-vi', but also works well with non-ASCII | |
1337 characters from various alphabets. | |
1338 | |
1339 `extended' means Viper word constituents are symbols that are marked as being | |
1340 parts of words OR symbols in Emacs syntax tables. | |
1341 This is most appropriate for major modes intended for editing programs. | |
1342 | |
1343 `emacs' means Viper words are the same as Emacs words as specified by Emacs | |
1344 syntax tables. | |
1345 This option is appropriate if you like Emacs-style words." | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47520
diff
changeset
|
1346 :type '(radio (const strict-vi) (const reformed-vi) |
19462 | 1347 (const extended) (const emacs)) |
1348 :set 'viper-set-syntax-preference | |
1349 :group 'viper) | |
1350 (make-variable-buffer-local 'viper-syntax-preference) | |
1351 | |
13213
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1352 |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1353 ;; addl-chars are characters to be temporarily considered as alphanumerical |
19079 | 1354 (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
|
1355 (or (stringp addl-chars) (setq addl-chars "")) |
19079 | 1356 (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
|
1357 (setq addl-chars (concat addl-chars "_"))) |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1358 (let ((char (char-after (point)))) |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1359 (if char |
19079 | 1360 (if (eq viper-syntax-preference 'strict-vi) |
1361 (looking-at (concat "[" viper-strict-ALPHA-chars addl-chars "]")) | |
19462 | 1362 (or |
1363 ;; or one of the additional chars being asked to include | |
33019
6306740f6938
2000-10-29 Michael Kifer <kifer@cs.sunysb.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
28510
diff
changeset
|
1364 (viper-memq-char char (viper-string-to-list addl-chars)) |
19462 | 1365 (and |
33019
6306740f6938
2000-10-29 Michael Kifer <kifer@cs.sunysb.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
28510
diff
changeset
|
1366 ;; not one of the excluded word chars (note: |
6306740f6938
2000-10-29 Michael Kifer <kifer@cs.sunysb.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
28510
diff
changeset
|
1367 ;; viper-non-word-characters is a list) |
6306740f6938
2000-10-29 Michael Kifer <kifer@cs.sunysb.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
28510
diff
changeset
|
1368 (not (viper-memq-char char viper-non-word-characters)) |
19462 | 1369 ;; char of the Viper-word syntax class |
33019
6306740f6938
2000-10-29 Michael Kifer <kifer@cs.sunysb.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
28510
diff
changeset
|
1370 (viper-memq-char (char-syntax char) |
6306740f6938
2000-10-29 Michael Kifer <kifer@cs.sunysb.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
28510
diff
changeset
|
1371 (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
|
1372 )) |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1373 |
19079 | 1374 (defun viper-looking-at-separator () |
13213
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1375 (let ((char (char-after (point)))) |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1376 (if char |
19462 | 1377 (if (eq viper-syntax-preference 'strict-vi) |
33019
6306740f6938
2000-10-29 Michael Kifer <kifer@cs.sunysb.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
28510
diff
changeset
|
1378 (viper-memq-char char (viper-string-to-list viper-strict-SEP-chars)) |
19462 | 1379 (or (eq char ?\n) ; RET is always a separator in Vi |
33019
6306740f6938
2000-10-29 Michael Kifer <kifer@cs.sunysb.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
28510
diff
changeset
|
1380 (viper-memq-char (char-syntax char) |
6306740f6938
2000-10-29 Michael Kifer <kifer@cs.sunysb.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
28510
diff
changeset
|
1381 (viper-string-to-list viper-SEP-char-class))))) |
19462 | 1382 )) |
13213
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1383 |
19079 | 1384 (defsubst viper-looking-at-alphasep (&optional addl-chars) |
1385 (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
|
1386 |
19079 | 1387 (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
|
1388 (or (stringp addl-chars) (setq addl-chars "")) |
19079 | 1389 (viper-skip-syntax |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47520
diff
changeset
|
1390 'forward |
19079 | 1391 (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
|
1392 "") |
19241 | 1393 (t viper-ALPHA-char-class)) |
19079 | 1394 (cond ((eq viper-syntax-preference 'strict-vi) |
1395 (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
|
1396 (t addl-chars)))) |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1397 |
19079 | 1398 (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
|
1399 (or (stringp addl-chars) (setq addl-chars "")) |
19079 | 1400 (viper-skip-syntax |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47520
diff
changeset
|
1401 'backward |
19079 | 1402 (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
|
1403 "") |
19241 | 1404 (t viper-ALPHA-char-class)) |
19079 | 1405 (cond ((eq viper-syntax-preference 'strict-vi) |
1406 (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
|
1407 (t addl-chars)))) |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1408 |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1409 ;; weird syntax tables may confuse strict-vi style |
19079 | 1410 (defsubst viper-skip-all-separators-forward (&optional within-line) |
19462 | 1411 (if (eq viper-syntax-preference 'strict-vi) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47520
diff
changeset
|
1412 (if within-line |
19462 | 1413 (skip-chars-forward viper-strict-SEP-chars-sans-newline) |
1414 (skip-chars-forward viper-strict-SEP-chars)) | |
1415 (viper-skip-syntax 'forward | |
1416 viper-SEP-char-class | |
1417 (or within-line "\n") | |
1418 (if within-line (viper-line-pos 'end))))) | |
65627
511f8e9d22ca
2005-09-20 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
64750
diff
changeset
|
1419 |
19079 | 1420 (defsubst viper-skip-all-separators-backward (&optional within-line) |
19462 | 1421 (if (eq viper-syntax-preference 'strict-vi) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47520
diff
changeset
|
1422 (if within-line |
19462 | 1423 (skip-chars-backward viper-strict-SEP-chars-sans-newline) |
1424 (skip-chars-backward viper-strict-SEP-chars)) | |
1425 (viper-skip-syntax 'backward | |
1426 viper-SEP-char-class | |
1427 (or within-line "\n") | |
1428 (if within-line (viper-line-pos 'start))))) | |
19079 | 1429 (defun viper-skip-nonseparators (direction) |
19462 | 1430 (viper-skip-syntax |
1431 direction | |
1432 (concat "^" viper-SEP-char-class) | |
1433 nil | |
1434 (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
|
1435 |
19462 | 1436 |
1437 ;; skip over non-word constituents and non-separators | |
19079 | 1438 (defun viper-skip-nonalphasep-forward () |
1439 (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
|
1440 (skip-chars-forward |
19079 | 1441 (concat "^" viper-strict-SEP-chars viper-strict-ALPHA-chars)) |
19462 | 1442 (viper-skip-syntax |
1443 'forward | |
1444 (concat "^" viper-ALPHA-char-class viper-SEP-char-class) | |
1445 ;; Emacs may consider some of these as words, but we don't want them | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47520
diff
changeset
|
1446 viper-non-word-characters |
19462 | 1447 (viper-line-pos 'end)))) |
65627
511f8e9d22ca
2005-09-20 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
64750
diff
changeset
|
1448 |
19079 | 1449 (defun viper-skip-nonalphasep-backward () |
1450 (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
|
1451 (skip-chars-backward |
19079 | 1452 (concat "^" viper-strict-SEP-chars viper-strict-ALPHA-chars)) |
19462 | 1453 (viper-skip-syntax |
1454 'backward | |
1455 (concat "^" viper-ALPHA-char-class viper-SEP-char-class) | |
1456 ;; Emacs may consider some of these as words, but we don't want them | |
1457 viper-non-word-characters | |
19079 | 1458 (viper-line-pos 'start)))) |
13213
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1459 |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1460 ;; 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
|
1461 ;; Return the number of chars traveled. |
19462 | 1462 ;; Both SYNTAX or ADDL-CHARS can be strings or lists of characters. |
1463 ;; When SYNTAX is "w", then viper-non-word-characters are not considered to be | |
1464 ;; words, even if Emacs syntax table says they are. | |
19079 | 1465 (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
|
1466 (let ((total 0) |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1467 (local 1) |
19462 | 1468 (skip-chars-func |
1469 (if (eq direction 'forward) | |
1470 'skip-chars-forward 'skip-chars-backward)) | |
1471 (skip-syntax-func | |
1472 (if (eq direction 'forward) | |
1473 'viper-forward-char-carefully 'viper-backward-char-carefully)) | |
1474 char-looked-at syntax-of-char-looked-at negated-syntax) | |
1475 (setq addl-chars | |
1476 (cond ((listp addl-chars) (viper-charlist-to-string addl-chars)) | |
1477 ((stringp addl-chars) addl-chars) | |
1478 (t ""))) | |
1479 (setq syntax | |
1480 (cond ((listp syntax) syntax) | |
1481 ((stringp syntax) (viper-string-to-list syntax)) | |
1482 (t nil))) | |
1483 (if (memq ?^ syntax) (setq negated-syntax t)) | |
1484 | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47520
diff
changeset
|
1485 (while (and (not (= local 0)) |
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47520
diff
changeset
|
1486 (cond ((eq direction 'forward) |
22284
7c92be9aea04
(viper-skip-syntax): Bug fix for eob/bob cases.
Karl Heuer <kwzh@gnu.org>
parents:
21940
diff
changeset
|
1487 (not (eobp))) |
7c92be9aea04
(viper-skip-syntax): Bug fix for eob/bob cases.
Karl Heuer <kwzh@gnu.org>
parents:
21940
diff
changeset
|
1488 (t (not (bobp))))) |
19462 | 1489 (setq char-looked-at (viper-char-at-pos direction) |
1490 ;; if outside the range, set to nil | |
1491 syntax-of-char-looked-at (if char-looked-at | |
1492 (char-syntax char-looked-at))) | |
13213
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1493 (setq local |
19462 | 1494 (+ (if (and |
1495 (cond ((and limit (eq direction 'forward)) | |
1496 (< (point) limit)) | |
1497 (limit ; backward & limit | |
1498 (> (point) limit)) | |
1499 (t t)) ; no limit | |
1500 ;; char under/before cursor has appropriate syntax | |
1501 (if negated-syntax | |
1502 (not (memq syntax-of-char-looked-at syntax)) | |
1503 (memq syntax-of-char-looked-at syntax)) | |
1504 ;; if char-syntax class is "word", make sure it is not one | |
1505 ;; of the excluded characters | |
1506 (if (and (eq syntax-of-char-looked-at ?w) | |
1507 (not negated-syntax)) | |
33019
6306740f6938
2000-10-29 Michael Kifer <kifer@cs.sunysb.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
28510
diff
changeset
|
1508 (not (viper-memq-char |
6306740f6938
2000-10-29 Michael Kifer <kifer@cs.sunysb.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
28510
diff
changeset
|
1509 char-looked-at viper-non-word-characters)) |
19462 | 1510 t)) |
1511 (funcall skip-syntax-func 1) | |
1512 0) | |
13213
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1513 (funcall skip-chars-func addl-chars limit))) |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1514 (setq total (+ total local))) |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1515 total |
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1516 )) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47520
diff
changeset
|
1517 |
65627
511f8e9d22ca
2005-09-20 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
64750
diff
changeset
|
1518 ;; tells when point is at the beginning of field |
511f8e9d22ca
2005-09-20 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
64750
diff
changeset
|
1519 (defun viper-beginning-of-field () |
511f8e9d22ca
2005-09-20 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
64750
diff
changeset
|
1520 (or (bobp) |
511f8e9d22ca
2005-09-20 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
64750
diff
changeset
|
1521 (not (eq (get-char-property (point) 'field) |
511f8e9d22ca
2005-09-20 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
64750
diff
changeset
|
1522 (get-char-property (1- (point)) 'field))))) |
511f8e9d22ca
2005-09-20 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
64750
diff
changeset
|
1523 |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47520
diff
changeset
|
1524 |
64215
a4c59075cac8
* viper-cmd.el (viper--key-maps): new variable.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
64085
diff
changeset
|
1525 ;; this is copied from cl-extra.el |
a4c59075cac8
* viper-cmd.el (viper--key-maps): new variable.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
64085
diff
changeset
|
1526 ;; Return the subsequence of SEQ from START to END. |
a4c59075cac8
* viper-cmd.el (viper--key-maps): new variable.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
64085
diff
changeset
|
1527 ;; If END is omitted, it defaults to the length of the sequence. |
a4c59075cac8
* viper-cmd.el (viper--key-maps): new variable.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
64085
diff
changeset
|
1528 ;; If START or END is negative, it counts from the end. |
a4c59075cac8
* viper-cmd.el (viper--key-maps): new variable.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
64085
diff
changeset
|
1529 (defun viper-subseq (seq start &optional end) |
a4c59075cac8
* viper-cmd.el (viper--key-maps): new variable.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
64085
diff
changeset
|
1530 (if (stringp seq) (substring seq start end) |
a4c59075cac8
* viper-cmd.el (viper--key-maps): new variable.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
64085
diff
changeset
|
1531 (let (len) |
a4c59075cac8
* viper-cmd.el (viper--key-maps): new variable.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
64085
diff
changeset
|
1532 (and end (< end 0) (setq end (+ end (setq len (length seq))))) |
a4c59075cac8
* viper-cmd.el (viper--key-maps): new variable.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
64085
diff
changeset
|
1533 (if (< start 0) (setq start (+ start (or len (setq len (length seq)))))) |
a4c59075cac8
* viper-cmd.el (viper--key-maps): new variable.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
64085
diff
changeset
|
1534 (cond ((listp seq) |
a4c59075cac8
* viper-cmd.el (viper--key-maps): new variable.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
64085
diff
changeset
|
1535 (if (> start 0) (setq seq (nthcdr start seq))) |
a4c59075cac8
* viper-cmd.el (viper--key-maps): new variable.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
64085
diff
changeset
|
1536 (if end |
a4c59075cac8
* viper-cmd.el (viper--key-maps): new variable.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
64085
diff
changeset
|
1537 (let ((res nil)) |
a4c59075cac8
* viper-cmd.el (viper--key-maps): new variable.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
64085
diff
changeset
|
1538 (while (>= (setq end (1- end)) start) |
a4c59075cac8
* viper-cmd.el (viper--key-maps): new variable.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
64085
diff
changeset
|
1539 (push (pop seq) res)) |
a4c59075cac8
* viper-cmd.el (viper--key-maps): new variable.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
64085
diff
changeset
|
1540 (nreverse res)) |
a4c59075cac8
* viper-cmd.el (viper--key-maps): new variable.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
64085
diff
changeset
|
1541 (copy-sequence seq))) |
a4c59075cac8
* viper-cmd.el (viper--key-maps): new variable.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
64085
diff
changeset
|
1542 (t |
a4c59075cac8
* viper-cmd.el (viper--key-maps): new variable.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
64085
diff
changeset
|
1543 (or end (setq end (or len (length seq)))) |
a4c59075cac8
* viper-cmd.el (viper--key-maps): new variable.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
64085
diff
changeset
|
1544 (let ((res (make-vector (max (- end start) 0) nil)) |
a4c59075cac8
* viper-cmd.el (viper--key-maps): new variable.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
64085
diff
changeset
|
1545 (i 0)) |
a4c59075cac8
* viper-cmd.el (viper--key-maps): new variable.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
64085
diff
changeset
|
1546 (while (< start end) |
a4c59075cac8
* viper-cmd.el (viper--key-maps): new variable.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
64085
diff
changeset
|
1547 (aset res i (aref seq start)) |
a4c59075cac8
* viper-cmd.el (viper--key-maps): new variable.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
64085
diff
changeset
|
1548 (setq i (1+ i) start (1+ start))) |
a4c59075cac8
* viper-cmd.el (viper--key-maps): new variable.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
64085
diff
changeset
|
1549 res)))))) |
a4c59075cac8
* viper-cmd.el (viper--key-maps): new variable.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
64085
diff
changeset
|
1550 |
a4c59075cac8
* viper-cmd.el (viper--key-maps): new variable.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
64085
diff
changeset
|
1551 |
13213
68b3f6d9156f
(vip-leave-region-active): new function.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12899
diff
changeset
|
1552 |
101721
c55394eee0de
Follow commenting conventions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
100908
diff
changeset
|
1553 ;; Local Variables: |
c55394eee0de
Follow commenting conventions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
100908
diff
changeset
|
1554 ;; eval: (put 'viper-deflocalvar 'lisp-indent-hook 'defun) |
c55394eee0de
Follow commenting conventions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
100908
diff
changeset
|
1555 ;; End: |
10789 | 1556 |
93975
1e3a407766b9
Fix up comment convention on the arch-tag lines.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
93652
diff
changeset
|
1557 ;; arch-tag: 7f023fd5-dd9e-4378-a397-9c179553b0e3 |
38414
67b464da13ec
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
36857
diff
changeset
|
1558 ;;; viper-util.el ends here |