unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* [jidanni@jidanni.org: ffap: if file at point doesn't exist, but its directory does]
@ 2003-12-17  3:28 Richard Stallman
  2004-01-03  8:46 ` gnu
  2004-02-16 21:54 ` Juri Linkov
  0 siblings, 2 replies; 8+ messages in thread
From: Richard Stallman @ 2003-12-17  3:28 UTC (permalink / raw)
  Cc: rv

Would someone like to work on this?  (rv has not responded in a month.)

------- Start of forwarded message -------
To: bug-gnu-emacs@gnu.org
From: Dan Jacobson <jidanni@jidanni.org>
Date: Sun, 16 Nov 2003 02:30:33 +0800
Subject: ffap: if file at point doesn't exist, but its directory does
Sender: bug-gnu-emacs-bounces+rms=gnu.org@gnu.org

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.


_______________________________________________
Bug-gnu-emacs mailing list
Bug-gnu-emacs@gnu.org
http://mail.gnu.org/mailman/listinfo/bug-gnu-emacs
------- End of forwarded message -------

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [jidanni@jidanni.org: ffap: if file at point doesn't exist, but its directory does]
  2003-12-17  3:28 [jidanni@jidanni.org: ffap: if file at point doesn't exist, but its directory does] Richard Stallman
@ 2004-01-03  8:46 ` gnu
  2004-02-16 21:54 ` Juri Linkov
  1 sibling, 0 replies; 8+ messages in thread
From: gnu @ 2004-01-03  8:46 UTC (permalink / raw)
  Cc: rv, emacs-devel

I'm sorry. I'm have been in India for over a month now attending to some 
personal affairs and I will not be able to work on any outstanding issues till 
February 10th.

rv

Quoting Richard Stallman <rms@gnu.org>:

> Would someone like to work on this?  (rv has not responded in a month.)
> 
> ------- Start of forwarded message -------
> To: bug-gnu-emacs@gnu.org
> From: Dan Jacobson <jidanni@jidanni.org>
> Date: Sun, 16 Nov 2003 02:30:33 +0800
> Subject: ffap: if file at point doesn't exist, but its directory does
> Sender: bug-gnu-emacs-bounces+rms=gnu.org@gnu.org
> 
> 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.
> 
> 
> _______________________________________________
> Bug-gnu-emacs mailing list
> Bug-gnu-emacs@gnu.org
> http://mail.gnu.org/mailman/listinfo/bug-gnu-emacs
> ------- End of forwarded message -------
> 
> 
> 
> _______________________________________________
> Emacs-devel mailing list
> Emacs-devel@gnu.org
> http://mail.gnu.org/mailman/listinfo/emacs-devel
> 

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [jidanni@jidanni.org: ffap: if file at point doesn't exist, but its directory does]
  2003-12-17  3:28 [jidanni@jidanni.org: ffap: if file at point doesn't exist, but its directory does] Richard Stallman
  2004-01-03  8:46 ` gnu
@ 2004-02-16 21:54 ` Juri Linkov
  2004-02-17  3:38   ` Rajesh Vaidheeswarran
  1 sibling, 1 reply; 8+ messages in thread
From: Juri Linkov @ 2004-02-16 21:54 UTC (permalink / raw)
  Cc: jidanni, rms, rv, gnu

Richard Stallman <rms@gnu.org> writes:
> Would someone like to work on this?  (rv has not responded in a month.)
>
> From: Dan Jacobson <jidanni@jidanni.org>
> Subject: ffap: if file at point doesn't exist, but its directory does
> To: bug-gnu-emacs@gnu.org
> 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  <juri@jurta.org>

	* 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))))
  \f

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [jidanni@jidanni.org: ffap: if file at point doesn't exist, but its directory does]
  2004-02-16 21:54 ` Juri Linkov
@ 2004-02-17  3:38   ` Rajesh Vaidheeswarran
  2004-02-17 21:09     ` Juri Linkov
  0 siblings, 1 reply; 8+ messages in thread
From: Rajesh Vaidheeswarran @ 2004-02-17  3:38 UTC (permalink / raw)
  Cc: jidanni, rms, emacs-devel

It seems Juri just beat me to it. I'll test it and check it in, if all 
is well.

Thanks Juri.

rv

Juri Linkov wrote:
> Richard Stallman <rms@gnu.org> writes:
> 
>>Would someone like to work on this?  (rv has not responded in a month.)
>>
>>From: Dan Jacobson <jidanni@jidanni.org>
>>Subject: ffap: if file at point doesn't exist, but its directory does
>>To: bug-gnu-emacs@gnu.org
>>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  <juri@jurta.org>
> 
> 	* 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))))
>   \f
> 

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [jidanni@jidanni.org: ffap: if file at point doesn't exist, but its directory does]
  2004-02-17  3:38   ` Rajesh Vaidheeswarran
@ 2004-02-17 21:09     ` Juri Linkov
  2004-02-18 19:52       ` Dan Jacobson
  0 siblings, 1 reply; 8+ messages in thread
From: Juri Linkov @ 2004-02-17 21:09 UTC (permalink / raw)
  Cc: jidanni, emacs-devel

Rajesh Vaidheeswarran <rv@gnu.org> writes:
> I'll test it and check it in, if all is well.

I noticed that the function `ffap-file-at-point' has some redundant
code: the code for testing local filenames has two copies.  I think
one of them should be removed.  The second copy might be needed only
if the variable `name' is changed between the first copy and the second.
But it's not so: after trying to strip off line numbers and shell
prompts the name remains unchanged.

I added also another useful feature: if filename has spaces then the
user can select a region with full filename with spaces to help ffap
to get filename from the buffer.

2004-02-17  Juri Linkov  <juri@jurta.org>

	* ffap.el (ffap-string-at-point): Get string from active region.
	(ffap-file-at-point): Remove redundant code.

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	17 Feb 2004 19:05:14 -0000
***************
*** 966,971 ****
--- 966,973 ----
  MODE (defaults to value of `major-mode') is a symbol used to look up string
  syntax parameters in `ffap-string-at-point-mode-alist'.
  If MODE is not found, we use `file' instead of MODE.
+ Get string from the region if region is active.  This is useful
+ to help ffap to find file names with spaces.
  Sets `ffap-string-at-point' and `ffap-string-at-point-region'."
    (let* ((args
  	  (cdr
***************
*** 973,987 ****
  	       (assq 'file ffap-string-at-point-mode-alist))))
  	 (pt (point))
  	 (str
! 	  (buffer-substring
! 	   (save-excursion
! 	     (skip-chars-backward (car args))
! 	     (skip-chars-forward (nth 1 args) pt)
! 	     (setcar ffap-string-at-point-region (point)))
! 	   (save-excursion
! 	     (skip-chars-forward (car args))
! 	     (skip-chars-backward (nth 2 args) pt)
! 	     (setcar (cdr ffap-string-at-point-region) (point))))))
      (set-text-properties 0 (length str) nil str)
      (setq ffap-string-at-point str)))
  
--- 975,993 ----
  	       (assq 'file ffap-string-at-point-mode-alist))))
  	 (pt (point))
  	 (str
! 	  (if (and transient-mark-mode mark-active)
! 	      (buffer-substring
! 	       (setcar ffap-string-at-point-region (region-beginning))
! 	       (setcar (cdr ffap-string-at-point-region) (region-end)))
! 	    (buffer-substring
! 	     (save-excursion
! 	       (skip-chars-backward (car args))
! 	       (skip-chars-forward (nth 1 args) pt)
! 	       (setcar ffap-string-at-point-region (point)))
! 	     (save-excursion
! 	       (skip-chars-forward (car args))
! 	       (skip-chars-backward (nth 2 args) pt)
! 	       (setcar (cdr ffap-string-at-point-region) (point)))))))
      (set-text-properties 0 (length str) nil str)
      (setq ffap-string-at-point str)))
  
***************
*** 1128,1136 ****
           ((and ffap-shell-prompt-regexp
  	       (not abs) (string-match ffap-shell-prompt-regexp name)
                 (ffap-file-exists-string (substring name (match-end 0)))))
- 	 ;; Immediately test local filenames.  If default-directory is
- 	 ;; remote, you probably already have a connection.
- 	 ((and (not abs) (ffap-file-exists-string name)))
  	 ;; Accept remote names without actual checking (too slow):
  	 ((if abs
  	      (ffap-file-remote-p name)
--- 1134,1139 ----

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [jidanni@jidanni.org: ffap: if file at point doesn't exist, but its directory does]
  2004-02-17 21:09     ` Juri Linkov
@ 2004-02-18 19:52       ` Dan Jacobson
  2004-02-19  7:07         ` Eli Zaretskii
  0 siblings, 1 reply; 8+ messages in thread
From: Dan Jacobson @ 2004-02-18 19:52 UTC (permalink / raw)


By the way, it is a rare occasion that one wants to create files when
1000 times more likely one merely has made a typo, so ffap should not
so readily ask the user "create it?", and instead do other things.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [jidanni@jidanni.org: ffap: if file at point doesn't exist, but  its directory does]
  2004-02-18 19:52       ` Dan Jacobson
@ 2004-02-19  7:07         ` Eli Zaretskii
  2004-02-19 23:24           ` Dan Jacobson
  0 siblings, 1 reply; 8+ messages in thread
From: Eli Zaretskii @ 2004-02-19  7:07 UTC (permalink / raw)
  Cc: emacs-devel

> From: Dan Jacobson <jidanni@jidanni.org>
> Date: Thu, 19 Feb 2004 03:52:43 +0800
> 
> By the way, it is a rare occasion that one wants to create files when
> 1000 times more likely one merely has made a typo, so ffap should not
> so readily ask the user "create it?", and instead do other things.

Like what, for example?  Do you have specific proposals?

In my experience, many (most?) programs that deal with files ask for
confirmation in the situations where it is unlikely that the user
indeed meant what the program thinks she meant.  The situation we are
discussing sounds like one of those cases.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [jidanni@jidanni.org: ffap: if file at point doesn't exist, but  its directory does]
  2004-02-19  7:07         ` Eli Zaretskii
@ 2004-02-19 23:24           ` Dan Jacobson
  0 siblings, 0 replies; 8+ messages in thread
From: Dan Jacobson @ 2004-02-19 23:24 UTC (permalink / raw)


>> so readily ask the user "create it?", and instead do other things.

Eli> Like what, for example?  Do you have specific proposals?

I just recall that we weren't given the opportunity to correct our
entry without ^G-ing out first and then using M-p etc.

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2004-02-19 23:24 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-12-17  3:28 [jidanni@jidanni.org: ffap: if file at point doesn't exist, but its directory does] Richard Stallman
2004-01-03  8:46 ` gnu
2004-02-16 21:54 ` Juri Linkov
2004-02-17  3:38   ` Rajesh Vaidheeswarran
2004-02-17 21:09     ` Juri Linkov
2004-02-18 19:52       ` Dan Jacobson
2004-02-19  7:07         ` Eli Zaretskii
2004-02-19 23:24           ` Dan Jacobson

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).