unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Advising interactive commands
@ 2024-07-23  0:16 Ag Ibragimov
  2024-07-23  7:52 ` Andreas Schwab
  0 siblings, 1 reply; 2+ messages in thread
From: Ag Ibragimov @ 2024-07-23  0:16 UTC (permalink / raw)
  To: emacs-devel


Can someone please clarify my confusion about advising interactive commands? For some reason, I am unable to advise commands with interactive parameters. So, check this out:

(defun my-command (file)
  (interactive (list (read-file-name "Find file: "))))

When called, it prompts to select a file, alright?

Now, if I do this:

(defun my-command-override ()
  (message "running override"))

(advice-add 'my-command :override 'my-command-override)

I expect my new function to run instead, right? And indeed, this works:

(funcall 'my-command) ;; immediately shows the message

However, for whatever reason the following doesn't:

(call-interactively 'my-command)

Meaning, that it doesn't fully override it when called from M-x menu. I mean, it would prompt for the file but only after that it would call my-command-override. Why is that? Is this expected? If it is, how do you advise such commands so they don't show prompts for their parameters?



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-07-23  7:52 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-23  0:16 Advising interactive commands Ag Ibragimov
2024-07-23  7:52 ` Andreas Schwab

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).