all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Andrea Greselin <greselin.andrea@gmail.com>
To: Help Gnu Emacs mailing list <help-gnu-emacs@gnu.org>
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	[thread overview]
Message-ID: <CAJ_oJbZHb4KOpUfeecTLiA86ruS8_pkC962jEv7ihOZo8Nz2Xg@mail.gmail.com> (raw)

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	other threads:[~2021-02-22 18:20 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAJ_oJbZHb4KOpUfeecTLiA86ruS8_pkC962jEv7ihOZo8Nz2Xg@mail.gmail.com \
    --to=greselin.andrea@gmail.com \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.