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

ivy-completing-read sets wrong :caller #1606

Closed
basil-conto opened this issue May 31, 2018 · 5 comments
Closed

ivy-completing-read sets wrong :caller #1606

basil-conto opened this issue May 31, 2018 · 5 comments

Comments

@basil-conto
Copy link
Collaborator

I think ce3c0ec introduced the following behaviour:

  1. make plain
  2. (defun foo ()
      (interactive)
      (setq unread-command-events '(?\C-m))
      (completing-read "Command: " obarray #'commandp t)
      (message ">>> %s" (ivy-state-caller ivy-last)))
  3. C-j
  4. M-xfooRET
    • Expected result: >>> foo in echo area.
    • Actual result: >>> nil in echo area.

What is the purpose of the (called-interactively-p 'any) guard in the aforementioned commit? In my tests it always returns nil. Can we do the following?

diff --git a/ivy.el b/ivy.el
index f8aceb2..d02a8b9 100644
--- a/ivy.el
+++ b/ivy.el
@@ -2067,7 +2067,9 @@ ivy-completing-read
                 :caller (cond ((called-interactively-p 'any)
                                this-command)
                               ((and collection (symbolp collection))
-                               collection))))))
+                               collection)
+                              (t
+                               this-command))))))
 
 (defun ivy-completing-read-with-empty-string-def
     (prompt collection

Is there a better solution?

@basil-conto
Copy link
Collaborator Author

This also relates to #1297.

@basil-conto
Copy link
Collaborator Author

#1621, which is a simpler version of #1297, fixes this issue, but my question about the use of (called-interactively-p 'any) still remains.

@abo-abo
Copy link
Owner

abo-abo commented Jun 14, 2018

purpose of (called-interactively-p 'any)

I'm not sure anymore. I think this can be used to detect of we're running tests in emacs -batch mode or not.

I think changing the code to this should work:

(if (and collection (symbolp collection))
    collection
  this-command)

@basil-conto
Copy link
Collaborator Author

I think changing the code to this should work:

If you still think so (and I don't see anything wrong with the suggestion), would you like to make this change?

@abo-abo
Copy link
Owner

abo-abo commented Nov 21, 2018

I've made the change. Thanks.

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

2 participants