From c4b18360a1a1f0f26ba6aca71eeb118ed60fd49e Mon Sep 17 00:00:00 2001 From: Mark Wooding Date: Sun, 27 Dec 2009 12:30:13 +0000 Subject: [PATCH] el/dot-emacs.el: Complicated `exchange-point-and-mark' hack. Inspired by a remark made in http://www.emacswiki.org/emacs/TransientMarkMode --- el/dot-emacs.el | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/el/dot-emacs.el b/el/dot-emacs.el index e08b6fc..e9390dd 100644 --- a/el/dot-emacs.el +++ b/el/dot-emacs.el @@ -164,6 +164,25 @@ library." (other-window 1)) (select-window win))) +;; Transient mark mode hacks. + +(defadvice exchange-point-and-mark + (around mdw-highlight (&optional arg) activate compile) + "Maybe don't actually exchange point and mark. +If `transient-mark-mode' is on and the mark is inactive, then +just activate it. A non-trivial prefix argument will force the +usual behaviour. A trivial prefix argument (i.e., just C-u) will +activate the mark and temporarily enable `transient-mark-mode' if +it's currently off." + (cond ((or mark-active + (and (not transient-mark-mode) (not arg)) + (and arg (or (not (consp arg)) + (not (= (car arg) 4))))) + ad-do-it) + (t + (or transient-mark-mode (setq transient-mark-mode 'only)) + (set-mark (mark t))))) + ;; Functions for sexp diary entries. (defun mdw-weekday (l) -- 2.11.0