The Emacs Selected Package by Erik Sjöstrand

https://github.com/Kungsgeten/selected.el

Erik Sjöstrand

selected.el provides selected-minor-mode for Emacs. When active, keybindings you define in a given keymap will be enabled when the region is active.

Why would I need it? Useful for commands that operate on a region.

How to activate it?

M-x selected-minor-mode

Or

M-x selected-global-mode

One can also add it to the hooks of major mode to actiavte it in certain modes:

  (use-package selected
    :ensure t
    :commands selected-minor-mode
    :bind (:map selected-keymap
    ("q" . selected-off) ;; deactivates until the next time the region becomes active
    ("u" . upcase-region)
    ("d" . downcase-region)
    ("w" . count-words-region)
    ("m" . apply-macro-to-region-lines)
    ("[" . align-code)
    ("f" . fill-region)
    ("U" . unfill-region)
    ("d" . downcase-region)
    ("r" . reverse-region)
    ("S" . sort-lines))
    :config
    (selected-global-mode 1))  

Note: It conflicts with these other modes: worf, lispy or ryo, in which case:

(setq selected-minor-mode-override t)

It is esp. useful for certain functions and packages:

My config

(use-package selected
  :ensure t
  :commands selected-minor-mode
  :bind (:map selected-keymap
              ("q" . selected-off)
              ("1" . count-words-region)
        ("l"   . mc/edit-lines)
              ("."   . mc/mark-next-like-this)
              (","   . mc/mark-previous-like-this)
              (">"   . mc/skip-to-next-like-this)
              ("<"   . mc/unmark-next-like-this)
              ("C-<" . mc/skip-to-previous-like-this)
              ("C->" . mc/unmark-previous-like-this)
              ("w"   . mc/mark-next-word-like-this)
              ("W"   . mc/mark-previous-word-like-this)
        ("d" . mc/mark-all-like-this-dwim)
        ("a" . mc/mark-all-like-this)
              ("f" . flush-lines)
        ("r" . write-region)
        ("s" . ispell-region)
        ("\"" . replace-smart-quotes)
        ("S" . sort-lines)
        ("C-d" . delete-duplicate-lines)
        ("C-s" . single-lines-only)))

(add-hook 'emacs-lisp-mode-hook 'selected-minor-mode)
(add-hook 'org-mode-hook 'selected-minor-mode)
(add-hook 'markdown-mode-hook 'selected-minor-mode)

Return to Home