Re: [dev] snotes v0.9 - a simple notes system

From: markus schnalke <meillo_AT_marmaro.de>
Date: Tue, 05 Feb 2013 14:18:18 +0100

[2013-02-05 13:16] v4hn <me_AT_v4hn.de>
> On Tue, Feb 05, 2013 at 12:10:12PM +0100, markus schnalke wrote:
>> [2013-02-05 00:54] v4hn <me_AT_v4hn.de>
>>> I see. Thanks for note. I've changed it to the following now,
>>> which should work for all reasonable setups.
>>> If this doesn't work for someone, honestly, I couldn't care less.
>>> It's a default, not the final truth.
>>>
>>> SNOTES_EDITOR="${EDITOR:+xterm -e $EDITOR}"
>>> SNOTES_EDITOR="${SNOTES_EDITOR:-xterm -e vi}"
>>
>> Sorry, but you've missed the point. This setup does not solve
>> the issue at all.

Sorry for using too rough words -- I've misread `:+' for `:-'.

> Missing the point(VISUAL) was the idea. Quoting from Wikibooks[0]:
>
> Generally you will want to set it [VISUAL] to the same value as the EDITOR
> variable. Originally EDITOR would have be set to ed (a line-based editor)
> and VISUAL would've been set to vi (a screen-based editor). These days,
> you're unlikely to ever find yourself using a teletype as your terminal,
> so there is no need to choose different editors for the two.

I agree on the quoted statement but not on your conclusion. Not setting
different editors into the variables is different from evaluating only
one of the two variables. As it is hardly necessary to set the variables
differently, users might set only one of them (likely visual as they use
visual editors). This is safe if programs follow the common practice of
evaluating in the order VISUAL -> EDITOR -> vi.

> ok, so either I'll keep the above two lines or I'll move the logic
> to the initialization to retain a clean config file without sequential
> logic:
>
> SNOTES_EDITOR=${VISUAL:-${EDITOR:-vi}}
> SNOTES_EDITOR="xterm -e $SNOTES_EDITOR"
> cat > $HOME/.snotes/config <<EOF
> SNOTES_EDITOR="$SNOTES_EDITOR"
> [...]
>
> You may choose.

What kind of choice is that? I argue about sane solutions and you
want me to choose between two bad ones.

Let my suggest a solution: Put the first two lines of your second
option in place of your first option and thus use:

        SNOTES_EDITOR=${VISUAL:-${EDITOR:-vi}}
        SNOTES_EDITOR="xterm -e $SNOTES_EDITOR"

Or even shorter:

        SNOTES_EDITOR="xterm -e ${VISUAL:-${EDITOR:-vi}}"

Or if you like to be able to override the xterm spawning, use:

        SNOTES_EDITOR="${SNOTES_EDITOR:-xterm -e ${VISUAL:-${EDITOR:-vi}}}"

The first two of my suggestions are very much ideoms, whereas
both of your suggestions would produce unexpected behavior for
me.


meillo
Received on Tue Feb 05 2013 - 14:18:18 CET

This archive was generated by hypermail 2.3.0 : Tue Feb 05 2013 - 14:24:04 CET