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

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

Re: ffap: if file at point doesn't exist, but its directory does


From: Juri Linkov
Subject: Re: ffap: if file at point doesn't exist, but its directory does
Date: Mon, 17 Nov 2003 19:14:17 +0200
User-agent: Gnus/5.1003 (Gnus v5.10.3) Emacs/21.3.50 (gnu/linux)

Dan Jacobson <jidanni@jidanni.org> writes:
> Ffap gentlemen, assume your cursor is on
> "/usr/X11R6/lib/X11/xdm/Xreset" but the file doesn't exist, but the
> directory does.  Well, ffap should (optionally ask, and) take you to a
> dired of that directory... better than the current nothing.

I have another problem with ffap: it can't find a file if file name
contains spaces.  I fixed this problem by the new function:

(defun my-find-file-at-point-or-region (&optional arg)
  "Find filename at point or selected by region.
This function is useful, when filename contains spaces, and so can't
be fully matched by `find-file-at-point'.  In this case user should
manually select region around the full filename and invoke this command.
This function also maps UNIX filenames to Window$ filenames."
  (interactive "P")
  (let ((filename
         (if (and transient-mark-mode mark-active)
             (buffer-substring-no-properties (mark) (point))
           (ffap-string-at-point))))
    (and (eq system-type 'windows-nt)
         filename
         (string-match "^/dos/\\([A-Za-z]\\)\\(.*\\)" filename)
         (setq filename (concat (match-string 1 filename) ":"
                                (match-string 2 filename))))
    (or (and filename (file-exists-p filename))
        (setq filename (ffap-guesser)))
    (find-file-at-point (ffap-prompter filename))))

But I think it is not the right thing yet.  Ffap should be fixed
to pick up full file name with spaces without requiring the user
to select a region.

-- 
http://www.jurta.org/emacs/





reply via email to

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