comparison lisp/emulation/pc-select.el @ 41299:77b08a460f84

Doc string fixes. (pc-selection-mode): Don't treat macos as a tty.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Mon, 19 Nov 2001 23:09:28 +0000
parents b174db545cfd
children 6134751ae11f
comparison
equal deleted inserted replaced
41298:dd0332958888 41299:77b08a460f84
77 ;; other programs. 77 ;; other programs.
78 ;; 78 ;;
79 79
80 ;;; Code: 80 ;;; Code:
81 81
82 ;;;; Customization: 82 ;; Customization:
83 (defgroup pc-select nil 83 (defgroup pc-select nil
84 "Emulate pc bindings." 84 "Emulate pc bindings."
85 :prefix "pc-select" 85 :prefix "pc-select"
86 :group 'editing-basics 86 :group 'editing-basics
87 :group 'convenience) 87 :group 'convenience)
117 (defun copy-region-as-kill-nomark (beg end) 117 (defun copy-region-as-kill-nomark (beg end)
118 "Save the region as if killed; but don't kill it; deactivate mark. 118 "Save the region as if killed; but don't kill it; deactivate mark.
119 If `interprogram-cut-function' is non-nil, also save the text for a window 119 If `interprogram-cut-function' is non-nil, also save the text for a window
120 system cut and paste. 120 system cut and paste.
121 121
122 Deactivating mark is to avoid confusion with delete-selection-mode 122 Deactivating mark is to avoid confusion with `delete-selection-mode'
123 and transient-mark-mode." 123 and `transient-mark-mode'."
124 (interactive "r") 124 (interactive "r")
125 (copy-region-as-kill beg end) 125 (copy-region-as-kill beg end)
126 (setq mark-active nil) 126 (setq mark-active nil)
127 (message "Region saved")) 127 (message "Region saved"))
128 128
129 (defun exchange-point-and-mark-nomark () 129 (defun exchange-point-and-mark-nomark ()
130 "Like `exchange-point-and-mark' but without activating the mark."
130 (interactive) 131 (interactive)
131 (exchange-point-and-mark) 132 (exchange-point-and-mark)
132 (setq mark-active nil)) 133 (setq mark-active nil))
133 134
134 ;;;; 135 ;;;;
196 value of `next-line-add-newlines'. If non-nil, it inserts a newline character 197 value of `next-line-add-newlines'. If non-nil, it inserts a newline character
197 to create a line, and moves the cursor to that line. Otherwise it moves the 198 to create a line, and moves the cursor to that line. Otherwise it moves the
198 cursor to the end of the buffer \(if already at the end of the buffer, an error 199 cursor to the end of the buffer \(if already at the end of the buffer, an error
199 is signaled). 200 is signaled).
200 201
201 The command C-x C-n can be used to create 202 The command \\[set-goal-column] can be used to create
202 a semipermanent goal column to which this command always moves. 203 a semipermanent goal column to which this command always moves.
203 Then it does not try to move vertically. This goal column is stored 204 Then it does not try to move vertically. This goal column is stored
204 in `goal-column', which is nil when there is none." 205 in `goal-column', which is nil when there is none."
205 (interactive "p") 206 (interactive "p")
206 (ensure-mark) 207 (ensure-mark)
329 value of `next-line-add-newlines'. If non-nil, it inserts a newline character 330 value of `next-line-add-newlines'. If non-nil, it inserts a newline character
330 to create a line, and moves the cursor to that line. Otherwise it moves the 331 to create a line, and moves the cursor to that line. Otherwise it moves the
331 cursor to the end of the buffer (if already at the end of the buffer, an error 332 cursor to the end of the buffer (if already at the end of the buffer, an error
332 is signaled). 333 is signaled).
333 334
334 The command C-x C-n can be used to create 335 The command \\[set-goal-column] can be used to create
335 a semipermanent goal column to which this command always moves. 336 a semipermanent goal column to which this command always moves.
336 Then it does not try to move vertically. This goal column is stored 337 Then it does not try to move vertically. This goal column is stored
337 in `goal-column', which is nil when there is none." 338 in `goal-column', which is nil when there is none."
338 (interactive "p") 339 (interactive "p")
339 (setq mark-active nil) 340 (setq mark-active nil)
451 "Ensure mark is active; move cursor vertically up ARG lines. 452 "Ensure mark is active; move cursor vertically up ARG lines.
452 If there is no character in the target line exactly over the current column, 453 If there is no character in the target line exactly over the current column,
453 the cursor is positioned after the character in that line which spans this 454 the cursor is positioned after the character in that line which spans this
454 column, or at the end of the line if it is not long enough. 455 column, or at the end of the line if it is not long enough.
455 456
456 The command C-x C-n can be used to create 457 The command \\[set-goal-column] can be used to create
457 a semipermanent goal column to which this command always moves. 458 a semipermanent goal column to which this command always moves.
458 Then it does not try to move vertically. 459 Then it does not try to move vertically.
459 460
460 If you are thinking of using this in a Lisp program, consider using 461 If you are thinking of using this in a Lisp program, consider using
461 `forward-line' with a negative argument instead. It is usually easier 462 `forward-line' with a negative argument instead. It is usually easier
553 "Deactivate mark; move cursor vertically up ARG lines. 554 "Deactivate mark; move cursor vertically up ARG lines.
554 If there is no character in the target line exactly over the current column, 555 If there is no character in the target line exactly over the current column,
555 the cursor is positioned after the character in that line which spans this 556 the cursor is positioned after the character in that line which spans this
556 column, or at the end of the line if it is not long enough. 557 column, or at the end of the line if it is not long enough.
557 558
558 The command C-x C-n can be used to create 559 The command \\[set-goal-column] can be used to create
559 a semipermanent goal column to which this command always moves. 560 a semipermanent goal column to which this command always moves.
560 Then it does not try to move vertically." 561 Then it does not try to move vertically."
561 (interactive "p") 562 (interactive "p")
562 (setq mark-active nil) 563 (setq mark-active nil)
563 (previous-line arg) 564 (previous-line arg)
620 C-LEFT and C-RIGHT move back or forward one word, disabling the mark. 621 C-LEFT and C-RIGHT move back or forward one word, disabling the mark.
621 S-C-LEFT and S-C-RIGHT move back or forward one word, leaving the mark behind. 622 S-C-LEFT and S-C-RIGHT move back or forward one word, leaving the mark behind.
622 623
623 M-LEFT and M-RIGHT move back or forward one word or sexp, disabling the mark. 624 M-LEFT and M-RIGHT move back or forward one word or sexp, disabling the mark.
624 S-M-LEFT and S-M-RIGHT move back or forward one word or sexp, leaving the mark 625 S-M-LEFT and S-M-RIGHT move back or forward one word or sexp, leaving the mark
625 behind. To control wether these keys move word-wise or sexp-wise set the 626 behind. To control whether these keys move word-wise or sexp-wise set the
626 variable pc-select-meta-moves-sexps after loading pc-select.el but before 627 variable `pc-select-meta-moves-sexps' after loading pc-select.el but before
627 turning pc-selection-mode on. 628 turning `pc-selection-mode' on.
628 629
629 C-DOWN and C-UP move back or forward a paragraph, disabling the mark. 630 C-DOWN and C-UP move back or forward a paragraph, disabling the mark.
630 S-C-DOWN and S-C-UP move back or forward a paragraph, leaving the mark behind. 631 S-C-DOWN and S-C-UP move back or forward a paragraph, leaving the mark behind.
631 632
632 HOME moves to beginning of line, disabling the mark. 633 HOME moves to beginning of line, disabling the mark.
643 S-DELETE kills the region (`kill-region'). 644 S-DELETE kills the region (`kill-region').
644 S-INSERT yanks text from the kill ring (`yank'). 645 S-INSERT yanks text from the kill ring (`yank').
645 C-INSERT copies the region into the kill ring (`copy-region-as-kill'). 646 C-INSERT copies the region into the kill ring (`copy-region-as-kill').
646 647
647 In addition, certain other PC bindings are imitated (to avoid this, set 648 In addition, certain other PC bindings are imitated (to avoid this, set
648 the variable pc-select-selection-keys-only to t after loading pc-select.el 649 the variable `pc-select-selection-keys-only' to t after loading pc-select.el
649 but before calling pc-selection-mode): 650 but before calling `pc-selection-mode'):
650 651
651 F6 other-window 652 F6 `other-window'
652 DELETE delete-char 653 DELETE `delete-char'
653 C-DELETE kill-line 654 C-DELETE `kill-line'
654 M-DELETE kill-word 655 M-DELETE `kill-word'
655 C-M-DELETE kill-sexp 656 C-M-DELETE `kill-sexp'
656 C-BACKSPACE backward-kill-word 657 C-BACKSPACE `backward-kill-word'
657 M-BACKSPACE undo" 658 M-BACKSPACE `undo'"
658 659 ;; FIXME: make into a proper minor mode (i.e. undoable).
660 ;; FIXME: bring pc-bindings-mode here ?
659 (interactive) 661 (interactive)
660 ;; 662 ;;
661 ;; keybindings 663 ;; keybindings
662 ;; 664 ;;
663 665
725 (global-set-key [C-down] 'forward-paragraph-nomark) ; KNextPara cDn 727 (global-set-key [C-down] 'forward-paragraph-nomark) ; KNextPara cDn
726 (global-set-key [C-up] 'backward-paragraph-nomark) ; KPrevPara cUp 728 (global-set-key [C-up] 'backward-paragraph-nomark) ; KPrevPara cUp
727 (global-set-key [S-C-down] 'forward-paragraph-mark) 729 (global-set-key [S-C-down] 'forward-paragraph-mark)
728 (global-set-key [S-C-up] 'backward-paragraph-mark) 730 (global-set-key [S-C-up] 'backward-paragraph-mark)
729 731
730 (or pc-select-selection-keys-only 732 (unless pc-select-selection-keys-only
731 (progn 733 ;; We are behaving like normal-erase-is-backspace-mode, so
732 ;; We are behaving like normal-erase-is-backspace-mode, so 734 ;; say so explicitly. But don't do that on a Unix tty, since
733 ;; say so explicitly. But don't do that on a Unix tty, since 735 ;; some of them have keyboards that by default already behave
734 ;; some of them have keyboards that by default already behave 736 ;; as if normal-erase-is-backspace mode is on, and turning it
735 ;; as if normal-erase-is-backspace mode is on, and turning it 737 ;; a second time screws them up.
736 ;; a second time screws them up. 738 (if (or (eq window-system 'x)
737 (if (or (eq window-system 'x) 739 (memq system-name '(ms-dos windows-nt macos)))
738 (memq system-name '(ms-dos windows-nt))) 740 (progn
739 (progn 741 (setq-default normal-erase-is-backspace t)
740 (setq-default normal-erase-is-backspace t) 742 (normal-erase-is-backspace-mode 1))
741 (normal-erase-is-backspace-mode 1)) 743 ;; This is for tty. We don't turn on normal-erase-is-backspace,
742 ;; This is for tty. We don't turn on normal-erase-is-backspace, 744 ;; but bind keys as pc-selection-mode did before
743 ;; but bind keys as pc-selection-mode did before 745 ;; normal-erase-is-backspace was invented, to keep us back
744 ;; normal-erase-is-backspace was invented, to keep us back 746 ;; compatible.
745 ;; compatible. 747 (global-set-key [delete] 'delete-char) ; KDelete Del
746 (global-set-key [delete] 'delete-char) ; KDelete Del 748 (define-key function-key-map [M-delete] [?\M-d])
747 (define-key function-key-map [M-delete] [?\M-d]) 749 (global-set-key [C-backspace] 'backward-kill-word))
748 (global-set-key [C-backspace] 'backward-kill-word)) 750 (define-key global-map [S-insert] 'yank)
749 (define-key global-map [S-insert] 'yank) 751 (define-key global-map [C-insert] 'copy-region-as-kill)
750 (define-key global-map [C-insert] 'copy-region-as-kill) 752 (define-key global-map [S-delete] 'kill-region)
751 (define-key global-map [S-delete] 'kill-region) 753
752 754 ;; The following bindings are useful on Sun Type 3 keyboards
753 ;; The following bindings are useful on Sun Type 3 keyboards 755 ;; They implement the Get-Delete-Put (copy-cut-paste)
754 ;; They implement the Get-Delete-Put (copy-cut-paste) 756 ;; functions from sunview on the L6, L8 and L10 keys
755 ;; functions from sunview on the L6, L8 and L10 keys 757 ;; Sam Steingold <sds@gnu.org> says that f16 is copy and f18 is paste.
756 ;; Sam Steingold <sds@gnu.org> says that f16 is copy and f18 is paste. 758 (define-key global-map [f16] 'copy-region-as-kill)
757 (define-key global-map [f16] 'copy-region-as-kill) 759 (define-key global-map [f18] 'yank)
758 (define-key global-map [f18] 'yank) 760 (define-key global-map [f20] 'kill-region)
759 (define-key global-map [f20] 'kill-region) 761
760 762 ;; The following bindings are from Pete Forman.
761 ;; The following bindings are from Pete Forman. 763 (global-set-key [f6] 'other-window) ; KNextPane F6
762 (global-set-key [f6] 'other-window) ; KNextPane F6 764 (global-set-key [C-delete] 'kill-line) ; KEraseEndLine cDel
763 (global-set-key [C-delete] 'kill-line) ; KEraseEndLine cDel 765 (global-set-key "\M-\d" 'undo) ; KUndo aBS
764 (global-set-key "\M-\d" 'undo) ; KUndo aBS 766
765 767 ;; The following binding is taken from pc-mode.el
766 ;; The following binding is taken from pc-mode.el 768 ;; as suggested by RMS.
767 ;; as suggested by RMS. 769 ;; I only used the one that is not covered above.
768 ;; I only used the one that is not covered above. 770 (global-set-key [C-M-delete] 'kill-sexp)
769 (global-set-key [C-M-delete] 'kill-sexp) 771 ;; Next line proposed by Eli Barzilay
770 ;; Next line proposed by Eli Barzilay 772 (global-set-key [C-escape] 'electric-buffer-list))
771 (global-set-key [C-escape] 'electric-buffer-list)))
772 ;; 773 ;;
773 ;; setup 774 ;; setup
774 ;; 775 ;;
775 ;; Next line proposed by Eli Barzilay 776 ;; Next line proposed by Eli Barzilay
776 (setq highlight-nonselected-windows nil) 777 (setq highlight-nonselected-windows nil)
777 (setq transient-mark-mode t) 778 (transient-mark-mode 1)
778 (setq mark-even-if-inactive t) 779 (setq mark-even-if-inactive t)
779 (delete-selection-mode 1) 780 (delete-selection-mode 1))
780 )
781 781
782 ;;;###autoload 782 ;;;###autoload
783 (defcustom pc-selection-mode nil 783 (defcustom pc-selection-mode nil
784 "Toggle PC Selection mode. 784 "Toggle PC Selection mode.
785 Change mark behaviour to emulate Motif, MAC or MS-Windows cut and paste style, 785 Change mark behaviour to emulate Motif, MAC or MS-Windows cut and paste style,