aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman1996-08-24 16:10:28 +0000
committerRichard M. Stallman1996-08-24 16:10:28 +0000
commit20c5a87d0b8a3fb8682a2d4ade4606daa030f66d (patch)
treefe733ad4460681d4e72a637682182cb1e2ed1952
parentd4866ec362eaed539e62b39ae4f6585dbc051e6d (diff)
downloademacs-20c5a87d0b8a3fb8682a2d4ade4606daa030f66d.tar.gz
emacs-20c5a87d0b8a3fb8682a2d4ade4606daa030f66d.zip
Replace \n in doc strings.
(pc-selection-mode): Big doc fix. Don't bind f1. (forward-line-mark): New function. (forward-line-nomark): New function. (backward-line-mark): New function. (backward-line-nomark): New function. (pc-selection-mode): Add keybindings for those functions. (pc-select-override-scroll-error): New variable.
-rw-r--r--lisp/emulation/pc-select.el178
1 files changed, 145 insertions, 33 deletions
diff --git a/lisp/emulation/pc-select.el b/lisp/emulation/pc-select.el
index b4bc0812bbc..77a50c5f3c1 100644
--- a/lisp/emulation/pc-select.el
+++ b/lisp/emulation/pc-select.el
@@ -55,7 +55,8 @@
55;; for additional motif keybindings. 55;; for additional motif keybindings.
56;; Thanks to jvromans@squirrel.nl (Johan Vromans) for a bug report 56;; Thanks to jvromans@squirrel.nl (Johan Vromans) for a bug report
57;; concerning setting of this-command. 57;; concerning setting of this-command.
58;; 58;; Dan Nicolaescu <done@nexus.sorostm.ro> suggested suppressing the
59;; scroll-up/scroll-down error.
59;; 60;;
60;; Ok, some details about the idea of pc-selection-mode: 61;; Ok, some details about the idea of pc-selection-mode:
61;; 62;;
@@ -71,8 +72,17 @@
71;; They will be bound according to the "old" behaviour to S-delete (cut), 72;; They will be bound according to the "old" behaviour to S-delete (cut),
72;; S-insert (paste) and C-insert (copy). These keys do the same in many 73;; S-insert (paste) and C-insert (copy). These keys do the same in many
73;; other programs. 74;; other programs.
75;;
74 76
75;;; Code: 77;;;; Customization:
78
79(defvar pc-select-override-scroll-error t
80 "*Non-nil means don't generate error on scrolling past edge of buffer.
81This variable applies in PC Selection mode only.
82The scroll commands normally generate an error if you try to scroll
83past the top or bottom of the buffer. This is annoying when selecting
84text with these commands. If you set this variable to non-nil, these
85errors are suppressed.")
76 86
77;;;; 87;;;;
78;; misc 88;; misc
@@ -83,7 +93,8 @@
83(defun copy-region-as-kill-nomark (beg end) 93(defun copy-region-as-kill-nomark (beg end)
84 "Save the region as if killed; but don't kill it; deactivate mark. 94 "Save the region as if killed; but don't kill it; deactivate mark.
85If `interprogram-cut-function' is non-nil, also save the text for a window 95If `interprogram-cut-function' is non-nil, also save the text for a window
86system cut and paste.\n 96system cut and paste.
97
87Deactivating mark is to avoid confusion with delete-selection-mode 98Deactivating mark is to avoid confusion with delete-selection-mode
88and transient-mark-mode." 99and transient-mark-mode."
89 (interactive "r") 100 (interactive "r")
@@ -119,9 +130,18 @@ and nil is returned."
119 (ensure-mark) 130 (ensure-mark)
120 (forward-word arg)) 131 (forward-word arg))
121 132
133(defun forward-line-mark (&optional arg)
134 "Ensure mark is active; move cursor vertically down ARG lines."
135 (interactive "p")
136 (ensure-mark)
137 (forward-line arg)
138 (setq this-command 'forward-line)
139)
140
122(defun forward-paragraph-mark (&optional arg) 141(defun forward-paragraph-mark (&optional arg)
123 "Ensure mark is active; move forward to end of paragraph. 142 "Ensure mark is active; move forward to end of paragraph.
124With arg N, do it N times; negative arg -N means move backward N paragraphs.\n 143With arg N, do it N times; negative arg -N means move backward N paragraphs.
144
125A line which `paragraph-start' matches either separates paragraphs 145A line which `paragraph-start' matches either separates paragraphs
126\(if `paragraph-separate' matches it also) or is the first line of a paragraph. 146\(if `paragraph-separate' matches it also) or is the first line of a paragraph.
127A paragraph end is the beginning of a line which is not part of the paragraph 147A paragraph end is the beginning of a line which is not part of the paragraph
@@ -129,7 +149,7 @@ to which the end of the previous line belongs, or the end of the buffer."
129 (interactive "p") 149 (interactive "p")
130 (ensure-mark) 150 (ensure-mark)
131 (forward-paragraph arg)) 151 (forward-paragraph arg))
132 152
133(defun next-line-mark (&optional arg) 153(defun next-line-mark (&optional arg)
134 "Ensure mark is active; move cursor vertically down ARG lines. 154 "Ensure mark is active; move cursor vertically down ARG lines.
135If there is no character in the target line exactly under the current column, 155If there is no character in the target line exactly under the current column,
@@ -139,7 +159,8 @@ If there is no line in the buffer after this one, behavior depends on the
139value of `next-line-add-newlines'. If non-nil, it inserts a newline character 159value of `next-line-add-newlines'. If non-nil, it inserts a newline character
140to create a line, and moves the cursor to that line. Otherwise it moves the 160to create a line, and moves the cursor to that line. Otherwise it moves the
141cursor to the end of the buffer \(if already at the end of the buffer, an error 161cursor to the end of the buffer \(if already at the end of the buffer, an error
142is signaled).\n 162is signaled).
163
143The command C-x C-n can be used to create 164The command C-x C-n can be used to create
144a semipermanent goal column to which this command always moves. 165a semipermanent goal column to which this command always moves.
145Then it does not try to move vertically. This goal column is stored 166Then it does not try to move vertically. This goal column is stored
@@ -158,6 +179,16 @@ If scan reaches end of buffer, stop there without error."
158 (end-of-line arg) 179 (end-of-line arg)
159 (setq this-command 'end-of-line)) 180 (setq this-command 'end-of-line))
160 181
182(defun backward-line-mark (&optional arg)
183 "Ensure mark is active; move cursor vertically up ARG lines."
184 (interactive "p")
185 (ensure-mark)
186 (if (null arg)
187 (setq arg 1))
188 (forward-line (- arg))
189 (setq this-command 'forward-line)
190)
191
161(defun scroll-down-mark (&optional arg) 192(defun scroll-down-mark (&optional arg)
162 "Ensure mark is active; scroll down ARG lines; or near full screen if no ARG. 193 "Ensure mark is active; scroll down ARG lines; or near full screen if no ARG.
163A near full screen is `next-screen-context-lines' less than a full screen. 194A near full screen is `next-screen-context-lines' less than a full screen.
@@ -169,9 +200,11 @@ When calling from a program, supply a number as argument or nil."
169 200
170(defun end-of-buffer-mark (&optional arg) 201(defun end-of-buffer-mark (&optional arg)
171 "Ensure mark is active; move point to the end of the buffer. 202 "Ensure mark is active; move point to the end of the buffer.
172With arg N, put point N/10 of the way from the end.\n 203With arg N, put point N/10 of the way from the end.
204
173If the buffer is narrowed, this command uses the beginning and size 205If the buffer is narrowed, this command uses the beginning and size
174of the accessible part of the buffer.\n 206of the accessible part of the buffer.
207
175Don't use this command in Lisp programs! 208Don't use this command in Lisp programs!
176\(goto-char \(point-max)) is faster and avoids clobbering the mark." 209\(goto-char \(point-max)) is faster and avoids clobbering the mark."
177 (interactive "P") 210 (interactive "P")
@@ -219,9 +252,18 @@ and nil is returned."
219 (setq mark-active nil) 252 (setq mark-active nil)
220 (forward-word arg)) 253 (forward-word arg))
221 254
255(defun forward-line-nomark (&optional arg)
256 "Deactivate mark; move cursor vertically down ARG lines."
257 (interactive "p")
258 (setq mark-active nil)
259 (forward-line arg)
260 (setq this-command 'forward-line)
261)
262
222(defun forward-paragraph-nomark (&optional arg) 263(defun forward-paragraph-nomark (&optional arg)
223 "Deactivate mark; move forward to end of paragraph. 264 "Deactivate mark; move forward to end of paragraph.
224With arg N, do it N times; negative arg -N means move backward N paragraphs.\n 265With arg N, do it N times; negative arg -N means move backward N paragraphs.
266
225A line which `paragraph-start' matches either separates paragraphs 267A line which `paragraph-start' matches either separates paragraphs
226\(if `paragraph-separate' matches it also) or is the first line of a paragraph. 268\(if `paragraph-separate' matches it also) or is the first line of a paragraph.
227A paragraph end is the beginning of a line which is not part of the paragraph 269A paragraph end is the beginning of a line which is not part of the paragraph
@@ -239,7 +281,8 @@ If there is no line in the buffer after this one, behavior depends on the
239value of `next-line-add-newlines'. If non-nil, it inserts a newline character 281value of `next-line-add-newlines'. If non-nil, it inserts a newline character
240to create a line, and moves the cursor to that line. Otherwise it moves the 282to create a line, and moves the cursor to that line. Otherwise it moves the
241cursor to the end of the buffer (if already at the end of the buffer, an error 283cursor to the end of the buffer (if already at the end of the buffer, an error
242is signaled).\n 284is signaled).
285
243The command C-x C-n can be used to create 286The command C-x C-n can be used to create
244a semipermanent goal column to which this command always moves. 287a semipermanent goal column to which this command always moves.
245Then it does not try to move vertically. This goal column is stored 288Then it does not try to move vertically. This goal column is stored
@@ -258,6 +301,16 @@ If scan reaches end of buffer, stop there without error."
258 (end-of-line arg) 301 (end-of-line arg)
259 (setq this-command 'end-of-line)) 302 (setq this-command 'end-of-line))
260 303
304(defun backward-line-nomark (&optional arg)
305 "Deactivate mark; move cursor vertically up ARG lines."
306 (interactive "p")
307 (setq mark-active nil)
308 (if (null arg)
309 (setq arg 1))
310 (forward-line (- arg))
311 (setq this-command 'forward-line)
312)
313
261(defun scroll-down-nomark (&optional arg) 314(defun scroll-down-nomark (&optional arg)
262 "Deactivate mark; scroll down ARG lines; or near full screen if no ARG. 315 "Deactivate mark; scroll down ARG lines; or near full screen if no ARG.
263A near full screen is `next-screen-context-lines' less than a full screen. 316A near full screen is `next-screen-context-lines' less than a full screen.
@@ -269,9 +322,11 @@ When calling from a program, supply a number as argument or nil."
269 322
270(defun end-of-buffer-nomark (&optional arg) 323(defun end-of-buffer-nomark (&optional arg)
271 "Deactivate mark; move point to the end of the buffer. 324 "Deactivate mark; move point to the end of the buffer.
272With arg N, put point N/10 of the way from the end.\n 325With arg N, put point N/10 of the way from the end.
326
273If the buffer is narrowed, this command uses the beginning and size 327If the buffer is narrowed, this command uses the beginning and size
274of the accessible part of the buffer.\n 328of the accessible part of the buffer.
329
275Don't use this command in Lisp programs! 330Don't use this command in Lisp programs!
276\(goto-char (point-max)) is faster and avoids clobbering the mark." 331\(goto-char (point-max)) is faster and avoids clobbering the mark."
277 (interactive "P") 332 (interactive "P")
@@ -320,12 +375,14 @@ With argument, do this that many times."
320 375
321(defun backward-paragraph-mark (&optional arg) 376(defun backward-paragraph-mark (&optional arg)
322 "Ensure mark is active; move backward to start of paragraph. 377 "Ensure mark is active; move backward to start of paragraph.
323With arg N, do it N times; negative arg -N means move forward N paragraphs.\n 378With arg N, do it N times; negative arg -N means move forward N paragraphs.
379
324A paragraph start is the beginning of a line which is a 380A paragraph start is the beginning of a line which is a
325`first-line-of-paragraph' or which is ordinary text and follows a 381`first-line-of-paragraph' or which is ordinary text and follows a
326paragraph-separating line; except: if the first real line of a 382paragraph-separating line; except: if the first real line of a
327paragraph is preceded by a blank line, the paragraph starts at that 383paragraph is preceded by a blank line, the paragraph starts at that
328blank line.\n 384blank line.
385
329See `forward-paragraph' for more information." 386See `forward-paragraph' for more information."
330 (interactive "p") 387 (interactive "p")
331 (ensure-mark) 388 (ensure-mark)
@@ -335,10 +392,12 @@ See `forward-paragraph' for more information."
335 "Ensure mark is active; move cursor vertically up ARG lines. 392 "Ensure mark is active; move cursor vertically up ARG lines.
336If there is no character in the target line exactly over the current column, 393If there is no character in the target line exactly over the current column,
337the cursor is positioned after the character in that line which spans this 394the cursor is positioned after the character in that line which spans this
338column, or at the end of the line if it is not long enough.\n 395column, or at the end of the line if it is not long enough.
396
339The command C-x C-n can be used to create 397The command C-x C-n can be used to create
340a semipermanent goal column to which this command always moves. 398a semipermanent goal column to which this command always moves.
341Then it does not try to move vertically.\n 399Then it does not try to move vertically.
400
342If you are thinking of using this in a Lisp program, consider using 401If you are thinking of using this in a Lisp program, consider using
343`forward-line' with a negative argument instead. It is usually easier 402`forward-line' with a negative argument instead. It is usually easier
344to use and more reliable (no dependence on goal column, etc.)." 403to use and more reliable (no dependence on goal column, etc.)."
@@ -367,9 +426,11 @@ When calling from a program, supply a number as argument or nil."
367 426
368(defun beginning-of-buffer-mark (&optional arg) 427(defun beginning-of-buffer-mark (&optional arg)
369 "Ensure mark is active; move point to the beginning of the buffer. 428 "Ensure mark is active; move point to the beginning of the buffer.
370With arg N, put point N/10 of the way from the beginning.\n 429With arg N, put point N/10 of the way from the beginning.
430
371If the buffer is narrowed, this command uses the beginning and size 431If the buffer is narrowed, this command uses the beginning and size
372of the accessible part of the buffer.\n 432of the accessible part of the buffer.
433
373Don't use this command in Lisp programs! 434Don't use this command in Lisp programs!
374\(goto-char (p\oint-min)) is faster and avoids clobbering the mark." 435\(goto-char (p\oint-min)) is faster and avoids clobbering the mark."
375 (interactive "P") 436 (interactive "P")
@@ -405,12 +466,14 @@ With argument, do this that many times."
405 466
406(defun backward-paragraph-nomark (&optional arg) 467(defun backward-paragraph-nomark (&optional arg)
407 "Deactivate mark; move backward to start of paragraph. 468 "Deactivate mark; move backward to start of paragraph.
408With arg N, do it N times; negative arg -N means move forward N paragraphs.\n 469With arg N, do it N times; negative arg -N means move forward N paragraphs.
470
409A paragraph start is the beginning of a line which is a 471A paragraph start is the beginning of a line which is a
410`first-line-of-paragraph' or which is ordinary text and follows a 472`first-line-of-paragraph' or which is ordinary text and follows a
411paragraph-separating line; except: if the first real line of a 473paragraph-separating line; except: if the first real line of a
412paragraph is preceded by a blank line, the paragraph starts at that 474paragraph is preceded by a blank line, the paragraph starts at that
413blank line.\n 475blank line.
476
414See `forward-paragraph' for more information." 477See `forward-paragraph' for more information."
415 (interactive "p") 478 (interactive "p")
416 (setq mark-active nil) 479 (setq mark-active nil)
@@ -420,7 +483,8 @@ See `forward-paragraph' for more information."
420 "Deactivate mark; move cursor vertically up ARG lines. 483 "Deactivate mark; move cursor vertically up ARG lines.
421If there is no character in the target line exactly over the current column, 484If there is no character in the target line exactly over the current column,
422the cursor is positioned after the character in that line which spans this 485the cursor is positioned after the character in that line which spans this
423column, or at the end of the line if it is not long enough.\n 486column, or at the end of the line if it is not long enough.
487
424The command C-x C-n can be used to create 488The command C-x C-n can be used to create
425a semipermanent goal column to which this command always moves. 489a semipermanent goal column to which this command always moves.
426Then it does not try to move vertically." 490Then it does not try to move vertically."
@@ -448,9 +512,11 @@ When calling from a program, supply a number as argument or nil."
448 512
449(defun beginning-of-buffer-nomark (&optional arg) 513(defun beginning-of-buffer-nomark (&optional arg)
450 "Deactivate mark; move point to the beginning of the buffer. 514 "Deactivate mark; move point to the beginning of the buffer.
451With arg N, put point N/10 of the way from the beginning.\n 515With arg N, put point N/10 of the way from the beginning.
516
452If the buffer is narrowed, this command uses the beginning and size 517If the buffer is narrowed, this command uses the beginning and size
453of the accessible part of the buffer.\n 518of the accessible part of the buffer.
519
454Don't use this command in Lisp programs! 520Don't use this command in Lisp programs!
455\(goto-char (point-min)) is faster and avoids clobbering the mark." 521\(goto-char (point-min)) is faster and avoids clobbering the mark."
456 (interactive "P") 522 (interactive "P")
@@ -468,14 +534,47 @@ Don't use this command in Lisp programs!
468 534
469;;;###autoload 535;;;###autoload
470(defun pc-selection-mode () 536(defun pc-selection-mode ()
471 "Change mark behaviour to emulate motif, MAC or MS-Windows cut and paste style.\n 537 "Change mark behaviour to emulate Motif, MAC or MS-Windows cut and paste style.
472This mode will switch on delete-selection-mode and 538
473transient-mark-mode.\n 539This mode enables Delete Selection mode and Transient Mark mode.
474The cursor keys (and others) are bound to new functions 540
475which will modify the status of the mark. It will be 541The arrow keys (and others) are bound to new functions
476possible to select regions with shift-cursorkeys. All this 542which modify the status of the mark.
477tries to emulate the look-and-feel of GUIs like motif, 543
478the MAC GUI or MS-Windows (sorry for the last one)." 544The ordinary arrow keys disable the mark.
545The shift-arrow keys move, leaving the mark behind.
546
547C-LEFT and C-RIGHT move back or forward one word, disabling the mark.
548S-C-LEFT and S-C-RIGHT move back or forward one word, leaving the mark behind.
549
550C-DOWN and C-UP move back or forward a paragraph, disabling the mark.
551S-C-DOWN and S-C-UP move back or forward a paragraph, leaving the mark behind.
552
553HOME moves to beginning of line, disabling the mark.
554S-HOME moves to beginning of line, leaving the mark behind.
555With Ctrl or Meta, these keys move to beginning of buffer instead.
556
557END moves to end of line, disabling the mark.
558S-END moves to end of line, leaving the mark behind.
559With Ctrl or Meta, these keys move to end of buffer instead.
560
561PRIOR or PAGE-UP scrolls and disables the mark.
562S-PRIOR or S-PAGE-UP scrolls and leaves the mark behind.
563
564S-DELETE kills the region (`kill-region').
565S-INSERT yanks text from the kill ring (`yank').
566C-INSERT copies the region into the kill ring (`copy-region-as-kill').
567
568In addition, certain other PC bindings are imitated:
569
570 F6 other-window
571 DELETE delete-char
572 C-DELETE kill-line
573 M-DELETE kill-word
574 C-M-DELETE kill-sexp
575 C-BACKSPACE backward-kill-word
576 M-BACKSPACE undo"
577
479 (interactive) 578 (interactive)
480 ;; 579 ;;
481 ;; keybindings 580 ;; keybindings
@@ -535,6 +634,11 @@ the MAC GUI or MS-Windows (sorry for the last one)."
535 (define-key global-map [C-insert] 'copy-region-as-kill) 634 (define-key global-map [C-insert] 'copy-region-as-kill)
536 (define-key global-map [S-delete] 'kill-region) 635 (define-key global-map [S-delete] 'kill-region)
537 636
637 (define-key global-map [M-S-down] 'forward-line-mark)
638 (define-key global-map [M-down] 'forward-line-nomark)
639 (define-key global-map [M-S-up] 'backward-line-mark)
640 (define-key global-map [M-up] 'backward-line-nomark)
641
538 ;; The following bindings are useful on Sun Type 3 keyboards 642 ;; The following bindings are useful on Sun Type 3 keyboards
539 ;; They implement the Get-Delete-Put (copy-cut-paste) 643 ;; They implement the Get-Delete-Put (copy-cut-paste)
540 ;; functions from sunview on the L6, L8 and L10 keys 644 ;; functions from sunview on the L6, L8 and L10 keys
@@ -546,7 +650,6 @@ the MAC GUI or MS-Windows (sorry for the last one)."
546 ;; I modified them a little to work together with the 650 ;; I modified them a little to work together with the
547 ;; mark functionality I added. 651 ;; mark functionality I added.
548 652
549 (global-set-key [f1] 'help) ; KHelp F1
550 (global-set-key [f6] 'other-window) ; KNextPane F6 653 (global-set-key [f6] 'other-window) ; KNextPane F6
551 (global-set-key [delete] 'delete-char) ; KDelete Del 654 (global-set-key [delete] 'delete-char) ; KDelete Del
552 (global-set-key [C-delete] 'kill-line) ; KEraseEndLine cDel 655 (global-set-key [C-delete] 'kill-line) ; KEraseEndLine cDel
@@ -569,6 +672,15 @@ the MAC GUI or MS-Windows (sorry for the last one)."
569 ;; 672 ;;
570 (setq transient-mark-mode t) 673 (setq transient-mark-mode t)
571 (setq mark-even-if-inactive t) 674 (setq mark-even-if-inactive t)
572 (delete-selection-mode 1)) 675 (delete-selection-mode 1)
676 (cond (pc-select-override-scroll-error
677 (defadvice scroll-up (around scroll-to-bottom-if-eob activate)
678 (condition-case nil
679 ad-do-it
680 (end-of-buffer (goto-char (point-max)))))
681 (defadvice scroll-down (around scroll-to-top-if-bob activate)
682 (condition-case nil
683 ad-do-it
684 (beginning-of-buffer (goto-char (point-min))))))))
573 685
574;;; pc-select.el ends here 686;;; pc-select.el ends here