kungsgeten / selected.el Goto Github PK
View Code? Open in Web Editor NEWKeymap for when region is active
License: MIT License
Keymap for when region is active
License: MIT License
With the following:
(use-package selected
:commands selected-minor-mode
:bind (:map selected-keymap
("<M-left>" . indent-rigidly-left)
("<M-right>" . indent-rigidly-right)))
I wish I could just keep indenting things, but region is lost.
I guess it has something to do with indent-rigidly-left/right
. Assuming a ^
in interactive
's arguments would fix it, how do I do that from my own files?
(defun indent-rigidly-right (beg end)
"Indent all lines between BEG and END rightward by one space."
(interactive "r")
(indent-rigidly--pop-undo)
(indent-rigidly
beg end
(if (eq (current-bidi-paragraph-direction) 'right-to-left) -1 1)))
I use selected in org-mode and now have to repeat the bindings for org-journal-mode.
It would be nice if that would be automatic.
Hi
i started playing today with selected.el and it seems really cool, thx for this!
the problem is that im also an evil user and it seems selected wont really launch when i select text in evil mode. is there any chance these two can work together or thats just not technically possible?
thx!
Z
selected global mode uses selected--global-on-p
to determine whether we are in the minibuffer and if yes, does not turn on selected-minor-mode
. However, selected-minor-mode
does add to global rather then buffer-local hooks. Thus, the selected--on
will still be called in the minibuffer activating the keymap.
(define-minor-mode selected-minor-mode
"If enabled activates the `selected-keymap' when the region is active."
:lighter " sel"
(if selected-minor-mode
(progn
(if mark-active (selected--on))
(add-hook 'activate-mark-hook #'selected--on)
(add-hook 'deactivate-mark-hook #'selected-off))
(remove-hook 'activate-mark-hook #'selected--on)
(remove-hook 'deactivate-mark-hook #'selected-off)
(selected-off)))
Also it would be nice if a list of major modes to ignore could be added, e.g., I use s
to activate swiper-at-point
, but this ovrerides, s
as staging in magit. I'll send a pull request soon
It would be great to have selected on stable.melpa.org. I believe all that's required is to tag a commit with a version number.
I have a (bad) habit of hitting C-g (keyboard-quit
) to cancel my current mark. When selected-minor-mode
is active and doing this selected will remain on and active until I hit q (selected-off
).
Would it be possible to turn selected off on keyboard-quit
?
Hi, I'm using the technique recommended in the ryo-modal README, to synchronize selected-minor-mode with ryo-modal-mode, something like this:
(defun cl/ryo-sync-selected-mode ()
(selected-minor-mode (if ryo-modal-mode 1 -1)))
(add-hook 'ryo-modal-mode-hook 'cl/ryo-sync-selected-mode)
But one issue I encountered is that if I already have a region active in "insert" mode (ryo-modal off), and then I hit escape (turning ryo-modal on), the selected keymap doesn't activate and I'm stuck with just the ryo-modal bindings (until I toggle mark off and on again). I guess that's because selected-minor-mode hooks into mark activation/deactivation, but those are removed once out of selected and ryo.
Anyway, it seems to be a one-line fix:
--- a/selected.el
+++ b/selected.el
@@ -69,6 +69,7 @@
:lighter " sel"
(if selected-minor-mode
(progn
+ (if mark-active (selected--on))
(add-hook 'activate-mark-hook #'selected--on)
(add-hook 'deactivate-mark-hook #'selected-off))
(remove-hook 'activate-mark-hook #'selected--on)
which of course I can also do in my hook, but it seems to me like it would be the right thing™ for all users of selected…?
Thanks for both these packages – I gave Evil a fair shake but it wasn't for me, so now I'm having a good time rolling my own!
Hi
when using the use-package install
I have an error
Symbol's value as variable is void: selected-keymap
What can I do to fix this ?
thanks
Thx alot
seems very cool, will it be on MELPA?
thx!
z
Seeing as I can't reproduce the issue with other packages where I want :bind
to override other active maps, I figured I would ask here first. I may just be missing something obvious :-)
In my case, I use C-c l
in LSP buffers, but I would like the same keybinding to take over when the selected keymap becomes active. I would expect the following to work:
(setq-default use-package-always-defer t)
(use-package lsp-mode
:bind
(:map lsp-mode-map
("C-c l" . hydra-lsp/body)))
(use-package selected
:bind*
(:map selected-keymap
("C-c l" . downcase-region))
:hook
(after-init . selected-global-mode))
What am I missing?
I don't have an issue. I just LOVE this package. Thank you for making it. I'm a big fan of modal navigation (not editing) and used this to create a very fast way to edit the active region and act on it. Fan-tas-tic.
Here's my config:
(use-package selected
:init (selected-global-mode 1)
:bind (:map selected-keymap
("q" . selected-off)
("u" . upcase-dwim)
("d" . downcase-dwim)
("w" . kill-ring-save)
("n" . next-line)
("p" . previous-line)
("f" . forward-char)
("b" . backward-char)
("F" . forward-word)
("B" . backward-word)
("a" . beginning-of-visual-line)
("e" . end-of-visual-line)
("{" . backward-paragraph)
("}" . forward-paragraph)
("(" . backward-sentence)
(")" . forward-sentence)
("s" . ctrlf-forward-fuzzy)
("r" . ctrlf-backward-fuzzy)
("[" . scroll-down-line)
("]" . scroll-up-line)
("M" . rectangle-mark-mode)
("R" . replace-rectangle)
("x" . exchange-point-and-mark)
))
Whenever I try to mark a region with S-up/right/down/left
, I get the following error:
selected--on: Wrong type argument: consp, nil
This makes the first attempt at marking region fail and forces me to press again up/right/down/left
while maintaining Shift. Apparently the error occurs on M-x set-mark-command
and when I click somewhere in the buffer (to move point) as well.
Here is my setup:
(use-package selected
:bind (:map selected-keymap ...)
:config (selected-global-mode))
Let me know if you need anything else.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.