annotate lisp/delsel.el @ 103616:af77bf73dfe0

* verilog-mode.el (verilog-beg-of-statement) (verilog-endcomment-reason-re): Support unique case and priority case. (verilog-basic-complete-re): Support localparam lineup. (verilog-beg-of-statement-1): Fix for robustness, unique case. (verilog-set-auto-endcomments): Fix for unique case, always_comb commenting. (verilog-leap-to-case-head): Now support *nested* unique & priority case statements. (verilog-auto-lineup): Make just declarations the default (as it had been). (verilog-leap-to-case-head): Support priority/unique case statements. (verilog-auto-lineup): Rework to give users radio buttons to select the various styles of automatic lineup (verilog-error-regexp-alist): Rework to support the XEmacs style of error regular expressions from compilers, lint tools & simulators. Note that GNU Emacs has made it impossible for a mode to load such things. (electric-verilog-terminate-line, verilog-indent-declaration) (verilog-auto-wiure): Rework for radio button selection of auto-lineup selection of specification of auto lineup. (verilog-beg-of-statement-1): Redesign to support proper operation in additional code, based on testing with auto-lineup. (verilog-calculate-indent, assignments & declarations) (verilog-backward-token): Enhance to support auto-lineup of assignments & declarations. (verilog-in-directive-p, verilog-at-struct-p): New function for easy test of whether we are. (verilog-pretty-declarations, verilog-pretty-expr): Massive rework to support safe execution at almost anyline. (verilog-calc-1): Properly support indenting deep inside generate blocks. (verilog-init-font) Remove definition & use of verilog-init-font, as it is redundant with font-lock-defaults. (verilog-mode): Alter the definition of verilog-font-lock-defualts to avoid circular calls if syntax-ppss is a function (as is the case now in 22.x GNU Emacs) as that function would sometimes call itself, leading to (nearly) infinite recursion (verilog-ovm-begin-re, verilog-ovm-end-re) (verilog-ovm-statement-re, verilog-leap-to-head) (verilog-backward-token): Add support for OVM macros. Some are complete statements, and others open and close scopes like begin and end. (verilog-defun-level-not-generate-re, verilog-defun-level-re) (verilog-defun-level-generate-only-re): Really fix the defun-list compilation issue (verilog-calc-1) (verilog-beg-of-statement): Enhance support for coverpoint, constraint and cross statements (verilog-defun-level-list, verilog-generate-defun-level-list) (verilog-all-defun-level-list): Redo these specifications - it is too hard to support eval-when compile aggregation of lists also built at when-compile time. (verilog-defun-level-list): Place defconsts of variables used in building regular expressions which are built in eval-when-compile bodies in the same eval-when-compile body to facilitate compile without load. (verilog-beg-block-re-ordered): Support indenting virtual/protected tasks and functions. (verilog-defun-level-list,verilog-in-generate-region-p) (verilog-backward-ws&directives, verilog-calc-1): Speed up indentation of some module items (generate items). (verilog-forward-sexp, verilog-leap-to-head): Support stepping across virtual/protected tasks and functions. * verilog-mode.el (verilog-auto-arg, verilog-auto-arg-sort): Allow sorting AUTOARG lists. Suggested by Andrea Fedeli. (verilog-read-sub-decls-line): Fix AUTOWIRE signals getting lost in concatenations. Reported by Yishay Belkind. (verilog-auto-ascii-enum): Support one-hot state machines in AUTOASCIIENUM. Suggested by Lloyd Gomez. (verilog-auto-inst, verilog-auto-inst-port): Include interface modport in AUTOINST and add vl-modport for users. Reported by David Rogoff. (verilog-auto-inout-module, verilog-auto-inst) (verilog-decls-get-interfaces, verilog-insert-definition) (verilog-insert-one-definition, verilog-read-decls) (verilog-read-sub-decls, verilog-read-sub-decls-sig) (verilog-sig-modport, verilog-signals-combine-bus) (verilog-subdecls-get-interfaces): Fix expansion of SystemVerilog interfaces in AUTOINOUTMODULE, AUTOINOUTCOMP, and AUTOINST. Suggested by David Rogoff. (verilog-repair-open-comma): Fix non-insertion of comma when `DEFINE occurs in V2K argument list. Reported by Lane Brooks. (verilog-make-width-expression): Simplify [A-1:0] expression widths to just {A{1'b0}}. (verilog-mode): Cleanup checkdoc warnings. (verilog-auto-inout-module, verilog-signals-matching-dir-re): Add third optional regexp to AUTOINOUTMODULE to allow selecting only inputs/outputs or data type. Suggested by Vasu Kandadi. (next-error-last-buffer): Fix byte-compiler warning. (verilog-auto, verilog-auto-insert-lisp, verilog-auto-inst) (verilog-delete-auto): Add AUTOINSERTLISP to insert arbitrary lisp or shell command text during AUTO expansion. Suggested by Tad Truex. (verilog-read-sub-decls-expr, verilog-read-sub-decls-line) (verilog-read-sub-decls-sig, verilog-symbol-detick-text): Fix dotted nets {a.b,c.d} and excaped identifiers being mis-included in AUTOINOUT. Reported by Matthew Lovell. (verilog-read-always-signals-recurse): Fix AUTORESET "if (a<=b)" causing use of <= assignments. Reported by Alex Reed. (verilog-read-decls): Fix triand, trior, wand, wor to be recognized by AUTOWIRE. Reported by Spencer Isaacson. (verilog-extended-complete-re): Support import "DPI-C" functions. (verilog-read-always-signals-recurse): Fix AUTORESET of "x <= y[a+1:a+1]" to not include a in reset list. Reported by Dan Dever. (verilog-insert-date, verilog-insert-year) (verilog-sk-header-tmpl): Fix verilog-header inserting error on Windows systems. Reported by Michael Potts. (verilog-read-module-name): Fix AUTOINST when the child module declaration's name is a tick define. Reported by Elliot Mednick. (verilog-read-decls): Fix V2K parameter bit subscripts getting passed to next parameter's definition. Reported by Bruce T. (verilog-read-decls): Fix detecting "parameter int" when using AUTOINSTPARAM. Reported by Bruce T. (verilog-goto-defun): Fix goto not finding modules unless first perform a verilog-auto expansion. Suggested by Lawrence Butcher. (verilog-mode): Expand -f flag arguments on entry to mode so verilog-goto-defun will work. Reported by Lawrence Butcher. (verilog-getopt): Expand environment variables in -f file arguments. Suggested by Lawrence Butcher. (verilog-set-define): Fix "Symbol's value as variable is void" when reading enumerations. (verilog-auto-ascii-enum): Fix duplicate labels in AUTOASCIIENUM. Suggested by Stephen Peltan. (verilog-read-defines): Fix reading of enumerations in include files. Reported by Steve Peltan.
author Dan Nicolaescu <dann@ics.uci.edu>
date Sun, 28 Jun 2009 17:52:45 +0000
parents a9dc0e7c3f2b
children 1d1d5d9bd884
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,
100908
a9dc0e7c3f2b Add 2009 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 94678
diff changeset
4 ;; 2005, 2006, 2007, 2008, 2009 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
94678
ee5932bf781d Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93975
diff changeset
13 ;; GNU Emacs is free software: you can redistribute it and/or modify
14169
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
94678
ee5932bf781d Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93975
diff changeset
15 ;; the Free Software Foundation, either version 3 of the License, or
ee5932bf781d Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93975
diff changeset
16 ;; (at your option) 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
94678
ee5932bf781d Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93975
diff changeset
24 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
2073
b4d5c9926d98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
25
2233
fb0ed5a1d0f3 Add standard library headers.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2074
diff changeset
26 ;;; Commentary:
2073
b4d5c9926d98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
27
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13077
diff changeset
28 ;; 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
29 ;; 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
30 ;; This is a popular behavior of personal computers text editors.
2073
b4d5c9926d98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
31
21720
b1ee274d921b Don't require cl. Minor doc fixes.
Dave Love <fx@gnu.org>
parents: 19488
diff changeset
32 ;; Interface:
2233
fb0ed5a1d0f3 Add standard library headers.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2074
diff changeset
33
21720
b1ee274d921b Don't require cl. Minor doc fixes.
Dave Love <fx@gnu.org>
parents: 19488
diff changeset
34 ;; 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
35 ;; property on their symbols; commands which insert text but don't
85811
cd42bdedadb3 (delsel-unload-hook): Remove function and variable.
Juanma Barranquero <lekktu@gmail.com>
parents: 85073
diff changeset
36 ;; have this property won't delete the selection. It can be one of
21720
b1ee274d921b Don't require cl. Minor doc fixes.
Dave Love <fx@gnu.org>
parents: 19488
diff changeset
37 ;; the values:
b1ee274d921b Don't require cl. Minor doc fixes.
Dave Love <fx@gnu.org>
parents: 19488
diff changeset
38 ;; 'yank
b1ee274d921b Don't require cl. Minor doc fixes.
Dave Love <fx@gnu.org>
parents: 19488
diff changeset
39 ;; 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
40 ;; deleted isn't yanked.
b1ee274d921b Don't require cl. Minor doc fixes.
Dave Love <fx@gnu.org>
parents: 19488
diff changeset
41 ;; 'supersede
b1ee274d921b Don't require cl. Minor doc fixes.
Dave Love <fx@gnu.org>
parents: 19488
diff changeset
42 ;; 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
43 ;; 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
44 ;; 'kill
b1ee274d921b Don't require cl. Minor doc fixes.
Dave Love <fx@gnu.org>
parents: 19488
diff changeset
45 ;; `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
46 ;; `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
47 ;; be yankable anyhow.)
b1ee274d921b Don't require cl. Minor doc fixes.
Dave Love <fx@gnu.org>
parents: 19488
diff changeset
48 ;; non-nil
b1ee274d921b Don't require cl. Minor doc fixes.
Dave Love <fx@gnu.org>
parents: 19488
diff changeset
49 ;; 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
50 ;; the command which will insert replacement text.
b1ee274d921b Don't require cl. Minor doc fixes.
Dave Love <fx@gnu.org>
parents: 19488
diff changeset
51
b1ee274d921b Don't require cl. Minor doc fixes.
Dave Love <fx@gnu.org>
parents: 19488
diff changeset
52 ;;; 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
53
1a455d8dfa7c Customise. Don't modify pre-command-hook on file load; do in command.
Simon Marshall <simon@gnu.org>
parents: 18641
diff changeset
54 ;;;###autoload
1a455d8dfa7c Customise. Don't modify pre-command-hook on file load; do in command.
Simon Marshall <simon@gnu.org>
parents: 18641
diff changeset
55 (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
56
1a455d8dfa7c Customise. Don't modify pre-command-hook on file load; do in command.
Simon Marshall <simon@gnu.org>
parents: 18641
diff changeset
57 ;;;###autoload
32043
63a2ec6dae39 (delete-selection-mode): Use define-minor-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 30817
diff changeset
58 (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
59 "Toggle Delete Selection mode.
79678
08240fd93b4f (delete-selection-mode): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 78236
diff changeset
60 With prefix ARG, turn Delete Selection mode on if ARG is
08240fd93b4f (delete-selection-mode): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 78236
diff changeset
61 positive, off if ARG is not 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
62
21720
b1ee274d921b Don't require cl. Minor doc fixes.
Dave Love <fx@gnu.org>
parents: 19488
diff changeset
63 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
64 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
65 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
66 any selection."
33185
7630435cbccd (delete-selection-mode): Drop unneeded positional args.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32043
diff changeset
67 :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
68 (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
69 (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
70 (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
71 (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
72
2073
b4d5c9926d98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
73 (defun delete-active-region (&optional killp)
2074
0196b8bce529 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 2073
diff changeset
74 (if killp
0196b8bce529 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 2073
diff changeset
75 (kill-region (point) (mark))
0196b8bce529 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 2073
diff changeset
76 (delete-region (point) (mark)))
0196b8bce529 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 2073
diff changeset
77 t)
2073
b4d5c9926d98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
78
2903
fa41174db2fa Renamed from pending-del.el.
Richard M. Stallman <rms@gnu.org>
parents: 2233
diff changeset
79 (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
80 (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
81 (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
82 (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
83 (get this-command 'delete-selection))))
41254
2538b11fc837 (delete-selection-pre-hook): Handle and resignal
Richard M. Stallman <rms@gnu.org>
parents: 38616
diff changeset
84 (condition-case data
2538b11fc837 (delete-selection-pre-hook): Handle and resignal
Richard M. Stallman <rms@gnu.org>
parents: 38616
diff changeset
85 (cond ((eq type 'kill)
2538b11fc837 (delete-selection-pre-hook): Handle and resignal
Richard M. Stallman <rms@gnu.org>
parents: 38616
diff changeset
86 (delete-active-region t))
2538b11fc837 (delete-selection-pre-hook): Handle and resignal
Richard M. Stallman <rms@gnu.org>
parents: 38616
diff changeset
87 ((eq type 'yank)
81894
fb5c5d1a8fe2 (delete-selection-pre-hook): Before a yank command,
Juri Linkov <juri@jurta.org>
parents: 75347
diff changeset
88 ;; 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
89 ;; 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
90 ;; currently active region we are going to delete.
41254
2538b11fc837 (delete-selection-pre-hook): Handle and resignal
Richard M. Stallman <rms@gnu.org>
parents: 38616
diff changeset
91 ;; 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
92 (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
93 (car kill-ring))
85073
6ae29c2dfff0 (delete-selection-pre-hook): Check if mouse-region-match is fbound
Juri Linkov <juri@jurta.org>
parents: 82507
diff changeset
94 (fboundp 'mouse-region-match)
82507
9c9e50cbdf1e (delete-selection-pre-hook): Use `mouse-region-match' instead of checking last-command.
Juri Linkov <juri@jurta.org>
parents: 82140
diff changeset
95 (mouse-region-match))
41254
2538b11fc837 (delete-selection-pre-hook): Handle and resignal
Richard M. Stallman <rms@gnu.org>
parents: 38616
diff changeset
96 (current-kill 1))
2538b11fc837 (delete-selection-pre-hook): Handle and resignal
Richard M. Stallman <rms@gnu.org>
parents: 38616
diff changeset
97 (delete-active-region))
2538b11fc837 (delete-selection-pre-hook): Handle and resignal
Richard M. Stallman <rms@gnu.org>
parents: 38616
diff changeset
98 ((eq type 'supersede)
2538b11fc837 (delete-selection-pre-hook): Handle and resignal
Richard M. Stallman <rms@gnu.org>
parents: 38616
diff changeset
99 (let ((empty-region (= (point) (mark))))
2538b11fc837 (delete-selection-pre-hook): Handle and resignal
Richard M. Stallman <rms@gnu.org>
parents: 38616
diff changeset
100 (delete-active-region)
2538b11fc837 (delete-selection-pre-hook): Handle and resignal
Richard M. Stallman <rms@gnu.org>
parents: 38616
diff changeset
101 (unless empty-region
2538b11fc837 (delete-selection-pre-hook): Handle and resignal
Richard M. Stallman <rms@gnu.org>
parents: 38616
diff changeset
102 (setq this-command 'ignore))))
2538b11fc837 (delete-selection-pre-hook): Handle and resignal
Richard M. Stallman <rms@gnu.org>
parents: 38616
diff changeset
103 (type
64947
803494c7e4b7 (delete-selection-pre-hook): If overwrite-mode is
Juri Linkov <juri@jurta.org>
parents: 64762
diff changeset
104 (delete-active-region)
803494c7e4b7 (delete-selection-pre-hook): If overwrite-mode is
Juri Linkov <juri@jurta.org>
parents: 64762
diff changeset
105 (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
106 (let ((overwrite-mode nil))
803494c7e4b7 (delete-selection-pre-hook): If overwrite-mode is
Juri Linkov <juri@jurta.org>
parents: 64762
diff changeset
107 (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
108 (setq this-command 'ignore)))))
41254
2538b11fc837 (delete-selection-pre-hook): Handle and resignal
Richard M. Stallman <rms@gnu.org>
parents: 38616
diff changeset
109 (file-supersession
2538b11fc837 (delete-selection-pre-hook): Handle and resignal
Richard M. Stallman <rms@gnu.org>
parents: 38616
diff changeset
110 ;; 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
111 ;; 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
112 (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
113 (setq inhibit-quit 'delete-selection-dummy))
87933
1c868d4c8354 (delete-selection-pre-hook): Avoid clearing out
Martin Rudalics <rudalics@gmx.at>
parents: 87649
diff changeset
114 (signal 'file-supersession (cdr data)))
1c868d4c8354 (delete-selection-pre-hook): Avoid clearing out
Martin Rudalics <rudalics@gmx.at>
parents: 87649
diff changeset
115 (text-read-only
1c868d4c8354 (delete-selection-pre-hook): Avoid clearing out
Martin Rudalics <rudalics@gmx.at>
parents: 87649
diff changeset
116 ;; This signal may come either from `delete-active-region' or
1c868d4c8354 (delete-selection-pre-hook): Avoid clearing out
Martin Rudalics <rudalics@gmx.at>
parents: 87649
diff changeset
117 ;; `self-insert-command' (when `overwrite-mode' is non-nil).
1c868d4c8354 (delete-selection-pre-hook): Avoid clearing out
Martin Rudalics <rudalics@gmx.at>
parents: 87649
diff changeset
118 ;; To avoid clearing out `pre-command-hook' we handle this case
1c868d4c8354 (delete-selection-pre-hook): Avoid clearing out
Martin Rudalics <rudalics@gmx.at>
parents: 87649
diff changeset
119 ;; by issuing a simple message. Note, however, that we do not
1c868d4c8354 (delete-selection-pre-hook): Avoid clearing out
Martin Rudalics <rudalics@gmx.at>
parents: 87649
diff changeset
120 ;; handle all related problems: When read-only text ends before
1c868d4c8354 (delete-selection-pre-hook): Avoid clearing out
Martin Rudalics <rudalics@gmx.at>
parents: 87649
diff changeset
121 ;; the end of the region, the latter is not deleted but any
1c868d4c8354 (delete-selection-pre-hook): Avoid clearing out
Martin Rudalics <rudalics@gmx.at>
parents: 87649
diff changeset
122 ;; subsequent insertion will succeed. We could avoid this case
1c868d4c8354 (delete-selection-pre-hook): Avoid clearing out
Martin Rudalics <rudalics@gmx.at>
parents: 87649
diff changeset
123 ;; by doing a (setq this-command 'ignore) here. This would,
1c868d4c8354 (delete-selection-pre-hook): Avoid clearing out
Martin Rudalics <rudalics@gmx.at>
parents: 87649
diff changeset
124 ;; however, still not handle the case where read-only text ends
1c868d4c8354 (delete-selection-pre-hook): Avoid clearing out
Martin Rudalics <rudalics@gmx.at>
parents: 87649
diff changeset
125 ;; precisely where the region starts: In that case the deletion
1c868d4c8354 (delete-selection-pre-hook): Avoid clearing out
Martin Rudalics <rudalics@gmx.at>
parents: 87649
diff changeset
126 ;; would succeed but the subsequent insertion would fail with a
1c868d4c8354 (delete-selection-pre-hook): Avoid clearing out
Martin Rudalics <rudalics@gmx.at>
parents: 87649
diff changeset
127 ;; text-read-only error. To handle that case we would have to
1c868d4c8354 (delete-selection-pre-hook): Avoid clearing out
Martin Rudalics <rudalics@gmx.at>
parents: 87649
diff changeset
128 ;; investigate text properties at both ends of the region and
1c868d4c8354 (delete-selection-pre-hook): Avoid clearing out
Martin Rudalics <rudalics@gmx.at>
parents: 87649
diff changeset
129 ;; skip the deletion when inserting text is forbidden there.
1c868d4c8354 (delete-selection-pre-hook): Avoid clearing out
Martin Rudalics <rudalics@gmx.at>
parents: 87649
diff changeset
130 (message "Text is read-only") (ding))))))
2073
b4d5c9926d98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
131
2903
fa41174db2fa Renamed from pending-del.el.
Richard M. Stallman <rms@gnu.org>
parents: 2233
diff changeset
132 (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
133 (put 'self-insert-iso 'delete-selection t)
2073
b4d5c9926d98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
134
12790
afe7f3c735a3 (delete-selection-pre-hook): New type value `yank'.
Richard M. Stallman <rms@gnu.org>
parents: 11589
diff changeset
135 (put 'yank 'delete-selection 'yank)
13077
65092cab3f43 (clipboard-yank): Add delete-selection property.
Richard M. Stallman <rms@gnu.org>
parents: 12790
diff changeset
136 (put 'clipboard-yank 'delete-selection 'yank)
2925
902c32c709f7 Provide delsel.
Richard M. Stallman <rms@gnu.org>
parents: 2903
diff changeset
137 (put 'insert-register 'delete-selection t)
2073
b4d5c9926d98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
138
2903
fa41174db2fa Renamed from pending-del.el.
Richard M. Stallman <rms@gnu.org>
parents: 2233
diff changeset
139 (put 'delete-backward-char 'delete-selection 'supersede)
fa41174db2fa Renamed from pending-del.el.
Richard M. Stallman <rms@gnu.org>
parents: 2233
diff changeset
140 (put 'backward-delete-char-untabify 'delete-selection 'supersede)
fa41174db2fa Renamed from pending-del.el.
Richard M. Stallman <rms@gnu.org>
parents: 2233
diff changeset
141 (put 'delete-char 'delete-selection 'supersede)
2073
b4d5c9926d98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
142
21720
b1ee274d921b Don't require cl. Minor doc fixes.
Dave Love <fx@gnu.org>
parents: 19488
diff changeset
143 (put 'newline-and-indent 'delete-selection t)
2903
fa41174db2fa Renamed from pending-del.el.
Richard M. Stallman <rms@gnu.org>
parents: 2233
diff changeset
144 (put 'newline 'delete-selection t)
21720
b1ee274d921b Don't require cl. Minor doc fixes.
Dave Love <fx@gnu.org>
parents: 19488
diff changeset
145 (put 'open-line 'delete-selection 'kill)
b1ee274d921b Don't require cl. Minor doc fixes.
Dave Love <fx@gnu.org>
parents: 19488
diff changeset
146
30817
fd8b296712e7 (delsel-unload-hook): New function.
Dave Love <fx@gnu.org>
parents: 29156
diff changeset
147 ;; 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
148 ;; aborting the minibuffer.
b4d5c9926d98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
149 (defun minibuffer-keyboard-quit ()
b4d5c9926d98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
150 "Abort recursive edit.
21720
b1ee274d921b Don't require cl. Minor doc fixes.
Dave Love <fx@gnu.org>
parents: 19488
diff changeset
151 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
152 then it takes a second \\[keyboard-quit] to abort the minibuffer."
2073
b4d5c9926d98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
153 (interactive)
2925
902c32c709f7 Provide delsel.
Richard M. Stallman <rms@gnu.org>
parents: 2903
diff changeset
154 (if (and delete-selection-mode transient-mark-mode mark-active)
902c32c709f7 Provide delsel.
Richard M. Stallman <rms@gnu.org>
parents: 2903
diff changeset
155 (setq deactivate-mark t)
2073
b4d5c9926d98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
156 (abort-recursive-edit)))
b4d5c9926d98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
157
30817
fd8b296712e7 (delsel-unload-hook): New function.
Dave Love <fx@gnu.org>
parents: 29156
diff changeset
158 (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
159 (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
160 (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
161 (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
162 (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
163
85811
cd42bdedadb3 (delsel-unload-hook): Remove function and variable.
Juanma Barranquero <lekktu@gmail.com>
parents: 85073
diff changeset
164 (defun delsel-unload-function ()
cd42bdedadb3 (delsel-unload-hook): Remove function and variable.
Juanma Barranquero <lekktu@gmail.com>
parents: 85073
diff changeset
165 "Unload the Delete Selection library."
30817
fd8b296712e7 (delsel-unload-hook): New function.
Dave Love <fx@gnu.org>
parents: 29156
diff changeset
166 (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
167 (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
168 (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
169 (define-key minibuffer-local-must-match-map "\C-g" 'abort-recursive-edit)
85811
cd42bdedadb3 (delsel-unload-hook): Remove function and variable.
Juanma Barranquero <lekktu@gmail.com>
parents: 85073
diff changeset
170 (define-key minibuffer-local-isearch-map "\C-g" 'abort-recursive-edit)
cd42bdedadb3 (delsel-unload-hook): Remove function and variable.
Juanma Barranquero <lekktu@gmail.com>
parents: 85073
diff changeset
171 (dolist (sym '(self-insert-command self-insert-iso yank clipboard-yank
cd42bdedadb3 (delsel-unload-hook): Remove function and variable.
Juanma Barranquero <lekktu@gmail.com>
parents: 85073
diff changeset
172 insert-register delete-backward-char backward-delete-char-untabify
cd42bdedadb3 (delsel-unload-hook): Remove function and variable.
Juanma Barranquero <lekktu@gmail.com>
parents: 85073
diff changeset
173 delete-char newline-and-indent newline open-line))
87936
b3879b6d2e40 (delsel-unload-function): Don't use `remprop'; it is not autoloaded,
Juanma Barranquero <lekktu@gmail.com>
parents: 87933
diff changeset
174 (put sym 'delete-selection nil))
85811
cd42bdedadb3 (delsel-unload-hook): Remove function and variable.
Juanma Barranquero <lekktu@gmail.com>
parents: 85073
diff changeset
175 ;; continue standard unloading
cd42bdedadb3 (delsel-unload-hook): Remove function and variable.
Juanma Barranquero <lekktu@gmail.com>
parents: 85073
diff changeset
176 nil)
57540
8bf58c5521d8 (delsel-unload-hook): Set as a variable.
Richard M. Stallman <rms@gnu.org>
parents: 55278
diff changeset
177
2925
902c32c709f7 Provide delsel.
Richard M. Stallman <rms@gnu.org>
parents: 2903
diff changeset
178 (provide 'delsel)
2073
b4d5c9926d98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
179
93975
1e3a407766b9 Fix up comment convention on the arch-tag lines.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 87936
diff changeset
180 ;; arch-tag: 1e388890-1b50-4ed0-9347-763b1343b6ed
2925
902c32c709f7 Provide delsel.
Richard M. Stallman <rms@gnu.org>
parents: 2903
diff changeset
181 ;;; delsel.el ends here