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

Comments

@basil-conto
Copy link
Collaborator

commented May 31, 2018

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

This comment has been minimized.

Copy link
Collaborator Author

commented Jun 4, 2018

This also relates to #1297.

@basil-conto

This comment has been minimized.

Copy link
Collaborator Author

commented Jun 13, 2018

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

basil-conto added a commit to basil-conto/swiper that referenced this issue Jun 14, 2018
@abo-abo

This comment has been minimized.

Copy link
Owner

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)
abo-abo added a commit that referenced this issue Jun 14, 2018
@basil-conto

This comment has been minimized.

Copy link
Collaborator Author

commented Nov 21, 2018

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 abo-abo closed this in ad8bed6 Nov 21, 2018

@abo-abo

This comment has been minimized.

Copy link
Owner

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
Projects
None yet
2 participants
You can’t perform that action at this time.