unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Ido: let C-d open a dired buffer for commands other than ido-find-file
@ 2021-02-22 18:20 Andrea Greselin
  0 siblings, 0 replies; only message in thread
From: Andrea Greselin @ 2021-02-22 18:20 UTC (permalink / raw)
  To: Help Gnu Emacs mailing list

Hi everyone,

I use ‘(setq ido-everywhere t)’, so ‘find-file-at-point’ uses Ido's
completion. I'd like ‘ido-magic-delete-char’ (C-d) to open the
candidate directory in a Dired buffer, like it does when entering Ido
with ‘ido-find-file’, also for ‘find-file-at-point’.

Here's the (abridged) definition of ‘ido-magic-delete-char’:

  (defun ido-magic-delete-char (arg)
    …
    (cond
     ((or arg (not (eobp)))
      (delete-char (min (prefix-numeric-value arg)
        (- (point-max) (point)))))
     (ido-context-switch-command
      nil)
     ((memq ido-cur-item '(file dir))
      (ido-enter-dired))))

The problem lies in the fact that ‘ido-context-switch-command’ is
always non-nil when I hit C-d from a ‘find-file-at-point’ prompt, and
so the second condition kicks in in place of ‘ido-enter-dired’.

I know I could use something like this

  (define-advice ido-magic-delete-char
      (:around (orig-fn &rest args) dired-everywhere)
    "Let ‘ido-magic-delete-char’ open ‘dired’ in the candidate
  directory."
    (let ((ido-context-switch-command nil))
      (apply orig-fn args)))

but I don't know the workings of ‘ido-context-switch-command’ and
‘ido-cur-item’ so now I wonder what could go wrong with this thing.
Can you tell me if there are contraindication with it?

Andrea


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-02-22 18:20 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-02-22 18:20 Ido: let C-d open a dired buffer for commands other than ido-find-file Andrea Greselin

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