emacselispdiredido-mode

Getting ido mode functionality similar to dired-at-point in emacs


I like using ido mode in emacs and the listing of directories with C-x C-d which runs ido-list-directory. Is there a command to enable ido-mode operation but at the current point like dired-at-point. I use this quite often but would prefer to use something like ido-dired-at-point.

Didn't know if this was already implemented and I just couldn't find it in the documentation or if it is easy to implement.


Solution

  • Looks like ido-list-directory is used for interactive completion of list-directory. So, if the thing at point is a filename, rather than use ido, using list-directory directly should achieve the same end result.

    How about something like this:

    (defun ido-ffap-list-directory ()
      (interactive)
      (let ((fap (ffap-guess-file-name-at-point)))
        (if fap
            (list-directory (file-name-directory fap))
          (ido-list-directory))))
    

    EDIT:

    or, if you want confirmation for the directory @ point (only for a C-u prefix) replace the list-directory sexp above with something like this:

    (defun ido-ffap-list-directory (&optional arg)
      (interactive "P")
      (let ((fap (ffap-guess-file-name-at-point)))
        (if (null fap)
            (ido-list-directory)
          (if arg
              (list-directory 
               (ido-read-directory-name "Directory: "
                                        (file-name-directory fap)))
            (list-directory (file-name-directory fap))))))