leoliu pushed a commit to branch master in repository elpa. commit df62c2abe62571fa27eeaf5dd97906b2d4e68443 Author: Leo Liu <sdl....@gmail.com> Date: Mon Nov 11 19:52:18 2013 +0800
Consolidate easy-mark and easy-mark-sexp into one command --- README.rst | 78 ++++++++++++++++++++++++++-------------------------------- easy-kill.el | 32 ++++++++++++----------- 2 files changed, 52 insertions(+), 58 deletions(-) diff --git a/README.rst b/README.rst index f5fb6e6..427a251 100644 --- a/README.rst +++ b/README.rst @@ -2,40 +2,38 @@ Kill Things Easily in Emacs ============================= -Provide commands (``easy-kill``, ``easy-mark`` etc.) to let users kill -or mark things easily. +Provide commands ``easy-kill`` and ``easy-mark`` to let users kill or +mark things easily. easy-kill ~~~~~~~~~ -``easy-kill`` is a drop-in replacement for ``kill-ring-save``. It -saves something to ``kill-ring`` in this order: - -#. current region if active -#. url at point (snarf char properties ``help-echo``, ``shr-url``, - ``w3m-href-anchor`` etc.) -#. email at point -#. current line - -Immediately following ``easy-kill``, the follow keys are temporarily -active: - -#. ``w`` -> word at point -#. ``s`` -> sexp at point -#. ``f`` -> file at point -#. ``l`` -> list at point -#. ``d`` -> defun at point -#. ``D`` -> defun-name; works even when in a diff hunk -#. ``b`` -> ``buffer-file-name`` or ``default-directory`` -#. ``@`` -> append selection to previous kill -#. ``C-w`` -> kill selection -#. ``+``, ``-`` and ``0..9`` -> expand/shrink selection -#. ``C-SPC`` -> turn selection into an active region -#. ``C-g`` -> abort - -Any other keys exit the temporary keymap and automatically save -selection to the ``kill-ring``. See ``M-w l`` (save list at point to -the kill ring) in action in `screenshot +``easy-kill`` is a drop-in replacement for ``kill-ring-save``. To Use: +:: + + (global-set-key [remap kill-ring-save] 'easy-kill) + +After this configuration, ``M-w`` serves as both a command and a +prefix key for other commands. ``M-w`` alone saves in the order of +active region, url, email and finally current line. As a prefix key: + +#. ``M-w w``: save word at point +#. ``M-w s``: save sexp at point +#. ``M-w f``: save file at point +#. ``M-w l``: save list at point +#. ``M-w d``: save defun at point +#. ``M-w D``: save defun-name; works even when in a diff hunk +#. ``M-w b``: save ``buffer-file-name`` or ``default-directory`` + +The following keys modify the selection: + +#. ``@``: append selection to previous kill and exit +#. ``C-w``: kill selection and exit +#. ``+``, ``-`` and ``0..9``: expand/shrink selection +#. ``C-SPC``: turn selection into an active region +#. ``C-g``: abort + +See ``M-w l`` (save list at point) in action in `screenshot <http://i.imgur.com/8TNgPly.png>`_: .. figure:: http://i.imgur.com/8TNgPly.png @@ -46,24 +44,18 @@ easy-mark ~~~~~~~~~ ``easy-mark`` is similar to ``easy-kill`` but marks the region -immediately. +immediately. It can be a handy replacement for ``mark-sexp`` allowing +``+``/``-`` to do list-wise expanding/shrinking and marks the whole +sexp even when in the middle of one. :: -``easy-mark-sexp`` can be a handy replacement for ``mark-sexp``, which -allows +,=/- to do list-wise expanding/shrinking and marks the -whole sexp even when in the middle of one. + (global-set-key [remap mark-sexp] 'easy-mark) -To Use -~~~~~~ +Install +~~~~~~~ ``easy-kill`` is available on `MELPA <http://melpa.milkbox.net/#/easy-kill>`_. - -:: - - (require 'easy-kill) - (global-set-key [remap kill-ring-save] 'easy-kill) - (global-set-key [remap mark-sexp] 'easy-mark-sexp) - + Extensions ~~~~~~~~~~ diff --git a/easy-kill.el b/easy-kill.el index c7fb903..cf9247d 100644 --- a/easy-kill.el +++ b/easy-kill.el @@ -3,7 +3,7 @@ ;; Copyright (C) 2013 Leo Liu ;; Author: Leo Liu <sdl....@gmail.com> -;; Version: 0.9.0 +;; Version: 0.9.1 ;; Package-Requires: ((emacs "24")) ;; Keywords: convenience ;; Created: 2013-08-12 @@ -29,12 +29,10 @@ ;; To use: (global-set-key [remap kill-ring-save] 'easy-kill) ;; `easy-mark' is similar to `easy-kill' but marks the region -;; immediately. +;; immediately. It can be a handy replacement for `mark-sexp' allowing +;; `+'/`-' to do list-wise expanding/shrinking. ;; -;; `easy-mark-sexp' can be a handy replacement for `mark-sexp' which -;; allows you to use +,=/- to do list-wise expanding/shrinking. -;; -;; To use: (global-set-key [remap mark-sexp] 'easy-mark-sexp) +;; To use: (global-set-key [remap mark-sexp] 'easy-mark) ;; Please send bug reports or feature requests to: ;; https://github.com/leoliu/easy-kill/issues @@ -86,6 +84,11 @@ CHAR is used immediately following `easy-kill' to select THING." :type '(repeat symbol) :group 'killing) +(defcustom easy-mark-try-things '(url email sexp) + "A list of things for `easy-mark' to try." + :type '(repeat symbol) + :group 'killing) + (defface easy-kill-selection '((t (:inherit secondary-selection))) "Faced used to highlight kill candidate." :group 'killing) @@ -382,18 +385,17 @@ Temporally activate additional key bindings as follows: (easy-kill-activate-keymap))) ;;;###autoload -(defun easy-mark (&optional n) - "Like `easy-kill' (which see) but for marking." - (interactive "p") - (setq easy-kill-mark t) - (easy-kill-init-candidate n) - (easy-kill-activate-keymap)) +(defalias 'easy-mark-sexp 'easy-mark + "Use `easy-mark' instead. The alias may be removed in future.") ;;;###autoload -(defun easy-mark-sexp (&optional n) +(defun easy-mark (&optional n) + "Similar to `easy-kill' (which see) but for marking." (interactive "p") - (let ((easy-kill-try-things '(sexp))) - (easy-mark n) + (let ((easy-kill-try-things easy-mark-try-things)) + (setq easy-kill-mark t) + (easy-kill-init-candidate n) + (easy-kill-activate-keymap) (unless (overlay-get easy-kill-candidate 'thing) (overlay-put easy-kill-candidate 'thing 'sexp) (easy-kill-thing 'sexp n))))