Mercurial > emacs
annotate lisp/emulation/pc-select.el @ 18262:e5e99de79a88
Fix up whitespace.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Sun, 15 Jun 1997 19:05:59 +0000 |
parents | 75f7eec6d388 |
children | 4e824f1fe62d |
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. | |
15907
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
58 ;; Dan Nicolaescu <done@nexus.sorostm.ro> suggested suppressing the |
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: |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
80 |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
81 (defvar pc-select-override-scroll-error t |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
82 "*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
|
83 This variable applies in PC Selection mode only. |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
84 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
|
85 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
|
86 text with these commands. If you set this variable to non-nil, these |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
87 errors are suppressed.") |
13233 | 88 |
18216
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
89 (defvar pc-select-selection-keys-only nil |
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
90 "*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
|
91 Other keys that emulate pc-behavior will be untouched. |
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
92 This gives mostly Emacs-like behaviour with only the selection keys enabled.") |
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
93 |
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
94 (defvar pc-select-meta-moves-sexps nil |
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
95 "*Non-nil means move sexp-wise with Meta key, otherwise move word-wise.") |
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
96 |
13233 | 97 ;;;; |
98 ;; misc | |
99 ;;;; | |
100 | |
101 (provide 'pc-select) | |
102 | |
103 (defun copy-region-as-kill-nomark (beg end) | |
104 "Save the region as if killed; but don't kill it; deactivate mark. | |
105 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
|
106 system cut and paste. |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
107 |
13233 | 108 Deactivating mark is to avoid confusion with delete-selection-mode |
109 and transient-mark-mode." | |
110 (interactive "r") | |
111 (copy-region-as-kill beg end) | |
112 (setq mark-active nil) | |
113 (message "Region saved")) | |
114 | |
18216
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
115 (defun exchange-point-and-mark-nomark () |
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
116 (interactive) |
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
117 (exchange-point-and-mark) |
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
118 (setq mark-active nil)) |
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
119 |
13233 | 120 ;;;; |
121 ;; non-interactive | |
122 ;;;; | |
123 (defun ensure-mark() | |
124 ;; make sure mark is active | |
125 ;; 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
|
126 (or mark-active (set-mark-command nil))) |
13233 | 127 |
128 ;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
129 ;;;;; forward and mark | |
130 ;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
131 | |
132 (defun forward-char-mark (&optional arg) | |
133 "Ensure mark is active; move point right ARG characters (left if ARG negative). | |
134 On reaching end of buffer, stop and signal error." | |
135 (interactive "p") | |
136 (ensure-mark) | |
137 (forward-char arg)) | |
138 | |
139 (defun forward-word-mark (&optional arg) | |
140 "Ensure mark is active; move point right ARG words (backward if ARG is negative). | |
141 Normally returns t. | |
142 If an edge of the buffer is reached, point is left there | |
143 and nil is returned." | |
144 (interactive "p") | |
145 (ensure-mark) | |
146 (forward-word arg)) | |
147 | |
15907
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
148 (defun forward-line-mark (&optional arg) |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
149 "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
|
150 (interactive "p") |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
151 (ensure-mark) |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
152 (forward-line arg) |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
153 (setq this-command 'forward-line) |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
154 ) |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
155 |
18216
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
156 (defun forward-sexp-mark (&optional arg) |
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
157 "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
|
158 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
|
159 move backward across N balanced expressions." |
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
160 (interactive "p") |
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
161 (ensure-mark) |
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
162 (forward-sexp arg)) |
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
163 |
13233 | 164 (defun forward-paragraph-mark (&optional arg) |
165 "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
|
166 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
|
167 |
13233 | 168 A line which `paragraph-start' matches either separates paragraphs |
14382 | 169 \(if `paragraph-separate' matches it also) or is the first line of a paragraph. |
13233 | 170 A paragraph end is the beginning of a line which is not part of the paragraph |
171 to which the end of the previous line belongs, or the end of the buffer." | |
172 (interactive "p") | |
173 (ensure-mark) | |
174 (forward-paragraph arg)) | |
15907
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
175 |
13233 | 176 (defun next-line-mark (&optional arg) |
177 "Ensure mark is active; move cursor vertically down ARG lines. | |
178 If there is no character in the target line exactly under the current column, | |
179 the cursor is positioned after the character in that line which spans this | |
180 column, or at the end of the line if it is not long enough. | |
181 If there is no line in the buffer after this one, behavior depends on the | |
182 value of `next-line-add-newlines'. If non-nil, it inserts a newline character | |
183 to create a line, and moves the cursor to that line. Otherwise it moves the | |
184 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
|
185 is signaled). |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
186 |
13233 | 187 The command C-x C-n can be used to create |
188 a semipermanent goal column to which this command always moves. | |
189 Then it does not try to move vertically. This goal column is stored | |
190 in `goal-column', which is nil when there is none." | |
191 (interactive "p") | |
192 (ensure-mark) | |
14382 | 193 (next-line arg) |
194 (setq this-command 'next-line)) | |
13233 | 195 |
196 (defun end-of-line-mark (&optional arg) | |
197 "Ensure mark is active; move point to end of current line. | |
198 With argument ARG not nil or 1, move forward ARG - 1 lines first. | |
199 If scan reaches end of buffer, stop there without error." | |
200 (interactive "p") | |
201 (ensure-mark) | |
14382 | 202 (end-of-line arg) |
203 (setq this-command 'end-of-line)) | |
13233 | 204 |
15907
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
205 (defun backward-line-mark (&optional arg) |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
206 "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
|
207 (interactive "p") |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
208 (ensure-mark) |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
209 (if (null arg) |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
210 (setq arg 1)) |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
211 (forward-line (- arg)) |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
212 (setq this-command 'forward-line) |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
213 ) |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
214 |
13233 | 215 (defun scroll-down-mark (&optional arg) |
216 "Ensure mark is active; scroll down ARG lines; or near full screen if no ARG. | |
217 A near full screen is `next-screen-context-lines' less than a full screen. | |
218 Negative ARG means scroll upward. | |
219 When calling from a program, supply a number as argument or nil." | |
220 (interactive "P") | |
221 (ensure-mark) | |
15931
c729af982039
(ensure-mark): Minor rewrite.
Richard M. Stallman <rms@gnu.org>
parents:
15907
diff
changeset
|
222 (cond (pc-select-override-scroll-error |
c729af982039
(ensure-mark): Minor rewrite.
Richard M. Stallman <rms@gnu.org>
parents:
15907
diff
changeset
|
223 (condition-case nil (scroll-down arg) |
c729af982039
(ensure-mark): Minor rewrite.
Richard M. Stallman <rms@gnu.org>
parents:
15907
diff
changeset
|
224 (beginning-of-buffer (goto-char (point-min))))) |
c729af982039
(ensure-mark): Minor rewrite.
Richard M. Stallman <rms@gnu.org>
parents:
15907
diff
changeset
|
225 (t (scroll-down arg)))) |
13233 | 226 |
227 (defun end-of-buffer-mark (&optional arg) | |
228 "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
|
229 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
|
230 |
13233 | 231 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
|
232 of the accessible part of the buffer. |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
233 |
13233 | 234 Don't use this command in Lisp programs! |
235 \(goto-char \(point-max)) is faster and avoids clobbering the mark." | |
236 (interactive "P") | |
237 (ensure-mark) | |
238 (let ((size (- (point-max) (point-min)))) | |
239 (goto-char (if arg | |
240 (- (point-max) | |
241 (if (> size 10000) | |
242 ;; Avoid overflow for large buffer sizes! | |
243 (* (prefix-numeric-value arg) | |
244 (/ size 10)) | |
245 (/ (* size (prefix-numeric-value arg)) 10))) | |
246 (point-max)))) | |
247 ;; If we went to a place in the middle of the buffer, | |
248 ;; adjust it to the beginning of a line. | |
249 (if arg (forward-line 1) | |
250 ;; If the end of the buffer is not already on the screen, | |
251 ;; then scroll specially to put it near, but not at, the bottom. | |
252 (if (let ((old-point (point))) | |
253 (save-excursion | |
254 (goto-char (window-start)) | |
255 (vertical-motion (window-height)) | |
256 (< (point) old-point))) | |
257 (progn | |
258 (overlay-recenter (point)) | |
259 (recenter -3))))) | |
260 | |
261 ;;;;;;;;; | |
262 ;;;;; no mark | |
263 ;;;;;;;;; | |
264 | |
265 (defun forward-char-nomark (&optional arg) | |
266 "Deactivate mark; move point right ARG characters \(left if ARG negative). | |
267 On reaching end of buffer, stop and signal error." | |
268 (interactive "p") | |
269 (setq mark-active nil) | |
270 (forward-char arg)) | |
271 | |
272 (defun forward-word-nomark (&optional arg) | |
273 "Deactivate mark; move point right ARG words \(backward if ARG is negative). | |
274 Normally returns t. | |
275 If an edge of the buffer is reached, point is left there | |
276 and nil is returned." | |
277 (interactive "p") | |
278 (setq mark-active nil) | |
279 (forward-word arg)) | |
280 | |
15907
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
281 (defun forward-line-nomark (&optional arg) |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
282 "Deactivate mark; move cursor vertically down ARG lines." |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
283 (interactive "p") |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
284 (setq mark-active nil) |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
285 (forward-line arg) |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
286 (setq this-command 'forward-line) |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
287 ) |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
288 |
18216
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
289 (defun forward-sexp-nomark (&optional arg) |
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
290 "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
|
291 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
|
292 move backward across N balanced expressions." |
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
293 (interactive "p") |
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
294 (setq mark-active nil) |
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
295 (forward-sexp arg)) |
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
296 |
13233 | 297 (defun forward-paragraph-nomark (&optional arg) |
298 "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
|
299 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
|
300 |
13233 | 301 A line which `paragraph-start' matches either separates paragraphs |
14382 | 302 \(if `paragraph-separate' matches it also) or is the first line of a paragraph. |
13233 | 303 A paragraph end is the beginning of a line which is not part of the paragraph |
304 to which the end of the previous line belongs, or the end of the buffer." | |
305 (interactive "p") | |
306 (setq mark-active nil) | |
307 (forward-paragraph arg)) | |
308 | |
309 (defun next-line-nomark (&optional arg) | |
310 "Deactivate mark; move cursor vertically down ARG lines. | |
311 If there is no character in the target line exactly under the current column, | |
312 the cursor is positioned after the character in that line which spans this | |
313 column, or at the end of the line if it is not long enough. | |
314 If there is no line in the buffer after this one, behavior depends on the | |
315 value of `next-line-add-newlines'. If non-nil, it inserts a newline character | |
316 to create a line, and moves the cursor to that line. Otherwise it moves the | |
317 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
|
318 is signaled). |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
319 |
13233 | 320 The command C-x C-n can be used to create |
321 a semipermanent goal column to which this command always moves. | |
322 Then it does not try to move vertically. This goal column is stored | |
323 in `goal-column', which is nil when there is none." | |
324 (interactive "p") | |
325 (setq mark-active nil) | |
14382 | 326 (next-line arg) |
327 (setq this-command 'next-line)) | |
13233 | 328 |
329 (defun end-of-line-nomark (&optional arg) | |
330 "Deactivate mark; move point to end of current line. | |
331 With argument ARG not nil or 1, move forward ARG - 1 lines first. | |
332 If scan reaches end of buffer, stop there without error." | |
333 (interactive "p") | |
334 (setq mark-active nil) | |
14382 | 335 (end-of-line arg) |
336 (setq this-command 'end-of-line)) | |
13233 | 337 |
15907
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
338 (defun backward-line-nomark (&optional arg) |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
339 "Deactivate mark; move cursor vertically up ARG lines." |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
340 (interactive "p") |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
341 (setq mark-active nil) |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
342 (if (null arg) |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
343 (setq arg 1)) |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
344 (forward-line (- arg)) |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
345 (setq this-command 'forward-line) |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
346 ) |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
347 |
13233 | 348 (defun scroll-down-nomark (&optional arg) |
349 "Deactivate mark; scroll down ARG lines; or near full screen if no ARG. | |
350 A near full screen is `next-screen-context-lines' less than a full screen. | |
351 Negative ARG means scroll upward. | |
352 When calling from a program, supply a number as argument or nil." | |
353 (interactive "P") | |
354 (setq mark-active nil) | |
15931
c729af982039
(ensure-mark): Minor rewrite.
Richard M. Stallman <rms@gnu.org>
parents:
15907
diff
changeset
|
355 (cond (pc-select-override-scroll-error |
c729af982039
(ensure-mark): Minor rewrite.
Richard M. Stallman <rms@gnu.org>
parents:
15907
diff
changeset
|
356 (condition-case nil (scroll-down arg) |
c729af982039
(ensure-mark): Minor rewrite.
Richard M. Stallman <rms@gnu.org>
parents:
15907
diff
changeset
|
357 (beginning-of-buffer (goto-char (point-min))))) |
c729af982039
(ensure-mark): Minor rewrite.
Richard M. Stallman <rms@gnu.org>
parents:
15907
diff
changeset
|
358 (t (scroll-down arg)))) |
13233 | 359 |
360 (defun end-of-buffer-nomark (&optional arg) | |
361 "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
|
362 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
|
363 |
13233 | 364 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
|
365 of the accessible part of the buffer. |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
366 |
13233 | 367 Don't use this command in Lisp programs! |
14382 | 368 \(goto-char (point-max)) is faster and avoids clobbering the mark." |
13233 | 369 (interactive "P") |
370 (setq mark-active nil) | |
371 (let ((size (- (point-max) (point-min)))) | |
372 (goto-char (if arg | |
373 (- (point-max) | |
374 (if (> size 10000) | |
375 ;; Avoid overflow for large buffer sizes! | |
376 (* (prefix-numeric-value arg) | |
377 (/ size 10)) | |
378 (/ (* size (prefix-numeric-value arg)) 10))) | |
379 (point-max)))) | |
380 ;; If we went to a place in the middle of the buffer, | |
381 ;; adjust it to the beginning of a line. | |
382 (if arg (forward-line 1) | |
383 ;; If the end of the buffer is not already on the screen, | |
384 ;; then scroll specially to put it near, but not at, the bottom. | |
385 (if (let ((old-point (point))) | |
386 (save-excursion | |
387 (goto-char (window-start)) | |
388 (vertical-motion (window-height)) | |
389 (< (point) old-point))) | |
390 (progn | |
391 (overlay-recenter (point)) | |
392 (recenter -3))))) | |
393 | |
394 | |
395 ;;;;;;;;;;;;;;;;;;;; | |
396 ;;;;;; backwards and mark | |
397 ;;;;;;;;;;;;;;;;;;;; | |
398 | |
399 (defun backward-char-mark (&optional arg) | |
400 "Ensure mark is active; move point left ARG characters (right if ARG negative). | |
401 On attempt to pass beginning or end of buffer, stop and signal error." | |
402 (interactive "p") | |
403 (ensure-mark) | |
404 (backward-char arg)) | |
405 | |
406 (defun backward-word-mark (&optional arg) | |
407 "Ensure mark is active; move backward until encountering the end of a word. | |
408 With argument, do this that many times." | |
409 (interactive "p") | |
410 (ensure-mark) | |
411 (backward-word arg)) | |
412 | |
18216
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
413 (defun backward-sexp-mark (&optional arg) |
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
414 "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
|
415 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
|
416 move forward across N balanced expressions." |
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
417 (interactive "p") |
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
418 (ensure-mark) |
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
419 (backward-sexp arg)) |
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
420 |
13233 | 421 (defun backward-paragraph-mark (&optional arg) |
422 "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
|
423 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
|
424 |
13233 | 425 A paragraph start is the beginning of a line which is a |
426 `first-line-of-paragraph' or which is ordinary text and follows a | |
427 paragraph-separating line; except: if the first real line of a | |
428 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
|
429 blank line. |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
430 |
13233 | 431 See `forward-paragraph' for more information." |
432 (interactive "p") | |
433 (ensure-mark) | |
434 (backward-paragraph arg)) | |
435 | |
436 (defun previous-line-mark (&optional arg) | |
437 "Ensure mark is active; move cursor vertically up ARG lines. | |
438 If there is no character in the target line exactly over the current column, | |
439 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
|
440 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
|
441 |
13233 | 442 The command C-x C-n can be used to create |
443 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
|
444 Then it does not try to move vertically. |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
445 |
13233 | 446 If you are thinking of using this in a Lisp program, consider using |
447 `forward-line' with a negative argument instead. It is usually easier | |
448 to use and more reliable (no dependence on goal column, etc.)." | |
449 (interactive "p") | |
450 (ensure-mark) | |
14382 | 451 (previous-line arg) |
452 (setq this-command 'previous-line)) | |
13233 | 453 |
454 (defun beginning-of-line-mark (&optional arg) | |
455 "Ensure mark is active; move point to beginning of current line. | |
456 With argument ARG not nil or 1, move forward ARG - 1 lines first. | |
457 If scan reaches end of buffer, stop there without error." | |
458 (interactive "p") | |
459 (ensure-mark) | |
460 (beginning-of-line arg)) | |
461 | |
462 | |
463 (defun scroll-up-mark (&optional arg) | |
464 "Ensure mark is active; scroll upward ARG lines; or near full screen if no ARG. | |
465 A near full screen is `next-screen-context-lines' less than a full screen. | |
466 Negative ARG means scroll downward. | |
467 When calling from a program, supply a number as argument or nil." | |
468 (interactive "P") | |
469 (ensure-mark) | |
15931
c729af982039
(ensure-mark): Minor rewrite.
Richard M. Stallman <rms@gnu.org>
parents:
15907
diff
changeset
|
470 (cond (pc-select-override-scroll-error |
c729af982039
(ensure-mark): Minor rewrite.
Richard M. Stallman <rms@gnu.org>
parents:
15907
diff
changeset
|
471 (condition-case nil (scroll-up arg) |
c729af982039
(ensure-mark): Minor rewrite.
Richard M. Stallman <rms@gnu.org>
parents:
15907
diff
changeset
|
472 (end-of-buffer (goto-char (point-max))))) |
c729af982039
(ensure-mark): Minor rewrite.
Richard M. Stallman <rms@gnu.org>
parents:
15907
diff
changeset
|
473 (t (scroll-up arg)))) |
13233 | 474 |
475 (defun beginning-of-buffer-mark (&optional arg) | |
476 "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
|
477 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
|
478 |
13233 | 479 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
|
480 of the accessible part of the buffer. |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
481 |
13233 | 482 Don't use this command in Lisp programs! |
483 \(goto-char (p\oint-min)) is faster and avoids clobbering the mark." | |
484 (interactive "P") | |
485 (ensure-mark) | |
486 (let ((size (- (point-max) (point-min)))) | |
487 (goto-char (if arg | |
488 (+ (point-min) | |
489 (if (> size 10000) | |
490 ;; Avoid overflow for large buffer sizes! | |
491 (* (prefix-numeric-value arg) | |
492 (/ size 10)) | |
493 (/ (+ 10 (* size (prefix-numeric-value arg))) 10))) | |
494 (point-min)))) | |
495 (if arg (forward-line 1))) | |
496 | |
497 ;;;;;;;; | |
498 ;;; no mark | |
499 ;;;;;;;; | |
500 | |
501 (defun backward-char-nomark (&optional arg) | |
502 "Deactivate mark; move point left ARG characters (right if ARG negative). | |
503 On attempt to pass beginning or end of buffer, stop and signal error." | |
504 (interactive "p") | |
505 (setq mark-active nil) | |
506 (backward-char arg)) | |
507 | |
508 (defun backward-word-nomark (&optional arg) | |
509 "Deactivate mark; move backward until encountering the end of a word. | |
510 With argument, do this that many times." | |
511 (interactive "p") | |
512 (setq mark-active nil) | |
513 (backward-word arg)) | |
514 | |
18216
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
515 (defun backward-sexp-nomark (&optional arg) |
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
516 "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
|
517 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
|
518 move forward across N balanced expressions." |
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
519 (interactive "p") |
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
520 (setq mark-active nil) |
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
521 (backward-sexp arg)) |
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
522 |
13233 | 523 (defun backward-paragraph-nomark (&optional arg) |
524 "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
|
525 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
|
526 |
13233 | 527 A paragraph start is the beginning of a line which is a |
528 `first-line-of-paragraph' or which is ordinary text and follows a | |
529 paragraph-separating line; except: if the first real line of a | |
530 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
|
531 blank line. |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
532 |
13233 | 533 See `forward-paragraph' for more information." |
534 (interactive "p") | |
535 (setq mark-active nil) | |
536 (backward-paragraph arg)) | |
537 | |
538 (defun previous-line-nomark (&optional arg) | |
539 "Deactivate mark; move cursor vertically up ARG lines. | |
540 If there is no character in the target line exactly over the current column, | |
541 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
|
542 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
|
543 |
13233 | 544 The command C-x C-n can be used to create |
545 a semipermanent goal column to which this command always moves. | |
546 Then it does not try to move vertically." | |
547 (interactive "p") | |
548 (setq mark-active nil) | |
14382 | 549 (previous-line arg) |
550 (setq this-command 'previous-line)) | |
13233 | 551 |
552 (defun beginning-of-line-nomark (&optional arg) | |
553 "Deactivate mark; move point to beginning of current line. | |
554 With argument ARG not nil or 1, move forward ARG - 1 lines first. | |
555 If scan reaches end of buffer, stop there without error." | |
556 (interactive "p") | |
557 (setq mark-active nil) | |
558 (beginning-of-line arg)) | |
559 | |
560 (defun scroll-up-nomark (&optional arg) | |
561 "Deactivate mark; scroll upward ARG lines; or near full screen if no ARG. | |
562 A near full screen is `next-screen-context-lines' less than a full screen. | |
563 Negative ARG means scroll downward. | |
564 When calling from a program, supply a number as argument or nil." | |
565 (interactive "P") | |
566 (setq mark-active nil) | |
15931
c729af982039
(ensure-mark): Minor rewrite.
Richard M. Stallman <rms@gnu.org>
parents:
15907
diff
changeset
|
567 (cond (pc-select-override-scroll-error |
c729af982039
(ensure-mark): Minor rewrite.
Richard M. Stallman <rms@gnu.org>
parents:
15907
diff
changeset
|
568 (condition-case nil (scroll-up arg) |
c729af982039
(ensure-mark): Minor rewrite.
Richard M. Stallman <rms@gnu.org>
parents:
15907
diff
changeset
|
569 (end-of-buffer (goto-char (point-max))))) |
c729af982039
(ensure-mark): Minor rewrite.
Richard M. Stallman <rms@gnu.org>
parents:
15907
diff
changeset
|
570 (t (scroll-up arg)))) |
13233 | 571 |
572 (defun beginning-of-buffer-nomark (&optional arg) | |
573 "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
|
574 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
|
575 |
13233 | 576 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
|
577 of the accessible part of the buffer. |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
578 |
13233 | 579 Don't use this command in Lisp programs! |
14382 | 580 \(goto-char (point-min)) is faster and avoids clobbering the mark." |
13233 | 581 (interactive "P") |
582 (setq mark-active nil) | |
583 (let ((size (- (point-max) (point-min)))) | |
584 (goto-char (if arg | |
585 (+ (point-min) | |
586 (if (> size 10000) | |
587 ;; Avoid overflow for large buffer sizes! | |
588 (* (prefix-numeric-value arg) | |
589 (/ size 10)) | |
590 (/ (+ 10 (* size (prefix-numeric-value arg))) 10))) | |
591 (point-min)))) | |
592 (if arg (forward-line 1))) | |
593 | |
13234
e3b1df16f4b4
(pc-selection-mode): Add autoload cookie.
Richard M. Stallman <rms@gnu.org>
parents:
13233
diff
changeset
|
594 ;;;###autoload |
13233 | 595 (defun pc-selection-mode () |
15907
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
596 "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
|
597 |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
598 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
|
599 |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
600 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
|
601 which modify the status of the mark. |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
602 |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
603 The ordinary arrow keys disable the mark. |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
604 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
|
605 |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
606 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
|
607 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
|
608 |
18216
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
609 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
|
610 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
|
611 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
|
612 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
|
613 turning pc-selection-mode on. |
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
614 |
15907
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
615 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
|
616 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
|
617 |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
618 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
|
619 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
|
620 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
|
621 |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
622 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
|
623 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
|
624 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
|
625 |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
626 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
|
627 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
|
628 |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
629 S-DELETE kills the region (`kill-region'). |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
630 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
|
631 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
|
632 |
18216
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
633 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
|
634 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
|
635 but before calling pc-selection-mode): |
15907
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
636 |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
637 F6 other-window |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
638 DELETE delete-char |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
639 C-DELETE kill-line |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
640 M-DELETE kill-word |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
641 C-M-DELETE kill-sexp |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
642 C-BACKSPACE backward-kill-word |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
643 M-BACKSPACE undo" |
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
644 |
13233 | 645 (interactive) |
646 ;; | |
647 ;; keybindings | |
648 ;; | |
649 | |
650 ;; This is to avoid confusion with the delete-selection-mode | |
651 ;; 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
|
652 ;; 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
|
653 ;; copy-region-as-kill this is confusing. |
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
654 ;; The same goes for exchange-point-and-mark |
13233 | 655 (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
|
656 (define-key global-map "\C-x\C-x" 'exchange-point-and-mark-nomark) |
14040 | 657 ;; The following keybindings are for standard ISO keyboards |
13233 | 658 ;; as they are used with IBM compatible PCs, IBM RS/6000, |
659 ;; MACs, many X-Stations and probably more | |
660 (define-key global-map [S-right] 'forward-char-mark) | |
661 (define-key global-map [right] 'forward-char-nomark) | |
662 (define-key global-map [C-S-right] 'forward-word-mark) | |
663 (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
|
664 (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
|
665 (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
|
666 (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
|
667 (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
|
668 (cond (pc-select-meta-moves-sexps |
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
669 (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
|
670 (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
|
671 (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
|
672 (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
|
673 (t |
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
674 (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
|
675 (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
|
676 (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
|
677 (define-key global-map [M-left] 'backward-word-nomark))) |
13233 | 678 |
679 (define-key global-map [S-down] 'next-line-mark) | |
680 (define-key global-map [down] 'next-line-nomark) | |
681 | |
682 (define-key global-map [S-end] 'end-of-line-mark) | |
683 (define-key global-map [end] 'end-of-line-nomark) | |
684 (global-set-key [S-C-end] 'end-of-buffer-mark) | |
685 (global-set-key [C-end] 'end-of-buffer-nomark) | |
14382 | 686 (global-set-key [S-M-end] 'end-of-buffer-mark) |
687 (global-set-key [M-end] 'end-of-buffer-nomark) | |
13233 | 688 |
689 (define-key global-map [S-next] 'scroll-up-mark) | |
690 (define-key global-map [next] 'scroll-up-nomark) | |
691 | |
692 (define-key global-map [S-up] 'previous-line-mark) | |
693 (define-key global-map [up] 'previous-line-nomark) | |
694 | |
695 (define-key global-map [S-home] 'beginning-of-line-mark) | |
696 (define-key global-map [home] 'beginning-of-line-nomark) | |
697 (global-set-key [S-C-home] 'beginning-of-buffer-mark) | |
698 (global-set-key [C-home] 'beginning-of-buffer-nomark) | |
14382 | 699 (global-set-key [S-M-home] 'beginning-of-buffer-mark) |
700 (global-set-key [M-home] 'beginning-of-buffer-nomark) | |
13233 | 701 |
15907
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
702 (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
|
703 (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
|
704 (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
|
705 (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
|
706 |
18216
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
707 (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
|
708 (define-key global-map [prior] 'scroll-down-nomark) |
13233 | 709 |
18216
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
710 ;; Next four lines are from Pete Forman. |
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
711 (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
|
712 (global-set-key [C-up] 'backward-paragraph-nomark) ; KPrevPara cUp |
13233 | 713 (global-set-key [S-C-down] 'forward-paragraph-mark) |
714 (global-set-key [S-C-up] 'backward-paragraph-mark) | |
715 | |
18216
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
716 (or pc-select-selection-keys-only |
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
717 (progn |
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
718 (define-key global-map [S-insert] 'yank) |
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
719 (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
|
720 (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
|
721 |
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
722 ;; 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
|
723 ;; 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
|
724 ;; 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
|
725 ;; 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
|
726 (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
|
727 (define-key global-map [f18] 'yank) |
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
728 (define-key global-map [f20] 'kill-region) |
13233 | 729 |
18216
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
730 ;; The following bindings are from Pete Forman. |
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
731 (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
|
732 (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
|
733 (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
|
734 (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
|
735 |
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
736 ;; 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
|
737 ;; as suggested by RMS. |
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
738 ;; 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
|
739 (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
|
740 (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
|
741 (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
|
742 ;; Next line proposed by Eli Barzilay |
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
743 (global-set-key [C-escape] 'electric-buffer-list))) |
13233 | 744 ;; |
745 ;; setup | |
746 ;; | |
18216
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
747 ;; Next line proposed by Eli Barzilay |
75f7eec6d388
(pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
17915
diff
changeset
|
748 (setq highlight-nonselected-windows nil) |
13233 | 749 (setq transient-mark-mode t) |
750 (setq mark-even-if-inactive t) | |
15907
c25492075289
Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
751 (delete-selection-mode 1) |
15931
c729af982039
(ensure-mark): Minor rewrite.
Richard M. Stallman <rms@gnu.org>
parents:
15907
diff
changeset
|
752 ) |
13233 | 753 ;;; pc-select.el ends here |