[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Better way to make sure external command exists in the system?
From: |
Emanuel Berg |
Subject: |
Re: Better way to make sure external command exists in the system? |
Date: |
Thu, 25 Mar 2021 21:47:15 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) |
Jean Louis wrote:
>>> Now it is:
>>>
>>> (defvar image-default-resize-size "1536")
>>> (defvar image-resize-sizes '("1536" "1024" "800" "1200" "640"))
>>
>> Well, the width of a computer image is not a string but
>> an integer.
>
> Maybe yes, maybe not, but it does not matter neither for
> human or computer. Human sees the number at completion.
...
>>> Maybe it works with numbers, but now I changed it to
>>> completing-read, maybe that is why I placed it as strings.
>>
>> Don't do that, data should be in its natural, sound state,
>> then it is up to functions and/or users who use it to
>> convert it to fit their purposes. And the better everything
>> is, the less of that is required.
>
> In general yes, but in this specific case, who cares
... >:[
> This does not work:
>
> (completing-read "Number: " '(1 2 3))
>
> This works:
>
> (completing-read "Number: " '("1" "2" "3"))
>
> Now you get it
... >:[
> why they are strings in the completion list? They are not
> strings for the underlying function `image-resize' but only
> for the completion candidates.
Use a set function
(cl-map 'list #'number-to-string '(1 2 3)) ; ("1" "2" "3")
>> Yes, compare:
>>
>> (interactive
>> `(,(string-to-number
>> (completing-read "Digit: " '("11" "12" "13") nil t "11"))))
>
> That would mean if I change candidates list I would actually
> need to change the function. Not practical.
... just unheard of
>>>> And, no need for globals if they are only used here.
>>>> Use let* for that as well.
>>>
>>> Which globals?
>>
>> The two global variables.
>
> I would not know which...
I give up.
--
underground experts united
https://dataswamp.org/~incal
- Re: Better way to make sure external command exists in the system?, (continued)
- Re: Better way to make sure external command exists in the system?, Jean Louis, 2021/03/21
- Re: Better way to make sure external command exists in the system?, Emanuel Berg, 2021/03/21
- Re: Better way to make sure external command exists in the system?, Jean Louis, 2021/03/23
- Re: Better way to make sure external command exists in the system?, Emanuel Berg, 2021/03/23
- Re: Better way to make sure external command exists in the system?, Jean Louis, 2021/03/23
- Re: Better way to make sure external command exists in the system?, Emanuel Berg, 2021/03/25
- Re: Better way to make sure external command exists in the system?, Jean Louis, 2021/03/25
- Re: Better way to make sure external command exists in the system?,
Emanuel Berg <=
- Re: Better way to make sure external command exists in the system?, Jean Louis, 2021/03/25
- Re: Better way to make sure external command exists in the system?, Emanuel Berg, 2021/03/25