Mercurial > emacs
annotate lisp/s-region.el @ 16842:72276b334084 before-thomas-posix1996 glibc-2_0_2 libc-970108 libc-970109 libc-970110 libc-970111 libc-970112 libc-970113 libc-970114 libc-970115 libc-970116 libc-970117 libc-970118 libc-970119 libc-970120 libc-970121 libc-970122 libc-970123 libc-970124 libc-970125 libc-970126 libc-970127 libc-970128 libc-970129 libc-970130 libc-970131 libc-970201 libc-970202 libc-970203 libc-970204 libc-970205 libc-970206 libc-970207 libc-970208 libc-970209 libc-970210 libc-970211 libc-970212 libc-970213 libc-970214 libc-970215 libc-970216 libc-970217 libc-970218 libc-970219 libc-970220 libc-970221 libc-970222 libc-970223 libc-970224 libc-970225 libc-970226 libc-970227 libc-970228 libc-970301 libc-970302 libc-970303 libc-970304 libc-970305 libc-970306 libc-970307 libc-970308 libc-970309 libc-970310 libc-970311 libc-970312 libc-970313 libc-970314 libc-970315 libc-970316 libc-970317 libc-970318 libc-970319 libc-970320 libc-970321 libc-970322 libc-970323 libc-970324 libc20x-970306 libc20x-97031 libc20x-970316 libc20x-970318 libc20x-970319 libc20x-970404 root-libc-2_0_x-branch
Add hppa1.1-hitachi-hiuxmpp support, passed along by rms.
author | David J. MacKenzie <djm@gnu.org> |
---|---|
date | Tue, 07 Jan 1997 19:29:28 +0000 |
parents | 83f275dcd93a |
children | 727cf56647a4 |
rev | line source |
---|---|
6220 | 1 ;;; s-region.el --- set region using shift key. |
14169 | 2 |
3 ;; Copyright (C) 1994, 1995 Free Software Foundation, Inc. | |
6220 | 4 |
5 ;; Author: Morten Welinder (terra@diku.dk) | |
6 ;; Keywords: terminals | |
7 ;; Favourite-brand-of-beer: None, I hate beer. | |
8 | |
9 ;; This file is part of GNU Emacs. | |
10 | |
11 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
12 ;; it under the terms of the GNU General Public License as published by | |
13 ;; the Free Software Foundation; either version 2, or (at your option) | |
14 ;; any later version. | |
15 | |
16 ;; GNU Emacs is distributed in the hope that it will be useful, | |
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 ;; GNU General Public License for more details. | |
20 | |
21 ;; You should have received a copy of the GNU General Public License | |
14169 | 22 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
24 ;; Boston, MA 02111-1307, USA. | |
6220 | 25 |
26 ;;; Commentary: | |
27 | |
28 ;; Having loaded this code you can set the region by holding down the | |
29 ;; shift key and move the cursor to the other end of the region. The | |
14040 | 30 ;; functionality provided by this code is similar to that provided by |
6220 | 31 ;; the editors of Borland International's compilers for ms-dos. |
32 | |
33 ;; Currently, s-region-move may be bound only to events that are vectors | |
34 ;; of length one and whose last element is a symbol. Also, the functions | |
35 ;; that are given this kind of overlay should be (interactive "p") | |
36 ;; functions. | |
37 | |
7991
f2e16be5a263
Don't bind keys C-insert, C-delete, and
Richard M. Stallman <rms@gnu.org>
parents:
6220
diff
changeset
|
38 ;; If the following keys are not already bound then... |
6220 | 39 ;; C-insert is bound to copy-region-as-kill |
40 ;; S-delete is bound to kill-region | |
41 ;; S-insert is bound to yank | |
42 | |
43 ;;; Code: | |
44 | |
45 (defvar s-region-overlay (make-overlay 1 1)) | |
46 (overlay-put s-region-overlay 'face 'region) | |
47 (overlay-put s-region-overlay 'priority 1000000) ; for hilit19 | |
48 | |
49 (defun s-region-unshift (key) | |
50 "Remove shift modifier from last keypress KEY and return that as a key." | |
51 (if (vectorp key) | |
52 (let ((last (aref key (1- (length key))))) | |
53 (if (symbolp last) | |
54 (let* ((keyname (symbol-name last)) | |
55 (pos (string-match "S-" keyname))) | |
56 (if pos | |
57 ;; We skip all initial parts of the event assuming that | |
58 ;; those are setting up the prefix argument to the command. | |
59 (vector (intern (concat (substring keyname 0 pos) | |
60 (substring keyname (+ 2 pos))))) | |
61 (error "Non-shifted key: %S" key))) | |
62 (error "Key does not end in a symbol: %S" key))) | |
63 (error "Non-vector key: %S" key))) | |
64 | |
12103 | 65 (defun s-region-move-p1 (&rest arg) |
66 "This is an overlay function to point-moving keys that are interactive \"p\"" | |
67 (interactive "p") | |
68 (apply (function s-region-move) arg)) | |
69 | |
70 (defun s-region-move-p2 (&rest arg) | |
71 "This is an overlay function to point-moving keys that are interactive \"P\"" | |
72 (interactive "P") | |
73 (apply (function s-region-move) arg)) | |
74 | |
6220 | 75 (defun s-region-move (&rest arg) |
76 (if (if mark-active (not (equal last-command 's-region-move)) t) | |
77 (set-mark-command nil) | |
78 (message "")) ; delete the "Mark set" message | |
12103 | 79 (setq this-command 's-region-move) |
6220 | 80 (apply (key-binding (s-region-unshift (this-command-keys))) arg) |
81 (move-overlay s-region-overlay (mark) (point) (current-buffer)) | |
82 (sit-for 1) | |
83 (delete-overlay s-region-overlay)) | |
84 | |
85 (defun s-region-bind (keylist &optional map) | |
12103 | 86 "Bind shifted keys in KEYLIST to s-region-move-p1 or s-region-move-p2. |
87 Each key in KEYLIST is shifted and bound to one of the s-region-move | |
88 functions provided it is already bound to some command or other. | |
89 Optional third argument MAP specifies keymap to add binding to, defaulting | |
90 to global keymap." | |
91 (let ((p2 (list 'scroll-up 'scroll-down | |
92 'beginning-of-buffer 'end-of-buffer))) | |
93 (or map (setq map global-map)) | |
94 (while keylist | |
95 (let* ((key (car keylist)) | |
96 (binding (key-binding key))) | |
97 (if (commandp binding) | |
98 (define-key | |
99 map | |
100 (vector (intern (concat "S-" (symbol-name (aref key 0))))) | |
101 (cond ((memq binding p2) | |
102 's-region-move-p2) | |
103 (t 's-region-move-p1))))) | |
104 (setq keylist (cdr keylist))))) | |
6220 | 105 |
12103 | 106 ;; Single keys (plus modifiers) only! |
6220 | 107 (s-region-bind |
108 (list [right] [left] [up] [down] | |
109 [C-left] [C-right] [C-up] [C-down] | |
110 [M-left] [M-right] [M-up] [M-down] | |
111 [next] [previous] [home] [end] | |
112 [C-next] [C-previous] [C-home] [C-end] | |
113 [M-next] [M-previous] [M-home] [M-end])) | |
114 | |
7991
f2e16be5a263
Don't bind keys C-insert, C-delete, and
Richard M. Stallman <rms@gnu.org>
parents:
6220
diff
changeset
|
115 (or (global-key-binding [C-insert]) |
f2e16be5a263
Don't bind keys C-insert, C-delete, and
Richard M. Stallman <rms@gnu.org>
parents:
6220
diff
changeset
|
116 (global-set-key [C-insert] 'copy-region-as-kill)) |
11653
5416e2c64d19
(S-delete): Fix typo (was C-delete).
Richard M. Stallman <rms@gnu.org>
parents:
7991
diff
changeset
|
117 (or (global-key-binding [S-delete]) |
7991
f2e16be5a263
Don't bind keys C-insert, C-delete, and
Richard M. Stallman <rms@gnu.org>
parents:
6220
diff
changeset
|
118 (global-set-key [S-delete] 'kill-region)) |
f2e16be5a263
Don't bind keys C-insert, C-delete, and
Richard M. Stallman <rms@gnu.org>
parents:
6220
diff
changeset
|
119 (or (global-key-binding [S-insert]) |
f2e16be5a263
Don't bind keys C-insert, C-delete, and
Richard M. Stallman <rms@gnu.org>
parents:
6220
diff
changeset
|
120 (global-set-key [S-insert] 'yank)) |
6220 | 121 |
122 (provide 's-region) | |
123 | |
124 ;; s-region.el ends here. |