Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add bookmark and possibly register actions #54

Closed
minad opened this issue Dec 18, 2020 · 26 comments
Closed

Add bookmark and possibly register actions #54

minad opened this issue Dec 18, 2020 · 26 comments

Comments

@minad
Copy link
Contributor

minad commented Dec 18, 2020

@oantolin I can add those if you like.

@minad minad changed the title Add bookmark actions Add bookmark and possibly register actions Dec 18, 2020
@oantolin
Copy link
Owner

Thanks for the bookmark actions!

@oantolin
Copy link
Owner

Do the register actions really make sense? I don't think there are built-in commands that prompt with completing-read for a register. They all use register-read-with-preview, which only requires you to type one character. That means there is no chance to run an action, there is no moment before pressing RET when you have specified a register but haven't finished the command you started,

@minad
Copy link
Contributor Author

minad commented Dec 18, 2020

Yes, there is the register menu in consult though, but it does not make sense to add actions for them here.

@minad minad closed this as completed Dec 18, 2020
@oantolin
Copy link
Owner

Yes, there is the register menu in consult though, but it does not make sense to add actions for them here.

Well, hold on a second. Why not add them here? They won't bother people who don't use consult, and might be useful for consult users. I do not oppose adding stuff that benefits consult users as long as it does not involve making consult a dependency. I already have default list view for the line and kill-ring categories that consult introduces.

@oantolin
Copy link
Owner

oantolin commented Dec 18, 2020

But the thing with registers is that other that inserting them or jumping to them, I can't really think of relevant actions, and the consult-register command combines both of those into one command already.

@minad
Copy link
Contributor Author

minad commented Dec 18, 2020

But the things with registers is that other that inserting them or jumping to them, I can't really think of relevant actions, and the consult-register command combines both of those into one command already.

This is exactly what I thought when I pressed close ;) But there is also increment-register and maybe there are more useful ones which make sense in the action menu of consult-register...

@minad minad reopened this Dec 18, 2020
@oantolin
Copy link
Owner

To be honest, I don't use consult-register, because it's a lot more typing than the built-in register commands, and from a quick glance didn't seem to offer any advantages. What am I missing?

@minad
Copy link
Contributor Author

minad commented Dec 18, 2020

It is nothing more than a reminder of what register values you have stored, but I am also not using it much. You can always use the register list though. There has been some recent discussion in minad/consult#6 if there is a possibility to make it more useful

@oantolin
Copy link
Owner

But the built-in commands also remind you of what you have stored, that's what register-read-with-preview does.

@minad
Copy link
Contributor Author

minad commented Dec 18, 2020

@oantolin That's right. But in that case the order of selection action is reversed. As I said, consult-register is of questionable usefulness. Maybe I should kick it out of consult again. But still it might be neat to have a consult view of registers and bookmarks and other similar things.

@minad
Copy link
Contributor Author

minad commented Dec 18, 2020

At least I am pretty sure we should not add actions in Embark for registers as of now. If something comes up we can still reconsider?

@oantolin
Copy link
Owner

But in that case the order of selection action is reversed.

Ah, gotcha! Yes. I wasn't noticing this because I don't actually use either insert-register or jump-to-register, instead I use this command I wrote, which is basically the same as consult-register but using the special register-read-with-preview instead of completing-read:

(defun use-register-dwim (register &optional arg)
  "Do what I mean with a register.
For a window configuration, restore it. For a number or text, insert it.
For a location, jump to it."
  (interactive
   (list (register-read-with-preview "Use register: ")
         current-prefix-arg))
  (condition-case nil
      (jump-to-register register arg)
    (user-error (insert-register register arg))))

So I sort of forgot that with the built-in command you need to know whether you want to insert or jump before you select your command.

At least I am pretty sure we should not add actions in Embark for registers as of now.

OK, yes, seems better not to yet.

If something comes up we can still reconsider?

Always!

@minad
Copy link
Contributor Author

minad commented Dec 18, 2020

Cool command! I should scan your config for ideas more carefully at some point ;) So let's close this!

@minad minad closed this as completed Dec 18, 2020
@oantolin
Copy link
Owner

That's my command to use registers, I also have one to store stuff in them, which is more ad hoc, but I've gotten used to it:

