1

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.

J Spen
  • 2,614
  • 4
  • 26
  • 41

2 Answers2

1

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))))))
assem
  • 2,077
  • 1
  • 19
  • 24
  • That function works great but curious how you can change it so instead of just bringing up the list-directory contents automatically. I can change the folder before confirming the directory to show the contents of. I will probably keep the function as is but also curious how to do this. – J Spen Aug 03 '12 at 22:15
  • Sweet, that works exactly as I want but I was hoping to set the ask version as a prefix, for example C-u C-x C-d. Do you know how to set prefixes?? It won't let me use C-u. – J Spen Aug 05 '12 at 02:33
  • `(interactive "P")` and an `&optional arg` in the function signature that is set if invoked with a prefix. check out the modified example – assem Aug 05 '12 at 04:37
0

(setq ido-use-filename-at-point 'guess)

Nicolas Dudebout
  • 9,172
  • 2
  • 34
  • 43
  • That doesn't seem to do anything for me as I already had that set. I try using it in org-mode on links like: /home/username/test/ and it just brings up the current folder the file is in but dired-at-point which I think is supposed to use the same function works correctly. Not sure if my ido is broken or how I can check this to get it working properly? – J Spen Aug 03 '12 at 21:55
  • Actually figured out it works correctly for find file but not for dired ido-mode. Anyway, to enable it there as well? – J Spen Aug 03 '12 at 21:58
  • You confused me. What are you trying to do? Give a use case of what is in the buffer, what it should do, and what it actually does. – Nicolas Dudebout Aug 04 '12 at 22:08
  • Lets say /home/foldertemp/inbufferfile is in the buffer and I'm in file /home/workingfile and I run ido-find-file when cursor is on /home/foldertemp/inbufferfile it works and starts at that location but if I run ido-list-directory at the same spot it starts at /home/workingfile. Doesn't work the same as ido-find-file. It looks like the setting for ido-use-filename-at-point isn't being applied for ido-list-directory function. Does that help? – J Spen Aug 05 '12 at 02:36
  • When do you need to do `ido-list-directory`? If I was in that use case I would use `ido-find-file` and just type `C-j` to open the directory in dired. – Nicolas Dudebout Aug 05 '12 at 16:53
  • Yes, that is true but I like that list directory splits the screen when bringing up a new buffer. Really don't need a dired but the above function by assem works great for what I needed. – J Spen Aug 05 '12 at 23:53