From a4c89bd91c4f2a511d5c272a27aaa42b2c4dae0b Mon Sep 17 00:00:00 2001 From: Bozhidar Batsov Date: Thu, 6 Sep 2012 22:42:07 +0300 Subject: [PATCH] made C-x C-x (exchange mark and point) transient-mark-mode friendly --- prelude/prelude-core.el | 17 +++++++++++++---- prelude/prelude-global-keybindings.el | 2 ++ 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/prelude/prelude-core.el b/prelude/prelude-core.el index 924c27f..d2bbf5b 100644 --- a/prelude/prelude-core.el +++ b/prelude/prelude-core.el @@ -338,7 +338,7 @@ there's a region, all lines that region covers will be duplicated." The new command is named CMD-repeat. CMD should be a quoted command. -This allows you to bind the command to a compound keystroke and +This allows you to bind the command to a compound keystroke andб repeat it with just the final key. For example: (global-set-key (kbd \"C-c a\") (make-repeatable-command 'foo)) @@ -348,7 +348,8 @@ just invoke foo. Typing C-c a a a will invoke foo three times, and so on." (fset (intern (concat (symbol-name cmd) "-repeat")) `(lambda ,(help-function-arglist cmd) ;; arg list - ,(format "A repeatable version of `%s'." (symbol-name cmd)) ;; doc string + ,(format "A repeatable version of `%s'." + (symbol-name cmd)) ;; doc string ,(interactive-form cmd) ;; interactive form ;; see also repeat-message-function (setq last-repeatable-command ',cmd) @@ -359,7 +360,8 @@ and so on." "Create a new scratch buffer." (interactive) (progn - (switch-to-buffer (get-buffer-create (generate-new-buffer-name "*scratch*"))) + (switch-to-buffer + (get-buffer-create (generate-new-buffer-name "*scratch*"))) (emacs-lisp-mode))) (defvar prelude-tips @@ -375,7 +377,8 @@ and so on." (defun prelude-tip-of-the-day () (interactive) - (message (concat "Prelude tip: " (nth (random (length prelude-tips)) prelude-tips)))) + (message + (concat "Prelude tip: " (nth (random (length prelude-tips)) prelude-tips)))) (defun prelude-eval-after-init (form) "Add `(lambda () FORM)' to `after-init-hook'. @@ -386,5 +389,11 @@ and so on." (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) + (deactivate-mark nil)) + (provide 'prelude-core) ;;; prelude-core.el ends here diff --git a/prelude/prelude-global-keybindings.el b/prelude/prelude-global-keybindings.el index 949e5c9..6e1daf0 100644 --- a/prelude/prelude-global-keybindings.el +++ b/prelude/prelude-global-keybindings.el @@ -90,6 +90,8 @@ (global-set-key (kbd "C-=") 'er/expand-region) (global-set-key (kbd "C-c w") (make-repeatable-command 'er/expand-region)) +(define-key global-map [remap exchange-point-and-mark] 'prelude-exchange-point-and-mark) + (provide 'prelude-global-keybindings) ;;; prelude-global-keybindings.el ends here