GNU bug report logs - #44822
27.1; Regression in `ffap-read-file-or-url'

Previous Next

Package: emacs;

Reported by: Drew Adams <drew.adams <at> oracle.com>

Date: Mon, 23 Nov 2020 17:25:02 UTC

Severity: normal

Merged with 44841

Found in version 27.1

Fixed in version 28.1

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 44822 in the body.
You can then email your comments to 44822 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#44822; Package emacs. (Mon, 23 Nov 2020 17:25:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Drew Adams <drew.adams <at> oracle.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Mon, 23 Nov 2020 17:25:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Drew Adams <drew.adams <at> oracle.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 27.1; Regression in `ffap-read-file-or-url'
Date: Mon, 23 Nov 2020 09:23:37 -0800 (PST)
`ffap-read-file-or-url' now reads a URL as a file name, truncating to
remove a prefix such as http:/.  Prior to Emacs 27, it correctly
returned the URL.

If point is not on a URL, then the guess is nil.  The user is prompted
(as before) with the default directory as default.  If the user rejects
that default value and replaces it by a URL (e.g. yanking), then
`ffap-read-file-or-url' should just return that URL, as it has always
done.  In Emacs 27, it instead tries to handle it as a file name,
removing the prefix up to the first `/' before a non-/ char.

emacs -Q

;; With point not on a URL or file name:

(ffap-read-file-or-url "URL: " nil)

;; User is prompted, with the default-directory as default:

URL: /my/default/dir/

;; User pastes a URL after that or replaces that with a URL.

URL: /my/default/dir/http://foobar.com RET
;; or
URL: http://foobar.com RET

;; This is returned: /foobar.com

In Emacs 26.3 the URL entered by the user is returned correctly.

A main use of `read-file-or-url' is to prompt for and read a URL.  If a
user enters a URL when FFAP has not been able to guess a URL, FFAP now
just treats the input as a filename.  It treats prefix `http:/' the same
way it would treat prefix `c:' on MS Windows.

Reading a URL is maybe the main use case of `ffap-read-file-or-url'.  (There is no `ffap-read-url'.)  It's now broken.


In GNU Emacs 27.1 (build 1, x86_64-w64-mingw32)
 of 2020-08-12 built on CIRROCUMULUS
Repository revision: 86d8d76aa36037184db0b2897c434cdaab1a9ae8
Repository branch: HEAD
Windowing system distributor 'Microsoft Corp.', version 10.0.18362
System Description: Microsoft Windows 10 Pro (v10.0.1903.18362.1139)




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#44822; Package emacs. (Mon, 23 Nov 2020 17:54:01 GMT) Full text and rfc822 format available.

Message #8 received at 44822 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Thierry Volpiatto <thierry.volpiatto <at> gmail.com>,
 Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 44822 <at> debbugs.gnu.org, Drew Adams <drew.adams <at> oracle.com>
Subject: Re: bug#44822: 27.1; Regression in `ffap-read-file-or-url'
Date: Mon, 23 Nov 2020 19:53:34 +0200
> Date: Mon, 23 Nov 2020 09:23:37 -0800 (PST)
> From: Drew Adams <drew.adams <at> oracle.com>
> 
> `ffap-read-file-or-url' now reads a URL as a file name, truncating to
> remove a prefix such as http:/.  Prior to Emacs 27, it correctly
> returned the URL.
> 
> If point is not on a URL, then the guess is nil.  The user is prompted
> (as before) with the default directory as default.  If the user rejects
> that default value and replaces it by a URL (e.g. yanking), then
> `ffap-read-file-or-url' should just return that URL, as it has always
> done.  In Emacs 27, it instead tries to handle it as a file name,
> removing the prefix up to the first `/' before a non-/ char.
> 
> emacs -Q
> 
> ;; With point not on a URL or file name:
> 
> (ffap-read-file-or-url "URL: " nil)
> 
> ;; User is prompted, with the default-directory as default:
> 
> URL: /my/default/dir/
> 
> ;; User pastes a URL after that or replaces that with a URL.
> 
> URL: /my/default/dir/http://foobar.com RET
> ;; or
> URL: http://foobar.com RET
> 
> ;; This is returned: /foobar.com
> 
> In Emacs 26.3 the URL entered by the user is returned correctly.
> 
> A main use of `read-file-or-url' is to prompt for and read a URL.  If a
> user enters a URL when FFAP has not been able to guess a URL, FFAP now
> just treats the input as a filename.  It treats prefix `http:/' the same
> way it would treat prefix `c:' on MS Windows.
> 
> Reading a URL is maybe the main use case of `ffap-read-file-or-url'.  (There is no `ffap-read-url'.)  It's now broken.

Thierry and Stefan, these changes seem to have been done by you.  Can
you please take a look at this issue?  Would it be possible to fix
this for Emacs 27.2?




Forcibly Merged 44822 44841. Request was from 積丹尼 Dan Jacobson <jidanni <at> jidanni.org> to control <at> debbugs.gnu.org. (Fri, 27 Nov 2020 00:40:02 GMT) Full text and rfc822 format available.

Disconnected #44841 from all other report(s). Request was from Glenn Morris <rgm <at> gnu.org> to control <at> debbugs.gnu.org. (Sat, 28 Nov 2020 03:37:01 GMT) Full text and rfc822 format available.

Forcibly Merged 44822 44841. Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Sat, 31 Jul 2021 12:40:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#44822; Package emacs. (Sat, 31 Jul 2021 12:49:02 GMT) Full text and rfc822 format available.

Message #17 received at 44822 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 44822 <at> debbugs.gnu.org, Stefan Monnier <monnier <at> iro.umontreal.ca>,
 Drew Adams <drew.adams <at> oracle.com>,
 Thierry Volpiatto <thierry.volpiatto <at> gmail.com>
Subject: Re: bug#44822: 27.1; Regression in `ffap-read-file-or-url'
Date: Sat, 31 Jul 2021 14:48:15 +0200
Eli Zaretskii <eliz <at> gnu.org> writes:

> Thierry and Stefan, these changes seem to have been done by you.  Can
> you please take a look at this issue? 

I don't understand the changes either.

With (ffap-read-file-or-url "Url: " nil) it's now currently impossible
to enter an URL after this change:

commit 8685db187b891bcadcf61e41dea3124e4c45b7d4
Author:     Stefan Monnier <monnier <at> iro.umontreal.ca>
AuthorDate: Sat Nov 9 13:32:20 2019 -0500

    * lisp/ffap.el (ffap-read-file-or-url): Don't use url-file-handler

Stefan?

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#44822; Package emacs. (Sat, 31 Jul 2021 16:48:02 GMT) Full text and rfc822 format available.

Message #20 received at 44822 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 44822 <at> debbugs.gnu.org,
 Drew Adams <drew.adams <at> oracle.com>,
 Thierry Volpiatto <thierry.volpiatto <at> gmail.com>
Subject: Re: bug#44822: 27.1; Regression in `ffap-read-file-or-url'
Date: Sat, 31 Jul 2021 12:47:36 -0400
Lars Ingebrigtsen [2021-07-31 14:48:15] wrote:
> Eli Zaretskii <eliz <at> gnu.org> writes:
>> Thierry and Stefan, these changes seem to have been done by you.  Can
>> you please take a look at this issue? 
> I don't understand the changes either.
> With (ffap-read-file-or-url "Url: " nil) it's now currently impossible
> to enter an URL after this change:
>
> commit 8685db187b891bcadcf61e41dea3124e4c45b7d4
> Author:     Stefan Monnier <monnier <at> iro.umontreal.ca>
> AuthorDate: Sat Nov 9 13:32:20 2019 -0500
>
>     * lisp/ffap.el (ffap-read-file-or-url): Don't use url-file-handler
>
> Stefan?

Hmm... the motivation for the change is described in the comment:

      ;; FIXME: We earlier tried to make use of `url-file-handler' so
      ;; `read-file-name' could also be used for URLs, but it
      ;; introduced all kinds of subtle breakage such as:
      ;; - (file-name-directory "http://a") returning "http://a/"
      ;; - Trying to contact remote hosts with no justification
      ;; These should be fixed in url-handler-mode before we can try
      ;; using it here again.

Maybe the cure is worse than the disease,


        Stefan





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#44822; Package emacs. (Sat, 31 Jul 2021 16:59:02 GMT) Full text and rfc822 format available.

Message #23 received at 44822 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 44822 <at> debbugs.gnu.org,
 Drew Adams <drew.adams <at> oracle.com>,
 Thierry Volpiatto <thierry.volpiatto <at> gmail.com>
Subject: Re: bug#44822: 27.1; Regression in `ffap-read-file-or-url'
Date: Sat, 31 Jul 2021 18:58:12 +0200
Stefan Monnier <monnier <at> iro.umontreal.ca> writes:

> Hmm... the motivation for the change is described in the comment:
>
>       ;; FIXME: We earlier tried to make use of `url-file-handler' so
>       ;; `read-file-name' could also be used for URLs, but it
>       ;; introduced all kinds of subtle breakage such as:
>       ;; - (file-name-directory "http://a") returning "http://a/"
>       ;; - Trying to contact remote hosts with no justification
>       ;; These should be fixed in url-handler-mode before we can try
>       ;; using it here again.

Duh; my eyes just skipped that bit.  :-/

> Maybe the cure is worse than the disease,

