unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / 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

  List information: https://www.gnu.org/software/emacs/

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