From 78bd021354254c645a5605eec86676ebb08518ec Mon Sep 17 00:00:00 2001 From: Bozhidar Batsov Date: Fri, 9 Mar 2012 16:20:46 +0200 Subject: [PATCH] fixed #89 - changed er/expand-region's default keybinding to C-c w --- modules/prelude-core.el | 24 ++++++++++++++++++++++++ modules/prelude-editor.el | 1 - modules/prelude-global-keybindings.el | 2 ++ 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/modules/prelude-core.el b/modules/prelude-core.el index c766496..b3df828 100644 --- a/modules/prelude-core.el +++ b/modules/prelude-core.el @@ -360,5 +360,29 @@ there's a region, all lines that region covers will be duplicated." (global-set-key [M-left] 'left-word) (message "Arrow keys navigation in buffers in now allowed.")) +(require 'repeat) + +(defun make-repeatable-command (cmd) + "Returns a new command that is a repeatable version of CMD. +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 +repeat it with just the final key. For example: + + (global-set-key (kbd \"C-c a\") (make-repeatable-command 'foo)) + +will create a new command called foo-repeat. Typing C-c a will +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 + ,(interactive-form cmd) ;; interactive form + ;; see also repeat-message-function + (setq last-repeatable-command ',cmd) + (repeat nil))) + (intern (concat (symbol-name cmd) "-repeat"))) + (provide 'prelude-core) ;;; prelude-core.el ends here diff --git a/modules/prelude-editor.el b/modules/prelude-editor.el index 4e18fe2..c6d0bc2 100644 --- a/modules/prelude-editor.el +++ b/modules/prelude-editor.el @@ -193,7 +193,6 @@ (put 'downcase-region 'disabled nil) (require 'expand-region) -(global-set-key (kbd "C-@") 'er/expand-region) ;; bookmarks (setq bookmark-default-file (concat user-emacs-directory "bookmarks") diff --git a/modules/prelude-global-keybindings.el b/modules/prelude-global-keybindings.el index 28ee156..648cf0c 100644 --- a/modules/prelude-global-keybindings.el +++ b/modules/prelude-global-keybindings.el @@ -104,6 +104,8 @@ (global-set-key (kbd "C-x g") 'magit-status) +(global-set-key (kbd "C-c w") (make-repeatable-command 'er/expand-region)) + (provide 'prelude-global-keybindings) ;;; prelude-global-keybindings.el ends here