cannot advice find-file reddit / emacs ---------------------------------------------------------------------- ntrysii · 2022-12-10 11:27 I'm trying to advice the function `find-file` but the advice doesn't seem to work at all, while other advices work normally this function won't be adviced here is the code: (advice-add 'find-file :around #'my-vertico-select-first) (defun my-vertico-select-first-file (fn &rest args) (apply fn args) (vertico-next ) ) ---------------------------------------------------------------------- Bodertz · 2022-12-10 13:51 Well, it's just a guess, but I'm assuming it's calling vertico-next after emacs opens the file (that's what find-file does, and your advice tells it to run that before doing vertico-next), whereas I assume you want it to call vertico-next when find-file prompts for a file. You should test with a message function instead of vertico-next so you can see if the advice is being applied. ---------------------------------------------------------------------- ayy_ess · 2022-12-10 16:04 IIRC you want to advise `find-file-read-args` which is the `interactive` part of `find-file`. ---------------------------------------------------------------------- trararawe · 2022-12-10 16:52 Isn't the advicing function missing a -file suffix? Should be ``` (advice-add 'find-file :around #'my-vertico-select-first-file) ``` ---------------------------------------------------------------------- ntrysii · 2022-12-10 19:48 yeah, sorry I changed the function name but never run it. either way it doesn't work. ---------------------------------------------------------------------- ntrysii · 2022-12-10 19:49 I tested with a message but the message only appears after selecting a file, I guess `vertico` takes control before the `find-file` does. ---------------------------------------------------------------------- ntrysii · 2022-12-10 19:51 that worked, Thanks for you help. ---------------------------------------------------------------------- ntrysii · 2022-12-10 19:53 it runs the function but still I cannot make `vertico` go to the next line