Git Product home page Git Product logo

Comments (12)

DamienCassou avatar DamienCassou commented on August 17, 2024 1

Thank you for your answers @minad and @manuel-uberti. I just gave you 2 use cases but there are many more: starting an isearch with the thing at point, starting a project-wide string replacement with the thing at point... Ivy provides just one binding (M-n) that works for all these use cases and I think it makes a lot of sense.

from vertico.

minad avatar minad commented on August 17, 2024 1

@DamienCassou Maybe you are looking for a function which adds things from point in a dwim fashion to the future history. See https://github.com/raxod502/selectrum/wiki/Additional-Configuration#minibuffer-default-add-function

(autoload 'ffap-guesser "ffap")
(setq minibuffer-default-add-function
      (defun minibuffer-default-add-function+ ()
        (with-selected-window (minibuffer-selected-window)
          (delete-dups
           (delq nil
                 (list (thing-at-point 'symbol)
                       (thing-at-point 'list)
                       (ffap-guesser)
                       (thing-at-point-url-at-point)))))))

I consider this code wiki quality at best. I don't think such a thing should be part of a completion UI (neither Selectrum nor Vertico).

from vertico.

hmelman avatar hmelman commented on August 17, 2024 1

@DamienCassou It's not clear to me if you tried these use cases or are just asking if it works before you tried. I loaded just vertico, not other "related" packages and tried the following:

  1. I tried what you described with projectile-find-file and vertico and M-n did not insert the filename-at-point, but it choose another filename from the project, I assume pulling it from the candidate list in some order. I tried the same thing using find-file and M-n inserted the filename at point, just like you want.
  2. I did exactly what you described in 2. and it worked fine with vertico. Though I'd rather just hit M-. here to go directly to the definition using xref-find-definitions without using imenu.

As mentioned above, emacs generically calls this "future history" and individual commands implement it in different ways. Those that want a symbol pull in a symbol, others pull in filenames, urls or words or other things. I think most commands I'd want to use in this position already use symbol-at-point, imenu seems to, if not it's probably a bug with them.

FWIW, projectile-find-file with selectrum also didn't pull in filename-at-point (it behaved the same as with vertico) but project-find-file did do what you want. I tried your example 1. with ivy and counsel and M-n did do what you describe. I think this is a function of counsel-projectile-find-file which AFAICT counsel-projectile replaces projectile-find-file with and it's not a generic function of ivy-next-history-element. As near as I can tell ivy-next-history-element is just defaulting the future history to symbol-at-point when in a prog-mode derivative and it's not on a file, url or other thing.

from vertico.

DamienCassou avatar DamienCassou commented on August 17, 2024 1

Thank you very much @hmelman for your detailed investigation. I will use that as a base to learn new ways of doing things.

from vertico.

minad avatar minad commented on August 17, 2024

You can use yank to insert text into the minibuffer obviously. Then you can use the ffap- functions which give you find file at point. Then the usual minibuffer history commands are still there, take a look at the vertico-map. I hope this answers your question. I am not sure if I understood all the points you made above since some seem ivy specific.

from vertico.

manuel-uberti avatar manuel-uberti commented on August 17, 2024

@DamienCassou doesn't M-n do what you're after already?

EDIT: no, now that I see what you mean.

from vertico.

manuel-uberti avatar manuel-uberti commented on August 17, 2024

One possible solution is using embark and embark-consult:

  • on the thing at point, use embark-act (I suggest to bind it to a quick key binding)
  • press C (as in capital c) and then f

from vertico.

manuel-uberti avatar manuel-uberti commented on August 17, 2024

For the imenu+ivy flow, isn't it enough to use xref-find-definitions?

from vertico.

manuel-uberti avatar manuel-uberti commented on August 17, 2024

I see your point, but I think it's also kind of related to your personal usage, isn't it? I mean, I have use cases for your new examples that don't require M-n:

  • isearch with the thing at point: M-s . (there is also M-s M-. on Emacs master as well)
  • project-wide string replacement: I use consult-ripgrep on the thing at point, embark-export and edit that buffer accordingly

Not that I don't see your point, of course. It's up to @minad understanding whether it is a complexity worth adding.

from vertico.

minad avatar minad commented on August 17, 2024

Sorry, no such complexity is worth adding here. Vertico provides what default completion provides, if this is insufficient, you can add your own small commands and bind them in vertico-map. My problem here is also a bit that I don't clearly understand what kind of command you would like to see here (some kind of dwim insert something from point?). Maybe if you provide a code snippet it becomes more clear to me. But such additions are so or so out of the question to be added here. If you are looking for a full featured solution, I recommend Selectrum.

I consider Vertico to be mostly feature complete, so you will generally have a very hard time of convincing me to add something here. The better approach for more features and commands is to maintain them separately. This works well as long as the additions don't require modifications to Vertico itself. If some external feature cannot be implemented (for example because the display code is too rigid), one could discuss adding hooks or splitting up some functions to make it easier for advices to do their job.

Closing.

from vertico.

DamienCassou avatar DamienCassou commented on August 17, 2024

I'm sorry I didn't managed to express myself clearly so you understand what I need. I also understand you don't want to add features to vertico.

I will try to explain myself again anyway: When in the minibuffer with vertico completion system, I would like to be able to press a shortcut and get the text at point in the main buffer copy-pasted into the vertico's prompt. It should work regardless of the command that triggered the completion system. Without this, I have to start by copying the text at point, then call the command that triggers completion and finally yank the text I've just copied.

from vertico.

minad avatar minad commented on August 17, 2024

Yes, this is exactly what the Emacs built-in future history is supposed to do (accessible via next-history-element). See above, the minibuffer-default-add-function adds things at point to the future history according to your preferences.

(Alternatively you can also write a small command bound to vertico-map which switches to the original buffer, takes the thing at point, goes back to the minibuffer and inserts. But I recommend the future history for this.)

from vertico.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.