aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lisp/emulation/pc-select.el165
1 files changed, 114 insertions, 51 deletions
diff --git a/lisp/emulation/pc-select.el b/lisp/emulation/pc-select.el
index fb001e8295a..e0e6aa2c215 100644
--- a/lisp/emulation/pc-select.el
+++ b/lisp/emulation/pc-select.el
@@ -1,8 +1,8 @@
1;;; pc-select.el --- emulate mark, cut, copy and paste from motif 1;;; pc-select.el --- emulate mark, cut, copy and paste from Motif
2;;; (or MAC GUI) or MS-windoze (bah)) look-and-feel 2;;; (or MAC GUI or MS-windoze (bah)) look-and-feel
3;;; including key bindings 3;;; including key bindings.
4 4
5;; Copyright (C) 1995, 1996 Free Software Foundation, Inc. 5;; Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
6 6
7;; Author: Michael Staats <michael@thp.Uni-Duisburg.DE> 7;; Author: Michael Staats <michael@thp.Uni-Duisburg.DE>
8;; Created: 26 Sep 1995 8;; Created: 26 Sep 1995
@@ -57,6 +57,8 @@
57;; concerning setting of this-command. 57;; concerning setting of this-command.
58;; Dan Nicolaescu <done@nexus.sorostm.ro> suggested suppressing the 58;; Dan Nicolaescu <done@nexus.sorostm.ro> suggested suppressing the
59;; scroll-up/scroll-down error. 59;; scroll-up/scroll-down error.
60;; Eli Barzilay (eli@cs.bgu.ac.il) suggested the sexps functions and
61;; keybindings.
60;; 62;;
61;; Ok, some details about the idea of pc-selection-mode: 63;; Ok, some details about the idea of pc-selection-mode:
62;; 64;;
@@ -84,6 +86,14 @@ past 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 86text with these commands. If you set this variable to non-nil, these
85errors are suppressed.") 87errors are suppressed.")
86 88
89(defvar pc-select-selection-keys-only nil
90 "*Non-nil means only bind the basic selection keys when started.
91Other keys that emulate pc-behavior will be untouched.
92This gives mostly Emacs-like behaviour with only the selection keys enabled.")
93
94(defvar pc-select-meta-moves-sexps nil
95 "*Non-nil means move sexp-wise with Meta key, otherwise move word-wise.")
96
87;;;; 97;;;;
88;; misc 98;; misc
89;;;; 99;;;;
@@ -102,6 +112,11 @@ and transient-mark-mode."
102 (setq mark-active nil) 112 (setq mark-active nil)
103 (message "Region saved")) 113 (message "Region saved"))
104 114
115(defun exchange-point-and-mark-nomark ()
116 (interactive)
117 (exchange-point-and-mark)
118 (setq mark-active nil))
119
105;;;; 120;;;;
106;; non-interactive 121;; non-interactive
107;;;; 122;;;;
@@ -138,6 +153,14 @@ and nil is returned."
138 (setq this-command 'forward-line) 153 (setq this-command 'forward-line)
139) 154)
140 155
156(defun forward-sexp-mark (&optional arg)
157 "Ensure mark is active; move forward across one balanced expression (sexp).
158With argument, do it that many times. Negative arg -N means
159move backward across N balanced expressions."
160 (interactive "p")
161 (ensure-mark)
162 (forward-sexp arg))
163
141(defun forward-paragraph-mark (&optional arg) 164(defun forward-paragraph-mark (&optional arg)
142 "Ensure mark is active; move forward to end of paragraph. 165 "Ensure mark is active; move forward to end of paragraph.
143With arg N, do it N times; negative arg -N means move backward N paragraphs. 166With arg N, do it N times; negative arg -N means move backward N paragraphs.
@@ -263,6 +286,14 @@ and nil is returned."
263 (setq this-command 'forward-line) 286 (setq this-command 'forward-line)
264) 287)
265 288
289(defun forward-sexp-nomark (&optional arg)
290 "Deactivate mark; move forward across one balanced expression (sexp).
291With argument, do it that many times. Negative arg -N means
292move backward across N balanced expressions."
293 (interactive "p")
294 (setq mark-active nil)
295 (forward-sexp arg))
296
266(defun forward-paragraph-nomark (&optional arg) 297(defun forward-paragraph-nomark (&optional arg)
267 "Deactivate mark; move forward to end of paragraph. 298 "Deactivate mark; move forward to end of paragraph.
268With arg N, do it N times; negative arg -N means move backward N paragraphs. 299With arg N, do it N times; negative arg -N means move backward N paragraphs.
@@ -379,6 +410,14 @@ With argument, do this that many times."
379 (ensure-mark) 410 (ensure-mark)
380 (backward-word arg)) 411 (backward-word arg))
381 412
413(defun backward-sexp-mark (&optional arg)
414 "Ensure mark is active; move backward across one balanced expression (sexp).
415With argument, do it that many times. Negative arg -N means
416move forward across N balanced expressions."
417 (interactive "p")
418 (ensure-mark)
419 (backward-sexp arg))
420
382(defun backward-paragraph-mark (&optional arg) 421(defun backward-paragraph-mark (&optional arg)
383 "Ensure mark is active; move backward to start of paragraph. 422 "Ensure mark is active; move backward to start of paragraph.
384With arg N, do it N times; negative arg -N means move forward N paragraphs. 423With arg N, do it N times; negative arg -N means move forward N paragraphs.
@@ -473,6 +512,14 @@ With argument, do this that many times."
473 (setq mark-active nil) 512 (setq mark-active nil)
474 (backward-word arg)) 513 (backward-word arg))
475 514
515(defun backward-sexp-nomark (&optional arg)
516 "Deactivate mark; move backward across one balanced expression (sexp).
517With argument, do it that many times. Negative arg -N means
518move forward across N balanced expressions."
519 (interactive "p")
520 (setq mark-active nil)
521 (backward-sexp arg))
522
476(defun backward-paragraph-nomark (&optional arg) 523(defun backward-paragraph-nomark (&optional arg)
477 "Deactivate mark; move backward to start of paragraph. 524 "Deactivate mark; move backward to start of paragraph.
478With arg N, do it N times; negative arg -N means move forward N paragraphs. 525With arg N, do it N times; negative arg -N means move forward N paragraphs.
@@ -559,6 +606,12 @@ The shift-arrow keys move, leaving the mark behind.
559C-LEFT and C-RIGHT move back or forward one word, disabling the mark. 606C-LEFT and C-RIGHT move back or forward one word, disabling the mark.
560S-C-LEFT and S-C-RIGHT move back or forward one word, leaving the mark behind. 607S-C-LEFT and S-C-RIGHT move back or forward one word, leaving the mark behind.
561 608
609M-LEFT and M-RIGHT move back or forward one word or sexp, disabling the mark.
610S-M-LEFT and S-M-RIGHT move back or forward one word or sexp, leaving the mark
611behind. To control wether these keys move word-wise or sexp-wise set the
612variable pc-select-meta-moves-sexps after loading pc-select.el but before
613turning pc-selection-mode on.
614
562C-DOWN and C-UP move back or forward a paragraph, disabling the mark. 615C-DOWN and C-UP move back or forward a paragraph, disabling the mark.
563S-C-DOWN and S-C-UP move back or forward a paragraph, leaving the mark behind. 616S-C-DOWN and S-C-UP move back or forward a paragraph, leaving the mark behind.
564 617
@@ -577,7 +630,9 @@ S-DELETE kills the region (`kill-region').
577S-INSERT yanks text from the kill ring (`yank'). 630S-INSERT yanks text from the kill ring (`yank').
578C-INSERT copies the region into the kill ring (`copy-region-as-kill'). 631C-INSERT copies the region into the kill ring (`copy-region-as-kill').
579 632
580In addition, certain other PC bindings are imitated: 633In addition, certain other PC bindings are imitated (to avoid this, set
634the variable pc-select-selection-keys-only to t after loading pc-select.el
635but before calling pc-selection-mode):
581 636
582 F6 other-window 637 F6 other-window
583 DELETE delete-char 638 DELETE delete-char
@@ -594,11 +649,11 @@ In addition, certain other PC bindings are imitated:
594 649
595 ;; This is to avoid confusion with the delete-selection-mode 650 ;; This is to avoid confusion with the delete-selection-mode
596 ;; On simple displays you can't see that a region is active and 651 ;; On simple displays you can't see that a region is active and
597 ;; will be deleted on the next keypress. IMHO especially for 652 ;; will be deleted on the next keypress. IMHO especially for
598 ;; copy-region-as-kill this is confusing 653 ;; copy-region-as-kill this is confusing.
654 ;; The same goes for exchange-point-and-mark
599 (define-key global-map "\M-w" 'copy-region-as-kill-nomark) 655 (define-key global-map "\M-w" 'copy-region-as-kill-nomark)
600 656 (define-key global-map "\C-x\C-x" 'exchange-point-and-mark-nomark)
601
602 ;; The following keybindings are for standard ISO keyboards 657 ;; The following keybindings are for standard ISO keyboards
603 ;; as they are used with IBM compatible PCs, IBM RS/6000, 658 ;; as they are used with IBM compatible PCs, IBM RS/6000,
604 ;; MACs, many X-Stations and probably more 659 ;; MACs, many X-Stations and probably more
@@ -606,8 +661,20 @@ In addition, certain other PC bindings are imitated:
606 (define-key global-map [right] 'forward-char-nomark) 661 (define-key global-map [right] 'forward-char-nomark)
607 (define-key global-map [C-S-right] 'forward-word-mark) 662 (define-key global-map [C-S-right] 'forward-word-mark)
608 (define-key global-map [C-right] 'forward-word-nomark) 663 (define-key global-map [C-right] 'forward-word-nomark)
609 (define-key global-map [M-S-right] 'forward-word-mark) 664 (define-key global-map [S-left] 'backward-char-mark)
610 (define-key global-map [M-right] 'forward-word-nomark) 665 (define-key global-map [left] 'backward-char-nomark)
666 (define-key global-map [C-S-left] 'backward-word-mark)
667 (define-key global-map [C-left] 'backward-word-nomark)
668 (cond (pc-select-meta-moves-sexps
669 (define-key global-map [M-S-right] 'forward-sexp-mark)
670 (define-key global-map [M-right] 'forward-sexp-nomark)
671 (define-key global-map [M-S-left] 'backward-sexp-mark)
672 (define-key global-map [M-left] 'backward-sexp-nomark))
673 (t
674 (define-key global-map [M-S-right] 'forward-word-mark)
675 (define-key global-map [M-right] 'forward-word-nomark)
676 (define-key global-map [M-S-left] 'backward-word-mark)
677 (define-key global-map [M-left] 'backward-word-nomark)))
611 678
612 (define-key global-map [S-down] 'next-line-mark) 679 (define-key global-map [S-down] 'next-line-mark)
613 (define-key global-map [down] 'next-line-nomark) 680 (define-key global-map [down] 'next-line-nomark)
@@ -622,13 +689,6 @@ In addition, certain other PC bindings are imitated:
622 (define-key global-map [S-next] 'scroll-up-mark) 689 (define-key global-map [S-next] 'scroll-up-mark)
623 (define-key global-map [next] 'scroll-up-nomark) 690 (define-key global-map [next] 'scroll-up-nomark)
624 691
625 (define-key global-map [S-left] 'backward-char-mark)
626 (define-key global-map [left] 'backward-char-nomark)
627 (define-key global-map [C-S-left] 'backward-word-mark)
628 (define-key global-map [C-left] 'backward-word-nomark)
629 (define-key global-map [M-S-left] 'backward-word-mark)
630 (define-key global-map [M-left] 'backward-word-nomark)
631
632 (define-key global-map [S-up] 'previous-line-mark) 692 (define-key global-map [S-up] 'previous-line-mark)
633 (define-key global-map [up] 'previous-line-nomark) 693 (define-key global-map [up] 'previous-line-nomark)
634 694
@@ -639,50 +699,53 @@ In addition, certain other PC bindings are imitated:
639 (global-set-key [S-M-home] 'beginning-of-buffer-mark) 699 (global-set-key [S-M-home] 'beginning-of-buffer-mark)
640 (global-set-key [M-home] 'beginning-of-buffer-nomark) 700 (global-set-key [M-home] 'beginning-of-buffer-nomark)
641 701
642 (define-key global-map [S-prior] 'scroll-down-mark)
643 (define-key global-map [prior] 'scroll-down-nomark)
644
645 (define-key global-map [S-insert] 'yank)
646 (define-key global-map [C-insert] 'copy-region-as-kill)
647 (define-key global-map [S-delete] 'kill-region)
648
649 (define-key global-map [M-S-down] 'forward-line-mark) 702 (define-key global-map [M-S-down] 'forward-line-mark)
650 (define-key global-map [M-down] 'forward-line-nomark) 703 (define-key global-map [M-down] 'forward-line-nomark)
651 (define-key global-map [M-S-up] 'backward-line-mark) 704 (define-key global-map [M-S-up] 'backward-line-mark)
652 (define-key global-map [M-up] 'backward-line-nomark) 705 (define-key global-map [M-up] 'backward-line-nomark)
653 706
654 ;; The following bindings are useful on Sun Type 3 keyboards 707 (define-key global-map [S-prior] 'scroll-down-mark)
655 ;; They implement the Get-Delete-Put (copy-cut-paste) 708 (define-key global-map [prior] 'scroll-down-nomark)
656 ;; functions from sunview on the L6, L8 and L10 keys 709
657 ;; Sam Steingold <sds@ptc.com> says that f16 is copy and f18 is paste. 710 ;; Next four lines are from Pete Forman.
658 (define-key global-map [f16] 'copy-region-as-kill) 711 (global-set-key [C-down] 'forward-paragraph-nomark) ; KNextPara cDn
659 (define-key global-map [f18] 'yank) 712 (global-set-key [C-up] 'backward-paragraph-nomark) ; KPrevPara cUp
660 (define-key global-map [f20] 'kill-region)
661
662 ;; The following bindings are from Pete Forman.
663 ;; I modified them a little to work together with the
664 ;; mark functionality I added.
665
666 (global-set-key [f6] 'other-window) ; KNextPane F6
667 (global-set-key [delete] 'delete-char) ; KDelete Del
668 (global-set-key [C-delete] 'kill-line) ; KEraseEndLine cDel
669 (global-set-key [M-backspace] 'undo) ; KUndo aBS
670 (global-set-key [C-down] 'forward-paragraph-nomark) ; KNextPara cDn
671 (global-set-key [C-up] 'backward-paragraph-nomark) ; KPrevPara cUp
672 (global-set-key [S-C-down] 'forward-paragraph-mark) 713 (global-set-key [S-C-down] 'forward-paragraph-mark)
673 (global-set-key [S-C-up] 'backward-paragraph-mark) 714 (global-set-key [S-C-up] 'backward-paragraph-mark)
674 715
675 ;; The following bindings are taken from pc-mode.el 716 (or pc-select-selection-keys-only
676 ;; as suggested by RMS. 717 (progn
677 ;; I only used the ones that are not covered above. 718 (define-key global-map [S-insert] 'yank)
678 (define-key function-key-map [M-delete] [?\M-d]) 719 (define-key global-map [C-insert] 'copy-region-as-kill)
679 (global-set-key [C-M-delete] 'kill-sexp) 720 (define-key global-map [S-delete] 'kill-region)
680 (global-set-key [C-backspace] 'backward-kill-word) 721
681 (global-set-key [C-escape] 'list-buffers) 722 ;; The following bindings are useful on Sun Type 3 keyboards
682 723 ;; They implement the Get-Delete-Put (copy-cut-paste)
724 ;; functions from sunview on the L6, L8 and L10 keys
725 ;; Sam Steingold <sds@ptc.com> says that f16 is copy and f18 is paste.
726 (define-key global-map [f16] 'copy-region-as-kill)
727 (define-key global-map [f18] 'yank)
728 (define-key global-map [f20] 'kill-region)
729
730 ;; The following bindings are from Pete Forman.
731 (global-set-key [f6] 'other-window) ; KNextPane F6
732 (global-set-key [delete] 'delete-char) ; KDelete Del
733 (global-set-key [C-delete] 'kill-line) ; KEraseEndLine cDel
734 (global-set-key [M-backspace] 'undo) ; KUndo aBS
735
736 ;; The following bindings are taken from pc-mode.el
737 ;; as suggested by RMS.
738 ;; I only used the ones that are not covered above.
739 (define-key function-key-map [M-delete] [?\M-d])
740 (global-set-key [C-M-delete] 'kill-sexp)
741 (global-set-key [C-backspace] 'backward-kill-word)
742 ;; Next line proposed by Eli Barzilay
743 (global-set-key [C-escape] 'electric-buffer-list)))
683 ;; 744 ;;
684 ;; setup 745 ;; setup
685 ;; 746 ;;
747 ;; Next line proposed by Eli Barzilay
748 (setq highlight-nonselected-windows nil)
686 (setq transient-mark-mode t) 749 (setq transient-mark-mode t)
687 (setq mark-even-if-inactive t) 750 (setq mark-even-if-inactive t)
688 (delete-selection-mode 1) 751 (delete-selection-mode 1)