(defun store-register-dwim (arg register)
  "Store what I mean in a register.
With an active region, store or append (with \\[universal-argument]) the
contents, optionally deleting the region (with a negative
argument). With a numeric prefix, store the number. With \\[universal-argument]
store the frame configuration. Otherwise, store the point."
  (interactive
   (list current-prefix-arg
         (register-read-with-preview "Store in register: ")))
  (cond
   ((use-region-p)
    (let ((begin (region-beginning))
          (end (region-end))
          (delete-flag (or (equal arg '-)  (equal arg '(-4)))))
      (if (consp arg)
          (append-to-register register begin end delete-flag)
        (copy-to-register register begin end delete-flag t))))
   ((numberp arg) (number-to-register arg register))
   (t (point-to-register register arg))))

@minad
Copy link
Contributor Author

minad commented Dec 18, 2020

Nice :)

@minad
Copy link
Contributor Author

minad commented Dec 18, 2020

Now I have to think if I can somehow adopt this for consult. Or maybe I only add something like this to my config...

@oantolin
Copy link
Owner

I love deleting stuff from my personal config, so I'd enjoy it if something like this made it into consult. I've already deleted functions that correspond to consult-line, consult-yank-replace and consult-completion-in-region, which made me very happy (I know maybe the last one shouldn't count since I contributed it).

I don't think there is anything wrong with saying, "normally commands in consult use completing-read for their UI, but in the case of registers the built-in function register-read-with-preview is even better than completing-read"...

@minad
Copy link
Contributor Author

minad commented Dec 18, 2020

I also love to remove stuff from the init.el :)
I will try these commands and see if it may make sense to add them to consult instead of or additional to consult-register.

@hmelman
Copy link

hmelman commented Dec 27, 2020

But there is also increment-register and maybe there are more useful ones which make sense in the action menu of consult-register...

I'm not certain they apply here but there are append-to-register and prepend-to-register commands that might be useful.

@oantolin
Copy link
Owner

Those would be good actions, @hmelman! The issue with register actions though, is that no built-in commands prompt you for a register with completing-read, they all use register-read-with-preview. There is no opportunity for the user to trigger actions since with register-read-with-preview you only type one letter to pick a register. (If instead it were one letter and RET to confirm, in between the letter and RET you could trigger actions.) Adding actions for registers would be solely for consult-register, which is a command I don't really believe in, since I think register-read-with-preview is better than completing-read for prompting for registers.

@minad
Copy link
Contributor Author

minad commented Dec 27, 2020

@oantolin I am not 100% convinced by register-read-with-preview tbh, but consult-register is also not good. Still having this in the backlog minad/consult#77...

@oantolin
Copy link
Owner

Oh, I'm not saying register-read-with-preview is the best UI for this, just that it is better than completing-read. But I do think my ideal UI would be pretty close to register-read-with-preview. Maybe just change the preview of positions to be more like consult-mark, keeping the preview for numbers, text, window configurations, etc. the same.

Although it might be nice to have a chance to trigger actions...

@minad
Copy link
Contributor Author

minad commented Dec 27, 2020

Maybe just change the preview of positions to be more like consult-mark, keeping the preview for numbers, text, window configurations, etc. the same.

This is exactly what I have been thinking.

@oantolin
Copy link
Owner

Also register-read-with-preview pops up the preview in a separate buffer. As an embark-live-occur-after-input user, I'm fine with this, but maybe Selectrum and Icomplete users would prefer the preview in the minibuffer.

@minad
Copy link
Contributor Author

minad commented Dec 27, 2020

Also register-read-with-preview pops up the preview in a separate buffer. As an embark-live-occur-after-input user, I'm fine with this, but maybe Selectrum and Icomplete users would prefer the preview in the minibuffer.

Obviously ;) But I feel stronger about the not-so-informative preview etc. And I think other users mentioned that too in minad/consult#6 also in relation to consult-register, which uses the same non-informative text for the candidates.

@hmelman
Copy link

hmelman commented Dec 27, 2020

I don't use registers much, I don't think many emacs users do. I understand the UI limitations of register-read-with-preview and consult-register and I think I prefer the consult-register treatment. I don't like the list-register buffer.

I'd really rather see a cleaner consult/marginalia one line/register display of this info. The first (narrow) column would be the register name. A column like the describe commands do with a letter indicating the type of the register (location, text, window, number, etc.) and then the value with a longer text snippet or other value. This would probably require new register-val-describe implementations and a replacement of register-read-with-preview and that's probably all too much work for an infrequently used features like registers, but that would be my ideal.

FWIW, evil-mode supports vim markers which are very much like emacs registers and I think more central to the evil experience than registers are to the emacs experience. I think they just support locations and text. I don't think evil has a good display of the markers and as such counsel-evil-markers is pretty popular. A consult-registers could probably be adapted to a consult-evil-markers though I don't think it supports more actions then save and insert/jump. I'm not an evil user so I don't know more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants