* call-interactively behavior
@ 2023-03-10 6:38 Nicolas P. Rougier (inria)
2023-03-10 18:16 ` Nicolas P. Rougier (inria)
0 siblings, 1 reply; 4+ messages in thread
From: Nicolas P. Rougier (inria) @ 2023-03-10 6:38 UTC (permalink / raw)
To: emacs-devel
Hi all,
I'm trying to use call-interactively using the following code:
#+begin_src
(with-current-buffer (get-buffer-create "hippie-test")
(setq-local hippie-expand-try-functions-list
'(try-complete-file-name-partially
try-complete-file-name))
(text-mode)
(use-local-map (copy-keymap text-mode-map))
(local-set-key (kbd "TAB") 'hippie-expand)
(insert "~/D")
(call-interactively (key-binding (kbd "TAB")))
(call-interactively (key-binding (kbd "TAB")))
(call-interactively (key-binding (kbd "TAB"))))
#+end_src
In my home root, there are 3 directoriess: ~/Desktop, ~/Downloads
and ~/Documents.
When I execute the code above, the final content in the buffer is:
~/Desktop/../../
If I switch to the buffer, insert "~/D" and hit tab three times, I
cycle over the three directories above, which is the expected
behavior. My question is thus: why I don't get the same behavior
and what would be the proper way to simulate the tab key press (or
any other key)?
Nicolas
--
Nicolas P. Rougier —— www.labri.fr/perso/nrougier
Institute of Neurodegenerative Diseases, Bordeaux
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: call-interactively behavior
2023-03-10 6:38 call-interactively behavior Nicolas P. Rougier (inria)
@ 2023-03-10 18:16 ` Nicolas P. Rougier (inria)
2023-03-11 10:52 ` Augusto Stoffel
0 siblings, 1 reply; 4+ messages in thread
From: Nicolas P. Rougier (inria) @ 2023-03-10 18:16 UTC (permalink / raw)
To: emacs-devel
Nicolas P. Rougier (inria) [2023-03-10 at 07:38] wrote:
> Hi all,
>
> I'm trying to use call-interactively using the following code:
>
> #+begin_src
> (with-current-buffer (get-buffer-create "hippie-test")
> (setq-local hippie-expand-try-functions-list
> '(try-complete-file-name-partially
> try-complete-file-name))
> (text-mode)
> (use-local-map (copy-keymap text-mode-map))
> (local-set-key (kbd "TAB") 'hippie-expand)
>
> (insert "~/D")
> (call-interactively (key-binding (kbd "TAB")))
> (call-interactively (key-binding (kbd "TAB")))
> (call-interactively (key-binding (kbd "TAB"))))
> #+end_src
>
> In my home root, there are 3 directoriess: ~/Desktop,
> ~/Downloads
> and ~/Documents.
>
> When I execute the code above, the final content in the buffer
> is:
> ~/Desktop/../../
>
> If I switch to the buffer, insert "~/D" and hit tab three times,
> I
> cycle over the three directories above, which is the expected
> behavior. My question is thus: why I don't get the same behavior
> and what would be the proper way to simulate the tab key press
> (or
> any other key)?
>
> Nicolas
Partially answering my question, it seems that evaluating
repeatedly the code works but it is not clear why. Maybe some
events need to be flushed?
#+begin_src
(with-current-buffer "hippie-test"
(call-interactively (key-binding (kbd "TAB"))))
#+end_sc
Nicolas
--
Nicolas P. Rougier —— www.labri.fr/perso/nrougier
Institute of Neurodegenerative Diseases, Bordeaux
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: call-interactively behavior
2023-03-10 18:16 ` Nicolas P. Rougier (inria)
@ 2023-03-11 10:52 ` Augusto Stoffel
2023-03-11 11:12 ` Nicolas P. Rougier (inria)
0 siblings, 1 reply; 4+ messages in thread
From: Augusto Stoffel @ 2023-03-11 10:52 UTC (permalink / raw)
To: Nicolas P. Rougier (inria); +Cc: emacs-devel
I suppose you want to use `execute-kbd-macro'?
On Fri, 10 Mar 2023 at 19:16, Nicolas P. Rougier (inria) wrote:
> Nicolas P. Rougier (inria) [2023-03-10 at 07:38] wrote:
>> Hi all,
>>
>> I'm trying to use call-interactively using the following code:
>>
>> #+begin_src
>> (with-current-buffer (get-buffer-create "hippie-test")
>> (setq-local hippie-expand-try-functions-list
>> '(try-complete-file-name-partially
>> try-complete-file-name))
>> (text-mode)
>> (use-local-map (copy-keymap text-mode-map))
>> (local-set-key (kbd "TAB") 'hippie-expand)
>>
>> (insert "~/D")
>> (call-interactively (key-binding (kbd "TAB")))
>> (call-interactively (key-binding (kbd "TAB")))
>> (call-interactively (key-binding (kbd "TAB"))))
>> #+end_src
>>
>> In my home root, there are 3 directoriess: ~/Desktop,
>> ~/Downloads
>> and ~/Documents.
>>
>> When I execute the code above, the final content in the buffer
>> is:
>> ~/Desktop/../../
>>
>> If I switch to the buffer, insert "~/D" and hit tab three times,
>> I
>> cycle over the three directories above, which is the expected
>> behavior. My question is thus: why I don't get the same behavior
>> and what would be the proper way to simulate the tab key press
>> (or
>> any other key)?
>>
>> Nicolas
>
> Partially answering my question, it seems that evaluating
> repeatedly the code works but it is not clear why. Maybe some
> events need to be flushed?
>
> #+begin_src
> (with-current-buffer "hippie-test"
> (call-interactively (key-binding (kbd "TAB"))))
> #+end_sc
>
> Nicolas
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: call-interactively behavior
2023-03-11 10:52 ` Augusto Stoffel
@ 2023-03-11 11:12 ` Nicolas P. Rougier (inria)
0 siblings, 0 replies; 4+ messages in thread
From: Nicolas P. Rougier (inria) @ 2023-03-11 11:12 UTC (permalink / raw)
To: Augusto Stoffel; +Cc: emacs-devel
Augusto Stoffel [2023-03-11 at 11:52] wrote:
> I suppose you want to use `execute-kbd-macro'?
Thank for the suggestion, but documentation indicates:
The buffer shown in the currently selected window will be made the
current
buffer before the macro is executed.
such that I'm unable to send the "TAB" to the right buffer.
Having looked more closely at the hippie-expand code, it tests
explicitely last-command vs this-command to continue the cycle or
not. I think I need to do something like:
#+begin_src
(let ((command (key-binding (kbd "TAB"))))
(command-execute command t)
(setq this-command command)
(setq last-command command)
#+end_src
Nicolas
--
Nicolas P. Rougier —— www.labri.fr/perso/nrougier
Institute of Neurodegenerative Diseases, Bordeaux
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-03-11 11:12 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-03-10 6:38 call-interactively behavior Nicolas P. Rougier (inria)
2023-03-10 18:16 ` Nicolas P. Rougier (inria)
2023-03-11 10:52 ` Augusto Stoffel
2023-03-11 11:12 ` Nicolas P. Rougier (inria)
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).