Mercurial > emacs
annotate lisp/delsel.el @ 8911:3abf3f2ef6cf
(rmail-summary-construct-io-menu): New function.
(rmail-new-summary): Call rmail-summary-construct-io-menu.
(rmail-summary-mode-map): New menu items 'Input Rmail File' and
'Output Rmail File'.
(rmail-summary-output-to-rmail-file): New arg 'file-name'. If it
non-nil, call rmail-output-to-rmail-file.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Mon, 19 Sep 1994 05:03:02 +0000 |
parents | 902c32c709f7 |
children | b589ba0d8960 |
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 |
2073 | 3 ;;; Copyright (C) 1992 Free Software Foundation, Inc. |
2233
fb0ed5a1d0f3
Add standard library headers.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2074
diff
changeset
|
4 |
fb0ed5a1d0f3
Add standard library headers.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2074
diff
changeset
|
5 ;; Author: Matthieu Devin <devin@lucid.com> |
fb0ed5a1d0f3
Add standard library headers.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2074
diff
changeset
|
6 ;; Created: 14 Jul 92 |
fb0ed5a1d0f3
Add standard library headers.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2074
diff
changeset
|
7 ;; Last change 18-Feb-93, devin. |
2073 | 8 |
9 ;;; This file is part of GNU Emacs. | |
10 | |
11 ;;; GNU Emacs is free software; you can redistribute it and/or modify | |
12 ;;; it under the terms of the GNU General Public License as published by | |
13 ;;; the Free Software Foundation; either version 2, or (at your option) | |
14 ;;; any later version. | |
15 | |
16 ;;; GNU Emacs is distributed in the hope that it will be useful, | |
17 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 ;;; GNU General Public License for more details. | |
20 | |
21 ;;; You should have received a copy of the GNU General Public License | |
22 ;;; along with GNU Emacs; see the file COPYING. If not, write to | |
23 ;;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. | |
24 | |
2233
fb0ed5a1d0f3
Add standard library headers.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2074
diff
changeset
|
25 ;;; Commentary: |
2073 | 26 |
2233
fb0ed5a1d0f3
Add standard library headers.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2074
diff
changeset
|
27 ;;; This file makes the active region be pending delete, meaning that |
2073 | 28 ;;; text inserted while the region is active will replace the region contents. |
29 ;;; This is a popular behavior of personal computers text editors. | |
30 | |
2233
fb0ed5a1d0f3
Add standard library headers.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2074
diff
changeset
|
31 ;;; Code: |
fb0ed5a1d0f3
Add standard library headers.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2074
diff
changeset
|
32 |
2903
fa41174db2fa
Renamed from pending-del.el.
Richard M. Stallman <rms@gnu.org>
parents:
2233
diff
changeset
|
33 (defvar delete-selection-mode t |
fa41174db2fa
Renamed from pending-del.el.
Richard M. Stallman <rms@gnu.org>
parents:
2233
diff
changeset
|
34 "*Non-nil means Delete Selection mode is enabled. |
fa41174db2fa
Renamed from pending-del.el.
Richard M. Stallman <rms@gnu.org>
parents:
2233
diff
changeset
|
35 In Delete Selection mode, when a region is highlighted, |
2074 | 36 insertion commands first delete the region and then insert.") |
37 | |
2073 | 38 (defun delete-active-region (&optional killp) |
2074 | 39 (if killp |
40 (kill-region (point) (mark)) | |
41 (delete-region (point) (mark))) | |
42 (setq mark-active nil) | |
43 (run-hooks 'deactivate-mark-hook) | |
44 t) | |
2073 | 45 |
2903
fa41174db2fa
Renamed from pending-del.el.
Richard M. Stallman <rms@gnu.org>
parents:
2233
diff
changeset
|
46 (defun delete-selection-pre-hook () |
fa41174db2fa
Renamed from pending-del.el.
Richard M. Stallman <rms@gnu.org>
parents:
2233
diff
changeset
|
47 (if (and delete-selection-mode |
2074 | 48 (not buffer-read-only) |
49 transient-mark-mode mark-active) | |
50 (let ((type (and (symbolp this-command) | |
2903
fa41174db2fa
Renamed from pending-del.el.
Richard M. Stallman <rms@gnu.org>
parents:
2233
diff
changeset
|
51 (get this-command 'delete-selection)))) |
2074 | 52 (cond ((eq type 'kill) |
53 (delete-active-region t)) | |
54 ((eq type 'supersede) | |
2925 | 55 (if (delete-active-region nil) |
2074 | 56 (setq this-command '(lambda () (interactive))))) |
57 (type | |
2925 | 58 (delete-active-region nil)))))) |
2074 | 59 |
2903
fa41174db2fa
Renamed from pending-del.el.
Richard M. Stallman <rms@gnu.org>
parents:
2233
diff
changeset
|
60 (add-hook 'pre-command-hook 'delete-selection-pre-hook) |
2073 | 61 |
2903
fa41174db2fa
Renamed from pending-del.el.
Richard M. Stallman <rms@gnu.org>
parents:
2233
diff
changeset
|
62 (put 'self-insert-command 'delete-selection t) |
2073 | 63 |
2903
fa41174db2fa
Renamed from pending-del.el.
Richard M. Stallman <rms@gnu.org>
parents:
2233
diff
changeset
|
64 (put 'yank 'delete-selection t) |
2925 | 65 (put 'insert-register 'delete-selection t) |
2073 | 66 |
2903
fa41174db2fa
Renamed from pending-del.el.
Richard M. Stallman <rms@gnu.org>
parents:
2233
diff
changeset
|
67 (put 'delete-backward-char 'delete-selection 'supersede) |
fa41174db2fa
Renamed from pending-del.el.
Richard M. Stallman <rms@gnu.org>
parents:
2233
diff
changeset
|
68 (put 'backward-delete-char-untabify 'delete-selection 'supersede) |
fa41174db2fa
Renamed from pending-del.el.
Richard M. Stallman <rms@gnu.org>
parents:
2233
diff
changeset
|
69 (put 'delete-char 'delete-selection 'supersede) |
2073 | 70 |
2903
fa41174db2fa
Renamed from pending-del.el.
Richard M. Stallman <rms@gnu.org>
parents:
2233
diff
changeset
|
71 (put 'newline-and-indent 'delete-selection 't) |
fa41174db2fa
Renamed from pending-del.el.
Richard M. Stallman <rms@gnu.org>
parents:
2233
diff
changeset
|
72 (put 'newline 'delete-selection t) |
fa41174db2fa
Renamed from pending-del.el.
Richard M. Stallman <rms@gnu.org>
parents:
2233
diff
changeset
|
73 (put 'open-line 'delete-selection t) |
2073 | 74 |
2925 | 75 ;;;###autoload |
2903
fa41174db2fa
Renamed from pending-del.el.
Richard M. Stallman <rms@gnu.org>
parents:
2233
diff
changeset
|
76 (defalias 'pending-delete-mode 'delete-selection-mode) |
2925 | 77 ;;;###autoload |
2903
fa41174db2fa
Renamed from pending-del.el.
Richard M. Stallman <rms@gnu.org>
parents:
2233
diff
changeset
|
78 (defun delete-selection-mode (arg) |
fa41174db2fa
Renamed from pending-del.el.
Richard M. Stallman <rms@gnu.org>
parents:
2233
diff
changeset
|
79 "Toggle Delete Selection mode. |
2073 | 80 When ON, typed text replaces the selection if the selection is active. |
81 When OFF, typed text is just inserted at point." | |
2074 | 82 (interactive "P") |
2903
fa41174db2fa
Renamed from pending-del.el.
Richard M. Stallman <rms@gnu.org>
parents:
2233
diff
changeset
|
83 (setq delete-selection-mode |
fa41174db2fa
Renamed from pending-del.el.
Richard M. Stallman <rms@gnu.org>
parents:
2233
diff
changeset
|
84 (if (null arg) (not delete-selection-mode) |
2074 | 85 (> (prefix-numeric-value arg) 0))) |
86 (set-buffer-modified-p (buffer-modified-p))) ;No-op, but updates mode line. | |
2073 | 87 |
88 ;; This is very useful for cancelling a selection in the minibuffer without | |
89 ;; aborting the minibuffer. | |
90 (defun minibuffer-keyboard-quit () | |
91 "Abort recursive edit. | |
2925 | 92 In Delete Selection mode mode, if the mark is active, just deactivate it; |
93 then it takes a second C-g to abort the minibuffer." | |
2073 | 94 (interactive) |
2925 | 95 (if (and delete-selection-mode transient-mark-mode mark-active) |
96 (setq deactivate-mark t) | |
2073 | 97 (abort-recursive-edit))) |
98 | |
99 (define-key minibuffer-local-map "\C-g" 'minibuffer-keyboard-quit) | |
2903
fa41174db2fa
Renamed from pending-del.el.
Richard M. Stallman <rms@gnu.org>
parents:
2233
diff
changeset
|
100 (define-key minibuffer-local-ns-map "\C-g" 'minibuffer-keyboard-quit) |
fa41174db2fa
Renamed from pending-del.el.
Richard M. Stallman <rms@gnu.org>
parents:
2233
diff
changeset
|
101 (define-key minibuffer-local-completion-map "\C-g" 'minibuffer-keyboard-quit) |
fa41174db2fa
Renamed from pending-del.el.
Richard M. Stallman <rms@gnu.org>
parents:
2233
diff
changeset
|
102 (define-key minibuffer-local-must-match-map "\C-g" 'minibuffer-keyboard-quit) |
fa41174db2fa
Renamed from pending-del.el.
Richard M. Stallman <rms@gnu.org>
parents:
2233
diff
changeset
|
103 (define-key minibuffer-local-isearch-map "\C-g" 'minibuffer-keyboard-quit) |
2073 | 104 |
2925 | 105 (provide 'delsel) |
2073 | 106 |
2925 | 107 ;;; delsel.el ends here |