emacs-devel
[Top][All Lists]
Advanced

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

Re: address@hidden: ffap: if file at point doesn't exist, but its direct


From: Juri Linkov
Subject: Re: address@hidden: ffap: if file at point doesn't exist, but its directory does]
Date: Mon, 16 Feb 2004 23:54:31 +0200
User-agent: Gnus/5.110002 (No Gnus v0.2) Emacs/21.3.50 (gnu/linux)

Richard Stallman <address@hidden> writes:
> Would someone like to work on this?  (rv has not responded in a month.)
>
> From: Dan Jacobson <address@hidden>
> Subject: ffap: if file at point doesn't exist, but its directory does
> To: address@hidden
> Date: Sun, 16 Nov 2003 02:30:33 +0800
>
> 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.

Since nobody has implemented this useful feature yet, here is the patch:

2004-02-16  Juri Linkov  <address@hidden>

        * ffap.el (ffap-file-at-point): Try parent directories.

Index: emacs/lisp/ffap.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/ffap.el,v
retrieving revision 1.42
diff -c -r1.42 ffap.el
*** emacs/lisp/ffap.el  25 Dec 2003 17:44:48 -0000      1.42
--- emacs/lisp/ffap.el  16 Feb 2004 21:44:46 -0000
***************
*** 1185,1190 ****
--- 1187,1200 ----
                         remote-dir (substring name (match-end 1)))))
                  (ffap-file-exists-string
                   (ffap-replace-file-component remote-dir name))))))
+          ;; Try all parent directories by deleting the trailing directory
+          ;; name until existing directory is found or name stops changing
+          ((let ((dir name))
+             (while (and dir
+                         (not (ffap-file-exists-string dir))
+                         (not (equal dir (setq dir (file-name-directory
+                                                    (directory-file-name 
dir)))))))
+             (ffap-file-exists-string dir)))
         )
        (set-match-data data))))
  

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





reply via email to

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