help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Ido: let C-d open a dired buffer for commands other than ido-find-file


From: Andrea Greselin
Subject: Ido: let C-d open a dired buffer for commands other than ido-find-file
Date: Mon, 22 Feb 2021 19:20:56 +0100

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


reply via email to

[Prev in Thread] Current Thread [Next in Thread]