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

Support marking multiple files and opening multiple files in ivy-hydra. #2068

Closed
hanjaelee opened this issue May 18, 2019 · 7 comments
Closed

Support marking multiple files and opening multiple files in ivy-hydra. #2068

hanjaelee opened this issue May 18, 2019 · 7 comments

Comments

@hanjaelee
Copy link

@hanjaelee hanjaelee commented May 18, 2019

In ivy-hydra, I makred multiple files I want to open and opened the files by pressing r o which means opening buffer in other window.

As a result, It's not working because emacs recognize file name as '>' marking flag followed.

For example, I open Makefile file then emacs open >Makefile NOT Makefile

I want it to be worked correctly So I open this issue.
Additionally, It's working in counsel-projectile-find-file But It's not working in counsel-find-file as it is intended.

@abo-abo abo-abo closed this in 2c57036 May 20, 2019
@abo-abo
Copy link
Owner

@abo-abo abo-abo commented May 20, 2019

Thanks. Please test. Here's how I tested it:

  • Open *scratch* and split it into 4 windows, so that the frame has 4 windows with *scratch*,
  • counsel-find-file, select a directory, and 4 files there,
  • rj.

As the result, the 4 files were opened in each of the 4 windows.

@basil-conto
Copy link
Collaborator

@basil-conto basil-conto commented May 20, 2019

Why require action functions to have an argument with a special name rather than exposing ivy-marked-candidates dynamically? There could be another way for a caller to tell Ivy whether the action should be called on one or all marked candidates, e.g. an ivy-read keyword or a variable such as ivy-calling. This would allow more dynamic behaviour going forward.

Also, I don't think it's right to refer to the action function as ivy-action, as the only symbol with that name is a face.

@abo-abo
Copy link
Owner

@abo-abo abo-abo commented May 20, 2019

@basil-conto I think the original intention was to have action functions that are ivy-agnostic.

But you're right that exposing ivy-marked-candidates is a better approach.

One other approach could be to have two functions that are ivy-agnostic:

(ivy-read "prompt: " collection
          :action (lambda (x) (insert (concat ":" x ":")))
          :multi-action (lambda (xs) (insert ":" (mapconcat #'identity xs ":") ":")))

@basil-conto
Copy link
Collaborator

@basil-conto basil-conto commented May 20, 2019

One other approach could be to have two functions that are ivy-agnostic:

Yeah, that's what I meant by adding another ivy-read keyword.

abo-abo added a commit that referenced this issue May 22, 2019
Re #2068
Re #561

Example:

    (defun test ()
      (interactive)
      (ivy-read "test:" '("a" "b" "c")
                :action
                (lambda (x) (insert ":" x ":\n"))
                :multi-action
                (lambda (lst)
                  (insert (mapconcat #'identity lst ":") "\n"))))
@abo-abo
Copy link
Owner

@abo-abo abo-abo commented May 22, 2019

@basil-conto Thanks, added a new keyword.

@CeleritasCelery
Copy link
Contributor

@CeleritasCelery CeleritasCelery commented Dec 5, 2019

@abo-abo @basil-conto
So unless I am missing something, this change removes the ability to define multi-actions via ivy-add-actions. Previous it checked the size of the argument list and if it had an additional argument it added the marked candidates as a list. However with this new change The only way to add multi actions is to redefine the ivy-read with :multi-action. And you can only have one multi-action per completion. Am I missing something here? Is there a way to get back the old functionality?

@abo-abo
Copy link
Owner

@abo-abo abo-abo commented Dec 19, 2019

@CeleritasCelery Yes, it looks like the functionality was reduced by this simplification. Please open a new issue where we can discuss which functionality we want and how to best implement it.

astoff added a commit to astoff/swiper that referenced this issue Jan 1, 2021
* ivy.el (ivy-call): The second arg in `ivy-action' must be called
  "marked-candidades" in order to be recognized. This is to allow the
  built-in functions such as `find-file-other-window' to be re-used as
  actions. The function in question, `find-file-other-window', already
  has 2 arguments, so it was mistaken for an action with the
  marked-candidates logic.
(ivy-mark): Document `marked-candidates'.

Re abo-abo#561
Fixes abo-abo#2068
astoff added a commit to astoff/swiper that referenced this issue Jan 1, 2021
Re abo-abo#2068
Re abo-abo#561

Example:

    (defun test ()
      (interactive)
      (ivy-read "test:" '("a" "b" "c")
                :action
                (lambda (x) (insert ":" x ":\n"))
                :multi-action
                (lambda (lst)
                  (insert (mapconcat #'identity lst ":") "\n"))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants