emacs-devel
[Top][All Lists]
Advanced

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

Re: giving `setq-local' the same signature as `setq'


From: Oleh Krehel
Subject: Re: giving `setq-local' the same signature as `setq'
Date: Thu, 19 Mar 2015 16:55:39 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4.91 (gnu/linux)

Drew Adams <address@hidden> writes:

>> I very much prefer the only-one-variable-per-setq style.
>
> You're in luck then.  You have the choice. ;-)

What I meant to say that I very much prefer the
only-one-variable-per-setq style when interacting with other people's
code. Obviously, I don't use this notation in my own code.

>
> You can do the same for `let*', if you like:
>
> (let ((foo  fooval))
>   (let ((phlop  phlopval))
>     (let ((toto  totoval))
>       ...)))
>

Now you've just lead yourself into a trap. This is similar to
one-var-per-setq:

(let* ((foo fooval)
       (phlop phlopval)
       (toto totoval))
  ...)

This is similar to multi-var-per-setq:

(let* (foo fooval
       phlop phlopval
       toto totoval)
  ...)

It already looks bad for single symbol statements. Imagine how bad it
would be if they were more complex.

>> It shows much more clearly where the variable is.
>
> Where the variable is?  How so?  (Where is it?  Where's Waldo?)

Obviously, the variable is by the big fat left paren.

>> It also gives an anchor to quickly navigate to the variable
>> to get its value.
>
> How so?  Please elaborate.

With C-M-n and C-M-p you can navigate to the big fat paren by which the
variable resides (after setq).

>> In a setq list of 10 items, by item 5 it is already unclear which is the
>> variable and which is the value.  In my opinion, it's not worth
>> complicating the code maintenance just to save a few chars.
>
> This is why it is good that you have the choice.

You're wrong here. I don't have the choice. Just yesterday I was debugging my
AUCTEX config. It wasn't pleasant to navigate 5-variable setq
statements, some of which took the whole page.

> I find it clearer to let `setq' do the grouping, instead of implicit or
> explicit `progn'.  But I put each var & value pair on a separate line:
>
> (setq foo    fooval
>       phlop  phlopval  ; Maybe this one needs a comment.
>       toto   totoval)
>
> I don't do this to save characters (e.g. for typing).  I do it to make
> the code clearer and maintenance less error prone and easier.  For me,
> at least.

Imagine that you want to comment out `phlop phlopval', which is a
multi-line statement. If it was bounded by parens, you could do it in an
easy and error-free way. Otherwise, you have to manually select the region.

Oleh



reply via email to

[Prev in Thread] Current Thread [Next in Thread]