-
-
Notifications
You must be signed in to change notification settings - Fork 390
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
helm-complex-command-history and interactivity #489
Comments
Hi Michael, michael-heerdegen notifications@github.com writes:
Could you provide a small recipe showing the current behavior, what it Thanks. Thierry |
Just try the simple example from the bug report of the according vanilla bug 14136: https://lists.gnu.org/archive/html/emacs-bug-tracker/2013-08/msg00161.html All commands that do a called-interactively-p test are problematic. There was some dired command where this problem often bites me, but I don't remeber now. Another example: I use this code to search e.g. for cl.el stuff in my libs: (require 'cl-lib)
(defvar lib-stuff-find-current-regexp)
(defvar lib-stuff-find-temp-map
(let ((map (make-sparse-keymap)))
(define-key map [?\ ] #'lib-stuff-find-redo)
map))
(defun lib-stuff-find (regexp)
"Search for symbols whoose symbol file is matched by regexp."
(interactive "sRegexp: ")
(setq lib-stuff-find-current-regexp regexp)
(let ((file)
(reporter (make-progress-reporter "Searching "
(point-min) (point-max) (point))))
(forward-symbol 1)
(while (not (or (eobp)
(and (not (nth 4 (syntax-ppss))) ;inside a comment
(not (nth 3 (syntax-ppss))) ;inside a string
(setq file (symbol-file (symbol-at-point)))
(setq file (and file (file-name-sans-extension
(file-name-nondirectory file))))
(string-match regexp file))))
(progress-reporter-update reporter (point))
(forward-symbol 1))
(if (eobp)
(progn (message "Nothing found") nil)
(forward-symbol -1)
(set-transient-map lib-stuff-find-temp-map t)
(message "%s: %s" (file-name-sans-extension file) (symbol-at-point))
(when (called-interactively-p 'any)
(sit-for 2)
(with-temp-message
(substitute-command-keys
"\\<lib-stuff-find-temp-map>\\[lib-stuff-find-redo] to repeat search")
(sit-for 2)))
(symbol-at-point))))
(defun lib-stuff-find-redo ()
(interactive)
(forward-symbol 1)
(lib-stuff-find lib-stuff-find-current-regexp))
(Sorry, github doesn't indent correctly.) When I use this, then make some edits, and want to search further with the very same regexp via helm-complex-command-history, the command lib-stuff-find doesn't consider itself as having been called interactively and doesn't set the temporary overlay map that allows hitting SPC to repeat. |
And yes, the problem is a bit exotic and triggered not very often, but it's annoying every time it happens, and you can't completely avoid it. |
BTW, 500db39 is not kosher:
(Or should we even avoid adding helm-complex-command-history to command-history?) |
michael-heerdegen notifications@github.com writes:
It is working now for this one.
Don't use it in your functions? (defun lib-stuff-find ;(regexp)
Yes this is a problem, not fixed already, I am unable for now to setup a Thierry |
Thierry Volpiatto notifications@github.com writes:
Thanks. Hhm, but the message (of the word count) is instantly erased,
Yes, it's possible to avoid to trigger that bug, no doubt. Not nice, BTW, I also don't like the vanilla fix much. |
michael-heerdegen notifications@github.com writes:
Hmm, here it is working as expected, can you figure out why the message is
Agreed.
Same here. Thierry |
Thierry Volpiatto notifications@github.com writes:
Correction: count-words is working as expected. What I tested was count-words-region. And for this, the message is not |
Looking at the definition of `called-interactively-p', which analyses I think the situation would be nicer when the vanilla code would be
would be exposed as a function. |
michael-heerdegen notifications@github.com writes:
I have fixed this issue but it have several problems:
So I will not commit it yet. Thierry |
…eractively-p (#489). Not backward compatible, not working with compiled code.
The branch is "complex-command-history" |
FYI: I've read your patch, but had no useful comments about it. I would also like to avoid doing this. But I would not take backwards compatibility too seriously, since older versions of Emacs have the bug even without using helm. |
We could use now the compatibility function Stefan sent (and you fixed) for compatibility and use the real fix for emacs-24.5 once commited WDYT ? |
See #508 |
Yes, that's what I thought, too. It's much better than the other hack. But this only fixes called-interactively-p calls. References to this-command and last-command will still not work, I think, right? BTW, did you test if this-command is set accordingly with Stefans patch for inclusion? |
michael-heerdegen notifications@github.com writes:
I don't know what references you are talking about.
How ? I don't see the point for complex-command-history. Thierry |
Thierry Volpiatto notifications@github.com writes:
Some commands need to behave differently depending on the command that When we repeat a command from complex-command-history, this-command and |
michael-heerdegen notifications@github.com writes:
Isn't `call-interactively' taking care of this ? Thierry |
Thierry Volpiatto notifications@github.com writes:
Actually, nothing is taking care of this. See my last message in the |
…functions hack (#489). * helm-utils.el: Remove funcall-interactively.
I don't use funcall-interactively anymore, it is failing in many places and sometimes return Now it is working for most things (emacs 24.4 only). |
Ok, thanks for the info (and thanks for your work). BTW, why is dont-compile necessary? I would expect that with compiling What about the obsoleteness of dont-compile? AFAICT, we could just |
michael-heerdegen notifications@github.com writes:
We can look at them in both cases, but they are different, so
Well, for now it is ok, obsolete warnings are disabled with local var, BTW feel free to close the bug if all is working fine for you. Thanks. Thierry |
Thanks. I'll make some final tests tomorrow, and then hopefully close |
Ok, looks good so far, thanks. |
Hi,
the current implementation of the helm-complex-command-history uses just the sexp type that comes with actions that are more or less the same as eval. In the case of helm-complex-command-history, we need (a bit) more: the called command must know that it was called interactively. With the current implementation, any called-interactively-p test (inside the command's defun) fails, and this-command is not updated accordingly, etc. The so repeated command behaves as it was called from Lisp, but it should behave as it was envoked normally, i.e., interactively.
In vanilla repeat-complex-command, there is a simple hack (search for "trick" in its defun) that solves that problem. Can we use this as well?
The text was updated successfully, but these errors were encountered: