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

Re: `w3m-input-url' bug



On 2010-09-08 04:32 +0100, Katsumi Yamaoka wrote:
> In [emacs-w3m : No.11340] Leo wrote:
>> On 2010-09-07 13:05 +0100, Katsumi Yamaoka wrote:
>>>> If a user calls w3m-input-url with INITIAL nil and DEFAULT non-nil, his
>>>> intention is pretty clear but w3m-input-url overrides it anyway. I think
>>>> this is a bug.
>>>
>>>> GNU Emacs actually prefers DEFAULT and considers INITIAL deprecated; see
>>>> doc string of completing-read (23.x).
>>>
>>> So what evil does it cause in emacs-w3m?
>
>> I wouldn't call it evil but it makes it difficult to customise the
>> behaviour. For example, when I call w3m-goto-url I often don't want to
>> edit the url suggested. I just want to go to a new one. So I would
>> prefer w3m-input-url sets a default url and leaves the initial input
>> empty. I can use a before advice to do that but then the prompt would
>> not show the default url.
>
> Well, I'm not quite sure if I got what you want.  I see no difference
> between 1 and 2 and between 3 and 4:

1 and 3 are different when point is at a url.

> 1. (w3m-input-url nil nil "DEF")
> 2. (completing-read "What? " nil nil nil nil nil "DEF")
>
> 3. (w3m-input-url nil "INIT" "DEF")
> 4. (completing-read "What? " nil nil nil "INIT" nil "DEF")
>
> But is what you want something like the following?
>
> --- w3m.el~	2010-09-06 03:39:33 +0000
> +++ w3m.el	2010-09-08 03:29:33 +0000
> @@ -4589,7 +4589,7 @@
>  					 "HOME"
>  				       default)
>  				     "): "))
> -			 (if (or initial (not default))
> +			 (if (not default)
>  			     (if feeling-lucky "URL or Keyword: " "URL: ")
>  			   (format "URL %s(default %s): "
>  				   (if feeling-lucky "or Keyword " "")
>
> If so, I agree with applying it to emacs-w3m.

I need a way to stop w3m-input-url from being too smart. So I wonder
whether extending it like this can be better:

If pass an empty string "" (or maybe a symbol noguess) as the INITIAL
arg, that means no initial input. nil means try guessing a value. Same
logic for DEFAULT arg.

The prompt part should always show DEFAULT if it is set (might need
shortening in case of long URLs).

What do you think?

Leo