I had forgotten all the peculiarities that url-file-handler has -- it's
simply not a usable solution.

Perhaps somebody can come up with a much, much simpler solution for use
in `read-file-name' only -- that shouldn't be insurmountable, I think...

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#44822; Package emacs. (Sat, 31 Jul 2021 17:52:02 GMT) Full text and rfc822 format available.

Message #26 received at 44822 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 44822 <at> debbugs.gnu.org,
 Drew Adams <drew.adams <at> oracle.com>,
 Thierry Volpiatto <thierry.volpiatto <at> gmail.com>
Subject: Re: bug#44822: 27.1; Regression in `ffap-read-file-or-url'
Date: Sat, 31 Jul 2021 19:51:42 +0200
Lars Ingebrigtsen <larsi <at> gnus.org> writes:

> Perhaps somebody can come up with a much, much simpler solution for use
> in `read-file-name' only -- that shouldn't be insurmountable, I think...

Sometimes that somebody is me, so this is now fixed in Emacs 28.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




bug marked as fixed in version 28.1, send any further explanations to 44822 <at> debbugs.gnu.org and Drew Adams <drew.adams <at> oracle.com> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Sat, 31 Jul 2021 17:53:01 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#44822; Package emacs. (Sat, 31 Jul 2021 17:56:01 GMT) Full text and rfc822 format available.

Message #31 received at 44822 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: Thierry Volpiatto <thievol <at> posteo.net>, Eli Zaretskii <eliz <at> gnu.org>,
 44822 <at> debbugs.gnu.org, Drew Adams <drew.adams <at> oracle.com>
Subject: Re: bug#44822: 27.1; Regression in `ffap-read-file-or-url'
Date: Sat, 31 Jul 2021 13:54:59 -0400
Lars Ingebrigtsen [2021-07-31 18:58:12] wrote:

> Stefan Monnier <monnier <at> iro.umontreal.ca> writes:
>
>> Hmm... the motivation for the change is described in the comment:
>>
>>       ;; FIXME: We earlier tried to make use of `url-file-handler' so
>>       ;; `read-file-name' could also be used for URLs, but it
>>       ;; introduced all kinds of subtle breakage such as:
>>       ;; - (file-name-directory "http://a") returning "http://a/"
>>       ;; - Trying to contact remote hosts with no justification
>>       ;; These should be fixed in url-handler-mode before we can try
>>       ;; using it here again.
>
> Duh; my eyes just skipped that bit.  :-/
>
>> Maybe the cure is worse than the disease,
>
> I had forgotten all the peculiarities that url-file-handler has -- it's
> simply not a usable solution.
>
> Perhaps somebody can come up with a much, much simpler solution for use
> in `read-file-name' only -- that shouldn't be insurmountable, I think...

Do you think that someone's last name could end in "olpiatto", maybe?


        Stefan





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#44822; Package emacs. (Mon, 09 Aug 2021 06:31:02 GMT) Full text and rfc822 format available.

Message #34 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Madhu <enometh <at> meer.net>
To: bug-gnu-emacs <at> gnu.org
Subject: Re: bug#44822: 27.1; Regression in `ffap-read-file-or-url'
Date: Mon, 09 Aug 2021 11:51:45 +0530
I couldn't follow the bug report as it always seemed to work for me[1],
but after the fix, if I do an M-x find-file-at-point with the point on
(say) https://debbugs.gnu.org/cgi/bugreport.cgi?bug=44822

I get a minibuffer prompt "Find file or URL" with the default set to the
url and the point at the beginning of the url string

wheras earlier I used to get the same prompt with the point positioned
at the end of the url string.

This makes a difference if i'm using some other system like vertico


1. My defaults for ffap were
(setq ffap-foo-at-bar-prefix nil)
(setq ffap-machine-p-known 'reject)
(setq ffap-machine-p-local 'reject)
(setq ffap-machine-p-unknown 'reject)





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#44822; Package emacs. (Mon, 09 Aug 2021 14:04:01 GMT) Full text and rfc822 format available.

Message #37 received at 44822 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Madhu <enometh <at> meer.net>
Cc: 44822 <at> debbugs.gnu.org
Subject: Re: bug#44822: 27.1; Regression in `ffap-read-file-or-url'
Date: Mon, 09 Aug 2021 16:03:26 +0200
Madhu <enometh <at> meer.net> writes:

> I couldn't follow the bug report as it always seemed to work for me[1],
> but after the fix, if I do an M-x find-file-at-point with the point on
> (say) https://debbugs.gnu.org/cgi/bugreport.cgi?bug=44822
>
> I get a minibuffer prompt "Find file or URL" with the default set to the
> url and the point at the beginning of the url string

This should now be fixed.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Tue, 07 Sep 2021 11:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 2 years and 226 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.