aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorChong Yidong2010-06-27 21:01:11 -0400
committerChong Yidong2010-06-27 21:01:11 -0400
commitb92296739624ac4928d7ed90155b4ee91625fea4 (patch)
tree987fb8c53b7d247c228c6910e2315b5183233dee /lisp
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.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/ChangeLog12
-rw-r--r--lisp/bindings.el3
-rw-r--r--lisp/mouse.el29
-rw-r--r--lisp/simple.el72
4 files changed, 92 insertions, 24 deletions
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;