emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] /srv/bzr/emacs/trunk r100654: * bindings.el (global-map):


From: Chong Yidong
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r100654: * bindings.el (global-map): Bind delete and DEL, the former to
Date: Sun, 27 Jun 2010 21:01:11 -0400
User-agent: Bazaar (2.0.3)

------------------------------------------------------------
revno: 100654
committer: Chong Yidong <address@hidden>
branch nick: trunk
timestamp: Sun 2010-06-27 21:01:11 -0400
message:
  * 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.
modified:
  etc/NEWS
  lisp/ChangeLog
  lisp/bindings.el
  lisp/mouse.el
  lisp/simple.el
  src/ChangeLog
  src/cmds.c
=== modified file 'etc/NEWS'
--- a/etc/NEWS  2010-06-27 00:30:52 +0000
+++ b/etc/NEWS  2010-06-28 01:01:11 +0000
@@ -144,6 +144,25 @@
 ** completion-at-point is now an alias for complete-symbol.
 
 ** mouse-region-delete-keys has been deleted.
+
+** Deletion changes
+
+*** New option `delete-active-region'.
+If non-nil, C-d, [delete], and DEL delete the region if it is active
+and no prefix argument is given.  If set to `kill', these commands
+kill instead.
+
+*** New command `delete-forward-char', bound to C-d and [delete].
+This is meant for interactive use, and obeys `delete-active-region';
+delete-char, meant for Lisp, does not obey `delete-active-region'.
+
+*** `delete-backward-char' is now a Lisp function.
+Apart from obeying `delete-active-region', its behavior is unchanged.
+However, the byte compiler now warns if it is called from Lisp; you
+should use delete-char with a negative argument instead.
+
+*** The option `mouse-region-delete-keys' has been deleted.
+
 
 * Changes in Specialized Modes and Packages in Emacs 24.1
 

=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2010-06-27 18:18:49 +0000
+++ b/lisp/ChangeLog    2010-06-28 01:01:11 +0000
@@ -1,3 +1,15 @@
+2010-06-28  Chong Yidong  <address@hidden>
+
+       * simple.el (delete-active-region): New option.
+       (delete-backward-char): Implement in Lisp.
+       (delete-forward-char): New command.
+
+       * mouse.el (mouse-region-delete-keys): Deleted.
+       (mouse-show-mark): Simplify.
+
+       * bindings.el (global-map): Bind delete and DEL, the former to
+       delete-forward-char.
+
 2010-01-16  Lennart Borgman  <address@hidden>
 
        * progmodes/ruby-mode.el (ruby-mode-map): Don't bind TAB.

