1 ;;; pc-select.el --- emulate mark, cut, copy and paste from Motif
2 ;;; (or MAC GUI or MS-windoze (bah)) look-and-feel
3 ;;; including key bindings.
5 ;; Copyright (C) 1995, 1996, 1997, 2000 Free Software Foundation, Inc.
7 ;; Author: Michael Staats <michael@thp.Uni-Duisburg.DE>
8 ;; Keywords: convenience emulation
9 ;; Created: 26 Sep 1995
11 ;; This file is part of GNU Emacs.
13 ;; GNU Emacs is free software; you can redistribute it and/or modify
14 ;; it under the terms of the GNU General Public License as published by
15 ;; the Free Software Foundation; either version 2, or (at your option)
18 ;; GNU Emacs is distributed in the hope that it will be useful,
19 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 ;; GNU General Public License for more details.
23 ;; You should have received a copy of the GNU General Public License
24 ;; along with GNU Emacs; see the file COPYING. If not, write to the
25 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
26 ;; Boston, MA 02111-1307, USA.
30 ;; This package emulates the mark, copy, cut and paste look-and-feel of motif
31 ;; programs (which is the same as the MAC gui and (sorry for that) MS-Windows).
32 ;; It modifies the keybindings of the cursor keys and the next, prior,
33 ;; home and end keys. They will modify mark-active.
34 ;; You can still get the old behaviour of cursor moving with the
35 ;; control sequences C-f, C-b, etc.
36 ;; This package uses transient-mark-mode and
37 ;; delete-selection-mode.
39 ;; In addition to that all key-bindings from the pc-mode are
40 ;; done here too (as suggested by RMS).
42 ;; As I found out after I finished the first version, s-region.el tries
43 ;; to do the same.... But my code is a little more complete and using
44 ;; delete-selection-mode is very important for the look-and-feel.
45 ;; Pete Forman <pete.forman@airgun.wg.waii.com> provided some motif
46 ;; compliant keybindings which I added. I had to modify them a little
47 ;; to add the -mark and -nomark functionality of cursor moving.
50 ;; Many thanks to all who made comments.
51 ;; Thanks to RMS and Ralf Muschall <prm@rz.uni-jena.de> for criticism.
52 ;; Kevin Cutts <cutts@ukraine.corp.mot.com> added the beginning-of-buffer
53 ;; and end-of-buffer functions which I modified a little.
54 ;; David Biesack <sasdjb@unx.sas.com> suggested some more cleanup.
55 ;; Thanks to Pete Forman <pete.forman@airgun.wg.waii.com>
56 ;; for additional motif keybindings.
57 ;; Thanks to jvromans@squirrel.nl (Johan Vromans) for a bug report
58 ;; concerning setting of this-command.
59 ;; Dan Nicolaescu <done@ece.arizona.ro> suggested suppressing the
60 ;; scroll-up/scroll-down error.
61 ;; Eli Barzilay (eli@cs.bgu.ac.il) suggested the sexps functions and
64 ;; Ok, some details about the idea of pc-selection-mode:
66 ;; o The standard keys for moving around (right, left, up, down, home, end,
67 ;; prior, next, called "move-keys" from now on) will always de-activate
69 ;; o If you press "Shift" together with the "move-keys", the region
70 ;; you pass along is activated
71 ;; o You have the copy, cut and paste functions (as in many other programs)
72 ;; which will operate on the active region
73 ;; It was not possible to bind them to C-v, C-x and C-c for obvious
75 ;; They will be bound according to the "old" behaviour to S-delete (cut),
76 ;; S-insert (paste) and C-insert (copy). These keys do the same in many
81 (defgroup pc-select nil
82 "Emulate pc bindings."
84 :group
'editing-basics
87 (defcustom pc-select-override-scroll-error t
88 "*Non-nil means don't generate error on scrolling past edge of buffer.
89 This variable applies in PC Selection mode only.
90 The scroll commands normally generate an error if you try to scroll
91 past the top or bottom of the buffer. This is annoying when selecting
92 text with these commands. If you set this variable to non-nil, these
93 errors are suppressed."
97 (defcustom pc-select-selection-keys-only nil
98 "*Non-nil means only bind the basic selection keys when started.
99 Other keys that emulate pc-behavior will be untouched.
100 This gives mostly Emacs-like behaviour with only the selection keys enabled."
104 (defcustom pc-select-meta-moves-sexps nil
105 "*Non-nil means move sexp-wise with Meta key, otherwise move word-wise."
115 (defun copy-region-as-kill-nomark (beg end
)
116 "Save the region as if killed; but don't kill it; deactivate mark.
117 If `interprogram-cut-function' is non-nil, also save the text for a window
118 system cut and paste.
120 Deactivating mark is to avoid confusion with delete-selection-mode
121 and transient-mark-mode."
123 (copy-region-as-kill beg end
)
124 (setq mark-active nil
)
125 (message "Region saved"))
127 (defun exchange-point-and-mark-nomark ()
129 (exchange-point-and-mark)
130 (setq mark-active nil
))
136 ;; make sure mark is active
137 ;; test if it is active, if it isn't, set it and activate it
138 (or mark-active
(set-mark-command nil
)))
140 ;;;;;;;;;;;;;;;;;;;;;;;;;;;
141 ;;;;; forward and mark
142 ;;;;;;;;;;;;;;;;;;;;;;;;;;;
144 (defun forward-char-mark (&optional arg
)
145 "Ensure mark is active; move point right ARG characters (left if ARG negative).
146 On reaching end of buffer, stop and signal error."
151 (defun forward-word-mark (&optional arg
)
152 "Ensure mark is active; move point right ARG words (backward if ARG is negative).
154 If an edge of the buffer is reached, point is left there
155 and nil is returned."
160 (defun forward-line-mark (&optional arg
)
161 "Ensure mark is active; move cursor vertically down ARG lines."
165 (setq this-command
'forward-line
)
168 (defun forward-sexp-mark (&optional arg
)
169 "Ensure mark is active; move forward across one balanced expression (sexp).
170 With argument, do it that many times. Negative arg -N means
171 move backward across N balanced expressions."
176 (defun forward-paragraph-mark (&optional arg
)
177 "Ensure mark is active; move forward to end of paragraph.
178 With arg N, do it N times; negative arg -N means move backward N paragraphs.
180 A line which `paragraph-start' matches either separates paragraphs
181 \(if `paragraph-separate' matches it also) or is the first line of a paragraph.
182 A paragraph end is the beginning of a line which is not part of the paragraph
183 to which the end of the previous line belongs, or the end of the buffer."
186 (forward-paragraph arg
))
188 (defun next-line-mark (&optional arg
)
189 "Ensure mark is active; move cursor vertically down ARG lines.
190 If there is no character in the target line exactly under the current column,
191 the cursor is positioned after the character in that line which spans this
192 column, or at the end of the line if it is not long enough.
193 If there is no line in the buffer after this one, behavior depends on the
194 value of `next-line-add-newlines'. If non-nil, it inserts a newline character
195 to create a line, and moves the cursor to that line. Otherwise it moves the
196 cursor to the end of the buffer \(if already at the end of the buffer, an error
199 The command C-x C-n can be used to create
200 a semipermanent goal column to which this command always moves.
201 Then it does not try to move vertically. This goal column is stored
202 in `goal-column', which is nil when there is none."
206 (setq this-command
'next-line
))
208 (defun end-of-line-mark (&optional arg
)
209 "Ensure mark is active; move point to end of current line.
210 With argument ARG not nil or 1, move forward ARG - 1 lines first.
211 If scan reaches end of buffer, stop there without error."
215 (setq this-command
'end-of-line
))
217 (defun backward-line-mark (&optional arg
)
218 "Ensure mark is active; move cursor vertically up ARG lines."
223 (forward-line (- arg
))
224 (setq this-command
'forward-line
)
227 (defun scroll-down-mark (&optional arg
)
228 "Ensure mark is active; scroll down ARG lines; or near full screen if no ARG.
229 A near full screen is `next-screen-context-lines' less than a full screen.
230 Negative ARG means scroll upward.
231 When calling from a program, supply a number as argument or nil."
234 (cond (pc-select-override-scroll-error
235 (condition-case nil
(scroll-down arg
)
236 (beginning-of-buffer (goto-char (point-min)))))
237 (t (scroll-down arg
))))
239 (defun end-of-buffer-mark (&optional arg
)
240 "Ensure mark is active; move point to the end of the buffer.
241 With arg N, put point N/10 of the way from the end.
243 If the buffer is narrowed, this command uses the beginning and size
244 of the accessible part of the buffer.
246 Don't use this command in Lisp programs!
247 \(goto-char \(point-max)) is faster and avoids clobbering the mark."
250 (let ((size (- (point-max) (point-min))))
254 ;; Avoid overflow for large buffer sizes!
255 (* (prefix-numeric-value arg
)
257 (/ (* size
(prefix-numeric-value arg
)) 10)))
259 ;; If we went to a place in the middle of the buffer,
260 ;; adjust it to the beginning of a line.
261 (if arg
(forward-line 1)
262 ;; If the end of the buffer is not already on the screen,
263 ;; then scroll specially to put it near, but not at, the bottom.
264 (if (let ((old-point (point)))
266 (goto-char (window-start))
267 (vertical-motion (window-height))
268 (< (point) old-point
)))
270 (overlay-recenter (point))
277 (defun forward-char-nomark (&optional arg
)
278 "Deactivate mark; move point right ARG characters \(left if ARG negative).
279 On reaching end of buffer, stop and signal error."
281 (setq mark-active nil
)
284 (defun forward-word-nomark (&optional arg
)
285 "Deactivate mark; move point right ARG words \(backward if ARG is negative).
287 If an edge of the buffer is reached, point is left there
288 and nil is returned."
290 (setq mark-active nil
)
293 (defun forward-line-nomark (&optional arg
)
294 "Deactivate mark; move cursor vertically down ARG lines."
296 (setq mark-active nil
)
298 (setq this-command
'forward-line
)
301 (defun forward-sexp-nomark (&optional arg
)
302 "Deactivate mark; move forward across one balanced expression (sexp).
303 With argument, do it that many times. Negative arg -N means
304 move backward across N balanced expressions."
306 (setq mark-active nil
)
309 (defun forward-paragraph-nomark (&optional arg
)
310 "Deactivate mark; move forward to end of paragraph.
311 With arg N, do it N times; negative arg -N means move backward N paragraphs.
313 A line which `paragraph-start' matches either separates paragraphs
314 \(if `paragraph-separate' matches it also) or is the first line of a paragraph.
315 A paragraph end is the beginning of a line which is not part of the paragraph
316 to which the end of the previous line belongs, or the end of the buffer."
318 (setq mark-active nil
)
319 (forward-paragraph arg
))
321 (defun next-line-nomark (&optional arg
)
322 "Deactivate mark; move cursor vertically down ARG lines.
323 If there is no character in the target line exactly under the current column,
324 the cursor is positioned after the character in that line which spans this
325 column, or at the end of the line if it is not long enough.
326 If there is no line in the buffer after this one, behavior depends on the
327 value of `next-line-add-newlines'. If non-nil, it inserts a newline character
328 to create a line, and moves the cursor to that line. Otherwise it moves the
329 cursor to the end of the buffer (if already at the end of the buffer, an error
332 The command C-x C-n can be used to create
333 a semipermanent goal column to which this command always moves.
334 Then it does not try to move vertically. This goal column is stored
335 in `goal-column', which is nil when there is none."
337 (setq mark-active nil
)
339 (setq this-command
'next-line
))
341 (defun end-of-line-nomark (&optional arg
)
342 "Deactivate mark; move point to end of current line.
343 With argument ARG not nil or 1, move forward ARG - 1 lines first.
344 If scan reaches end of buffer, stop there without error."
346 (setq mark-active nil
)
348 (setq this-command
'end-of-line
))
350 (defun backward-line-nomark (&optional arg
)
351 "Deactivate mark; move cursor vertically up ARG lines."
353 (setq mark-active nil
)
356 (forward-line (- arg
))
357 (setq this-command
'forward-line
)
360 (defun scroll-down-nomark (&optional arg
)
361 "Deactivate mark; scroll down ARG lines; or near full screen if no ARG.
362 A near full screen is `next-screen-context-lines' less than a full screen.
363 Negative ARG means scroll upward.
364 When calling from a program, supply a number as argument or nil."
366 (setq mark-active nil
)
367 (cond (pc-select-override-scroll-error
368 (condition-case nil
(scroll-down arg
)
369 (beginning-of-buffer (goto-char (point-min)))))
370 (t (scroll-down arg
))))
372 (defun end-of-buffer-nomark (&optional arg
)
373 "Deactivate mark; move point to the end of the buffer.
374 With arg N, put point N/10 of the way from the end.
376 If the buffer is narrowed, this command uses the beginning and size
377 of the accessible part of the buffer.
379 Don't use this command in Lisp programs!
380 \(goto-char (point-max)) is faster and avoids clobbering the mark."
382 (setq mark-active nil
)
383 (let ((size (- (point-max) (point-min))))
387 ;; Avoid overflow for large buffer sizes!
388 (* (prefix-numeric-value arg
)
390 (/ (* size
(prefix-numeric-value arg
)) 10)))
392 ;; If we went to a place in the middle of the buffer,
393 ;; adjust it to the beginning of a line.
394 (if arg
(forward-line 1)
395 ;; If the end of the buffer is not already on the screen,
396 ;; then scroll specially to put it near, but not at, the bottom.
397 (if (let ((old-point (point)))
399 (goto-char (window-start))
400 (vertical-motion (window-height))
401 (< (point) old-point
)))
403 (overlay-recenter (point))
408 ;;;;;; backwards and mark
411 (defun backward-char-mark (&optional arg
)
412 "Ensure mark is active; move point left ARG characters (right if ARG negative).
413 On attempt to pass beginning or end of buffer, stop and signal error."
418 (defun backward-word-mark (&optional arg
)
419 "Ensure mark is active; move backward until encountering the end of a word.
420 With argument, do this that many times."
425 (defun backward-sexp-mark (&optional arg
)
426 "Ensure mark is active; move backward across one balanced expression (sexp).
427 With argument, do it that many times. Negative arg -N means
428 move forward across N balanced expressions."
433 (defun backward-paragraph-mark (&optional arg
)
434 "Ensure mark is active; move backward to start of paragraph.
435 With arg N, do it N times; negative arg -N means move forward N paragraphs.
437 A paragraph start is the beginning of a line which is a
438 `first-line-of-paragraph' or which is ordinary text and follows a
439 paragraph-separating line; except: if the first real line of a
440 paragraph is preceded by a blank line, the paragraph starts at that
443 See `forward-paragraph' for more information."
446 (backward-paragraph arg
))
448 (defun previous-line-mark (&optional arg
)
449 "Ensure mark is active; move cursor vertically up ARG lines.
450 If there is no character in the target line exactly over the current column,
451 the cursor is positioned after the character in that line which spans this
452 column, or at the end of the line if it is not long enough.
454 The command C-x C-n can be used to create
455 a semipermanent goal column to which this command always moves.
456 Then it does not try to move vertically.
458 If you are thinking of using this in a Lisp program, consider using
459 `forward-line' with a negative argument instead. It is usually easier
460 to use and more reliable (no dependence on goal column, etc.)."
464 (setq this-command
'previous-line
))
466 (defun beginning-of-line-mark (&optional arg
)
467 "Ensure mark is active; move point to beginning of current line.
468 With argument ARG not nil or 1, move forward ARG - 1 lines first.
469 If scan reaches end of buffer, stop there without error."
472 (beginning-of-line arg
))
475 (defun scroll-up-mark (&optional arg
)
476 "Ensure mark is active; scroll upward ARG lines; or near full screen if no ARG.
477 A near full screen is `next-screen-context-lines' less than a full screen.
478 Negative ARG means scroll downward.
479 When calling from a program, supply a number as argument or nil."
482 (cond (pc-select-override-scroll-error
483 (condition-case nil
(scroll-up arg
)
484 (end-of-buffer (goto-char (point-max)))))
485 (t (scroll-up arg
))))
487 (defun beginning-of-buffer-mark (&optional arg
)
488 "Ensure mark is active; move point to the beginning of the buffer.
489 With arg N, put point N/10 of the way from the beginning.
491 If the buffer is narrowed, this command uses the beginning and size
492 of the accessible part of the buffer.
494 Don't use this command in Lisp programs!
495 \(goto-char (p\oint-min)) is faster and avoids clobbering the mark."
498 (let ((size (- (point-max) (point-min))))
502 ;; Avoid overflow for large buffer sizes!
503 (* (prefix-numeric-value arg
)
505 (/ (+ 10 (* size
(prefix-numeric-value arg
))) 10)))
507 (if arg
(forward-line 1)))
513 (defun backward-char-nomark (&optional arg
)
514 "Deactivate mark; move point left ARG characters (right if ARG negative).
515 On attempt to pass beginning or end of buffer, stop and signal error."
517 (setq mark-active nil
)
520 (defun backward-word-nomark (&optional arg
)
521 "Deactivate mark; move backward until encountering the end of a word.
522 With argument, do this that many times."
524 (setq mark-active nil
)
527 (defun backward-sexp-nomark (&optional arg
)
528 "Deactivate mark; move backward across one balanced expression (sexp).
529 With argument, do it that many times. Negative arg -N means
530 move forward across N balanced expressions."
532 (setq mark-active nil
)
535 (defun backward-paragraph-nomark (&optional arg
)
536 "Deactivate mark; move backward to start of paragraph.
537 With arg N, do it N times; negative arg -N means move forward N paragraphs.
539 A paragraph start is the beginning of a line which is a
540 `first-line-of-paragraph' or which is ordinary text and follows a
541 paragraph-separating line; except: if the first real line of a
542 paragraph is preceded by a blank line, the paragraph starts at that
545 See `forward-paragraph' for more information."
547 (setq mark-active nil
)
548 (backward-paragraph arg
))
550 (defun previous-line-nomark (&optional arg
)
551 "Deactivate mark; move cursor vertically up ARG lines.
552 If there is no character in the target line exactly over the current column,
553 the cursor is positioned after the character in that line which spans this
554 column, or at the end of the line if it is not long enough.
556 The command C-x C-n can be used to create
557 a semipermanent goal column to which this command always moves.
558 Then it does not try to move vertically."
560 (setq mark-active nil
)
562 (setq this-command
'previous-line
))
564 (defun beginning-of-line-nomark (&optional arg
)
565 "Deactivate mark; move point to beginning of current line.
566 With argument ARG not nil or 1, move forward ARG - 1 lines first.
567 If scan reaches end of buffer, stop there without error."
569 (setq mark-active nil
)
570 (beginning-of-line arg
))
572 (defun scroll-up-nomark (&optional arg
)
573 "Deactivate mark; scroll upward ARG lines; or near full screen if no ARG.
574 A near full screen is `next-screen-context-lines' less than a full screen.
575 Negative ARG means scroll downward.
576 When calling from a program, supply a number as argument or nil."
578 (setq mark-active nil
)
579 (cond (pc-select-override-scroll-error
580 (condition-case nil
(scroll-up arg
)
581 (end-of-buffer (goto-char (point-max)))))
582 (t (scroll-up arg
))))
584 (defun beginning-of-buffer-nomark (&optional arg
)
585 "Deactivate mark; move point to the beginning of the buffer.
586 With arg N, put point N/10 of the way from the beginning.
588 If the buffer is narrowed, this command uses the beginning and size
589 of the accessible part of the buffer.
591 Don't use this command in Lisp programs!
592 \(goto-char (point-min)) is faster and avoids clobbering the mark."
594 (setq mark-active nil
)
595 (let ((size (- (point-max) (point-min))))
599 ;; Avoid overflow for large buffer sizes!
600 (* (prefix-numeric-value arg
)
602 (/ (+ 10 (* size
(prefix-numeric-value arg
))) 10)))
604 (if arg
(forward-line 1)))
607 (defun pc-selection-mode ()
608 "Change mark behaviour to emulate Motif, MAC or MS-Windows cut and paste style.
610 This mode enables Delete Selection mode and Transient Mark mode.
612 The arrow keys (and others) are bound to new functions
613 which modify the status of the mark.
615 The ordinary arrow keys disable the mark.
616 The shift-arrow keys move, leaving the mark behind.
618 C-LEFT and C-RIGHT move back or forward one word, disabling the mark.
619 S-C-LEFT and S-C-RIGHT move back or forward one word, leaving the mark behind.
621 M-LEFT and M-RIGHT move back or forward one word or sexp, disabling the mark.
622 S-M-LEFT and S-M-RIGHT move back or forward one word or sexp, leaving the mark
623 behind. To control wether these keys move word-wise or sexp-wise set the
624 variable pc-select-meta-moves-sexps after loading pc-select.el but before
625 turning pc-selection-mode on.
627 C-DOWN and C-UP move back or forward a paragraph, disabling the mark.
628 S-C-DOWN and S-C-UP move back or forward a paragraph, leaving the mark behind.
630 HOME moves to beginning of line, disabling the mark.
631 S-HOME moves to beginning of line, leaving the mark behind.
632 With Ctrl or Meta, these keys move to beginning of buffer instead.
634 END moves to end of line, disabling the mark.
635 S-END moves to end of line, leaving the mark behind.
636 With Ctrl or Meta, these keys move to end of buffer instead.
638 PRIOR or PAGE-UP scrolls and disables the mark.
639 S-PRIOR or S-PAGE-UP scrolls and leaves the mark behind.
641 S-DELETE kills the region (`kill-region').
642 S-INSERT yanks text from the kill ring (`yank').
643 C-INSERT copies the region into the kill ring (`copy-region-as-kill').
645 In addition, certain other PC bindings are imitated (to avoid this, set
646 the variable pc-select-selection-keys-only to t after loading pc-select.el
647 but before calling pc-selection-mode):
654 C-BACKSPACE backward-kill-word
662 ;; This is to avoid confusion with the delete-selection-mode
663 ;; On simple displays you can't see that a region is active and
664 ;; will be deleted on the next keypress. IMHO especially for
665 ;; copy-region-as-kill this is confusing.
666 ;; The same goes for exchange-point-and-mark
667 (define-key global-map
"\M-w" 'copy-region-as-kill-nomark
)
668 (define-key global-map
"\C-x\C-x" 'exchange-point-and-mark-nomark
)
669 ;; The following keybindings are for standard ISO keyboards
670 ;; as they are used with IBM compatible PCs, IBM RS/6000,
671 ;; MACs, many X-Stations and probably more
672 (define-key global-map
[S-right
] 'forward-char-mark
)
673 (define-key global-map
[right] 'forward-char-nomark)
674 (define-key global-map [C-S-right] 'forward-word-mark)
675 (define-key global-map [C-right] 'forward-word-nomark)
676 (define-key global-map [S-left] 'backward-char-mark)
677 (define-key global-map [left] 'backward-char-nomark)
678 (define-key global-map [C-S-left] 'backward-word-mark)
679 (define-key global-map [C-left] 'backward-word-nomark)
680 (cond (pc-select-meta-moves-sexps
681 (define-key global-map [M-S-right] 'forward-sexp-mark)
682 (define-key global-map [M-right] 'forward-sexp-nomark)
683 (define-key global-map [M-S-left] 'backward-sexp-mark)
684 (define-key global-map [M-left] 'backward-sexp-nomark))
686 (define-key global-map [M-S-right] 'forward-word-mark)
687 (define-key global-map [M-right] 'forward-word-nomark)
688 (define-key global-map [M-S-left] 'backward-word-mark)
689 (define-key global-map [M-left] 'backward-word-nomark)))
691 (define-key global-map [S-down] 'next-line-mark)
692 (define-key global-map [down] 'next-line-nomark)
694 (define-key global-map [S-end] 'end-of-line-mark)
695 (define-key global-map [end] 'end-of-line-nomark)
696 (global-set-key [S-C-end] 'end-of-buffer-mark)
697 (global-set-key [C-end] 'end-of-buffer-nomark)
698 (global-set-key [S-M-end] 'end-of-buffer-mark)
699 (global-set-key [M-end] 'end-of-buffer-nomark)
701 (define-key global-map [S-next] 'scroll-up-mark)
702 (define-key global-map [next] 'scroll-up-nomark)
704 (define-key global-map [S-up] 'previous-line-mark)
705 (define-key global-map [up] 'previous-line-nomark)
707 (define-key global-map [S-home] 'beginning-of-line-mark)
708 (define-key global-map [home] 'beginning-of-line-nomark)
709 (global-set-key [S-C-home] 'beginning-of-buffer-mark)
710 (global-set-key [C-home] 'beginning-of-buffer-nomark)
711 (global-set-key [S-M-home] 'beginning-of-buffer-mark)
712 (global-set-key [M-home] 'beginning-of-buffer-nomark)
714 (define-key global-map [M-S-down] 'forward-line-mark)
715 (define-key global-map [M-down] 'forward-line-nomark)
716 (define-key global-map [M-S-up] 'backward-line-mark)
717 (define-key global-map [M-up] 'backward-line-nomark)
719 (define-key global-map [S-prior] 'scroll-down-mark)
720 (define-key global-map [prior] 'scroll-down-nomark)
722 ;; Next four lines are from Pete Forman.
723 (global-set-key [C-down] 'forward-paragraph-nomark) ; KNextPara cDn
724 (global-set-key [C-up] 'backward-paragraph-nomark) ; KPrevPara cUp
725 (global-set-key [S-C-down] 'forward-paragraph-mark)
726 (global-set-key [S-C-up] 'backward-paragraph-mark)
728 (or pc-select-selection-keys-only
730 (define-key global-map [S-insert] 'yank)
731 (define-key global-map [C-insert] 'copy-region-as-kill)
732 (define-key global-map [S-delete] 'kill-region)
734 ;; The following bindings are useful on Sun Type 3 keyboards
735 ;; They implement the Get-Delete-Put (copy-cut-paste)
736 ;; functions from sunview on the L6, L8 and L10 keys
737 ;; Sam Steingold <sds@gnu.org> says that f16 is copy and f18 is paste.
738 (define-key global-map [f16] 'copy-region-as-kill)
739 (define-key global-map [f18] 'yank)
740 (define-key global-map [f20] 'kill-region)
742 ;; The following bindings are from Pete Forman.
743 (global-set-key [f6] 'other-window) ; KNextPane F6
744 (global-set-key [delete] 'delete-char) ; KDelete Del
745 (global-set-key [C-delete] 'kill-line) ; KEraseEndLine cDel
746 (global-set-key "\M-\d" 'undo) ; KUndo aBS
748 ;; The following bindings are taken from pc-mode.el
749 ;; as suggested by RMS.
750 ;; I only used the ones that are not covered above.
751 (define-key function-key-map [M-delete] [?\M-d])
752 (global-set-key [C-M-delete] 'kill-sexp)
753 (global-set-key [C-backspace] 'backward-kill-word)
754 ;; Next line proposed by Eli Barzilay
755 (global-set-key [C-escape] 'electric-buffer-list)))
759 ;; Next line proposed by Eli Barzilay
760 (setq highlight-nonselected-windows nil)
761 (setq transient-mark-mode t)
762 (setq mark-even-if-inactive t)
763 (delete-selection-mode 1)
767 (defcustom pc-selection-mode nil
768 "Toggle PC Selection mode.
769 Change mark behaviour to emulate Motif, MAC or MS-Windows cut and paste style,
770 and cursor movement commands.
771 This mode enables Delete Selection mode and Transient Mark mode.
772 You must modify via \\[customize] for this variable to have an effect."
773 :set (lambda (symbol value)
774 (if value (pc-selection-mode)))
779 ;;; pc-select.el ends here