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