comparison lisp/mouse.el @ 109062:d8144fe7f3f8

* 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.
author Chong Yidong <cyd@stupidchicken.com>
date Sun, 27 Jun 2010 21:01:11 -0400
parents 1d1d5d9bd884
children a46a2b77a8b1
comparison
equal deleted inserted replaced
109061:c05c5a981dd9 109062:d8144fe7f3f8
927 will be deleted after return. DO-MOUSE-DRAG-REGION-POST-PROCESS 927 will be deleted after return. DO-MOUSE-DRAG-REGION-POST-PROCESS
928 should only be used by mouse-drag-region." 928 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)
936 (let* ((original-window (selected-window)) 936 (let* ((original-window (selected-window))
937 ;; We've recorded what we needed from the current buffer and 937 ;; We've recorded what we needed from the current buffer and
1261 (setcar last event) 1261 (setcar last event)
1262 nil))) 1262 nil)))
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)
1274 event events key ignore 1269 event events key ignore
1275 (x-lost-selection-functions 1270 (x-lost-selection-functions
1295 (and (consp event) 1290 (and (consp event)
1296 (eq (posn-point (event-end event)) 1291 (eq (posn-point (event-end event))
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))
1305 'vertical-scroll-bar)) 1299 'vertical-scroll-bar))
1306 (let ((keys (vector 'vertical-scroll-bar event))) 1300 (let ((keys (vector 'vertical-scroll-bar event)))
1309 (call-interactively (key-binding keys) 1303 (call-interactively (key-binding keys)
1310 nil keys) 1304 nil keys)
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))))
1333 1314
1334 (defun mouse-set-mark (click) 1315 (defun mouse-set-mark (click)