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

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

Re: ido-find-file


From: Sam Halliday
Subject: Re: ido-find-file
Date: Sat, 26 Dec 2015 15:27:38 -0800 (PST)
User-agent: G2/1.0

On Saturday, 26 December 2015 23:20:00 UTC, Sam Halliday  wrote:
> Dear Emacs users,
> 
> I have been trying out ido-find-file as a replacement for find-file and it 
> was going really well until I tried to open a directory in dired.
> 
> The default in normal find-file is for RET to open a directory in dired, but 
> with ido-find-file, RET will open a (useless) buffer containing the name of 
> the files in that directory and C-d is needed to open the directory in dired.
> 
> There is no way I'm going to be able to retrain my fingers to do that, and it 
> is also undesirable behaviour. Is there any way to get ido-find-file to DWIM?


I found this hack from JohnWiegley 
http://www.emacswiki.org/emacs/InteractivelyDoThings#toc29 which does the job 
but is really quite ugly/long. It would be good if this was in the mainline and 
possible the default.

 (defun ido-smart-select-text ()
    "Select the current completed item.  Do NOT descend into directories."
    (interactive)
    (when (and (or (not ido-require-match)
                   (if (memq ido-require-match
                             '(confirm confirm-after-completion))
                       (if (or (eq ido-cur-item 'dir)
                               (eq last-command this-command))
                           t
                         (setq ido-show-confirm-message t)
                         nil))
                   (ido-existing-item-p))
               (not ido-incomplete-regexp))
      (when ido-current-directory
        (setq ido-exit 'takeprompt)
        (unless (and ido-text (= 0 (length ido-text)))
          (let ((match (ido-name (car ido-matches))))
            (throw 'ido
                   (setq ido-selected
                         (if match
                             (replace-regexp-in-string "/\\'" "" match)
                           ido-text)
                         ido-text ido-selected
                         ido-final-text ido-text)))))
      (exit-minibuffer)))
  
  (eval-after-load "ido"
    '(define-key ido-common-completion-map "\C-m" 'ido-smart-select-text))


reply via email to

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