From ab6ecdedfd99241c2a430c20974a78ff8d5e8a84 Mon Sep 17 00:00:00 2001 From: toctan Date: Sun, 8 Jun 2014 12:40:42 +0800 Subject: [PATCH 1/2] Do not deactivate-mark if region active --- core/prelude-core.el | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/core/prelude-core.el b/core/prelude-core.el index 9216f9d..5cbc43e 100644 --- a/core/prelude-core.el +++ b/core/prelude-core.el @@ -472,8 +472,7 @@ Doesn't mess with special buffers." (defun prelude-exchange-point-and-mark () "Identical to `exchange-point-and-mark' but will not activate the region." (interactive) - (exchange-point-and-mark) - (deactivate-mark nil)) + (exchange-point-and-mark (not (region-active-p)))) (require 'epl) From ba2272a6900a051bd602951ac14725b84ea24adb Mon Sep 17 00:00:00 2001 From: toctan Date: Sun, 8 Jun 2014 13:16:17 +0800 Subject: [PATCH 2/2] Prefer advice over remap exchange-point-and-mark --- core/prelude-core.el | 5 ----- core/prelude-editor.el | 5 +++++ core/prelude-global-keybindings.el | 5 ----- 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/core/prelude-core.el b/core/prelude-core.el index 5cbc43e..7a9a144 100644 --- a/core/prelude-core.el +++ b/core/prelude-core.el @@ -469,11 +469,6 @@ Doesn't mess with special buffers." (when after-init-time (eval form)))) -(defun prelude-exchange-point-and-mark () - "Identical to `exchange-point-and-mark' but will not activate the region." - (interactive) - (exchange-point-and-mark (not (region-active-p)))) - (require 'epl) (defun prelude-update () diff --git a/core/prelude-editor.el b/core/prelude-editor.el index 809e7d5..e964e6d 100644 --- a/core/prelude-editor.el +++ b/core/prelude-editor.el @@ -280,6 +280,11 @@ The body of the advice is in BODY." (browse-kill-ring-default-keybindings) (global-set-key (kbd "s-y") 'browse-kill-ring) +(defadvice exchange-point-and-mark (before deactivate-mark activate compile) + "When called with no active region, do not activate mark." + (interactive + (list (not (region-active-p))))) + ;; automatically indenting yanked text if in programming-modes (defvar yank-indent-modes '(LaTeX-mode TeX-mode) diff --git a/core/prelude-global-keybindings.el b/core/prelude-global-keybindings.el index 9e29c89..a8e241f 100644 --- a/core/prelude-global-keybindings.el +++ b/core/prelude-global-keybindings.el @@ -110,11 +110,6 @@ (global-set-key (kbd "C-=") 'er/expand-region) -;; make C-x C-x usable with transient-mark-mode -(define-key global-map - [remap exchange-point-and-mark] - 'prelude-exchange-point-and-mark) - (global-set-key (kbd "C-c j") 'ace-jump-mode) (global-set-key (kbd "s-.") 'ace-jump-mode) (global-set-key (kbd "C-c J") 'ace-jump-buffer)