=== modified file 'lisp/bindings.el'
--- a/lisp/bindings.el  2010-05-29 15:19:13 +0000
+++ b/lisp/bindings.el  2010-06-28 01:01:11 +0000
@@ -822,6 +822,9 @@
     (setq i (1+ i))))
 (define-key global-map [?\C-\M--] 'negative-argument)
 
+(define-key global-map "\177" 'delete-backward-char)
+(define-key global-map "\C-d" 'delete-forward-char)
+
 (define-key global-map "\C-k" 'kill-line)
 (define-key global-map "\C-w" 'kill-region)
 (define-key esc-map "w" 'kill-ring-save)

=== modified file 'lisp/mouse.el'
--- a/lisp/mouse.el     2010-01-13 08:35:10 +0000
+++ b/lisp/mouse.el     2010-06-28 01:01:11 +0000
@@ -929,7 +929,7 @@
   (mouse-minibuffer-check start-event)
   (setq mouse-selection-click-count-buffer (current-buffer))
   ;; We must call deactivate-mark before repositioning point.
-  ;; Otherwise, for select-active-regions non-nil, we get the wrong
+  ;; Otherwise, for `select-active-regions' non-nil, we get the wrong
   ;; selection if the user drags a region, clicks elsewhere to
   ;; reposition point, then middle-clicks to paste the selection.
   (deactivate-mark)
@@ -1263,11 +1263,6 @@
 
 ;; Momentarily show where the mark is, if highlighting doesn't show it.
 
-(defcustom mouse-region-delete-keys '([delete] [deletechar] [backspace])
-  "List of keys that should cause the mouse region to be deleted."
-  :group 'mouse
-  :type '(repeat key-sequence))
-
 (defun mouse-show-mark ()
   (let ((inhibit-quit t)
        (echo-keystrokes 0)
@@ -1297,8 +1292,7 @@
                                 'vertical-scroll-bar))
                        (and (memq 'down (event-modifiers event))
                             (not (key-binding key))
-                            (not (mouse-undouble-last-event events))
-                            (not (member key mouse-region-delete-keys)))))
+                            (not (mouse-undouble-last-event events)))))
        (and (consp event)
             (or (eq (car event) 'switch-frame)
                 (eq (posn-point (event-end event))
@@ -1311,22 +1305,9 @@
                      (setq events nil)))))))
     ;; If we lost the selection, just turn off the highlighting.
     (unless ignore
-      ;; For certain special keys, delete the region.
-      (if (member key mouse-region-delete-keys)
-         (progn
-           ;; Since notionally this is a separate command,
-           ;; run all the hooks that would be run if it were
-           ;; executed separately.
-           (run-hooks 'post-command-hook)
-           (setq last-command this-command)
-           (setq this-original-command 'delete-region)
-           (setq this-command (or (command-remapping this-original-command)
-                                  this-original-command))
-           (run-hooks 'pre-command-hook)
-           (call-interactively this-command))
-       ;; Otherwise, unread the key so it gets executed normally.
-       (setq unread-command-events
-             (nconc events unread-command-events))))
+      ;; Unread the key so it gets executed normally.
+      (setq unread-command-events
+           (nconc events unread-command-events)))
     (setq quit-flag nil)
     (unless transient-mark-mode
       (delete-overlay mouse-drag-overlay))))

=== modified file 'lisp/simple.el'
--- a/lisp/simple.el    2010-06-21 23:26:46 +0000
+++ b/lisp/simple.el    2010-06-28 01:01:11 +0000
@@ -844,6 +844,78 @@
         (overlay-recenter (point))
         (recenter -3))))
 
+(defcustom delete-active-region t
+  "Whether single-char deletion commands delete an active region.
+This has an effect only if Transient Mark mode is enabled, and
+affects `delete-forward-char' and `delete-backward-char', though
+not `delete-char'.
+
+If the value is the symbol `kill', the active region is killed
+instead of deleted."
+  :type '(choice (const :tag "Delete active region" t)
+                 (const :tag "Kill active region" kill)
+                 (const :tag "Do ordinary deletion" nil))
+  :group 'editing
+  :version "24.1")
+
+(defun delete-backward-char (n &optional killflag)
+  "Delete the previous N characters (following if N is negative).
+If Transient Mark mode is enabled, the mark is active, and N is 1,
+delete the text in the region and deactivate the mark instead.
+To disable this, set `delete-active-region' to nil.
+
+Optional second arg KILLFLAG, if non-nil, means to kill (save in
+kill ring) instead of delete.  Interactively, N is the prefix
+arg, and KILLFLAG is set if N is explicitly specified.
+
+In Overwrite mode, single character backward deletion may replace
+tabs with spaces so as to back over columns, unless point is at
+the end of the line."
+  (interactive "p\nP")
+  (unless (integerp n)
+    (signal 'wrong-type-argument (list 'integerp n)))
+  (cond ((and (use-region-p)
+             delete-active-region
+             (= n 1))
+        ;; If a region is active, kill or delete it.
+        (if (eq delete-active-region 'kill)
+            (kill-region (region-beginning) (region-end))
+          (delete-region (region-beginning) (region-end))))
+       ;; In Overwrite mode, maybe untabify while deleting
+       ((null (or (null overwrite-mode)
+                  (<= n 0)
+                  (memq (char-before) '(?\t ?\n))
+                  (eobp)
+                  (eq (char-after) ?\n)))
+        (let* ((ocol (current-column))
+               (val (delete-char (- n) killflag)))
+          (save-excursion
+            (insert-char ?\s (- ocol (current-column)) nil))))
+       ;; Otherwise, do simple deletion.
+       (t (delete-char (- n) killflag))))
+
+(defun delete-forward-char (n &optional killflag)
+  "Delete the previous N characters (following if N is negative).
+If Transient Mark mode is enabled, the mark is active, and N is 1,
+delete the text in the region and deactivate the mark instead.
+To disable this, set `delete-active-region' to nil.
+
+Optional second arg KILLFLAG non-nil means to kill (save in kill
+ring) instead of delete.  Interactively, N is the prefix arg, and
+KILLFLAG is set if N was explicitly specified."
+  (interactive "p\nP")
+  (unless (integerp n)
+    (signal 'wrong-type-argument (list 'integerp n)))
+  (cond ((and (use-region-p)
+             delete-active-region
+             (= n 1))
+        ;; If a region is active, kill or delete it.
+        (if (eq delete-active-region 'kill)
+            (kill-region (region-beginning) (region-end))
+          (delete-region (region-beginning) (region-end))))
+       ;; Otherwise, do simple deletion.
+       (t (delete-char n killflag))))
+
 (defun mark-whole-buffer ()
   "Put point at beginning and mark at end of buffer.
 You probably should not use this function in Lisp programs;

=== modified file 'src/ChangeLog'
--- a/src/ChangeLog     2010-06-27 21:28:51 +0000
+++ b/src/ChangeLog     2010-06-28 01:01:11 +0000
@@ -1,3 +1,7 @@
+2010-06-28  Chong Yidong  <address@hidden>
+
+       * cmds.c (Fdelete_backward_char): Move into Lisp.
+
 2010-06-27  Dan Nicolaescu  <address@hidden>
 
        * s/freebsd.h (BSD4_2): Remove redundant definition.

=== modified file 'src/cmds.c'
--- a/src/cmds.c        2010-06-07 10:35:57 +0000
+++ b/src/cmds.c        2010-06-28 01:01:11 +0000
@@ -240,7 +240,9 @@
        doc: /* Delete the following N characters (previous if N is negative).
 Optional second arg KILLFLAG non-nil means kill instead (save in kill ring).
 Interactively, N is the prefix arg, and KILLFLAG is set if
-N was explicitly specified.  */)
+N was explicitly specified.
+
+The command `delete-forward' is preferable for interactive use.  */)
      (n, killflag)
      Lisp_Object n, killflag;
 {
@@ -273,60 +275,6 @@
   return Qnil;
 }
 
-DEFUN ("delete-backward-char", Fdelete_backward_char, Sdelete_backward_char,
-       1, 2, "p\nP",
-       doc: /* Delete the previous N characters (following if N is negative).
-Optional second arg KILLFLAG non-nil means kill instead (save in kill ring).
-Interactively, N is the prefix arg, and KILLFLAG is set if
-N was explicitly specified.
-This is meant for interactive use only; from Lisp, better use `delete-char'
-with a negated argument.  */)
-     (n, killflag)
-     Lisp_Object n, killflag;
-{
-  Lisp_Object value;
-  int deleted_special = 0;
-  int pos, pos_byte, i;
-
-  CHECK_NUMBER (n);
-
-  /* See if we are about to delete a tab or newline backwards.  */
-  pos = PT;
-  pos_byte = PT_BYTE;
-  for (i = 0; i < XINT (n) && pos_byte > BEGV_BYTE; i++)
-    {
-      int c;
-
-      DEC_BOTH (pos, pos_byte);
-      c = FETCH_BYTE (pos_byte);
-      if (c == '\t' || c == '\n')
-       {
-         deleted_special = 1;
-         break;
-       }
-    }
-
-  /* In overwrite mode, back over columns while clearing them out,
-     unless at end of line.  */
-  if (XINT (n) > 0
-      && ! NILP (current_buffer->overwrite_mode)
-      && ! deleted_special
-      && ! (PT == ZV || FETCH_BYTE (PT_BYTE) == '\n'))
-    {
-      int column = (int) current_column (); /* iftc */
-
-      value = Fdelete_char (make_number (-XINT (n)), killflag);
-      i = column - (int) current_column (); /* iftc */
-      Finsert_char (make_number (' '), make_number (i), Qnil);
-      /* Whitespace chars are ASCII chars, so we can simply subtract.  */
-      SET_PT_BOTH (PT - i, PT_BYTE - i);
-    }
-  else
-    value = Fdelete_char (make_number (-XINT (n)), killflag);
-
-  return value;
-}
-
 static int nonundocount;
 
 /* Note that there's code in command_loop_1 which typically avoids
@@ -635,8 +583,6 @@
   defsubr (&Send_of_line);
 
   defsubr (&Sdelete_char);
-  defsubr (&Sdelete_backward_char);
-
   defsubr (&Sself_insert_command);
 }
 
@@ -658,10 +604,8 @@
 
   initial_define_key (global_map, Ctl ('A'), "beginning-of-line");
   initial_define_key (global_map, Ctl ('B'), "backward-char");
-  initial_define_key (global_map, Ctl ('D'), "delete-char");
   initial_define_key (global_map, Ctl ('E'), "end-of-line");
   initial_define_key (global_map, Ctl ('F'), "forward-char");
-  initial_define_key (global_map, 0177, "delete-backward-char");
 }
 
 /* arch-tag: 022ba3cd-67f9-4978-9c5d-7d2b18d8644e


reply via email to

[Prev in Thread] Current Thread [Next in Thread]