meow
meow copied to clipboard
Region disapears after entering insert mode
Hello,
I have an issue where my region becomes inactive if I change to insert mode to start editing.
Example: I use inner-or-thing
to select a region, enter insert mode (either by a
or i
) and my region disappears. I have to do C-x C-x to recover it and do what I want.
Is this normal behaviour and if so how / can I change it?
sorry for no visual demonstration I don't know how to insert one in git hub.
Yeah, this is working as intended as far as I know. The idea is just that when you press insert, you lose access to the useful meow commands to operate on the region anyway. Try to stay in normal mode for as long as you need to complete your operations that operate at the region level, since you have a rich set of composable commands for those; and drop into insert only to type.
There's no simple way to change this behavior, and that functionality is not particularly exposed via hook or configuration. I'd recommend either adding :after
advice to meow-append
and meow-insert
to call exchange-point-and-mark
immediately after, or just redefine both functions and remove the call to meow-cancel-selection
which deactivates the mark. I'd say this is probably the best way to go, and here are the modified versions of those functions you may want.
(defun meow-insert ()
"Move to the start of selection, switch to INSERT state."
(interactive)
(if meow--temp-normal
(progn
(message "Quit temporary normal mode")
(meow--switch-state 'motion))
(meow--direction-backward)
(meow--switch-state 'insert)))
(defun meow-append ()
"Move to the end of selection, switch to INSERT state."
(interactive)
(if meow--temp-normal
(progn
(message "Quit temporary normal mode")
(meow--switch-state 'motion))
(if (not (region-active-p))
(when (and meow-use-cursor-position-hack
(< (point) (point-max)))
(forward-char 1))
(meow--direction-forward))
(meow--switch-state 'insert)))
The idea is just that when you press insert, you lose access to the useful meow commands to operate on the region anyway
meow isn't the only editing package I have that makes use of the region. By disabling it I can not use the ease of selecting that meow affords for other packages leading me to not use either meow for selecting or the additional package.
I am staying in meow for as long as I can. I am only switching to insert mode when I want to type something(in this case going from foo
-> "foo"
for example and with paredit or smart parents (i don't remember which) I can do that by selecting foo and insert a single "
but I need the region to be active.
otherwise, I need to go to the beginning of the word, enter insert mode, insert the quote, back to normal mode, word forward, insert mode, and insert quotes.
I've seen that you've recommended embrace.el
in the past and I am going to look into it later.
I do think that in general high quality selection commands are probably the weakest part of meow. Actually, it wasn't me who recommended embrace.el, but @mclearc who recommended it to me... embrace is definitely great though, it's very elegantly implemented. It works pretty perfectly with meow as well.
I'm also a heavy user of the paredit/smartparens editing style though, and I fully got around with wrapping selections in quotes and unwrapping s-exps with a smartparens custom state, although its a little sketchier than embrace. Take a look at this section of my config: https://github.com/eshrh/nyaatouch/blob/master/nyaatouch.el#L227 if you're interested in the custom-state implementation of pair-related commands.
Well, if you type, the region will always be cancelled. Probably you mean we need a better way to resume previous selection?
Seems like implementing this is both simple and a core idea change.