Open Alexander-Shukaev opened 4 years ago
The problem with
counsel-find-file
is that it can only be used by remappingfind-file
to it.
No, it can be used just like any other command, via custom key bindings or otherwise.
To cover them, corresponding
counsel-*
functions have to be implemented and remapped. This quickly gets tedious and error-prone.
I think that's an exaggeration, as it's the approach that vanilla Emacs has followed until now, and it seems to work fine in practice.
So is there already a hooking mechanism already available (or otherwise worth implementing), where instead of implementing something like
counsel-find-file
, we'd rather intercept/enhance/modify arguments toivy-read
based on:caller
Not the same thing, but FWIW many Ivy and Counsel functions, including counsel-find-file
, already take a j
action for opening in another window and an f
action for opening in another frame.
For example, to teach
find-file
and all other functions internally usingread-file-name-internal
to do whatcounsel-find-file
does, one would interceptivy-read
(e.g. withadvice-add
)
Sounds pretty invasive for a library to do without built-in support from Emacs in the form of a variable/hook.
What use case do you have in mind for which the current j
/k
actions or counsel-find-file-other-window
and counsel-find-file-other-frame
commands don't cut it?
IIUC, you want to set read-file-name-function
to some alternative that delegates to Ivy.
The problem with
counsel-find-file
is that it can only be used by remappingfind-file
to it. There are other sister functions likefind-file-other-window
,find-file-other-frame
, and etc. To cover them, correspondingcounsel-*
functions have to be implemented and remapped. This quickly gets tedious and error-prone.AFAIK, either
counsel-find-file
orfind-file
(withivy
enabled) will both boil down to simpleivy-read
invocation albeit with different arguments of course. So is there already a hooking mechanism already available (or otherwise worth implementing), where instead of implementing something likecounsel-find-file
, we'd rather intercept/enhance/modify arguments toivy-read
based on:caller
(which, for example, in case offind-file
would beread-file-name-internal
itself).For example, to teach
find-file
and all other functions internally usingread-file-name-internal
to do whatcounsel-find-file
does, one would interceptivy-read
(e.g. withadvice-add
), see that:caller
isread-file-name-internal
, and in this case applyivy-read
assimilar to how
counsel-find-file
does that explicitly.