annotate lisp/emulation/pc-select.el @ 56083:d62a2b6e582e

Doc fixes: say "PC Selection mode", not "`pc-selection-mode'".
author Richard M. Stallman <rms@gnu.org>
date Sun, 13 Jun 2004 22:02:49 +0000
parents 695cf19ef79e
children cac7024af280 4c90ffeb71c5
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4
42980
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
5 ;; Copyright (C) 1995, 1996, 1997, 2000, 2001 Free Software Foundation, Inc.
13233
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7 ;; Author: Michael Staats <michael@thp.Uni-Duisburg.DE>
31566
9d3da289cab8 Add `emulation' to keywords.
Dave Love <fx@gnu.org>
parents: 30792
diff changeset
8 ;; Keywords: convenience emulation
13233
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
9 ;; Created: 26 Sep 1995
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
10
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
11 ;; This file is part of GNU Emacs.
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
12
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
13 ;; GNU Emacs is free software; you can redistribute it and/or modify
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
14 ;; it under the terms of the GNU General Public License as published by
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
15 ;; the Free Software Foundation; either version 2, or (at your option)
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
16 ;; any later version.
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
17
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
18 ;; GNU Emacs is distributed in the hope that it will be useful,
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
19 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
21 ;; GNU General Public License for more details.
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
22
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
23 ;; You should have received a copy of the GNU General Public License
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14040
diff changeset
24 ;; along with GNU Emacs; see the file COPYING. If not, write to the
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14040
diff changeset
25 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14040
diff changeset
26 ;; Boston, MA 02111-1307, USA.
13233
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
27
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
28 ;;; Commentary:
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14040
diff changeset
29
13233
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
30 ;; This package emulates the mark, copy, cut and paste look-and-feel of motif
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
31 ;; programs (which is the same as the MAC gui and (sorry for that) MS-Windows).
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
32 ;; It modifies the keybindings of the cursor keys and the next, prior,
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
33 ;; home and end keys. They will modify mark-active.
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
34 ;; You can still get the old behaviour of cursor moving with the
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
35 ;; control sequences C-f, C-b, etc.
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
36 ;; This package uses transient-mark-mode and
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
37 ;; delete-selection-mode.
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
38 ;;
30792
97c0caec0a32 fixed sds e-mail
Sam Steingold <sds@gnu.org>
parents: 29807
diff changeset
39 ;; In addition to that all key-bindings from the pc-mode are
13233
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
40 ;; done here too (as suggested by RMS).
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
41 ;;
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
42 ;; As I found out after I finished the first version, s-region.el tries
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
43 ;; to do the same.... But my code is a little more complete and using
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
44 ;; delete-selection-mode is very important for the look-and-feel.
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
45 ;; Pete Forman <pete.forman@airgun.wg.waii.com> provided some motif
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
46 ;; compliant keybindings which I added. I had to modify them a little
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
47 ;; to add the -mark and -nomark functionality of cursor moving.
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
48 ;;
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
49 ;; Credits:
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
50 ;; Many thanks to all who made comments.
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
51 ;; Thanks to RMS and Ralf Muschall <prm@rz.uni-jena.de> for criticism.
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
52 ;; Kevin Cutts <cutts@ukraine.corp.mot.com> added the beginning-of-buffer
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
53 ;; and end-of-buffer functions which I modified a little.
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
54 ;; David Biesack <sasdjb@unx.sas.com> suggested some more cleanup.
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
55 ;; Thanks to Pete Forman <pete.forman@airgun.wg.waii.com>
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
56 ;; for additional motif keybindings.
14382
d74d8edde304 Add some keybindings.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
57 ;; Thanks to jvromans@squirrel.nl (Johan Vromans) for a bug report
d74d8edde304 Add some keybindings.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
58 ;; concerning setting of this-command.
19289
4e824f1fe62d Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18216
diff changeset
59 ;; Dan Nicolaescu <done@ece.arizona.ro> suggested suppressing the
15907
c25492075289 Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 14734
diff changeset
60 ;; scroll-up/scroll-down error.
18216
75f7eec6d388 (pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 17915
diff changeset
61 ;; Eli Barzilay (eli@cs.bgu.ac.il) suggested the sexps functions and
30792
97c0caec0a32 fixed sds e-mail
Sam Steingold <sds@gnu.org>
parents: 29807
diff changeset
62 ;; keybindings.
13233
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
63 ;;
56083
d62a2b6e582e Doc fixes: say "PC Selection mode", not "`pc-selection-mode'".
Richard M. Stallman <rms@gnu.org>
parents: 52401
diff changeset
64 ;; Ok, some details about the idea of PC Selection mode:
13233
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
65 ;;
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
66 ;; o The standard keys for moving around (right, left, up, down, home, end,
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
67 ;; prior, next, called "move-keys" from now on) will always de-activate
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
68 ;; the mark.
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
69 ;; o If you press "Shift" together with the "move-keys", the region
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
70 ;; you pass along is activated
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
71 ;; o You have the copy, cut and paste functions (as in many other programs)
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
72 ;; which will operate on the active region
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
73 ;; It was not possible to bind them to C-v, C-x and C-c for obvious
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
74 ;; emacs reasons.
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
75 ;; They will be bound according to the "old" behaviour to S-delete (cut),
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
76 ;; S-insert (paste) and C-insert (copy). These keys do the same in many
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
77 ;; other programs.
15907
c25492075289 Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 14734
diff changeset
78 ;;
13233
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
79
38436
b174db545cfd Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents: 37334
diff changeset
80 ;;; Code:
b174db545cfd Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents: 37334
diff changeset
81
41299
77b08a460f84 Doc string fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38436
diff changeset
82 ;; Customization:
19289
4e824f1fe62d Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18216
diff changeset
83 (defgroup pc-select nil
4e824f1fe62d Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18216
diff changeset
84 "Emulate pc bindings."
4e824f1fe62d Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18216
diff changeset
85 :prefix "pc-select"
22250
a77d473867b8 *** empty log message ***
Dan Nicolaescu <done@ece.arizona.edu>
parents: 19289
diff changeset
86 :group 'editing-basics
a77d473867b8 *** empty log message ***
Dan Nicolaescu <done@ece.arizona.edu>
parents: 19289
diff changeset
87 :group 'convenience)
15907
c25492075289 Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 14734
diff changeset
88
19289
4e824f1fe62d Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18216
diff changeset
89 (defcustom pc-select-override-scroll-error t
15907
c25492075289 Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 14734
diff changeset
90 "*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
91 This variable applies in PC Selection mode only.
c25492075289 Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 14734
diff changeset
92 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
93 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
94 text with these commands. If you set this variable to non-nil, these
19289
4e824f1fe62d Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18216
diff changeset
95 errors are suppressed."
4e824f1fe62d Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18216
diff changeset
96 :type 'boolean
4e824f1fe62d Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18216
diff changeset
97 :group 'pc-select)
13233
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
98
19289
4e824f1fe62d Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18216
diff changeset
99 (defcustom pc-select-selection-keys-only nil
18216
75f7eec6d388 (pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 17915
diff changeset
100 "*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
101 Other keys that emulate pc-behavior will be untouched.
19289
4e824f1fe62d Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18216
diff changeset
102 This gives mostly Emacs-like behaviour with only the selection keys enabled."
4e824f1fe62d Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18216
diff changeset
103 :type 'boolean
4e824f1fe62d Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18216
diff changeset
104 :group 'pc-select)
18216
75f7eec6d388 (pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 17915
diff changeset
105
19289
4e824f1fe62d Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18216
diff changeset
106 (defcustom pc-select-meta-moves-sexps nil
4e824f1fe62d Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18216
diff changeset
107 "*Non-nil means move sexp-wise with Meta key, otherwise move word-wise."
4e824f1fe62d Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18216
diff changeset
108 :type 'boolean
4e824f1fe62d Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18216
diff changeset
109 :group 'pc-select)
18216
75f7eec6d388 (pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 17915
diff changeset
110
42980
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
111 (defcustom pc-selection-mode-hook nil
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
112 "The hook to run when pc-selection-mode is toggled."
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
113 :type 'hook
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
114 :group 'pc-select)
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
115
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
116 (defvar pc-select-saved-settings-alist nil
56083
d62a2b6e582e Doc fixes: say "PC Selection mode", not "`pc-selection-mode'".
Richard M. Stallman <rms@gnu.org>
parents: 52401
diff changeset
117 "The values of the variables before PC Selection mode was toggled on.
d62a2b6e582e Doc fixes: say "PC Selection mode", not "`pc-selection-mode'".
Richard M. Stallman <rms@gnu.org>
parents: 52401
diff changeset
118 When PC Selection mode is toggled on, it sets quite a few variables
42980
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
119 for its own purposes. This alist holds the original values of the
56083
d62a2b6e582e Doc fixes: say "PC Selection mode", not "`pc-selection-mode'".
Richard M. Stallman <rms@gnu.org>
parents: 52401
diff changeset
120 variables PC Selection mode had set, so that these variables can be
d62a2b6e582e Doc fixes: say "PC Selection mode", not "`pc-selection-mode'".
Richard M. Stallman <rms@gnu.org>
parents: 52401
diff changeset
121 restored to their original values when PC Selection mode is toggled off.")
42980
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
122
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
123 (defvar pc-select-map nil
56083
d62a2b6e582e Doc fixes: say "PC Selection mode", not "`pc-selection-mode'".
Richard M. Stallman <rms@gnu.org>
parents: 52401
diff changeset
124 "The keymap used as the global map when PC Selection mode is on." )
42980
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
125
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
126 (defvar pc-select-saved-global-map nil
56083
d62a2b6e582e Doc fixes: say "PC Selection mode", not "`pc-selection-mode'".
Richard M. Stallman <rms@gnu.org>
parents: 52401
diff changeset
127 "The global map that was in effect when PC Selection mode was toggled on.")
42980
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
128
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
129 (defvar pc-select-key-bindings-alist nil
56083
d62a2b6e582e Doc fixes: say "PC Selection mode", not "`pc-selection-mode'".
Richard M. Stallman <rms@gnu.org>
parents: 52401
diff changeset
130 "This alist holds all the key bindings PC Selection mode sets.")
42980
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
131
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
132 (defvar pc-select-default-key-bindings nil
56083
d62a2b6e582e Doc fixes: say "PC Selection mode", not "`pc-selection-mode'".
Richard M. Stallman <rms@gnu.org>
parents: 52401
diff changeset
133 "These key bindings always get set by PC Selection mode.")
42980
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
134
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
135 (unless pc-select-default-key-bindings
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
136 (let ((lst
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
137 ;; This is to avoid confusion with the delete-selection-mode
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
138 ;; On simple displays you cant see that a region is active and
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
139 ;; will be deleted on the next keypress IMHO especially for
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
140 ;; copy-region-as-kill this is confusing.
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
141 ;; The same goes for exchange-point-and-mark
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
142 '(("\M-w" . copy-region-as-kill-nomark)
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
143 ("\C-x\C-x" . exchange-point-and-mark-nomark)
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
144 ([S-right] . forward-char-mark)
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
145 ([right] . forward-char-nomark)
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
146 ([C-S-right] . forward-word-mark)
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
147 ([C-right] . forward-word-nomark)
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
148 ([S-left] . backward-char-mark)
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
149 ([left] . backward-char-nomark)
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
150 ([C-S-left] . backward-word-mark)
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
151 ([C-left] . backward-word-nomark)
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
152 ([S-down] . next-line-mark)
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
153 ([down] . next-line-nomark)
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
154
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
155 ([S-end] . end-of-line-mark)
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
156 ([end] . end-of-line-nomark)
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
157 ([S-C-end] . end-of-buffer-mark)
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
158 ([C-end] . end-of-buffer-nomark)
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
159 ([S-M-end] . end-of-buffer-mark)
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
160 ([M-end] . end-of-buffer-nomark)
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
161
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
162 ([S-next] . scroll-up-mark)
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
163 ([next] . scroll-up-nomark)
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
164
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
165 ([S-up] . previous-line-mark)
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
166 ([up] . previous-line-nomark)
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
167
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
168 ([S-home] . beginning-of-line-mark)
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
169 ([home] . beginning-of-line-nomark)
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
170 ([S-C-home] . beginning-of-buffer-mark)
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
171 ([C-home] . beginning-of-buffer-nomark)
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
172 ([S-M-home] . beginning-of-buffer-mark)
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
173 ([M-home] . beginning-of-buffer-nomark)
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
174
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
175 ([M-S-down] . forward-line-mark)
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
176 ([M-down] . forward-line-nomark)
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
177 ([M-S-up] . backward-line-mark)
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
178 ([M-up] . backward-line-nomark)
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
179
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
180 ([S-prior] . scroll-down-mark)
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
181 ([prior] . scroll-down-nomark)
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
182
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
183 ;; Next four lines are from Pete Forman.
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
184 ([C-down] . forward-paragraph-nomark) ; KNextPara cDn
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
185 ([C-up] . backward-paragraph-nomark) ; KPrevPara cUp
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
186 ([S-C-down] . forward-paragraph-mark)
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
187 ([S-C-up] . backward-paragraph-mark))))
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 43985
diff changeset
188
42980
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
189 (setq pc-select-default-key-bindings lst)))
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
190
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
191 (defvar pc-select-extra-key-bindings nil
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
192 "Key bindings to set only if `pc-select-selection-keys-only' is nil.")
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
193
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
194 ;; The following keybindings are for standard ISO keyboards
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
195 ;; as they are used with IBM compatible PCs, IBM RS/6000,
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
196 ;; MACs, many X-Stations and probably more
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
197 (unless pc-select-extra-key-bindings
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
198 (let ((lst
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
199 '(([S-insert] . yank)
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
200 ([C-insert] . copy-region-as-kill)
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
201 ([S-delete] . kill-region)
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
202
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
203 ;; The following bindings are useful on Sun Type 3 keyboards
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
204 ;; They implement the Get-Delete-Put (copy-cut-paste)
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
205 ;; functions from sunview on the L6, L8 and L10 keys
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
206 ;; Sam Steingold <sds@gnu.org> says that f16 is copy and f18 is paste.
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
207 ([f16] . copy-region-as-kill)
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
208 ([f18] . yank)
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
209 ([f20] . kill-region)
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
210
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
211 ;; The following bindings are from Pete Forman.
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
212 ([f6] . other-window) ; KNextPane F6
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
213 ([C-delete] . kill-line) ; KEraseEndLine cDel
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
214 ("\M-\d" . undo) ; KUndo aBS
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
215
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
216 ;; The following binding is taken from pc-mode.el
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
217 ;; as suggested by RMS.
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
218 ;; I only used the one that is not covered above.
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
219 ([C-M-delete] . kill-sexp)
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
220 ;; Next line proposed by Eli Barzilay
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
221 ([C-escape] . electric-buffer-list))))
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 43985
diff changeset
222
42980
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
223 (setq pc-select-extra-key-bindings lst)))
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
224
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
225 (defvar pc-select-meta-moves-sexps-key-bindings
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
226 '((([M-S-right] . forward-sexp-mark)
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
227 ([M-right] . forward-sexp-nomark)
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
228 ([M-S-left] . backward-sexp-mark)
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
229 ([M-left] . backward-sexp-nomark))
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
230 (([M-S-right] . forward-word-mark)
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
231 ([M-right] . forward-word-nomark)
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
232 ([M-S-left] . backward-word-mark)
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
233 ([M-left] . backward-word-nomark)))
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
234 "The list of key bindings controlled by `pc-select-meta-moves-sexp'.
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
235 The bindings in the car of this list get installed if
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
236 `pc-select-meta-moves-sexp' is t, the bindings in the cadr of this
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
237 list get installed otherwise.")
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
238
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
239 ;; This is for tty. We don't turn on normal-erase-is-backspace,
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
240 ;; but bind keys as pc-selection-mode did before
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
241 ;; normal-erase-is-backspace was invented, to keep us back
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
242 ;; compatible.
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
243 (defvar pc-select-tty-key-bindings
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
244 '(([delete] . delete-char) ; KDelete Del
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
245 ([C-backspace] . backward-kill-word))
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
246 "The list of key bindings controlled by `pc-select-selection-keys-only'.
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
247 These key bindings get installed when running in a tty, but only if
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
248 `pc-select-selection-keys-only' is nil.")
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
249
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
250 (defvar pc-select-old-M-delete-binding nil
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
251 "Holds the old mapping of [M-delete] in the `function-key-map'.
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
252 This variable holds the value associated with [M-delete] in the
56083
d62a2b6e582e Doc fixes: say "PC Selection mode", not "`pc-selection-mode'".
Richard M. Stallman <rms@gnu.org>
parents: 52401
diff changeset
253 `function-key-map' before PC Selection mode had changed that
42980
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
254 association.")
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
255
13233
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
256 ;;;;
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
257 ;; misc
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
258 ;;;;
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
259
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
260 (provide 'pc-select)
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
261
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
262 (defun copy-region-as-kill-nomark (beg end)
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
263 "Save the region as if killed; but don't kill it; deactivate mark.
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
264 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
265 system cut and paste.
c25492075289 Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 14734
diff changeset
266
41299
77b08a460f84 Doc string fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38436
diff changeset
267 Deactivating mark is to avoid confusion with `delete-selection-mode'
77b08a460f84 Doc string fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38436
diff changeset
268 and `transient-mark-mode'."
13233
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
269 (interactive "r")
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
270 (copy-region-as-kill beg end)
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
271 (setq mark-active nil)
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
272 (message "Region saved"))
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
273
18216
75f7eec6d388 (pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 17915
diff changeset
274 (defun exchange-point-and-mark-nomark ()
41299
77b08a460f84 Doc string fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38436
diff changeset
275 "Like `exchange-point-and-mark' but without activating the mark."
18216
75f7eec6d388 (pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 17915
diff changeset
276 (interactive)
75f7eec6d388 (pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 17915
diff changeset
277 (exchange-point-and-mark)
75f7eec6d388 (pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 17915
diff changeset
278 (setq mark-active nil))
75f7eec6d388 (pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 17915
diff changeset
279
13233
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
280 ;;;;
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
281 ;; non-interactive
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
282 ;;;;
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
283 (defun ensure-mark()
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
284 ;; make sure mark is active
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
285 ;; 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
286 (or mark-active (set-mark-command nil)))
13233
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
287
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
288 ;;;;;;;;;;;;;;;;;;;;;;;;;;;
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
289 ;;;;; forward and mark
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
290 ;;;;;;;;;;;;;;;;;;;;;;;;;;;
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
291
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
292 (defun forward-char-mark (&optional arg)
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
293 "Ensure mark is active; move point right ARG characters (left if ARG negative).
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
294 On reaching end of buffer, stop and signal error."
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
295 (interactive "p")
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
296 (ensure-mark)
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
297 (forward-char arg))
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
298
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
299 (defun forward-word-mark (&optional arg)
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
300 "Ensure mark is active; move point right ARG words (backward if ARG is negative).
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
301 Normally returns t.
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
302 If an edge of the buffer is reached, point is left there
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
303 and nil is returned."
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
304 (interactive "p")
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
305 (ensure-mark)
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
306 (forward-word arg))
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
307
15907
c25492075289 Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 14734
diff changeset
308 (defun forward-line-mark (&optional arg)
c25492075289 Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 14734
diff changeset
309 "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
310 (interactive "p")
c25492075289 Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 14734
diff changeset
311 (ensure-mark)
c25492075289 Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 14734
diff changeset
312 (forward-line arg)
c25492075289 Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 14734
diff changeset
313 (setq this-command 'forward-line)
c25492075289 Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 14734
diff changeset
314 )
c25492075289 Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 14734
diff changeset
315
18216
75f7eec6d388 (pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 17915
diff changeset
316 (defun forward-sexp-mark (&optional arg)
75f7eec6d388 (pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 17915
diff changeset
317 "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
318 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
319 move backward across N balanced expressions."
75f7eec6d388 (pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 17915
diff changeset
320 (interactive "p")
75f7eec6d388 (pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 17915
diff changeset
321 (ensure-mark)
75f7eec6d388 (pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 17915
diff changeset
322 (forward-sexp arg))
75f7eec6d388 (pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 17915
diff changeset
323
13233
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
324 (defun forward-paragraph-mark (&optional arg)
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
325 "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
326 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
327
13233
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
328 A line which `paragraph-start' matches either separates paragraphs
14382
d74d8edde304 Add some keybindings.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
329 \(if `paragraph-separate' matches it also) or is the first line of a paragraph.
13233
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
330 A paragraph end is the beginning of a line which is not part of the paragraph
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
331 to which the end of the previous line belongs, or the end of the buffer."
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
332 (interactive "p")
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
333 (ensure-mark)
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
334 (forward-paragraph arg))
15907
c25492075289 Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 14734
diff changeset
335
13233
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
336 (defun next-line-mark (&optional arg)
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
337 "Ensure mark is active; move cursor vertically down ARG lines.
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
338 If there is no character in the target line exactly under the current column,
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
339 the cursor is positioned after the character in that line which spans this
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
340 column, or at the end of the line if it is not long enough.
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
341 If there is no line in the buffer after this one, behavior depends on the
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
342 value of `next-line-add-newlines'. If non-nil, it inserts a newline character
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
343 to create a line, and moves the cursor to that line. Otherwise it moves the
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
344 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
345 is signaled).
c25492075289 Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 14734
diff changeset
346
41299
77b08a460f84 Doc string fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38436
diff changeset
347 The command \\[set-goal-column] can be used to create
13233
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
348 a semipermanent goal column to which this command always moves.
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
349 Then it does not try to move vertically. This goal column is stored
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
350 in `goal-column', which is nil when there is none."
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
351 (interactive "p")
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
352 (ensure-mark)
14382
d74d8edde304 Add some keybindings.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
353 (next-line arg)
d74d8edde304 Add some keybindings.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
354 (setq this-command 'next-line))
13233
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
355
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
356 (defun end-of-line-mark (&optional arg)
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
357 "Ensure mark is active; move point to end of current line.
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
358 With argument ARG not nil or 1, move forward ARG - 1 lines first.
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
359 If scan reaches end of buffer, stop there without error."
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
360 (interactive "p")
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
361 (ensure-mark)
14382
d74d8edde304 Add some keybindings.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
362 (end-of-line arg)
d74d8edde304 Add some keybindings.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
363 (setq this-command 'end-of-line))
13233
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
364
15907
c25492075289 Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 14734
diff changeset
365 (defun backward-line-mark (&optional arg)
c25492075289 Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 14734
diff changeset
366 "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
367 (interactive "p")
c25492075289 Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 14734
diff changeset
368 (ensure-mark)
c25492075289 Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 14734
diff changeset
369 (if (null arg)
c25492075289 Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 14734
diff changeset
370 (setq arg 1))
c25492075289 Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 14734
diff changeset
371 (forward-line (- arg))
c25492075289 Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 14734
diff changeset
372 (setq this-command 'forward-line)
c25492075289 Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 14734
diff changeset
373 )
c25492075289 Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 14734
diff changeset
374
13233
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
375 (defun scroll-down-mark (&optional arg)
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
376 "Ensure mark is active; scroll down ARG lines; or near full screen if no ARG.
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
377 A near full screen is `next-screen-context-lines' less than a full screen.
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
378 Negative ARG means scroll upward.
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
379 When calling from a program, supply a number as argument or nil."
30792
97c0caec0a32 fixed sds e-mail
Sam Steingold <sds@gnu.org>
parents: 29807
diff changeset
380 (interactive "P")
13233
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
381 (ensure-mark)
15931
c729af982039 (ensure-mark): Minor rewrite.
Richard M. Stallman <rms@gnu.org>
parents: 15907
diff changeset
382 (cond (pc-select-override-scroll-error
c729af982039 (ensure-mark): Minor rewrite.
Richard M. Stallman <rms@gnu.org>
parents: 15907
diff changeset
383 (condition-case nil (scroll-down arg)
c729af982039 (ensure-mark): Minor rewrite.
Richard M. Stallman <rms@gnu.org>
parents: 15907
diff changeset
384 (beginning-of-buffer (goto-char (point-min)))))
c729af982039 (ensure-mark): Minor rewrite.
Richard M. Stallman <rms@gnu.org>
parents: 15907
diff changeset
385 (t (scroll-down arg))))
13233
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
386
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
387 (defun end-of-buffer-mark (&optional arg)
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
388 "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
389 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
390
13233
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
391 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
392 of the accessible part of the buffer.
c25492075289 Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 14734
diff changeset
393
13233
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
394 Don't use this command in Lisp programs!
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
395 \(goto-char \(point-max)) is faster and avoids clobbering the mark."
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
396 (interactive "P")
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
397 (ensure-mark)
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
398 (let ((size (- (point-max) (point-min))))
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
399 (goto-char (if arg
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
400 (- (point-max)
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
401 (if (> size 10000)
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
402 ;; Avoid overflow for large buffer sizes!
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
403 (* (prefix-numeric-value arg)
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
404 (/ size 10))
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
405 (/ (* size (prefix-numeric-value arg)) 10)))
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
406 (point-max))))
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
407 ;; If we went to a place in the middle of the buffer,
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
408 ;; adjust it to the beginning of a line.
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
409 (if arg (forward-line 1)
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
410 ;; If the end of the buffer is not already on the screen,
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
411 ;; then scroll specially to put it near, but not at, the bottom.
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
412 (if (let ((old-point (point)))
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
413 (save-excursion
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
414 (goto-char (window-start))
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
415 (vertical-motion (window-height))
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
416 (< (point) old-point)))
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
417 (progn
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
418 (overlay-recenter (point))
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
419 (recenter -3)))))
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
420
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
421 ;;;;;;;;;
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
422 ;;;;; no mark
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
423 ;;;;;;;;;
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
424
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
425 (defun forward-char-nomark (&optional arg)
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
426 "Deactivate mark; move point right ARG characters \(left if ARG negative).
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
427 On reaching end of buffer, stop and signal error."
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
428 (interactive "p")
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
429 (setq mark-active nil)
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
430 (forward-char arg))
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
431
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
432 (defun forward-word-nomark (&optional arg)
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
433 "Deactivate mark; move point right ARG words \(backward if ARG is negative).
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
434 Normally returns t.
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
435 If an edge of the buffer is reached, point is left there
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
436 and nil is returned."
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
437 (interactive "p")
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
438 (setq mark-active nil)
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
439 (forward-word arg))
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
440
15907
c25492075289 Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 14734
diff changeset
441 (defun forward-line-nomark (&optional arg)
c25492075289 Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 14734
diff changeset
442 "Deactivate mark; move cursor vertically down ARG lines."
c25492075289 Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 14734
diff changeset
443 (interactive "p")
c25492075289 Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 14734
diff changeset
444 (setq mark-active nil)
c25492075289 Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 14734
diff changeset
445 (forward-line arg)
c25492075289 Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 14734
diff changeset
446 (setq this-command 'forward-line)
c25492075289 Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 14734
diff changeset
447 )
c25492075289 Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 14734
diff changeset
448
18216
75f7eec6d388 (pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 17915
diff changeset
449 (defun forward-sexp-nomark (&optional arg)
75f7eec6d388 (pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 17915
diff changeset
450 "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
451 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
452 move backward across N balanced expressions."
75f7eec6d388 (pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 17915
diff changeset
453 (interactive "p")
75f7eec6d388 (pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 17915
diff changeset
454 (setq mark-active nil)
75f7eec6d388 (pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 17915
diff changeset
455 (forward-sexp arg))
75f7eec6d388 (pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 17915
diff changeset
456
13233
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
457 (defun forward-paragraph-nomark (&optional arg)
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
458 "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
459 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
460
13233
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
461 A line which `paragraph-start' matches either separates paragraphs
14382
d74d8edde304 Add some keybindings.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
462 \(if `paragraph-separate' matches it also) or is the first line of a paragraph.
13233
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
463 A paragraph end is the beginning of a line which is not part of the paragraph
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
464 to which the end of the previous line belongs, or the end of the buffer."
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
465 (interactive "p")
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
466 (setq mark-active nil)
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
467 (forward-paragraph arg))
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
468
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
469 (defun next-line-nomark (&optional arg)
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
470 "Deactivate mark; move cursor vertically down ARG lines.
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
471 If there is no character in the target line exactly under the current column,
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
472 the cursor is positioned after the character in that line which spans this
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
473 column, or at the end of the line if it is not long enough.
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
474 If there is no line in the buffer after this one, behavior depends on the
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
475 value of `next-line-add-newlines'. If non-nil, it inserts a newline character
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
476 to create a line, and moves the cursor to that line. Otherwise it moves the
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
477 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
478 is signaled).
c25492075289 Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 14734
diff changeset
479
41299
77b08a460f84 Doc string fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38436
diff changeset
480 The command \\[set-goal-column] can be used to create
13233
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
481 a semipermanent goal column to which this command always moves.
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
482 Then it does not try to move vertically. This goal column is stored
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
483 in `goal-column', which is nil when there is none."
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
484 (interactive "p")
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
485 (setq mark-active nil)
14382
d74d8edde304 Add some keybindings.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
486 (next-line arg)
d74d8edde304 Add some keybindings.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
487 (setq this-command 'next-line))
13233
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
488
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
489 (defun end-of-line-nomark (&optional arg)
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
490 "Deactivate mark; move point to end of current line.
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
491 With argument ARG not nil or 1, move forward ARG - 1 lines first.
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
492 If scan reaches end of buffer, stop there without error."
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
493 (interactive "p")
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
494 (setq mark-active nil)
14382
d74d8edde304 Add some keybindings.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
495 (end-of-line arg)
d74d8edde304 Add some keybindings.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
496 (setq this-command 'end-of-line))
13233
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
497
15907
c25492075289 Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 14734
diff changeset
498 (defun backward-line-nomark (&optional arg)
c25492075289 Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 14734
diff changeset
499 "Deactivate mark; move cursor vertically up ARG lines."
c25492075289 Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 14734
diff changeset
500 (interactive "p")
c25492075289 Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 14734
diff changeset
501 (setq mark-active nil)
c25492075289 Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 14734
diff changeset
502 (if (null arg)
c25492075289 Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 14734
diff changeset
503 (setq arg 1))
c25492075289 Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 14734
diff changeset
504 (forward-line (- arg))
c25492075289 Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 14734
diff changeset
505 (setq this-command 'forward-line)
c25492075289 Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 14734
diff changeset
506 )
c25492075289 Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 14734
diff changeset
507
13233
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
508 (defun scroll-down-nomark (&optional arg)
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
509 "Deactivate mark; scroll down ARG lines; or near full screen if no ARG.
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
510 A near full screen is `next-screen-context-lines' less than a full screen.
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
511 Negative ARG means scroll upward.
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
512 When calling from a program, supply a number as argument or nil."
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
513 (interactive "P")
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
514 (setq mark-active nil)
15931
c729af982039 (ensure-mark): Minor rewrite.
Richard M. Stallman <rms@gnu.org>
parents: 15907
diff changeset
515 (cond (pc-select-override-scroll-error
c729af982039 (ensure-mark): Minor rewrite.
Richard M. Stallman <rms@gnu.org>
parents: 15907
diff changeset
516 (condition-case nil (scroll-down arg)
c729af982039 (ensure-mark): Minor rewrite.
Richard M. Stallman <rms@gnu.org>
parents: 15907
diff changeset
517 (beginning-of-buffer (goto-char (point-min)))))
c729af982039 (ensure-mark): Minor rewrite.
Richard M. Stallman <rms@gnu.org>
parents: 15907
diff changeset
518 (t (scroll-down arg))))
13233
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
519
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
520 (defun end-of-buffer-nomark (&optional arg)
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
521 "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
522 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
523
13233
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
524 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
525 of the accessible part of the buffer.
c25492075289 Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 14734
diff changeset
526
13233
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
527 Don't use this command in Lisp programs!
14382
d74d8edde304 Add some keybindings.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
528 \(goto-char (point-max)) is faster and avoids clobbering the mark."
13233
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
529 (interactive "P")
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
530 (setq mark-active nil)
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
531 (let ((size (- (point-max) (point-min))))
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
532 (goto-char (if arg
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
533 (- (point-max)
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
534 (if (> size 10000)
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
535 ;; Avoid overflow for large buffer sizes!
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
536 (* (prefix-numeric-value arg)
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
537 (/ size 10))
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
538 (/ (* size (prefix-numeric-value arg)) 10)))
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
539 (point-max))))
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
540 ;; If we went to a place in the middle of the buffer,
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
541 ;; adjust it to the beginning of a line.
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
542 (if arg (forward-line 1)
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
543 ;; If the end of the buffer is not already on the screen,
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
544 ;; then scroll specially to put it near, but not at, the bottom.
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
545 (if (let ((old-point (point)))
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
546 (save-excursion
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
547 (goto-char (window-start))
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
548 (vertical-motion (window-height))
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
549 (< (point) old-point)))
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
550 (progn
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
551 (overlay-recenter (point))
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
552 (recenter -3)))))
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
553
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
554
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
555 ;;;;;;;;;;;;;;;;;;;;
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
556 ;;;;;; backwards and mark
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
557 ;;;;;;;;;;;;;;;;;;;;
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
558
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
559 (defun backward-char-mark (&optional arg)
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
560 "Ensure mark is active; move point left ARG characters (right if ARG negative).
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
561 On attempt to pass beginning or end of buffer, stop and signal error."
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
562 (interactive "p")
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
563 (ensure-mark)
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
564 (backward-char arg))
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
565
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
566 (defun backward-word-mark (&optional arg)
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
567 "Ensure mark is active; move backward until encountering the end of a word.
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
568 With argument, do this that many times."
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
569 (interactive "p")
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
570 (ensure-mark)
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
571 (backward-word arg))
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
572
18216
75f7eec6d388 (pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 17915
diff changeset
573 (defun backward-sexp-mark (&optional arg)
75f7eec6d388 (pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 17915
diff changeset
574 "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
575 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
576 move forward across N balanced expressions."
75f7eec6d388 (pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 17915
diff changeset
577 (interactive "p")
75f7eec6d388 (pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 17915
diff changeset
578 (ensure-mark)
75f7eec6d388 (pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 17915
diff changeset
579 (backward-sexp arg))
75f7eec6d388 (pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 17915
diff changeset
580
13233
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
581 (defun backward-paragraph-mark (&optional arg)
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
582 "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
583 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
584
13233
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
585 A paragraph start is the beginning of a line which is a
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
586 `first-line-of-paragraph' or which is ordinary text and follows a
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
587 paragraph-separating line; except: if the first real line of a
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
588 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
589 blank line.
c25492075289 Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 14734
diff changeset
590
13233
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
591 See `forward-paragraph' for more information."
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
592 (interactive "p")
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
593 (ensure-mark)
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
594 (backward-paragraph arg))
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
595
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
596 (defun previous-line-mark (&optional arg)
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
597 "Ensure mark is active; move cursor vertically up ARG lines.
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
598 If there is no character in the target line exactly over the current column,
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
599 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
600 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
601
41299
77b08a460f84 Doc string fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38436
diff changeset
602 The command \\[set-goal-column] can be used to create
13233
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
603 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
604 Then it does not try to move vertically.
c25492075289 Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 14734
diff changeset
605
13233
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
606 If you are thinking of using this in a Lisp program, consider using
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
607 `forward-line' with a negative argument instead. It is usually easier
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
608 to use and more reliable (no dependence on goal column, etc.)."
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
609 (interactive "p")
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
610 (ensure-mark)
14382
d74d8edde304 Add some keybindings.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
611 (previous-line arg)
d74d8edde304 Add some keybindings.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
612 (setq this-command 'previous-line))
13233
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
613
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
614 (defun beginning-of-line-mark (&optional arg)
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
615 "Ensure mark is active; move point to beginning of current line.
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
616 With argument ARG not nil or 1, move forward ARG - 1 lines first.
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
617 If scan reaches end of buffer, stop there without error."
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
618 (interactive "p")
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
619 (ensure-mark)
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
620 (beginning-of-line arg))
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
621
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
622
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
623 (defun scroll-up-mark (&optional arg)
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
624 "Ensure mark is active; scroll upward ARG lines; or near full screen if no ARG.
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
625 A near full screen is `next-screen-context-lines' less than a full screen.
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
626 Negative ARG means scroll downward.
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
627 When calling from a program, supply a number as argument or nil."
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
628 (interactive "P")
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
629 (ensure-mark)
15931
c729af982039 (ensure-mark): Minor rewrite.
Richard M. Stallman <rms@gnu.org>
parents: 15907
diff changeset
630 (cond (pc-select-override-scroll-error
c729af982039 (ensure-mark): Minor rewrite.
Richard M. Stallman <rms@gnu.org>
parents: 15907
diff changeset
631 (condition-case nil (scroll-up arg)
c729af982039 (ensure-mark): Minor rewrite.
Richard M. Stallman <rms@gnu.org>
parents: 15907
diff changeset
632 (end-of-buffer (goto-char (point-max)))))
c729af982039 (ensure-mark): Minor rewrite.
Richard M. Stallman <rms@gnu.org>
parents: 15907
diff changeset
633 (t (scroll-up arg))))
13233
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
634
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
635 (defun beginning-of-buffer-mark (&optional arg)
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
636 "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
637 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
638
13233
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
639 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
640 of the accessible part of the buffer.
c25492075289 Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 14734
diff changeset
641
13233
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
642 Don't use this command in Lisp programs!
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
643 \(goto-char (p\oint-min)) is faster and avoids clobbering the mark."
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
644 (interactive "P")
30792
97c0caec0a32 fixed sds e-mail
Sam Steingold <sds@gnu.org>
parents: 29807
diff changeset
645 (ensure-mark)
13233
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
646 (let ((size (- (point-max) (point-min))))
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
647 (goto-char (if arg
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
648 (+ (point-min)
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
649 (if (> size 10000)
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
650 ;; Avoid overflow for large buffer sizes!
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
651 (* (prefix-numeric-value arg)
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
652 (/ size 10))
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
653 (/ (+ 10 (* size (prefix-numeric-value arg))) 10)))
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
654 (point-min))))
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
655 (if arg (forward-line 1)))
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
656
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
657 ;;;;;;;;
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
658 ;;; no mark
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
659 ;;;;;;;;
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
660
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
661 (defun backward-char-nomark (&optional arg)
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
662 "Deactivate mark; move point left ARG characters (right if ARG negative).
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
663 On attempt to pass beginning or end of buffer, stop and signal error."
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
664 (interactive "p")
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
665 (setq mark-active nil)
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
666 (backward-char arg))
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
667
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
668 (defun backward-word-nomark (&optional arg)
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
669 "Deactivate mark; move backward until encountering the end of a word.
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
670 With argument, do this that many times."
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
671 (interactive "p")
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
672 (setq mark-active nil)
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
673 (backward-word arg))
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
674
18216
75f7eec6d388 (pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 17915
diff changeset
675 (defun backward-sexp-nomark (&optional arg)
75f7eec6d388 (pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 17915
diff changeset
676 "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
677 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
678 move forward across N balanced expressions."
75f7eec6d388 (pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 17915
diff changeset
679 (interactive "p")
75f7eec6d388 (pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 17915
diff changeset
680 (setq mark-active nil)
75f7eec6d388 (pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 17915
diff changeset
681 (backward-sexp arg))
75f7eec6d388 (pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 17915
diff changeset
682
13233
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
683 (defun backward-paragraph-nomark (&optional arg)
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
684 "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
685 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
686
13233
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
687 A paragraph start is the beginning of a line which is a
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
688 `first-line-of-paragraph' or which is ordinary text and follows a
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
689 paragraph-separating line; except: if the first real line of a
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
690 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
691 blank line.
c25492075289 Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 14734
diff changeset
692
13233
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
693 See `forward-paragraph' for more information."
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
694 (interactive "p")
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
695 (setq mark-active nil)
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
696 (backward-paragraph arg))
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
697
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
698 (defun previous-line-nomark (&optional arg)
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
699 "Deactivate mark; move cursor vertically up ARG lines.
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
700 If there is no character in the target line exactly over the current column,
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
701 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
702 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
703
41299
77b08a460f84 Doc string fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38436
diff changeset
704 The command \\[set-goal-column] can be used to create
13233
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
705 a semipermanent goal column to which this command always moves.
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
706 Then it does not try to move vertically."
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
707 (interactive "p")
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
708 (setq mark-active nil)
14382
d74d8edde304 Add some keybindings.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
709 (previous-line arg)
d74d8edde304 Add some keybindings.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
710 (setq this-command 'previous-line))
13233
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
711
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
712 (defun beginning-of-line-nomark (&optional arg)
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
713 "Deactivate mark; move point to beginning of current line.
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
714 With argument ARG not nil or 1, move forward ARG - 1 lines first.
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
715 If scan reaches end of buffer, stop there without error."
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
716 (interactive "p")
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
717 (setq mark-active nil)
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
718 (beginning-of-line arg))
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
719
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
720 (defun scroll-up-nomark (&optional arg)
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
721 "Deactivate mark; scroll upward ARG lines; or near full screen if no ARG.
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
722 A near full screen is `next-screen-context-lines' less than a full screen.
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
723 Negative ARG means scroll downward.
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
724 When calling from a program, supply a number as argument or nil."
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
725 (interactive "P")
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
726 (setq mark-active nil)
15931
c729af982039 (ensure-mark): Minor rewrite.
Richard M. Stallman <rms@gnu.org>
parents: 15907
diff changeset
727 (cond (pc-select-override-scroll-error
c729af982039 (ensure-mark): Minor rewrite.
Richard M. Stallman <rms@gnu.org>
parents: 15907
diff changeset
728 (condition-case nil (scroll-up arg)
c729af982039 (ensure-mark): Minor rewrite.
Richard M. Stallman <rms@gnu.org>
parents: 15907
diff changeset
729 (end-of-buffer (goto-char (point-max)))))
c729af982039 (ensure-mark): Minor rewrite.
Richard M. Stallman <rms@gnu.org>
parents: 15907
diff changeset
730 (t (scroll-up arg))))
13233
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
731
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
732 (defun beginning-of-buffer-nomark (&optional arg)
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
733 "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
734 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
735
13233
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
736 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
737 of the accessible part of the buffer.
c25492075289 Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 14734
diff changeset
738
13233
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
739 Don't use this command in Lisp programs!
14382
d74d8edde304 Add some keybindings.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
740 \(goto-char (point-min)) is faster and avoids clobbering the mark."
13233
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
741 (interactive "P")
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
742 (setq mark-active nil)
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
743 (let ((size (- (point-max) (point-min))))
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
744 (goto-char (if arg
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
745 (+ (point-min)
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
746 (if (> size 10000)
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
747 ;; Avoid overflow for large buffer sizes!
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
748 (* (prefix-numeric-value arg)
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
749 (/ size 10))
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
750 (/ (+ 10 (* size (prefix-numeric-value arg))) 10)))
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
751 (point-min))))
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
752 (if arg (forward-line 1)))
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
753
42980
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
754
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
755 (defun pc-select-define-keys (alist keymap)
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
756 "Make KEYMAP have the key bindings specified in ALIST."
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
757 (let ((lst alist))
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
758 (while lst
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
759 (define-key keymap (caar lst) (cdar lst))
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
760 (setq lst (cdr lst)))))
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
761
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
762 (defun pc-select-restore-keys (alist keymap saved-map)
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
763 "Use ALIST to restore key bindings from SAVED-MAP into KEYMAP.
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
764 Go through all the key bindings in ALIST, and, for each key
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
765 binding, if KEYMAP and ALIST still agree on the key binding,
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
766 restore the previous value of that key binding from SAVED-MAP."
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
767 (let ((lst alist))
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
768 (while lst
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
769 (when (equal (lookup-key keymap (caar lst)) (cdar lst))
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
770 (define-key keymap (caar lst) (lookup-key saved-map (caar lst))))
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
771 (setq lst (cdr lst)))))
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
772
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
773 (defmacro pc-select-add-to-alist (alist var val)
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
774 "Ensure that ALIST contains the cons cell (VAR . VAL).
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
775 If a cons cell whose car is VAR is already on the ALIST, update the
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 43985
diff changeset
776 cdr of that cell with VAL. Otherwise, make a new cons cell
42980
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
777 \(VAR . VAL), and prepend it onto ALIST."
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
778 (let ((elt (make-symbol "elt")))
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
779 `(let ((,elt (assq ',var ,alist)))
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
780 (if ,elt
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
781 (setcdr ,elt ,val)
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
782 (setq ,alist (cons (cons ',var ,val) ,alist))))))
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
783
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
784 (defmacro pc-select-save-and-set-var (var newval)
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
785 "Set VAR to NEWVAL; save the old value.
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
786 The old value is saved on the `pc-select-saved-settings-alist'."
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
787 `(when (boundp ',var)
43025
32f6fb5c961f (pc-select-save-and-set-mode): Properly use MODE-VAR.
Richard M. Stallman <rms@gnu.org>
parents: 42980
diff changeset
788 (pc-select-add-to-alist pc-select-saved-settings-alist ,var ,var)
32f6fb5c961f (pc-select-save-and-set-mode): Properly use MODE-VAR.
Richard M. Stallman <rms@gnu.org>
parents: 42980
diff changeset
789 (setq ,var ,newval)))
42980
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
790
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
791 (defmacro pc-select-save-and-set-mode (mode &optional arg mode-var)
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
792 "Call the function MODE; save the old value of the variable MODE.
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
793 MODE is presumed to be a function which turns on a minor mode. First,
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
794 save the value of the variable MODE on `pc-select-saved-settings-alist'.
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
795 Then, if ARG is specified, call MODE with ARG, otherwise call it with
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
796 nil as an argument. If MODE-VAR is specified, save the value of the
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
797 variable MODE-VAR (instead of the value of the variable MODE) on
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
798 `pc-select-saved-settings-alist'."
43025
32f6fb5c961f (pc-select-save-and-set-mode): Properly use MODE-VAR.
Richard M. Stallman <rms@gnu.org>
parents: 42980
diff changeset
799 (unless mode-var (setq mode-var mode))
32f6fb5c961f (pc-select-save-and-set-mode): Properly use MODE-VAR.
Richard M. Stallman <rms@gnu.org>
parents: 42980
diff changeset
800 `(when (fboundp ',mode)
32f6fb5c961f (pc-select-save-and-set-mode): Properly use MODE-VAR.
Richard M. Stallman <rms@gnu.org>
parents: 42980
diff changeset
801 (pc-select-add-to-alist pc-select-saved-settings-alist
32f6fb5c961f (pc-select-save-and-set-mode): Properly use MODE-VAR.
Richard M. Stallman <rms@gnu.org>
parents: 42980
diff changeset
802 ,mode-var ,mode-var)
32f6fb5c961f (pc-select-save-and-set-mode): Properly use MODE-VAR.
Richard M. Stallman <rms@gnu.org>
parents: 42980
diff changeset
803 (,mode ,arg)))
42980
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
804
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
805 (defmacro pc-select-restore-var (var)
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 43985
diff changeset
806 "Restore the previous value of the variable VAR.
42980
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
807 Look up VAR's previous value in `pc-select-saved-settings-alist', and,
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
808 if the value is found, set VAR to that value."
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
809 (let ((elt (make-symbol "elt")))
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
810 `(let ((,elt (assq ',var pc-select-saved-settings-alist)))
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
811 (unless (null ,elt)
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
812 (setq ,var (cdr ,elt))))))
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
813
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
814 (defmacro pc-select-restore-mode (mode)
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
815 "Restore the previous state (either on or off) of the minor mode MODE.
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
816 Look up the value of the variable MODE on `pc-select-saved-settings-alist'.
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
817 If the value is non-nil, call the function MODE with an argument of
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
818 1, otherwise call it with an argument of -1."
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
819 (let ((elt (make-symbol "elt")))
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
820 `(when (fboundp ',mode)
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
821 (let ((,elt (assq ',mode pc-select-saved-settings-alist)))
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
822 (unless (null ,elt)
43025
32f6fb5c961f (pc-select-save-and-set-mode): Properly use MODE-VAR.
Richard M. Stallman <rms@gnu.org>
parents: 42980
diff changeset
823 (,mode (if (cdr ,elt) 1 -1)))))))
42980
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
824
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
825
13234
e3b1df16f4b4 (pc-selection-mode): Add autoload cookie.
Richard M. Stallman <rms@gnu.org>
parents: 13233
diff changeset
826 ;;;###autoload
42980
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
827 (define-minor-mode pc-selection-mode
15907
c25492075289 Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 14734
diff changeset
828 "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
829
c25492075289 Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 14734
diff changeset
830 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
831
c25492075289 Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 14734
diff changeset
832 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
833 which modify the status of the mark.
c25492075289 Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 14734
diff changeset
834
c25492075289 Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 14734
diff changeset
835 The ordinary arrow keys disable the mark.
c25492075289 Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 14734
diff changeset
836 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
837
c25492075289 Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 14734
diff changeset
838 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
839 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
840
18216
75f7eec6d388 (pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 17915
diff changeset
841 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
842 S-M-LEFT and S-M-RIGHT move back or forward one word or sexp, leaving the mark
41299
77b08a460f84 Doc string fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38436
diff changeset
843 behind. To control whether these keys move word-wise or sexp-wise set the
77b08a460f84 Doc string fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38436
diff changeset
844 variable `pc-select-meta-moves-sexps' after loading pc-select.el but before
56083
d62a2b6e582e Doc fixes: say "PC Selection mode", not "`pc-selection-mode'".
Richard M. Stallman <rms@gnu.org>
parents: 52401
diff changeset
845 turning PC Selection mode on.
18216
75f7eec6d388 (pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 17915
diff changeset
846
15907
c25492075289 Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 14734
diff changeset
847 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
848 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
849
c25492075289 Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 14734
diff changeset
850 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
851 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
852 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
853
c25492075289 Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 14734
diff changeset
854 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
855 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
856 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
857
c25492075289 Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 14734
diff changeset
858 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
859 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
860
c25492075289 Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 14734
diff changeset
861 S-DELETE kills the region (`kill-region').
c25492075289 Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 14734
diff changeset
862 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
863 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
864
18216
75f7eec6d388 (pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 17915
diff changeset
865 In addition, certain other PC bindings are imitated (to avoid this, set
41299
77b08a460f84 Doc string fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38436
diff changeset
866 the variable `pc-select-selection-keys-only' to t after loading pc-select.el
56083
d62a2b6e582e Doc fixes: say "PC Selection mode", not "`pc-selection-mode'".
Richard M. Stallman <rms@gnu.org>
parents: 52401
diff changeset
867 but before calling PC Selection mode):
15907
c25492075289 Replace \n in doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 14734
diff changeset
868
42980
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
869 F6 other-window
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
870 DELETE delete-char
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
871 C-DELETE kill-line
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
872 M-DELETE kill-word
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
873 C-M-DELETE kill-sexp
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
874 C-BACKSPACE backward-kill-word
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
875 M-BACKSPACE undo"
41299
77b08a460f84 Doc string fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38436
diff changeset
876 ;; FIXME: bring pc-bindings-mode here ?
42980
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
877 nil nil nil
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
878
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
879 :group 'pc-select
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
880 :global t
13233
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
881
42980
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
882 (if pc-selection-mode
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
883 (if (null pc-select-key-bindings-alist)
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
884 (progn
43985
2fab49a69d94 (pc-selection-mode): Alter the existing global map, don't replace it.
Richard M. Stallman <rms@gnu.org>
parents: 43025
diff changeset
885 (setq pc-select-saved-global-map (copy-keymap (current-global-map)))
42980
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
886 (setq pc-select-key-bindings-alist
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
887 (append pc-select-default-key-bindings
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
888 (if pc-select-selection-keys-only
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
889 nil
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
890 pc-select-extra-key-bindings)
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
891 (if pc-select-meta-moves-sexps
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
892 (car pc-select-meta-moves-sexps-key-bindings)
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
893 (cadr pc-select-meta-moves-sexps-key-bindings))
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
894 (if (or pc-select-selection-keys-only
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
895 (eq window-system 'x)
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
896 (memq system-name '(ms-dos windows-nt)))
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
897 nil
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
898 pc-select-tty-key-bindings)))
13233
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
899
43985
2fab49a69d94 (pc-selection-mode): Alter the existing global map, don't replace it.
Richard M. Stallman <rms@gnu.org>
parents: 43025
diff changeset
900 (pc-select-define-keys pc-select-key-bindings-alist
2fab49a69d94 (pc-selection-mode): Alter the existing global map, don't replace it.
Richard M. Stallman <rms@gnu.org>
parents: 43025
diff changeset
901 (current-global-map))
13233
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
902
42980
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
903 (unless (or pc-select-selection-keys-only
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
904 (eq window-system 'x)
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
905 (memq system-name '(ms-dos windows-nt)))
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
906 ;; it is not clear that we need the following line
43985
2fab49a69d94 (pc-selection-mode): Alter the existing global map, don't replace it.
Richard M. Stallman <rms@gnu.org>
parents: 43025
diff changeset
907 ;; I hope it doesn't do too much harm to leave it in, though...
42980
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
908 (setq pc-select-old-M-delete-binding
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
909 (lookup-key function-key-map [M-delete]))
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
910 (define-key function-key-map [M-delete] [?\M-d]))
13233
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
911
42980
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
912 (when (and (not pc-select-selection-keys-only)
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
913 (or (eq window-system 'x)
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
914 (memq system-name '(ms-dos windows-nt)))
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
915 (fboundp 'normal-erase-is-backspace-mode))
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
916 (pc-select-save-and-set-mode normal-erase-is-backspace-mode 1
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
917 normal-erase-is-backspace))
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
918 ;; the original author also had this above:
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
919 ;; (setq-default normal-erase-is-backspace t)
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
920 ;; However, the documentation for the variable says that
43985
2fab49a69d94 (pc-selection-mode): Alter the existing global map, don't replace it.
Richard M. Stallman <rms@gnu.org>
parents: 43025
diff changeset
921 ;; "setting it with setq has no effect", so I'm removing it.
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 43985
diff changeset
922
42980
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
923 (pc-select-save-and-set-var highlight-nonselected-windows nil)
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
924 (pc-select-save-and-set-var transient-mark-mode t)
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
925 (pc-select-save-and-set-var mark-even-if-inactive t)
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
926 (pc-select-save-and-set-mode delete-selection-mode 1))
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
927 ;;else
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
928 ;; If the user turned on pc-selection-mode a second time
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
929 ;; do not clobber the values of the variables that were
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
930 ;; saved from before pc-selection mode was activated --
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
931 ;; just make sure the values are the way we like them.
43985
2fab49a69d94 (pc-selection-mode): Alter the existing global map, don't replace it.
Richard M. Stallman <rms@gnu.org>
parents: 43025
diff changeset
932 (pc-select-define-keys pc-select-key-bindings-alist
2fab49a69d94 (pc-selection-mode): Alter the existing global map, don't replace it.
Richard M. Stallman <rms@gnu.org>
parents: 43025
diff changeset
933 (current-global-map))
42980
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
934 (unless (or pc-select-selection-keys-only
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
935 (eq window-system 'x)
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
936 (memq system-name '(ms-dos windows-nt)))
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
937 ;; it is not clear that we need the following line
43985
2fab49a69d94 (pc-selection-mode): Alter the existing global map, don't replace it.
Richard M. Stallman <rms@gnu.org>
parents: 43025
diff changeset
938 ;; I hope it doesn't do too much harm to leave it in, though...
42980
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
939 (define-key function-key-map [M-delete] [?\M-d]))
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
940 (when (and (not pc-select-selection-keys-only)
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
941 (or (eq window-system 'x)
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
942 (memq system-name '(ms-dos windows-nt)))
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
943 (fboundp 'normal-erase-is-backspace-mode))
41299
77b08a460f84 Doc string fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38436
diff changeset
944 (normal-erase-is-backspace-mode 1))
42980
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
945 (setq highlight-nonselected-windows nil)
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
946 (setq transient-mark-mode t)
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
947 (setq mark-even-if-inactive t)
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
948 (delete-selection-mode 1))
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
949 ;;else
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
950 (when pc-select-key-bindings-alist
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
951 (when (and (not pc-select-selection-keys-only)
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
952 (or (eq window-system 'x)
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
953 (memq system-name '(ms-dos windows-nt))))
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
954 (pc-select-restore-mode normal-erase-is-backspace-mode))
13233
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
955
42980
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
956 (pc-select-restore-keys
43985
2fab49a69d94 (pc-selection-mode): Alter the existing global map, don't replace it.
Richard M. Stallman <rms@gnu.org>
parents: 43025
diff changeset
957 pc-select-key-bindings-alist (current-global-map)
2fab49a69d94 (pc-selection-mode): Alter the existing global map, don't replace it.
Richard M. Stallman <rms@gnu.org>
parents: 43025
diff changeset
958 pc-select-saved-global-map)
18216
75f7eec6d388 (pc-select-selection-keys-only): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 17915
diff changeset
959
42980
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
960 (pc-select-restore-var highlight-nonselected-windows)
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
961 (pc-select-restore-var transient-mark-mode)
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
962 (pc-select-restore-var mark-even-if-inactive)
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
963 (pc-select-restore-mode delete-selection-mode)
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
964 (and pc-select-old-M-delete-binding
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
965 (define-key function-key-map [M-delete]
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
966 pc-select-old-M-delete-binding))
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
967 (setq pc-select-key-bindings-alist nil
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
968 pc-select-saved-settings-alist nil))))
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 43985
diff changeset
969
19289
4e824f1fe62d Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18216
diff changeset
970
4e824f1fe62d Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18216
diff changeset
971 ;;;###autoload
4e824f1fe62d Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18216
diff changeset
972 (defcustom pc-selection-mode nil
4e824f1fe62d Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18216
diff changeset
973 "Toggle PC Selection mode.
4e824f1fe62d Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18216
diff changeset
974 Change mark behaviour to emulate Motif, MAC or MS-Windows cut and paste style,
4e824f1fe62d Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18216
diff changeset
975 and cursor movement commands.
4e824f1fe62d Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18216
diff changeset
976 This mode enables Delete Selection mode and Transient Mark mode.
56083
d62a2b6e582e Doc fixes: say "PC Selection mode", not "`pc-selection-mode'".
Richard M. Stallman <rms@gnu.org>
parents: 52401
diff changeset
977 Setting this variable directly does not take effect;
d62a2b6e582e Doc fixes: say "PC Selection mode", not "`pc-selection-mode'".
Richard M. Stallman <rms@gnu.org>
parents: 52401
diff changeset
978 you must modify it using \\[customize] or \\[pc-selection-mode]."
19289
4e824f1fe62d Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18216
diff changeset
979 :set (lambda (symbol value)
42980
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
980 (pc-selection-mode (if value 1 -1)))
6134751ae11f (pc-selection-mode-hook)
Richard M. Stallman <rms@gnu.org>
parents: 41299
diff changeset
981 :initialize 'custom-initialize-default
19289
4e824f1fe62d Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18216
diff changeset
982 :type 'boolean
4e824f1fe62d Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18216
diff changeset
983 :group 'pc-select
4e824f1fe62d Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18216
diff changeset
984 :require 'pc-select)
4e824f1fe62d Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18216
diff changeset
985
52401
695cf19ef79e Add arch taglines
Miles Bader <miles@gnu.org>
parents: 49598
diff changeset
986 ;;; arch-tag: 10697b70-ae07-4f3e-ad23-7814a3f418c2
13233
8b29f638af52 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
987 ;;; pc-select.el ends here