meow-edit / meow

Yet another modal editing on Emacs / 猫态编辑
GNU General Public License v3.0
1.07k stars 128 forks source link

Should pasting activate the selection? #559

Closed Haxxflaxx closed 3 months ago

Haxxflaxx commented 3 months ago

After calling meow-yank, should the pasted thing end up selected?

Nice things that we get from having the paste selected:

DogLooksGood commented 3 months ago

I think we shouldn't. The concept is to just build a selection after navigation. And pasting is not a navigation command.

jixiuf commented 3 months ago

After yank, a mark is already placed at the other side, so C-x C-x or SPC xx will activate the region.

Haxxflaxx commented 3 months ago

@jixiuf I'm aware, but I'll probably just make an advice to activate the mark after the function is called. Fewer key presses, and it shouldn't affect anything negatively to do that by default.

@DogLooksGood I think pasting can be closely related to wanting to navigate. Like how you in vim might want to paste before or after the cursor, or as I mentioned before: run some command on the region e.g. grab and edit, or surround or something.

Mostly I just expected it to be selected for some reason. Maybe it is in helix, and that's why I was expecting it?

DogLooksGood commented 3 months ago

Because the fundamentals of Emacs and Helix/Kak are completely different, we can't do simple simulation. Our goal is to have a lightweight layer for modal editing, the workflow of vanilla Emacs should not be affected. So we keep almost every builtin command unmodified.

But yeah, you can just add advice to achieve what you want, or write your own yank command.

Haxxflaxx commented 3 months ago

@DogLooksGood I don't know if I agree with your point. Your argument could be used against any of the functionality of meow. The reason I see it as lacking is for consistency with the functionality added by meow in general. But no matter, it should be small enough to not burden my config.

I was expecting to be able to just throw activate-mark in to an advice, but it doesn't seem to work, and I'm not sure why.

(advice-add 'meow-yank :after #'activate-mark)

My emacs-fu isn't great so I don't know what I'm missing here.

DogLooksGood commented 3 months ago

Hey @Haxxflaxx,

Try this

(defun meow-yank-select ()
  (interactive)
  (call-interactively #'yank)
  (setq deactivate-mark nil)
  (thread-first
    (meow--make-selection 'transient (mark) (point))
    (meow--select)))

yank will set deactivate-mark to t to deactivate the region after current command. So you have to write your own command, then unset this variable.