Mercurial > emacs
annotate lisp/emulation/pc-select.el @ 21466:98b189f8975f
(vhdl-loop, vhdl-while-loop): Add backslash.
author | Karl Heuer <kwzh@gnu.org> |
---|---|
date | Fri, 10 Apr 1998 09:28:12 +0000 |
parents | 4e824f1fe62d |
children | a77d473867b8 |
rev | line source |
---|---|
18216
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
1 ;;; pc-select.el --- emulate mark, cut, copy and paste from Motif |
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
2 ;;; (or MAC GUI or MS-windoze (bah)) look-and-feel |
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
3 ;;; including key bindings. |
13233 | 4 |
18216
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
5 ;; Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. |
13233 | 6 |
7 ;; Author: Michael Staats <michael@thp.Uni-Duisburg.DE> | |
8 ;; Created: 26 Sep 1995 | |
9 | |
10 ;; This file is part of GNU Emacs. | |
11 | |
12 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
13 ;; it under the terms of the GNU General Public License as published by | |
14 ;; the Free Software Foundation; either version 2, or (at your option) | |
15 ;; any later version. | |
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 | |
14169 | 23 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
24 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
25 ;; Boston, MA 02111-1307, USA. | |
13233 | 26 |
27 ;;; Commentary: | |
14169 | 28 |
13233 | 29 ;; This package emulates the mark, copy, cut and paste look-and-feel of motif |
30 ;; programs (which is the same as the MAC gui and (sorry for that) MS-Windows). | |
31 ;; It modifies the keybindings of the cursor keys and the next, prior, | |
32 ;; home and end keys. They will modify mark-active. | |
33 ;; You can still get the old behaviour of cursor moving with the | |
34 ;; control sequences C-f, C-b, etc. | |
35 ;; This package uses transient-mark-mode and | |
36 ;; delete-selection-mode. | |
37 ;; | |
38 ;; In addition to that all key-bindings from the pc-mode are | |
39 ;; done here too (as suggested by RMS). | |
40 ;; | |
41 ;; As I found out after I finished the first version, s-region.el tries | |
42 ;; to do the same.... But my code is a little more complete and using | |
43 ;; delete-selection-mode is very important for the look-and-feel. | |
44 ;; Pete Forman <pete.forman@airgun.wg.waii.com> provided some motif | |
45 ;; compliant keybindings which I added. I had to modify them a little | |
46 ;; to add the -mark and -nomark functionality of cursor moving. | |
47 ;; | |
48 ;; Credits: | |
49 ;; Many thanks to all who made comments. | |
50 ;; Thanks to RMS and Ralf Muschall <prm@rz.uni-jena.de> for criticism. | |
51 ;; Kevin Cutts <cutts@ukraine.corp.mot.com> added the beginning-of-buffer | |
52 ;; and end-of-buffer functions which I modified a little. | |
53 ;; David Biesack <sasdjb@unx.sas.com> suggested some more cleanup. | |
54 ;; Thanks to Pete Forman <pete.forman@airgun.wg.waii.com> | |
55 ;; for additional motif keybindings. | |
14382 | 56 ;; Thanks to jvromans@squirrel.nl (Johan Vromans) for a bug report |
57 ;; concerning setting of this-command. | |
19289 | 58 ;; Dan Nicolaescu <done@ece.arizona.ro> suggested suppressing the |
15907
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
59 ;; scroll-up/scroll-down error. |
18216
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
60 ;; Eli Barzilay (eli@cs.bgu.ac.il) suggested the sexps functions and |
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
61 ;; keybindings. |
13233 | 62 ;; |
63 ;; Ok, some details about the idea of pc-selection-mode: | |
64 ;; | |
65 ;; o The standard keys for moving around (right, left, up, down, home, end, | |
66 ;; prior, next, called "move-keys" from now on) will always de-activate | |
67 ;; the mark. | |
68 ;; o If you press "Shift" together with the "move-keys", the region | |
69 ;; you pass along is activated | |
70 ;; o You have the copy, cut and paste functions (as in many other programs) | |
71 ;; which will operate on the active region | |
72 ;; It was not possible to bind them to C-v, C-x and C-c for obvious | |
73 ;; emacs reasons. | |
74 ;; They will be bound according to the "old" behaviour to S-delete (cut), | |
75 ;; S-insert (paste) and C-insert (copy). These keys do the same in many | |
76 ;; other programs. | |
15907
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
77 ;; |
13233 | 78 |
15907
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
79 ;;;; Customization: |
19289 | 80 (defgroup pc-select nil |
81 "Emulate pc bindings." | |
82 :prefix "pc-select" | |
83 :group 'editing-basics) | |
15907
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
84 |
19289 | 85 (defcustom pc-select-override-scroll-error t |
15907
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
86 "*Non-nil means don't generate error on scrolling past edge of buffer. |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
87 This variable applies in PC Selection mode only. |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
88 The scroll commands normally generate an error if you try to scroll |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
89 past the top or bottom of the buffer. This is annoying when selecting |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
90 text with these commands. If you set this variable to non-nil, these |
19289 | 91 errors are suppressed." |
92 :type 'boolean | |
93 :group 'pc-select) | |
13233 | 94 |
19289 | 95 (defcustom pc-select-selection-keys-only nil |
18216
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
96 "*Non-nil means only bind the basic selection keys when started. |
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
97 Other keys that emulate pc-behavior will be untouched. |
19289 | 98 This gives mostly Emacs-like behaviour with only the selection keys enabled." |
99 :type 'boolean | |
100 :group 'pc-select) | |
18216
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
101 |
19289 | 102 (defcustom pc-select-meta-moves-sexps nil |
103 "*Non-nil means move sexp-wise with Meta key, otherwise move word-wise." | |
104 :type 'boolean | |
105 :group 'pc-select) | |
18216
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
106 |
13233 | 107 ;;;; |
108 ;; misc | |
109 ;;;; | |
110 | |
111 (provide 'pc-select) | |
112 | |
113 (defun copy-region-as-kill-nomark (beg end) | |
114 "Save the region as if killed; but don't kill it; deactivate mark. | |
115 If `interprogram-cut-function' is non-nil, also save the text for a window | |
15907
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
116 system cut and paste. |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
117 |
13233 | 118 Deactivating mark is to avoid confusion with delete-selection-mode |
119 and transient-mark-mode." | |
120 (interactive "r") | |
121 (copy-region-as-kill beg end) | |
122 (setq mark-active nil) | |
123 (message "Region saved")) | |
124 | |
18216
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
125 (defun exchange-point-and-mark-nomark () |
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
126 (interactive) |
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
127 (exchange-point-and-mark) |
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
128 (setq mark-active nil)) |
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
129 |
13233 | 130 ;;;; |
131 ;; non-interactive | |
132 ;;;; | |
133 (defun ensure-mark() | |
134 ;; make sure mark is active | |
135 ;; test if it is active, if it isn't, set it and activate it | |
15931
c729af982039
(ensure-mark): Minor rewrite.
Richard M. Stallman <rms@gnu.org>
parents:
15907
diff
changeset
|
136 (or mark-active (set-mark-command nil))) |
13233 | 137 |
138 ;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
139 ;;;;; forward and mark | |
140 ;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
141 | |
142 (defun forward-char-mark (&optional arg) | |
143 "Ensure mark is active; move point right ARG characters (left if ARG negative). | |
144 On reaching end of buffer, stop and signal error." | |
145 (interactive "p") | |
146 (ensure-mark) | |
147 (forward-char arg)) | |
148 | |
149 (defun forward-word-mark (&optional arg) | |
150 "Ensure mark is active; move point right ARG words (backward if ARG is negative). | |
151 Normally returns t. | |
152 If an edge of the buffer is reached, point is left there | |
153 and nil is returned." | |
154 (interactive "p") | |
155 (ensure-mark) | |
156 (forward-word arg)) | |
157 | |
15907
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
158 (defun forward-line-mark (&optional arg) |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
159 "Ensure mark is active; move cursor vertically down ARG lines." |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
160 (interactive "p") |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
161 (ensure-mark) |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
162 (forward-line arg) |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
163 (setq this-command 'forward-line) |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
164 ) |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
165 |
18216
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
166 (defun forward-sexp-mark (&optional arg) |
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
167 "Ensure mark is active; move forward across one balanced expression (sexp). |
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
168 With argument, do it that many times. Negative arg -N means |
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
169 move backward across N balanced expressions." |
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
170 (interactive "p") |
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
171 (ensure-mark) |
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
172 (forward-sexp arg)) |
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
173 |
13233 | 174 (defun forward-paragraph-mark (&optional arg) |
175 "Ensure mark is active; move forward to end of paragraph. | |
15907
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
176 With arg N, do it N times; negative arg -N means move backward N paragraphs. |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
177 |
13233 | 178 A line which `paragraph-start' matches either separates paragraphs |
14382 | 179 \(if `paragraph-separate' matches it also) or is the first line of a paragraph. |
13233 | 180 A paragraph end is the beginning of a line which is not part of the paragraph |
181 to which the end of the previous line belongs, or the end of the buffer." | |
182 (interactive "p") | |
183 (ensure-mark) | |
184 (forward-paragraph arg)) | |
15907
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
185 |
13233 | 186 (defun next-line-mark (&optional arg) |
187 "Ensure mark is active; move cursor vertically down ARG lines. | |
188 If there is no character in the target line exactly under the current column, | |
189 the cursor is positioned after the character in that line which spans this | |
190 column, or at the end of the line if it is not long enough. | |
191 If there is no line in the buffer after this one, behavior depends on the | |
192 value of `next-line-add-newlines'. If non-nil, it inserts a newline character | |
193 to create a line, and moves the cursor to that line. Otherwise it moves the | |
194 cursor to the end of the buffer \(if already at the end of the buffer, an error | |
15907
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
195 is signaled). |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
196 |
13233 | 197 The command C-x C-n can be used to create |
198 a semipermanent goal column to which this command always moves. | |
199 Then it does not try to move vertically. This goal column is stored | |
200 in `goal-column', which is nil when there is none." | |
201 (interactive "p") | |
202 (ensure-mark) | |
14382 | 203 (next-line arg) |
204 (setq this-command 'next-line)) | |
13233 | 205 |
206 (defun end-of-line-mark (&optional arg) | |
207 "Ensure mark is active; move point to end of current line. | |
208 With argument ARG not nil or 1, move forward ARG - 1 lines first. | |
209 If scan reaches end of buffer, stop there without error." | |
210 (interactive "p") | |
211 (ensure-mark) | |
14382 | 212 (end-of-line arg) |
213 (setq this-command 'end-of-line)) | |
13233 | 214 |
15907
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
215 (defun backward-line-mark (&optional arg) |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
216 "Ensure mark is active; move cursor vertically up ARG lines." |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
217 (interactive "p") |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
218 (ensure-mark) |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
219 (if (null arg) |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
220 (setq arg 1)) |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
221 (forward-line (- arg)) |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
222 (setq this-command 'forward-line) |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
223 ) |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
224 |
13233 | 225 (defun scroll-down-mark (&optional arg) |
226 "Ensure mark is active; scroll down ARG lines; or near full screen if no ARG. | |
227 A near full screen is `next-screen-context-lines' less than a full screen. | |
228 Negative ARG means scroll upward. | |
229 When calling from a program, supply a number as argument or nil." | |
230 (interactive "P") | |
231 (ensure-mark) | |
15931
c729af982039
(ensure-mark): Minor rewrite.
Richard M. Stallman <rms@gnu.org>
parents:
15907
diff
changeset
|
232 (cond (pc-select-override-scroll-error |
c729af982039
(ensure-mark): Minor rewrite.
Richard M. Stallman <rms@gnu.org>
parents:
15907
diff
changeset
|
233 (condition-case nil (scroll-down arg) |
c729af982039
(ensure-mark): Minor rewrite.
Richard M. Stallman <rms@gnu.org>
parents:
15907
diff
changeset
|
234 (beginning-of-buffer (goto-char (point-min))))) |
c729af982039
(ensure-mark): Minor rewrite.
Richard M. Stallman <rms@gnu.org>
parents:
15907
diff
changeset
|
235 (t (scroll-down arg)))) |
13233 | 236 |
237 (defun end-of-buffer-mark (&optional arg) | |
238 "Ensure mark is active; move point to the end of the buffer. | |
15907
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
239 With arg N, put point N/10 of the way from the end. |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
240 |
13233 | 241 If the buffer is narrowed, this command uses the beginning and size |
15907
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
242 of the accessible part of the buffer. |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
243 |
13233 | 244 Don't use this command in Lisp programs! |
245 \(goto-char \(point-max)) is faster and avoids clobbering the mark." | |
246 (interactive "P") | |
247 (ensure-mark) | |
248 (let ((size (- (point-max) (point-min)))) | |
249 (goto-char (if arg | |
250 (- (point-max) | |
251 (if (> size 10000) | |
252 ;; Avoid overflow for large buffer sizes! | |
253 (* (prefix-numeric-value arg) | |
254 (/ size 10)) | |
255 (/ (* size (prefix-numeric-value arg)) 10))) | |
256 (point-max)))) | |
257 ;; If we went to a place in the middle of the buffer, | |
258 ;; adjust it to the beginning of a line. | |
259 (if arg (forward-line 1) | |
260 ;; If the end of the buffer is not already on the screen, | |
261 ;; then scroll specially to put it near, but not at, the bottom. | |
262 (if (let ((old-point (point))) | |
263 (save-excursion | |
264 (goto-char (window-start)) | |
265 (vertical-motion (window-height)) | |
266 (< (point) old-point))) | |
267 (progn | |
268 (overlay-recenter (point)) | |
269 (recenter -3))))) | |
270 | |
271 ;;;;;;;;; | |
272 ;;;;; no mark | |
273 ;;;;;;;;; | |
274 | |
275 (defun forward-char-nomark (&optional arg) | |
276 "Deactivate mark; move point right ARG characters \(left if ARG negative). | |
277 On reaching end of buffer, stop and signal error." | |
278 (interactive "p") | |
279 (setq mark-active nil) | |
280 (forward-char arg)) | |
281 | |
282 (defun forward-word-nomark (&optional arg) | |
283 "Deactivate mark; move point right ARG words \(backward if ARG is negative). | |
284 Normally returns t. | |
285 If an edge of the buffer is reached, point is left there | |
286 and nil is returned." | |
287 (interactive "p") | |
288 (setq mark-active nil) | |
289 (forward-word arg)) | |
290 | |
15907
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
291 (defun forward-line-nomark (&optional arg) |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
292 "Deactivate mark; move cursor vertically down ARG lines." |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
293 (interactive "p") |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
294 (setq mark-active nil) |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
295 (forward-line arg) |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
296 (setq this-command 'forward-line) |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
297 ) |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
298 |
18216
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
299 (defun forward-sexp-nomark (&optional arg) |
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
300 "Deactivate mark; move forward across one balanced expression (sexp). |
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
301 With argument, do it that many times. Negative arg -N means |
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
302 move backward across N balanced expressions." |
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
303 (interactive "p") |
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
304 (setq mark-active nil) |
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
305 (forward-sexp arg)) |
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
306 |
13233 | 307 (defun forward-paragraph-nomark (&optional arg) |
308 "Deactivate mark; move forward to end of paragraph. | |
15907
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
309 With arg N, do it N times; negative arg -N means move backward N paragraphs. |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
310 |
13233 | 311 A line which `paragraph-start' matches either separates paragraphs |
14382 | 312 \(if `paragraph-separate' matches it also) or is the first line of a paragraph. |
13233 | 313 A paragraph end is the beginning of a line which is not part of the paragraph |
314 to which the end of the previous line belongs, or the end of the buffer." | |
315 (interactive "p") | |
316 (setq mark-active nil) | |
317 (forward-paragraph arg)) | |
318 | |
319 (defun next-line-nomark (&optional arg) | |
320 "Deactivate mark; move cursor vertically down ARG lines. | |
321 If there is no character in the target line exactly under the current column, | |
322 the cursor is positioned after the character in that line which spans this | |
323 column, or at the end of the line if it is not long enough. | |
324 If there is no line in the buffer after this one, behavior depends on the | |
325 value of `next-line-add-newlines'. If non-nil, it inserts a newline character | |
326 to create a line, and moves the cursor to that line. Otherwise it moves the | |
327 cursor to the end of the buffer (if already at the end of the buffer, an error | |
15907
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
328 is signaled). |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
329 |
13233 | 330 The command C-x C-n can be used to create |
331 a semipermanent goal column to which this command always moves. | |
332 Then it does not try to move vertically. This goal column is stored | |
333 in `goal-column', which is nil when there is none." | |
334 (interactive "p") | |
335 (setq mark-active nil) | |
14382 | 336 (next-line arg) |
337 (setq this-command 'next-line)) | |
13233 | 338 |
339 (defun end-of-line-nomark (&optional arg) | |
340 "Deactivate mark; move point to end of current line. | |
341 With argument ARG not nil or 1, move forward ARG - 1 lines first. | |
342 If scan reaches end of buffer, stop there without error." | |
343 (interactive "p") | |
344 (setq mark-active nil) | |
14382 | 345 (end-of-line arg) |
346 (setq this-command 'end-of-line)) | |
13233 | 347 |
15907
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
348 (defun backward-line-nomark (&optional arg) |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
349 "Deactivate mark; move cursor vertically up ARG lines." |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
350 (interactive "p") |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
351 (setq mark-active nil) |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
352 (if (null arg) |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
353 (setq arg 1)) |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
354 (forward-line (- arg)) |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
355 (setq this-command 'forward-line) |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
356 ) |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
357 |
13233 | 358 (defun scroll-down-nomark (&optional arg) |
359 "Deactivate mark; scroll down ARG lines; or near full screen if no ARG. | |
360 A near full screen is `next-screen-context-lines' less than a full screen. | |
361 Negative ARG means scroll upward. | |
362 When calling from a program, supply a number as argument or nil." | |
363 (interactive "P") | |
364 (setq mark-active nil) | |
15931
c729af982039
(ensure-mark): Minor rewrite.
Richard M. Stallman <rms@gnu.org>
parents:
15907
diff
changeset
|
365 (cond (pc-select-override-scroll-error |
c729af982039
(ensure-mark): Minor rewrite.
Richard M. Stallman <rms@gnu.org>
parents:
15907
diff
changeset
|
366 (condition-case nil (scroll-down arg) |
c729af982039
(ensure-mark): Minor rewrite.
Richard M. Stallman <rms@gnu.org>
parents:
15907
diff
changeset
|
367 (beginning-of-buffer (goto-char (point-min))))) |
c729af982039
(ensure-mark): Minor rewrite.
Richard M. Stallman <rms@gnu.org>
parents:
15907
diff
changeset
|
368 (t (scroll-down arg)))) |
13233 | 369 |
370 (defun end-of-buffer-nomark (&optional arg) | |
371 "Deactivate mark; move point to the end of the buffer. | |
15907
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
372 With arg N, put point N/10 of the way from the end. |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
373 |
13233 | 374 If the buffer is narrowed, this command uses the beginning and size |
15907
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
375 of the accessible part of the buffer. |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
376 |
13233 | 377 Don't use this command in Lisp programs! |
14382 | 378 \(goto-char (point-max)) is faster and avoids clobbering the mark." |
13233 | 379 (interactive "P") |
380 (setq mark-active nil) | |
381 (let ((size (- (point-max) (point-min)))) | |
382 (goto-char (if arg | |
383 (- (point-max) | |
384 (if (> size 10000) | |
385 ;; Avoid overflow for large buffer sizes! | |
386 (* (prefix-numeric-value arg) | |
387 (/ size 10)) | |
388 (/ (* size (prefix-numeric-value arg)) 10))) | |
389 (point-max)))) | |
390 ;; If we went to a place in the middle of the buffer, | |
391 ;; adjust it to the beginning of a line. | |
392 (if arg (forward-line 1) | |
393 ;; If the end of the buffer is not already on the screen, | |
394 ;; then scroll specially to put it near, but not at, the bottom. | |
395 (if (let ((old-point (point))) | |
396 (save-excursion | |
397 (goto-char (window-start)) | |
398 (vertical-motion (window-height)) | |
399 (< (point) old-point))) | |
400 (progn | |
401 (overlay-recenter (point)) | |
402 (recenter -3))))) | |
403 | |
404 | |
405 ;;;;;;;;;;;;;;;;;;;; | |
406 ;;;;;; backwards and mark | |
407 ;;;;;;;;;;;;;;;;;;;; | |
408 | |
409 (defun backward-char-mark (&optional arg) | |
410 "Ensure mark is active; move point left ARG characters (right if ARG negative). | |
411 On attempt to pass beginning or end of buffer, stop and signal error." | |
412 (interactive "p") | |
413 (ensure-mark) | |
414 (backward-char arg)) | |
415 | |
416 (defun backward-word-mark (&optional arg) | |
417 "Ensure mark is active; move backward until encountering the end of a word. | |
418 With argument, do this that many times." | |
419 (interactive "p") | |
420 (ensure-mark) | |
421 (backward-word arg)) | |
422 | |
18216
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
423 (defun backward-sexp-mark (&optional arg) |
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
424 "Ensure mark is active; move backward across one balanced expression (sexp). |
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
425 With argument, do it that many times. Negative arg -N means |
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
426 move forward across N balanced expressions." |
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
427 (interactive "p") |
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
428 (ensure-mark) |
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
429 (backward-sexp arg)) |
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
430 |
13233 | 431 (defun backward-paragraph-mark (&optional arg) |
432 "Ensure mark is active; move backward to start of paragraph. | |
15907
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
433 With arg N, do it N times; negative arg -N means move forward N paragraphs. |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
434 |
13233 | 435 A paragraph start is the beginning of a line which is a |
436 `first-line-of-paragraph' or which is ordinary text and follows a | |
437 paragraph-separating line; except: if the first real line of a | |
438 paragraph is preceded by a blank line, the paragraph starts at that | |
15907
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
439 blank line. |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
440 |
13233 | 441 See `forward-paragraph' for more information." |
442 (interactive "p") | |
443 (ensure-mark) | |
444 (backward-paragraph arg)) | |
445 | |
446 (defun previous-line-mark (&optional arg) | |
447 "Ensure mark is active; move cursor vertically up ARG lines. | |
448 If there is no character in the target line exactly over the current column, | |
449 the cursor is positioned after the character in that line which spans this | |
15907
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
450 column, or at the end of the line if it is not long enough. |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
451 |
13233 | 452 The command C-x C-n can be used to create |
453 a semipermanent goal column to which this command always moves. | |
15907
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
454 Then it does not try to move vertically. |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
455 |
13233 | 456 If you are thinking of using this in a Lisp program, consider using |
457 `forward-line' with a negative argument instead. It is usually easier | |
458 to use and more reliable (no dependence on goal column, etc.)." | |
459 (interactive "p") | |
460 (ensure-mark) | |
14382 | 461 (previous-line arg) |
462 (setq this-command 'previous-line)) | |
13233 | 463 |
464 (defun beginning-of-line-mark (&optional arg) | |
465 "Ensure mark is active; move point to beginning of current line. | |
466 With argument ARG not nil or 1, move forward ARG - 1 lines first. | |
467 If scan reaches end of buffer, stop there without error." | |
468 (interactive "p") | |
469 (ensure-mark) | |
470 (beginning-of-line arg)) | |
471 | |
472 | |
473 (defun scroll-up-mark (&optional arg) | |
474 "Ensure mark is active; scroll upward ARG lines; or near full screen if no ARG. | |
475 A near full screen is `next-screen-context-lines' less than a full screen. | |
476 Negative ARG means scroll downward. | |
477 When calling from a program, supply a number as argument or nil." | |
478 (interactive "P") | |
479 (ensure-mark) | |
15931
c729af982039
(ensure-mark): Minor rewrite.
Richard M. Stallman <rms@gnu.org>
parents:
15907
diff
changeset
|
480 (cond (pc-select-override-scroll-error |
c729af982039
(ensure-mark): Minor rewrite.
Richard M. Stallman <rms@gnu.org>
parents:
15907
diff
changeset
|
481 (condition-case nil (scroll-up arg) |
c729af982039
(ensure-mark): Minor rewrite.
Richard M. Stallman <rms@gnu.org>
parents:
15907
diff
changeset
|
482 (end-of-buffer (goto-char (point-max))))) |
c729af982039
(ensure-mark): Minor rewrite.
Richard M. Stallman <rms@gnu.org>
parents:
15907
diff
changeset
|
483 (t (scroll-up arg)))) |
13233 | 484 |
485 (defun beginning-of-buffer-mark (&optional arg) | |
486 "Ensure mark is active; move point to the beginning of the buffer. | |
15907
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
487 With arg N, put point N/10 of the way from the beginning. |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
488 |
13233 | 489 If the buffer is narrowed, this command uses the beginning and size |
15907
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
490 of the accessible part of the buffer. |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
491 |
13233 | 492 Don't use this command in Lisp programs! |
493 \(goto-char (p\oint-min)) is faster and avoids clobbering the mark." | |
494 (interactive "P") | |
495 (ensure-mark) | |
496 (let ((size (- (point-max) (point-min)))) | |
497 (goto-char (if arg | |
498 (+ (point-min) | |
499 (if (> size 10000) | |
500 ;; Avoid overflow for large buffer sizes! | |
501 (* (prefix-numeric-value arg) | |
502 (/ size 10)) | |
503 (/ (+ 10 (* size (prefix-numeric-value arg))) 10))) | |
504 (point-min)))) | |
505 (if arg (forward-line 1))) | |
506 | |
507 ;;;;;;;; | |
508 ;;; no mark | |
509 ;;;;;;;; | |
510 | |
511 (defun backward-char-nomark (&optional arg) | |
512 "Deactivate mark; move point left ARG characters (right if ARG negative). | |
513 On attempt to pass beginning or end of buffer, stop and signal error." | |
514 (interactive "p") | |
515 (setq mark-active nil) | |
516 (backward-char arg)) | |
517 | |
518 (defun backward-word-nomark (&optional arg) | |
519 "Deactivate mark; move backward until encountering the end of a word. | |
520 With argument, do this that many times." | |
521 (interactive "p") | |
522 (setq mark-active nil) | |
523 (backward-word arg)) | |
524 | |
18216
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
525 (defun backward-sexp-nomark (&optional arg) |
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
526 "Deactivate mark; move backward across one balanced expression (sexp). |
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
527 With argument, do it that many times. Negative arg -N means |
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
528 move forward across N balanced expressions." |
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
529 (interactive "p") |
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
530 (setq mark-active nil) |
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
531 (backward-sexp arg)) |
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
532 |
13233 | 533 (defun backward-paragraph-nomark (&optional arg) |
534 "Deactivate mark; move backward to start of paragraph. | |
15907
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
535 With arg N, do it N times; negative arg -N means move forward N paragraphs. |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
536 |
13233 | 537 A paragraph start is the beginning of a line which is a |
538 `first-line-of-paragraph' or which is ordinary text and follows a | |
539 paragraph-separating line; except: if the first real line of a | |
540 paragraph is preceded by a blank line, the paragraph starts at that | |
15907
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
541 blank line. |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
542 |
13233 | 543 See `forward-paragraph' for more information." |
544 (interactive "p") | |
545 (setq mark-active nil) | |
546 (backward-paragraph arg)) | |
547 | |
548 (defun previous-line-nomark (&optional arg) | |
549 "Deactivate mark; move cursor vertically up ARG lines. | |
550 If there is no character in the target line exactly over the current column, | |
551 the cursor is positioned after the character in that line which spans this | |
15907
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
552 column, or at the end of the line if it is not long enough. |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
553 |
13233 | 554 The command C-x C-n can be used to create |
555 a semipermanent goal column to which this command always moves. | |
556 Then it does not try to move vertically." | |
557 (interactive "p") | |
558 (setq mark-active nil) | |
14382 | 559 (previous-line arg) |
560 (setq this-command 'previous-line)) | |
13233 | 561 |
562 (defun beginning-of-line-nomark (&optional arg) | |
563 "Deactivate mark; move point to beginning of current line. | |
564 With argument ARG not nil or 1, move forward ARG - 1 lines first. | |
565 If scan reaches end of buffer, stop there without error." | |
566 (interactive "p") | |
567 (setq mark-active nil) | |
568 (beginning-of-line arg)) | |
569 | |
570 (defun scroll-up-nomark (&optional arg) | |
571 "Deactivate mark; scroll upward ARG lines; or near full screen if no ARG. | |
572 A near full screen is `next-screen-context-lines' less than a full screen. | |
573 Negative ARG means scroll downward. | |
574 When calling from a program, supply a number as argument or nil." | |
575 (interactive "P") | |
576 (setq mark-active nil) | |
15931
c729af982039
(ensure-mark): Minor rewrite.
Richard M. Stallman <rms@gnu.org>
parents:
15907
diff
changeset
|
577 (cond (pc-select-override-scroll-error |
c729af982039
(ensure-mark): Minor rewrite.
Richard M. Stallman <rms@gnu.org>
parents:
15907
diff
changeset
|
578 (condition-case nil (scroll-up arg) |
c729af982039
(ensure-mark): Minor rewrite.
Richard M. Stallman <rms@gnu.org>
parents:
15907
diff
changeset
|
579 (end-of-buffer (goto-char (point-max))))) |
c729af982039
(ensure-mark): Minor rewrite.
Richard M. Stallman <rms@gnu.org>
parents:
15907
diff
changeset
|
580 (t (scroll-up arg)))) |
13233 | 581 |
582 (defun beginning-of-buffer-nomark (&optional arg) | |
583 "Deactivate mark; move point to the beginning of the buffer. | |
15907
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
584 With arg N, put point N/10 of the way from the beginning. |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
585 |
13233 | 586 If the buffer is narrowed, this command uses the beginning and size |
15907
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
587 of the accessible part of the buffer. |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
588 |
13233 | 589 Don't use this command in Lisp programs! |
14382 | 590 \(goto-char (point-min)) is faster and avoids clobbering the mark." |
13233 | 591 (interactive "P") |
592 (setq mark-active nil) | |
593 (let ((size (- (point-max) (point-min)))) | |
594 (goto-char (if arg | |
595 (+ (point-min) | |
596 (if (> size 10000) | |
597 ;; Avoid overflow for large buffer sizes! | |
598 (* (prefix-numeric-value arg) | |
599 (/ size 10)) | |
600 (/ (+ 10 (* size (prefix-numeric-value arg))) 10))) | |
601 (point-min)))) | |
602 (if arg (forward-line 1))) | |
603 | |
13234
e3b1df16f4b4
(pc-selection-mode): Add autoload cookie.
Richard M. Stallman <rms@gnu.org>
parents:
13233
diff
changeset
|
604 ;;;###autoload |
13233 | 605 (defun pc-selection-mode () |
15907
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
606 "Change mark behaviour to emulate Motif, MAC or MS-Windows cut and paste style. |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
607 |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
608 This mode enables Delete Selection mode and Transient Mark mode. |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
609 |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
610 The arrow keys (and others) are bound to new functions |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
611 which modify the status of the mark. |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
612 |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
613 The ordinary arrow keys disable the mark. |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
614 The shift-arrow keys move, leaving the mark behind. |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
615 |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
616 C-LEFT and C-RIGHT move back or forward one word, disabling the mark. |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
617 S-C-LEFT and S-C-RIGHT move back or forward one word, leaving the mark behind. |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
618 |
18216
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
619 M-LEFT and M-RIGHT move back or forward one word or sexp, disabling the mark. |
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
620 S-M-LEFT and S-M-RIGHT move back or forward one word or sexp, leaving the mark |
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
621 behind. To control wether these keys move word-wise or sexp-wise set the |
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
622 variable pc-select-meta-moves-sexps after loading pc-select.el but before |
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
623 turning pc-selection-mode on. |
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
624 |
15907
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
625 C-DOWN and C-UP move back or forward a paragraph, disabling the mark. |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
626 S-C-DOWN and S-C-UP move back or forward a paragraph, leaving the mark behind. |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
627 |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
628 HOME moves to beginning of line, disabling the mark. |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
629 S-HOME moves to beginning of line, leaving the mark behind. |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
630 With Ctrl or Meta, these keys move to beginning of buffer instead. |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
631 |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
632 END moves to end of line, disabling the mark. |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
633 S-END moves to end of line, leaving the mark behind. |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
634 With Ctrl or Meta, these keys move to end of buffer instead. |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
635 |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
636 PRIOR or PAGE-UP scrolls and disables the mark. |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
637 S-PRIOR or S-PAGE-UP scrolls and leaves the mark behind. |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
638 |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
639 S-DELETE kills the region (`kill-region'). |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
640 S-INSERT yanks text from the kill ring (`yank'). |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
641 C-INSERT copies the region into the kill ring (`copy-region-as-kill'). |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
642 |
18216
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
643 In addition, certain other PC bindings are imitated (to avoid this, set |
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
644 the variable pc-select-selection-keys-only to t after loading pc-select.el |
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
645 but before calling pc-selection-mode): |
15907
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
646 |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
647 F6 other-window |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
648 DELETE delete-char |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
649 C-DELETE kill-line |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
650 M-DELETE kill-word |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
651 C-M-DELETE kill-sexp |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
652 C-BACKSPACE backward-kill-word |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
653 M-BACKSPACE undo" |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
654 |
13233 | 655 (interactive) |
656 ;; | |
657 ;; keybindings | |
658 ;; | |
659 | |
660 ;; This is to avoid confusion with the delete-selection-mode | |
661 ;; On simple displays you can't see that a region is active and | |
18216
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
662 ;; will be deleted on the next keypress. IMHO especially for |
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
663 ;; copy-region-as-kill this is confusing. |
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
664 ;; The same goes for exchange-point-and-mark |
13233 | 665 (define-key global-map "\M-w" 'copy-region-as-kill-nomark) |
18216
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
666 (define-key global-map "\C-x\C-x" 'exchange-point-and-mark-nomark) |
14040 | 667 ;; The following keybindings are for standard ISO keyboards |
13233 | 668 ;; as they are used with IBM compatible PCs, IBM RS/6000, |
669 ;; MACs, many X-Stations and probably more | |
670 (define-key global-map [S-right] 'forward-char-mark) | |
671 (define-key global-map [right] 'forward-char-nomark) | |
672 (define-key global-map [C-S-right] 'forward-word-mark) | |
673 (define-key global-map [C-right] 'forward-word-nomark) | |
18216
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
674 (define-key global-map [S-left] 'backward-char-mark) |
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
675 (define-key global-map [left] 'backward-char-nomark) |
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
676 (define-key global-map [C-S-left] 'backward-word-mark) |
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
677 (define-key global-map [C-left] 'backward-word-nomark) |
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
678 (cond (pc-select-meta-moves-sexps |
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
679 (define-key global-map [M-S-right] 'forward-sexp-mark) |
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
680 (define-key global-map [M-right] 'forward-sexp-nomark) |
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
681 (define-key global-map [M-S-left] 'backward-sexp-mark) |
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
682 (define-key global-map [M-left] 'backward-sexp-nomark)) |
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
683 (t |
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
684 (define-key global-map [M-S-right] 'forward-word-mark) |
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
685 (define-key global-map [M-right] 'forward-word-nomark) |
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
686 (define-key global-map [M-S-left] 'backward-word-mark) |
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
687 (define-key global-map [M-left] 'backward-word-nomark))) |
13233 | 688 |
689 (define-key global-map [S-down] 'next-line-mark) | |
690 (define-key global-map [down] 'next-line-nomark) | |
691 | |
692 (define-key global-map [S-end] 'end-of-line-mark) | |
693 (define-key global-map [end] 'end-of-line-nomark) | |
694 (global-set-key [S-C-end] 'end-of-buffer-mark) | |
695 (global-set-key [C-end] 'end-of-buffer-nomark) | |
14382 | 696 (global-set-key [S-M-end] 'end-of-buffer-mark) |
697 (global-set-key [M-end] 'end-of-buffer-nomark) | |
13233 | 698 |
699 (define-key global-map [S-next] 'scroll-up-mark) | |
700 (define-key global-map [next] 'scroll-up-nomark) | |
701 | |
702 (define-key global-map [S-up] 'previous-line-mark) | |
703 (define-key global-map [up] 'previous-line-nomark) | |
704 | |
705 (define-key global-map [S-home] 'beginning-of-line-mark) | |
706 (define-key global-map [home] 'beginning-of-line-nomark) | |
707 (global-set-key [S-C-home] 'beginning-of-buffer-mark) | |
708 (global-set-key [C-home] 'beginning-of-buffer-nomark) | |
14382 | 709 (global-set-key [S-M-home] 'beginning-of-buffer-mark) |
710 (global-set-key [M-home] 'beginning-of-buffer-nomark) | |
13233 | 711 |
15907
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
712 (define-key global-map [M-S-down] 'forward-line-mark) |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
713 (define-key global-map [M-down] 'forward-line-nomark) |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
714 (define-key global-map [M-S-up] 'backward-line-mark) |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
715 (define-key global-map [M-up] 'backward-line-nomark) |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
716 |
18216
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
717 (define-key global-map [S-prior] 'scroll-down-mark) |
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
718 (define-key global-map [prior] 'scroll-down-nomark) |
13233 | 719 |
18216
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
720 ;; Next four lines are from Pete Forman. |
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
721 (global-set-key [C-down] 'forward-paragraph-nomark) ; KNextPara cDn |
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
722 (global-set-key [C-up] 'backward-paragraph-nomark) ; KPrevPara cUp |
13233 | 723 (global-set-key [S-C-down] 'forward-paragraph-mark) |
724 (global-set-key [S-C-up] 'backward-paragraph-mark) | |
725 | |
18216
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
726 (or pc-select-selection-keys-only |
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
727 (progn |
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
728 (define-key global-map [S-insert] 'yank) |
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
729 (define-key global-map [C-insert] 'copy-region-as-kill) |
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
730 (define-key global-map [S-delete] 'kill-region) |
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
731 |
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
732 ;; The following bindings are useful on Sun Type 3 keyboards |
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
733 ;; They implement the Get-Delete-Put (copy-cut-paste) |
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
734 ;; functions from sunview on the L6, L8 and L10 keys |
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
735 ;; Sam Steingold <sds@ptc.com> says that f16 is copy and f18 is paste. |
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
736 (define-key global-map [f16] 'copy-region-as-kill) |
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
737 (define-key global-map [f18] 'yank) |
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
738 (define-key global-map [f20] 'kill-region) |
13233 | 739 |
18216
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
740 ;; The following bindings are from Pete Forman. |
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
741 (global-set-key [f6] 'other-window) ; KNextPane F6 |
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
742 (global-set-key [delete] 'delete-char) ; KDelete Del |
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
743 (global-set-key [C-delete] 'kill-line) ; KEraseEndLine cDel |
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
744 (global-set-key [M-backspace] 'undo) ; KUndo aBS |
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
745 |
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
746 ;; The following bindings are taken from pc-mode.el |
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
747 ;; as suggested by RMS. |
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
748 ;; I only used the ones that are not covered above. |
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
749 (define-key function-key-map [M-delete] [?\M-d]) |
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
750 (global-set-key [C-M-delete] 'kill-sexp) |
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
751 (global-set-key [C-backspace] 'backward-kill-word) |
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
752 ;; Next line proposed by Eli Barzilay |
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
753 (global-set-key [C-escape] 'electric-buffer-list))) |
13233 | 754 ;; |
755 ;; setup | |
756 ;; | |
18216
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
757 ;; Next line proposed by Eli Barzilay |
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
758 (setq highlight-nonselected-windows nil) |
13233 | 759 (setq transient-mark-mode t) |
760 (setq mark-even-if-inactive t) | |
15907
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
761 (delete-selection-mode 1) |
15931
c729af982039
(ensure-mark): Minor rewrite.
Richard M. Stallman <rms@gnu.org>
parents:
15907
diff
changeset
|
762 ) |
19289 | 763 |
764 ;;;###autoload | |
765 (defcustom pc-selection-mode nil | |
766 "Toggle PC Selection mode. | |
767 Change mark behaviour to emulate Motif, MAC or MS-Windows cut and paste style, | |
768 and cursor movement commands. | |
769 This mode enables Delete Selection mode and Transient Mark mode. | |
770 You must modify via \\[customize] for this variable to have an effect." | |
771 :set (lambda (symbol value) | |
772 (if value (pc-selection-mode))) | |
773 :type 'boolean | |
774 :group 'pc-select | |
775 :require 'pc-select) | |
776 | |
13233 | 777 ;;; pc-select.el ends here |