aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChong Yidong2010-06-27 21:01:11 -0400
committerChong Yidong2010-06-27 21:01:11 -0400
commitb92296739624ac4928d7ed90155b4ee91625fea4 (patch)
tree987fb8c53b7d247c228c6910e2315b5183233dee
parentbbc803b0bc876ed1f548cdbfc20fd819a430f0ac (diff)
downloademacs-b92296739624ac4928d7ed90155b4ee91625fea4.tar.gz
emacs-b92296739624ac4928d7ed90155b4ee91625fea4.zip
* bindings.el (global-map): Bind delete and DEL, the former to
delete-forward-char. * mouse.el (mouse-region-delete-keys): Deleted. (mouse-show-mark): Simplify. * simple.el (delete-active-region): New option. (delete-backward-char): Implement in Lisp. (delete-forward-char): New command. * src/cmds.c (Fdelete_backward_char): Move into Lisp.
-rw-r--r--etc/NEWS19
-rw-r--r--lisp/ChangeLog12
-rw-r--r--lisp/bindings.el3
-rw-r--r--lisp/mouse.el29
-rw-r--r--lisp/simple.el72
-rw-r--r--src/ChangeLog4
-rw-r--r--src/cmds.c62
7 files changed, 118 insertions, 83 deletions
diff --git a/etc/NEWS b/etc/NEWS
index ef791281671..ba320c153e0 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -144,6 +144,25 @@ loaded, customize `package-load-list'.
144** completion-at-point is now an alias for complete-symbol. 144** completion-at-point is now an alias for complete-symbol.
145 145
146** mouse-region-delete-keys has been deleted. 146** mouse-region-delete-keys has been deleted.
147
148** Deletion changes
149
150*** New option `delete-active-region'.
151If non-nil, C-d, [delete], and DEL delete the region if it is active
152and no prefix argument is given. If set to `kill', these commands
153kill instead.
154
155*** New command `delete-forward-char', bound to C-d and [delete].
156This is meant for interactive use, and obeys `delete-active-region';
157delete-char, meant for Lisp, does not obey `delete-active-region'.
158
159*** `delete-backward-char' is now a Lisp function.
160Apart from obeying `delete-active-region', its behavior is unchanged.
161However, the byte compiler now warns if it is called from Lisp; you
162should use delete-char with a negative argument instead.
163
164*** The option `mouse-region-delete-keys' has been deleted.
165
147 166
148* Changes in Specialized Modes and Packages in Emacs 24.1 167* Changes in Specialized Modes and Packages in Emacs 24.1
149 168
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index d88b7dfab2c..089264183bc 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,15 @@
12010-06-28 Chong Yidong <cyd@stupidchicken.com>
2
3 * simple.el (delete-active-region): New option.
4 (delete-backward-char): Implement in Lisp.
5 (delete-forward-char): New command.
6
7 * mouse.el (mouse-region-delete-keys): Deleted.
8 (mouse-show-mark): Simplify.
9
10 * bindings.el (global-map): Bind delete and DEL, the former to
11 delete-forward-char.
12
12010-01-16 Lennart Borgman <lennart.borgman@gmail.com> 132010-01-16 Lennart Borgman <lennart.borgman@gmail.com>
2 14
3 * progmodes/ruby-mode.el (ruby-mode-map): Don't bind TAB. 15 * progmodes/ruby-mode.el (ruby-mode-map): Don't bind TAB.
diff --git a/lisp/bindings.el b/lisp/bindings.el
index f9d3e75cf6e..4eab37edf46 100644
--- a/lisp/bindings.el
+++ b/lisp/bindings.el
@@ -822,6 +822,9 @@ if `inhibit-field-text-motion' is non-nil."
822 (setq i (1+ i)))) 822 (setq i (1+ i))))
823(define-key global-map [?\C-\M--] 'negative-argument) 823(define-key global-map [?\C-\M--] 'negative-argument)
824 824
825(define-key global-map "\177" 'delete-backward-char)
826(define-key global-map "\C-d" 'delete-forward-char)
827
825(define-key global-map "\C-k" 'kill-line) 828(define-key global-map "\C-k" 'kill-line)
826(define-key global-map "\C-w" 'kill-region) 829(define-key global-map "\C-w" 'kill-region)
827(define-key esc-map "w" 'kill-ring-save) 830(define-key esc-map "w" 'kill-ring-save)
diff --git a/lisp/mouse.el b/lisp/mouse.el
index d1abb7dd4b1..f6ff37794a5 100644
--- a/lisp/mouse.el
+++ b/lisp/mouse.el
@@ -929,7 +929,7 @@ should only be used by mouse-drag-region."
929 (mouse-minibuffer-check start-event) 929 (mouse-minibuffer-check start-event)
930 (setq mouse-selection-click-count-buffer (current-buffer)) 930 (setq mouse-selection-click-count-buffer (current-buffer))
931 ;; We must call deactivate-mark before repositioning point. 931 ;; We must call deactivate-mark before repositioning point.
932 ;; Otherwise, for select-active-regions non-nil, we get the wrong 932 ;; Otherwise, for `select-active-regions' non-nil, we get the wrong
933 ;; selection if the user drags a region, clicks elsewhere to 933 ;; selection if the user drags a region, clicks elsewhere to
934 ;; reposition point, then middle-clicks to paste the selection. 934 ;; reposition point, then middle-clicks to paste the selection.
935 (deactivate-mark) 935 (deactivate-mark)
@@ -1263,11 +1263,6 @@ If MODE is 2 then do the same for lines."
1263 1263
1264;; Momentarily show where the mark is, if highlighting doesn't show it. 1264;; Momentarily show where the mark is, if highlighting doesn't show it.
1265 1265
1266(defcustom mouse-region-delete-keys '([delete] [deletechar] [backspace])
1267 "List of keys that should cause the mouse region to be deleted."
1268 :group 'mouse
1269 :type '(repeat key-sequence))
1270
1271(defun mouse-show-mark () 1266(defun mouse-show-mark ()
1272 (let ((inhibit-quit t) 1267 (let ((inhibit-quit t)
1273 (echo-keystrokes 0) 1268 (echo-keystrokes 0)
@@ -1297,8 +1292,7 @@ If MODE is 2 then do the same for lines."
1297 'vertical-scroll-bar)) 1292 'vertical-scroll-bar))
1298 (and (memq 'down (event-modifiers event)) 1293 (and (memq 'down (event-modifiers event))
1299 (not (key-binding key)) 1294 (not (key-binding key))
1300 (not (mouse-undouble-last-event events)) 1295 (not (mouse-undouble-last-event events)))))
1301 (not (member key mouse-region-delete-keys)))))
1302 (and (consp event) 1296 (and (consp event)
1303 (or (eq (car event) 'switch-frame) 1297 (or (eq (car event) 'switch-frame)
1304 (eq (posn-point (event-end event)) 1298 (eq (posn-point (event-end event))
@@ -1311,22 +1305,9 @@ If MODE is 2 then do the same for lines."
1311 (setq events nil))))))) 1305 (setq events nil)))))))
1312 ;; If we lost the selection, just turn off the highlighting. 1306 ;; If we lost the selection, just turn off the highlighting.
1313 (unless ignore 1307 (unless ignore
1314 ;; For certain special keys, delete the region. 1308 ;; Unread the key so it gets executed normally.
1315 (if (member key mouse-region-delete-keys) 1309 (setq unread-command-events
1316 (progn 1310 (nconc events unread-command-events)))
1317 ;; Since notionally this is a separate command,
1318 ;; run all the hooks that would be run if it were
1319 ;; executed separately.
1320 (run-hooks 'post-command-hook)
1321 (setq last-command this-command)
1322 (setq this-original-command 'delete-region)
1323 (setq this-command (or (command-remapping this-original-command)
1324 this-original-command))
1325 (run-hooks 'pre-command-hook)
1326 (call-interactively this-command))
1327 ;; Otherwise, unread the key so it gets executed normally.
1328 (setq unread-command-events
1329 (nconc events unread-command-events))))
1330 (setq quit-flag nil) 1311 (setq quit-flag nil)
1331 (unless transient-mark-mode 1312 (unless transient-mark-mode
1332 (delete-overlay mouse-drag-overlay)))) 1313 (delete-overlay mouse-drag-overlay))))
diff --git a/lisp/simple.el b/lisp/simple.el
index ef30e98dd1c..a7876335c17 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -844,6 +844,78 @@ Don't use this command in Lisp programs!
844 (overlay-recenter (point)) 844 (overlay-recenter (point))
845 (recenter -3)))) 845 (recenter -3))))
846 846
847(defcustom delete-active-region t
848 "Whether single-char deletion commands delete an active region.
849This has an effect only if Transient Mark mode is enabled, and
850affects `delete-forward-char' and `delete-backward-char', though
851not `delete-char'.
852
853If the value is the symbol `kill', the active region is killed
854instead of deleted."
855 :type '(choice (const :tag "Delete active region" t)
856 (const :tag "Kill active region" kill)
857 (const :tag "Do ordinary deletion" nil))
858 :group 'editing
859 :version "24.1")
860
861(defun delete-backward-char (n &optional killflag)
862 "Delete the previous N characters (following if N is negative).
863If Transient Mark mode is enabled, the mark is active, and N is 1,
864delete the text in the region and deactivate the mark instead.
865To disable this, set `delete-active-region' to nil.
866
867Optional second arg KILLFLAG, if non-nil, means to kill (save in
868kill ring) instead of delete. Interactively, N is the prefix
869arg, and KILLFLAG is set if N is explicitly specified.
870
871In Overwrite mode, single character backward deletion may replace
872tabs with spaces so as to back over columns, unless point is at
873the end of the line."
874 (interactive "p\nP")
875 (unless (integerp n)
876 (signal 'wrong-type-argument (list 'integerp n)))
877 (cond ((and (use-region-p)
878 delete-active-region
879 (= n 1))
880 ;; If a region is active, kill or delete it.
881 (if (eq delete-active-region 'kill)
882 (kill-region (region-beginning) (region-end))
883 (delete-region (region-beginning) (region-end))))
884 ;; In Overwrite mode, maybe untabify while deleting
885 ((null (or (null overwrite-mode)
886 (<= n 0)
887 (memq (char-before) '(?\t ?\n))
888 (eobp)
889 (eq (char-after) ?\n)))
890 (let* ((ocol (current-column))
891 (val (delete-char (- n) killflag)))
892 (save-excursion
893 (insert-char ?\s (- ocol (current-column)) nil))))
894 ;; Otherwise, do simple deletion.
895 (t (delete-char (- n) killflag))))
896
897(defun delete-forward-char (n &optional killflag)
898 "Delete the previous N characters (following if N is negative).
899If Transient Mark mode is enabled, the mark is active, and N is 1,
900delete the text in the region and deactivate the mark instead.
901To disable this, set `delete-active-region' to nil.
902
903Optional second arg KILLFLAG non-nil means to kill (save in kill
904ring) instead of delete. Interactively, N is the prefix arg, and
905KILLFLAG is set if N was explicitly specified."
906 (interactive "p\nP")
907 (unless (integerp n)
908 (signal 'wrong-type-argument (list 'integerp n)))
909 (cond ((and (use-region-p)
910 delete-active-region
911 (= n 1))
912 ;; If a region is active, kill or delete it.
913 (if (eq delete-active-region 'kill)
914 (kill-region (region-beginning) (region-end))
915 (delete-region (region-beginning) (region-end))))
916 ;; Otherwise, do simple deletion.
917 (t (delete-char n killflag))))
918
847(defun mark-whole-buffer () 919(defun mark-whole-buffer ()
848 "Put point at beginning and mark at end of buffer. 920 "Put point at beginning and mark at end of buffer.
849You probably should not use this function in Lisp programs; 921You probably should not use this function in Lisp programs;
diff --git a/src/ChangeLog b/src/ChangeLog
index 12e45710e62..18e12b5e022 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,7 @@
12010-06-28 Chong Yidong <cyd@stupidchicken.com>
2
3 * cmds.c (Fdelete_backward_char): Move into Lisp.
4
12010-06-27 Dan Nicolaescu <dann@ics.uci.edu> 52010-06-27 Dan Nicolaescu <dann@ics.uci.edu>
2 6
3 * s/freebsd.h (BSD4_2): Remove redundant definition. 7 * s/freebsd.h (BSD4_2): Remove redundant definition.
diff --git a/src/cmds.c b/src/cmds.c
index ba89c532be8..465fce18a4b 100644
--- a/src/cmds.c
+++ b/src/cmds.c
@@ -240,7 +240,9 @@ DEFUN ("delete-char", Fdelete_char, Sdelete_char, 1, 2, "p\nP",
240 doc: /* Delete the following N characters (previous if N is negative). 240 doc: /* Delete the following N characters (previous if N is negative).
241Optional second arg KILLFLAG non-nil means kill instead (save in kill ring). 241Optional second arg KILLFLAG non-nil means kill instead (save in kill ring).
242Interactively, N is the prefix arg, and KILLFLAG is set if 242Interactively, N is the prefix arg, and KILLFLAG is set if
243N was explicitly specified. */) 243N was explicitly specified.
244
245The command `delete-forward' is preferable for interactive use. */)
244 (n, killflag) 246 (n, killflag)
245 Lisp_Object n, killflag; 247 Lisp_Object n, killflag;
246{ 248{
@@ -273,60 +275,6 @@ N was explicitly specified. */)
273 return Qnil; 275 return Qnil;
274} 276}
275 277
276DEFUN ("delete-backward-char", Fdelete_backward_char, Sdelete_backward_char,
277 1, 2, "p\nP",
278 doc: /* Delete the previous N characters (following if N is negative).
279Optional second arg KILLFLAG non-nil means kill instead (save in kill ring).
280Interactively, N is the prefix arg, and KILLFLAG is set if
281N was explicitly specified.
282This is meant for interactive use only; from Lisp, better use `delete-char'
283with a negated argument. */)
284 (n, killflag)
285 Lisp_Object n, killflag;
286{
287 Lisp_Object value;
288 int deleted_special = 0;
289 int pos, pos_byte, i;
290
291 CHECK_NUMBER (n);
292
293 /* See if we are about to delete a tab or newline backwards. */
294 pos = PT;
295 pos_byte = PT_BYTE;
296 for (i = 0; i < XINT (n) && pos_byte > BEGV_BYTE; i++)
297 {
298 int c;
299
300 DEC_BOTH (pos, pos_byte);
301 c = FETCH_BYTE (pos_byte);
302 if (c == '\t' || c == '\n')
303 {
304 deleted_special = 1;
305 break;
306 }
307 }
308
309 /* In overwrite mode, back over columns while clearing them out,
310 unless at end of line. */
311 if (XINT (n) > 0
312 && ! NILP (current_buffer->overwrite_mode)
313 && ! deleted_special
314 && ! (PT == ZV || FETCH_BYTE (PT_BYTE) == '\n'))
315 {
316 int column = (int) current_column (); /* iftc */
317
318 value = Fdelete_char (make_number (-XINT (n)), killflag);
319 i = column - (int) current_column (); /* iftc */
320 Finsert_char (make_number (' '), make_number (i), Qnil);
321 /* Whitespace chars are ASCII chars, so we can simply subtract. */
322 SET_PT_BOTH (PT - i, PT_BYTE - i);
323 }
324 else
325 value = Fdelete_char (make_number (-XINT (n)), killflag);
326
327 return value;
328}
329
330static int nonundocount; 278static int nonundocount;
331 279
332/* Note that there's code in command_loop_1 which typically avoids 280/* Note that there's code in command_loop_1 which typically avoids
@@ -635,8 +583,6 @@ More precisely, a char with closeparen syntax is self-inserted. */);
635 defsubr (&Send_of_line); 583 defsubr (&Send_of_line);
636 584
637 defsubr (&Sdelete_char); 585 defsubr (&Sdelete_char);
638 defsubr (&Sdelete_backward_char);
639
640 defsubr (&Sself_insert_command); 586 defsubr (&Sself_insert_command);
641} 587}
642 588
@@ -658,10 +604,8 @@ keys_of_cmds ()
658 604
659 initial_define_key (global_map, Ctl ('A'), "beginning-of-line"); 605 initial_define_key (global_map, Ctl ('A'), "beginning-of-line");
660 initial_define_key (global_map, Ctl ('B'), "backward-char"); 606 initial_define_key (global_map, Ctl ('B'), "backward-char");
661 initial_define_key (global_map, Ctl ('D'), "delete-char");
662 initial_define_key (global_map, Ctl ('E'), "end-of-line"); 607 initial_define_key (global_map, Ctl ('E'), "end-of-line");
663 initial_define_key (global_map, Ctl ('F'), "forward-char"); 608 initial_define_key (global_map, Ctl ('F'), "forward-char");
664 initial_define_key (global_map, 0177, "delete-backward-char");
665} 609}
666 610
667/* arch-tag: 022ba3cd-67f9-4978-9c5d-7d2b18d8644e 611/* arch-tag: 022ba3cd-67f9-4978-9c5d-7d2b18d8644e