annotate lisp/delsel.el @ 83676:27d11c1d4e46

Merge from emacs--devo--0 Patches applied: * emacs--devo--0 (patch 857-862) - Update from CVS - Merge from emacs--rel--22 - Update from CVS: lisp/emacs-lisp/avl-tree.el: New file. * emacs--rel--22 (patch 97-100) - Update from CVS - Merge from gnus--rel--5.10 * gnus--rel--5.10 (patch 246-247) - Update from CVS Revision: emacs@sv.gnu.org/emacs--multi-tty--0--patch-38
author Miles Bader <miles@gnu.org>
date Mon, 27 Aug 2007 09:21:49 +0000
parents 9c9e50cbdf1e
children 6ae29c2dfff0 b83d0dadb2a7
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2903
fa41174db2fa Renamed from pending-del.el.
Richard M. Stallman <rms@gnu.org>
parents: 2233
diff changeset
1 ;;; delsel.el --- delete selection if you insert
2233
fb0ed5a1d0f3 Add standard library headers.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2074
diff changeset
2
64762
41bb365f41c4 Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 64091
diff changeset
3 ;; Copyright (C) 1992, 1997, 1998, 2001, 2002, 2003, 2004,
75347
e3694f1cb928 Add 2007 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 68651
diff changeset
4 ;; 2005, 2006, 2007 Free Software Foundation, Inc.
2233
fb0ed5a1d0f3 Add standard library headers.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2074
diff changeset
5
fb0ed5a1d0f3 Add standard library headers.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2074
diff changeset
6 ;; Author: Matthieu Devin <devin@lucid.com>
17976
852464ce5d6a Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
7 ;; Maintainer: FSF
2233
fb0ed5a1d0f3 Add standard library headers.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2074
diff changeset
8 ;; Created: 14 Jul 92
29156
af5c31a82586 Add finder keywords.
Dave Love <fx@gnu.org>
parents: 26705
diff changeset
9 ;; Keywords: convenience emulations
2073
b4d5c9926d98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
10
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13077
diff changeset
11 ;; This file is part of GNU Emacs.
2073
b4d5c9926d98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
12
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13077
diff changeset
13 ;; GNU Emacs is free software; you can redistribute it and/or modify
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13077
diff changeset
14 ;; it under the terms of the GNU General Public License as published by
78236
9355f9b7bbff Switch license to GPLv3 or later.
Glenn Morris <rgm@gnu.org>
parents: 75347
diff changeset
15 ;; the Free Software Foundation; either version 3, or (at your option)
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13077
diff changeset
16 ;; any later version.
2073
b4d5c9926d98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
17
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13077
diff changeset
18 ;; GNU Emacs is distributed in the hope that it will be useful,
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13077
diff changeset
19 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13077
diff changeset
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13077
diff changeset
21 ;; GNU General Public License for more details.
2073
b4d5c9926d98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
22
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13077
diff changeset
23 ;; You should have received a copy of the GNU General Public License
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13077
diff changeset
24 ;; along with GNU Emacs; see the file COPYING. If not, write to the
64091
6fb026ad601f Update FSF's address.
Lute Kamstra <lute@gnu.org>
parents: 57540
diff changeset
25 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
6fb026ad601f Update FSF's address.
Lute Kamstra <lute@gnu.org>
parents: 57540
diff changeset
26 ;; Boston, MA 02110-1301, USA.
2073
b4d5c9926d98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
27
2233
fb0ed5a1d0f3 Add standard library headers.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2074
diff changeset
28 ;;; Commentary:
2073
b4d5c9926d98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
29
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13077
diff changeset
30 ;; This file makes the active region be pending delete, meaning that
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13077
diff changeset
31 ;; text inserted while the region is active will replace the region contents.
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13077
diff changeset
32 ;; This is a popular behavior of personal computers text editors.
2073
b4d5c9926d98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
33
21720
b1ee274d921b Don't require cl. Minor doc fixes.
Dave Love <fx@gnu.org>
parents: 19488
diff changeset
34 ;; Interface:
2233
fb0ed5a1d0f3 Add standard library headers.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2074
diff changeset
35
21720
b1ee274d921b Don't require cl. Minor doc fixes.
Dave Love <fx@gnu.org>
parents: 19488
diff changeset
36 ;; Commands which will delete the selection need a 'delete-selection
b1ee274d921b Don't require cl. Minor doc fixes.
Dave Love <fx@gnu.org>
parents: 19488
diff changeset
37 ;; property on their symbols; commands which insert text but don't
b1ee274d921b Don't require cl. Minor doc fixes.
Dave Love <fx@gnu.org>
parents: 19488
diff changeset
38 ;; have this property won't delete the selction. It can be one of
b1ee274d921b Don't require cl. Minor doc fixes.
Dave Love <fx@gnu.org>
parents: 19488
diff changeset
39 ;; the values:
b1ee274d921b Don't require cl. Minor doc fixes.
Dave Love <fx@gnu.org>
parents: 19488
diff changeset
40 ;; 'yank
b1ee274d921b Don't require cl. Minor doc fixes.
Dave Love <fx@gnu.org>
parents: 19488
diff changeset
41 ;; For commands which do a yank; ensures the region about to be
b1ee274d921b Don't require cl. Minor doc fixes.
Dave Love <fx@gnu.org>
parents: 19488
diff changeset
42 ;; deleted isn't yanked.
b1ee274d921b Don't require cl. Minor doc fixes.
Dave Love <fx@gnu.org>
parents: 19488
diff changeset
43 ;; 'supersede
b1ee274d921b Don't require cl. Minor doc fixes.
Dave Love <fx@gnu.org>
parents: 19488
diff changeset
44 ;; Delete the active region and ignore the current command,
b1ee274d921b Don't require cl. Minor doc fixes.
Dave Love <fx@gnu.org>
parents: 19488
diff changeset
45 ;; i.e. the command will just delete the region.
b1ee274d921b Don't require cl. Minor doc fixes.
Dave Love <fx@gnu.org>
parents: 19488
diff changeset
46 ;; 'kill
b1ee274d921b Don't require cl. Minor doc fixes.
Dave Love <fx@gnu.org>
parents: 19488
diff changeset
47 ;; `kill-region' is used on the selection, rather than
b1ee274d921b Don't require cl. Minor doc fixes.
Dave Love <fx@gnu.org>
parents: 19488
diff changeset
48 ;; `delete-region'. (Text selected with the mouse will typically
b1ee274d921b Don't require cl. Minor doc fixes.
Dave Love <fx@gnu.org>
parents: 19488
diff changeset
49 ;; be yankable anyhow.)
b1ee274d921b Don't require cl. Minor doc fixes.
Dave Love <fx@gnu.org>
parents: 19488
diff changeset
50 ;; non-nil
b1ee274d921b Don't require cl. Minor doc fixes.
Dave Love <fx@gnu.org>
parents: 19488
diff changeset
51 ;; The normal case: delete the active region prior to executing
b1ee274d921b Don't require cl. Minor doc fixes.
Dave Love <fx@gnu.org>
parents: 19488
diff changeset
52 ;; the command which will insert replacement text.
b1ee274d921b Don't require cl. Minor doc fixes.
Dave Love <fx@gnu.org>
parents: 19488
diff changeset
53
b1ee274d921b Don't require cl. Minor doc fixes.
Dave Love <fx@gnu.org>
parents: 19488
diff changeset
54 ;;; Code:
18785
1a455d8dfa7c Customise. Don't modify pre-command-hook on file load; do in command.
Simon Marshall <simon@gnu.org>
parents: 18641
diff changeset
55
1a455d8dfa7c Customise. Don't modify pre-command-hook on file load; do in command.
Simon Marshall <simon@gnu.org>
parents: 18641
diff changeset
56 ;;;###autoload
1a455d8dfa7c Customise. Don't modify pre-command-hook on file load; do in command.
Simon Marshall <simon@gnu.org>
parents: 18641
diff changeset
57 (defalias 'pending-delete-mode 'delete-selection-mode)
1a455d8dfa7c Customise. Don't modify pre-command-hook on file load; do in command.
Simon Marshall <simon@gnu.org>
parents: 18641
diff changeset
58
1a455d8dfa7c Customise. Don't modify pre-command-hook on file load; do in command.
Simon Marshall <simon@gnu.org>
parents: 18641
diff changeset
59 ;;;###autoload
32043
63a2ec6dae39 (delete-selection-mode): Use define-minor-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 30817
diff changeset
60 (define-minor-mode delete-selection-mode
18785
1a455d8dfa7c Customise. Don't modify pre-command-hook on file load; do in command.
Simon Marshall <simon@gnu.org>
parents: 18641
diff changeset
61 "Toggle Delete Selection mode.
21720
b1ee274d921b Don't require cl. Minor doc fixes.
Dave Love <fx@gnu.org>
parents: 19488
diff changeset
62 With prefix ARG, turn Delete Selection mode on if and only if ARG is
b1ee274d921b Don't require cl. Minor doc fixes.
Dave Love <fx@gnu.org>
parents: 19488
diff changeset
63 positive.
18785
1a455d8dfa7c Customise. Don't modify pre-command-hook on file load; do in command.
Simon Marshall <simon@gnu.org>
parents: 18641
diff changeset
64
21720
b1ee274d921b Don't require cl. Minor doc fixes.
Dave Love <fx@gnu.org>
parents: 19488
diff changeset
65 When Delete Selection mode is enabled, Transient Mark mode is also
b1ee274d921b Don't require cl. Minor doc fixes.
Dave Love <fx@gnu.org>
parents: 19488
diff changeset
66 enabled and typed text replaces the selection if the selection is
b1ee274d921b Don't require cl. Minor doc fixes.
Dave Love <fx@gnu.org>
parents: 19488
diff changeset
67 active. Otherwise, typed text is just inserted at point regardless of
b1ee274d921b Don't require cl. Minor doc fixes.
Dave Love <fx@gnu.org>
parents: 19488
diff changeset
68 any selection."
33185
7630435cbccd (delete-selection-mode): Drop unneeded positional args.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32043
diff changeset
69 :global t :group 'editing-basics
18785
1a455d8dfa7c Customise. Don't modify pre-command-hook on file load; do in command.
Simon Marshall <simon@gnu.org>
parents: 18641
diff changeset
70 (if (not delete-selection-mode)
1a455d8dfa7c Customise. Don't modify pre-command-hook on file load; do in command.
Simon Marshall <simon@gnu.org>
parents: 18641
diff changeset
71 (remove-hook 'pre-command-hook 'delete-selection-pre-hook)
1a455d8dfa7c Customise. Don't modify pre-command-hook on file load; do in command.
Simon Marshall <simon@gnu.org>
parents: 18641
diff changeset
72 (add-hook 'pre-command-hook 'delete-selection-pre-hook)
1a455d8dfa7c Customise. Don't modify pre-command-hook on file load; do in command.
Simon Marshall <simon@gnu.org>
parents: 18641
diff changeset
73 (transient-mark-mode t)))
1a455d8dfa7c Customise. Don't modify pre-command-hook on file load; do in command.
Simon Marshall <simon@gnu.org>
parents: 18641
diff changeset
74
2073
b4d5c9926d98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
75 (defun delete-active-region (&optional killp)
2074
0196b8bce529 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 2073
diff changeset
76 (if killp
0196b8bce529 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 2073
diff changeset
77 (kill-region (point) (mark))
0196b8bce529 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 2073
diff changeset
78 (delete-region (point) (mark)))
0196b8bce529 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 2073
diff changeset
79 t)
2073
b4d5c9926d98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
80
2903
fa41174db2fa Renamed from pending-del.el.
Richard M. Stallman <rms@gnu.org>
parents: 2233
diff changeset
81 (defun delete-selection-pre-hook ()
18785
1a455d8dfa7c Customise. Don't modify pre-command-hook on file load; do in command.
Simon Marshall <simon@gnu.org>
parents: 18641
diff changeset
82 (when (and delete-selection-mode transient-mark-mode mark-active
1a455d8dfa7c Customise. Don't modify pre-command-hook on file load; do in command.
Simon Marshall <simon@gnu.org>
parents: 18641
diff changeset
83 (not buffer-read-only))
1a455d8dfa7c Customise. Don't modify pre-command-hook on file load; do in command.
Simon Marshall <simon@gnu.org>
parents: 18641
diff changeset
84 (let ((type (and (symbolp this-command)
1a455d8dfa7c Customise. Don't modify pre-command-hook on file load; do in command.
Simon Marshall <simon@gnu.org>
parents: 18641
diff changeset
85 (get this-command 'delete-selection))))
41254
2538b11fc837 (delete-selection-pre-hook): Handle and resignal
Richard M. Stallman <rms@gnu.org>
parents: 38616
diff changeset
86 (condition-case data
2538b11fc837 (delete-selection-pre-hook): Handle and resignal
Richard M. Stallman <rms@gnu.org>
parents: 38616
diff changeset
87 (cond ((eq type 'kill)
2538b11fc837 (delete-selection-pre-hook): Handle and resignal
Richard M. Stallman <rms@gnu.org>
parents: 38616
diff changeset
88 (delete-active-region t))
2538b11fc837 (delete-selection-pre-hook): Handle and resignal
Richard M. Stallman <rms@gnu.org>
parents: 38616
diff changeset
89 ((eq type 'yank)
81894
fb5c5d1a8fe2 (delete-selection-pre-hook): Before a yank command,
Juri Linkov <juri@jurta.org>
parents: 75347
diff changeset
90 ;; Before a yank command, make sure we don't yank the
fb5c5d1a8fe2 (delete-selection-pre-hook): Before a yank command,
Juri Linkov <juri@jurta.org>
parents: 75347
diff changeset
91 ;; head of the kill-ring that really comes from the
82507
9c9e50cbdf1e (delete-selection-pre-hook): Use `mouse-region-match' instead of checking last-command.
Juri Linkov <juri@jurta.org>
parents: 82140
diff changeset
92 ;; currently active region we are going to delete.
9c9e50cbdf1e (delete-selection-pre-hook): Use `mouse-region-match' instead of checking last-command.
Juri Linkov <juri@jurta.org>
parents: 82140
diff changeset
93 ;; That would make yank a no-op.
81894
fb5c5d1a8fe2 (delete-selection-pre-hook): Before a yank command,
Juri Linkov <juri@jurta.org>
parents: 75347
diff changeset
94 (when (and (string= (buffer-substring-no-properties (point) (mark))
fb5c5d1a8fe2 (delete-selection-pre-hook): Before a yank command,
Juri Linkov <juri@jurta.org>
parents: 75347
diff changeset
95 (car kill-ring))
82507
9c9e50cbdf1e (delete-selection-pre-hook): Use `mouse-region-match' instead of checking last-command.
Juri Linkov <juri@jurta.org>
parents: 82140
diff changeset
96 (mouse-region-match))
41254
2538b11fc837 (delete-selection-pre-hook): Handle and resignal
Richard M. Stallman <rms@gnu.org>
parents: 38616
diff changeset
97 (current-kill 1))
2538b11fc837 (delete-selection-pre-hook): Handle and resignal
Richard M. Stallman <rms@gnu.org>
parents: 38616
diff changeset
98 (delete-active-region))
2538b11fc837 (delete-selection-pre-hook): Handle and resignal
Richard M. Stallman <rms@gnu.org>
parents: 38616
diff changeset
99 ((eq type 'supersede)
2538b11fc837 (delete-selection-pre-hook): Handle and resignal
Richard M. Stallman <rms@gnu.org>
parents: 38616
diff changeset
100 (let ((empty-region (= (point) (mark))))
2538b11fc837 (delete-selection-pre-hook): Handle and resignal
Richard M. Stallman <rms@gnu.org>
parents: 38616
diff changeset
101 (delete-active-region)
2538b11fc837 (delete-selection-pre-hook): Handle and resignal
Richard M. Stallman <rms@gnu.org>
parents: 38616
diff changeset
102 (unless empty-region
2538b11fc837 (delete-selection-pre-hook): Handle and resignal
Richard M. Stallman <rms@gnu.org>
parents: 38616
diff changeset
103 (setq this-command 'ignore))))
2538b11fc837 (delete-selection-pre-hook): Handle and resignal
Richard M. Stallman <rms@gnu.org>
parents: 38616
diff changeset
104 (type
64947
803494c7e4b7 (delete-selection-pre-hook): If overwrite-mode is
Juri Linkov <juri@jurta.org>
parents: 64762
diff changeset
105 (delete-active-region)
803494c7e4b7 (delete-selection-pre-hook): If overwrite-mode is
Juri Linkov <juri@jurta.org>
parents: 64762
diff changeset
106 (if (and overwrite-mode (eq this-command 'self-insert-command))
803494c7e4b7 (delete-selection-pre-hook): If overwrite-mode is
Juri Linkov <juri@jurta.org>
parents: 64762
diff changeset
107 (let ((overwrite-mode nil))
803494c7e4b7 (delete-selection-pre-hook): If overwrite-mode is
Juri Linkov <juri@jurta.org>
parents: 64762
diff changeset
108 (self-insert-command (prefix-numeric-value current-prefix-arg))
803494c7e4b7 (delete-selection-pre-hook): If overwrite-mode is
Juri Linkov <juri@jurta.org>
parents: 64762
diff changeset
109 (setq this-command 'ignore)))))
41254
2538b11fc837 (delete-selection-pre-hook): Handle and resignal
Richard M. Stallman <rms@gnu.org>
parents: 38616
diff changeset
110 (file-supersession
2538b11fc837 (delete-selection-pre-hook): Handle and resignal
Richard M. Stallman <rms@gnu.org>
parents: 38616
diff changeset
111 ;; If ask-user-about-supersession-threat signals an error,
2538b11fc837 (delete-selection-pre-hook): Handle and resignal
Richard M. Stallman <rms@gnu.org>
parents: 38616
diff changeset
112 ;; stop safe_run_hooks from clearing out pre-command-hook.
2538b11fc837 (delete-selection-pre-hook): Handle and resignal
Richard M. Stallman <rms@gnu.org>
parents: 38616
diff changeset
113 (and (eq inhibit-quit 'pre-command-hook)
2538b11fc837 (delete-selection-pre-hook): Handle and resignal
Richard M. Stallman <rms@gnu.org>
parents: 38616
diff changeset
114 (setq inhibit-quit 'delete-selection-dummy))
2538b11fc837 (delete-selection-pre-hook): Handle and resignal
Richard M. Stallman <rms@gnu.org>
parents: 38616
diff changeset
115 (signal 'file-supersession (cdr data)))))))
2073
b4d5c9926d98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
116
2903
fa41174db2fa Renamed from pending-del.el.
Richard M. Stallman <rms@gnu.org>
parents: 2233
diff changeset
117 (put 'self-insert-command 'delete-selection t)
9533
b589ba0d8960 (self-insert-iso): Add delete-selection property.
Richard M. Stallman <rms@gnu.org>
parents: 2925
diff changeset
118 (put 'self-insert-iso 'delete-selection t)
2073
b4d5c9926d98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
119
12790
afe7f3c735a3 (delete-selection-pre-hook): New type value `yank'.
Richard M. Stallman <rms@gnu.org>
parents: 11589
diff changeset
120 (put 'yank 'delete-selection 'yank)
13077
65092cab3f43 (clipboard-yank): Add delete-selection property.
Richard M. Stallman <rms@gnu.org>
parents: 12790
diff changeset
121 (put 'clipboard-yank 'delete-selection 'yank)
2925
902c32c709f7 Provide delsel.
Richard M. Stallman <rms@gnu.org>
parents: 2903
diff changeset
122 (put 'insert-register 'delete-selection t)
2073
b4d5c9926d98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
123
2903
fa41174db2fa Renamed from pending-del.el.
Richard M. Stallman <rms@gnu.org>
parents: 2233
diff changeset
124 (put 'delete-backward-char 'delete-selection 'supersede)
fa41174db2fa Renamed from pending-del.el.
Richard M. Stallman <rms@gnu.org>
parents: 2233
diff changeset
125 (put 'backward-delete-char-untabify 'delete-selection 'supersede)
fa41174db2fa Renamed from pending-del.el.
Richard M. Stallman <rms@gnu.org>
parents: 2233
diff changeset
126 (put 'delete-char 'delete-selection 'supersede)
2073
b4d5c9926d98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
127
21720
b1ee274d921b Don't require cl. Minor doc fixes.
Dave Love <fx@gnu.org>
parents: 19488
diff changeset
128 (put 'newline-and-indent 'delete-selection t)
2903
fa41174db2fa Renamed from pending-del.el.
Richard M. Stallman <rms@gnu.org>
parents: 2233
diff changeset
129 (put 'newline 'delete-selection t)
21720
b1ee274d921b Don't require cl. Minor doc fixes.
Dave Love <fx@gnu.org>
parents: 19488
diff changeset
130 (put 'open-line 'delete-selection 'kill)
b1ee274d921b Don't require cl. Minor doc fixes.
Dave Love <fx@gnu.org>
parents: 19488
diff changeset
131
30817
fd8b296712e7 (delsel-unload-hook): New function.
Dave Love <fx@gnu.org>
parents: 29156
diff changeset
132 ;; This is very useful for cancelling a selection in the minibuffer without
2073
b4d5c9926d98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
133 ;; aborting the minibuffer.
b4d5c9926d98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
134 (defun minibuffer-keyboard-quit ()
b4d5c9926d98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
135 "Abort recursive edit.
21720
b1ee274d921b Don't require cl. Minor doc fixes.
Dave Love <fx@gnu.org>
parents: 19488
diff changeset
136 In Delete Selection mode, if the mark is active, just deactivate it;
b1ee274d921b Don't require cl. Minor doc fixes.
Dave Love <fx@gnu.org>
parents: 19488
diff changeset
137 then it takes a second \\[keyboard-quit] to abort the minibuffer."
2073
b4d5c9926d98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
138 (interactive)
2925
902c32c709f7 Provide delsel.
Richard M. Stallman <rms@gnu.org>
parents: 2903
diff changeset
139 (if (and delete-selection-mode transient-mark-mode mark-active)
902c32c709f7 Provide delsel.
Richard M. Stallman <rms@gnu.org>
parents: 2903
diff changeset
140 (setq deactivate-mark t)
2073
b4d5c9926d98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
141 (abort-recursive-edit)))
b4d5c9926d98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
142
30817
fd8b296712e7 (delsel-unload-hook): New function.
Dave Love <fx@gnu.org>
parents: 29156
diff changeset
143 (define-key minibuffer-local-map "\C-g" 'minibuffer-keyboard-quit)
fd8b296712e7 (delsel-unload-hook): New function.
Dave Love <fx@gnu.org>
parents: 29156
diff changeset
144 (define-key minibuffer-local-ns-map "\C-g" 'minibuffer-keyboard-quit)
fd8b296712e7 (delsel-unload-hook): New function.
Dave Love <fx@gnu.org>
parents: 29156
diff changeset
145 (define-key minibuffer-local-completion-map "\C-g" 'minibuffer-keyboard-quit)
fd8b296712e7 (delsel-unload-hook): New function.
Dave Love <fx@gnu.org>
parents: 29156
diff changeset
146 (define-key minibuffer-local-must-match-map "\C-g" 'minibuffer-keyboard-quit)
fd8b296712e7 (delsel-unload-hook): New function.
Dave Love <fx@gnu.org>
parents: 29156
diff changeset
147 (define-key minibuffer-local-isearch-map "\C-g" 'minibuffer-keyboard-quit)
fd8b296712e7 (delsel-unload-hook): New function.
Dave Love <fx@gnu.org>
parents: 29156
diff changeset
148
fd8b296712e7 (delsel-unload-hook): New function.
Dave Love <fx@gnu.org>
parents: 29156
diff changeset
149 (defun delsel-unload-hook ()
fd8b296712e7 (delsel-unload-hook): New function.
Dave Love <fx@gnu.org>
parents: 29156
diff changeset
150 (define-key minibuffer-local-map "\C-g" 'abort-recursive-edit)
fd8b296712e7 (delsel-unload-hook): New function.
Dave Love <fx@gnu.org>
parents: 29156
diff changeset
151 (define-key minibuffer-local-ns-map "\C-g" 'abort-recursive-edit)
fd8b296712e7 (delsel-unload-hook): New function.
Dave Love <fx@gnu.org>
parents: 29156
diff changeset
152 (define-key minibuffer-local-completion-map "\C-g" 'abort-recursive-edit)
fd8b296712e7 (delsel-unload-hook): New function.
Dave Love <fx@gnu.org>
parents: 29156
diff changeset
153 (define-key minibuffer-local-must-match-map "\C-g" 'abort-recursive-edit)
fd8b296712e7 (delsel-unload-hook): New function.
Dave Love <fx@gnu.org>
parents: 29156
diff changeset
154 (define-key minibuffer-local-isearch-map "\C-g" 'abort-recursive-edit))
2073
b4d5c9926d98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
155
57540
8bf58c5521d8 (delsel-unload-hook): Set as a variable.
Richard M. Stallman <rms@gnu.org>
parents: 55278
diff changeset
156 (add-hook 'delsel-unload-hook 'delsel-unload-hook)
8bf58c5521d8 (delsel-unload-hook): Set as a variable.
Richard M. Stallman <rms@gnu.org>
parents: 55278
diff changeset
157
2925
902c32c709f7 Provide delsel.
Richard M. Stallman <rms@gnu.org>
parents: 2903
diff changeset
158 (provide 'delsel)
2073
b4d5c9926d98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
159
52401
695cf19ef79e Add arch taglines
Miles Bader <miles@gnu.org>
parents: 50422
diff changeset
160 ;;; arch-tag: 1e388890-1b50-4ed0-9347-763b1343b6ed
2925
902c32c709f7 Provide delsel.
Richard M. Stallman <rms@gnu.org>
parents: 2903
diff changeset
161 ;;; delsel.el ends here