unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
From: Zelphir Kaltstahl <zelphirkaltstahl@posteo.de>
To: Taylan Kammer <taylan.kammer@gmail.com>
Cc: guile-user <guile-user@gnu.org>
Subject: Re: Indentation with inline comments in Emacs
Date: Sun, 17 Apr 2022 11:06:51 +0000	[thread overview]
Message-ID: <15968029-3c0c-9ced-ea8f-3bbc8446d96d@posteo.de> (raw)
In-Reply-To: <5c6cec2d-4898-27d5-574b-2fcd75e53a64@gmail.com>

Hello Taylan!

On 4/17/22 05:03, Taylan Kammer wrote:
> On 16.04.2022 14:12, Zelphir Kaltstahl wrote:
>> Hello Guile users!
>>
>> The subject might not be only Guile related, but I figure, that many on this mailing list are using Emacs for writing Guile code. I wonder, if anyone has some trick for fixing the following indentation issue:
>>
>> Sometimes I want to put inline comments with #||# in things like lists, arguments for function calls or vectors. For example I want to write the name of the month next to the number of days of that month, in a vector creation. Here is the example:
>>
>> ~~~~
>> (define DAYS-IN-MONTH
>>    #(#|January|# 31
>>                  #|February|# 28
>>                               #|March|# 31 #|April|# 30 #|May|# 31 #|June|# 30 #|July|# 31 #|August|# 30
>>                                30 30))
>> ~~~~
>>
>> As you can see, the indentation is adjusted each line according to the non-comment thing on the previous line, when I press TAB or whatever other key binding one has for indentation. However, in this case I would rather want it to adjust indentation. Is there a quick fix for this? Or some way to make Emacs understand this as a separate case and have it indent "correctly"? Does anyone have a solution?
>>
>> Regards,
>> Zelphir
>>
> To be honest, the easiest thing to do here is probably use a different comment style.
>
> In this particular example I would probably just go full vertical:
>
>    (define DAYS-IN-MONTH
>      #(31 ;january
>        28 ;february
>        31 ;march
>        30 ;april
>        31 ;may
>        ;; ...
>      )
>
> I know it doesn't fulfill your requirement, but usually I find it wise to use the
> "path of least resistance" when it comes to how an editor/IDE wants to format code
> and just go with the rules it has.  Makes life easier for others who might not have
> whatever custom configuration you add to your editor to bend it to your will.
Good point! For some reason I always shun the single semi-colon comments. I 
think that is, because I usually start writing such a comment and then notice, 
that the comment will make the line very long, so I want to break it. However, 
to break it, it makes more sense to have the comment above the line and use 
double semi-colon. In this case however, the single semi-colon does actually 
seem like a good alternative.
> Tangential:
>
> I've also tried out a "columns" variant with multiple numbers per row and a comment
> above each row identifying the numbers, but Emacs seems to insist on special-casing
> the first column in that case, regardless of comments, like this:
>
>    (define days
>      #(31      28       31
>                30       31          30
>                xx       yy          zz
>                ;; ...
>                ))
>
> That's already ugly without comments, and IMO a significant issue.
>
> Maybe it would be good to teach Emacs to indent lists/vectors that don't represent
> a function/macro call.  This indentation clearly assumes that the leading "31" in
> the vector is the operator, and the rest of the vector operands.
>
> It should probably not assume that for vectors #(...) and quoted lists '(...).

I never understood, why Emacs indented that way, but now I understand. First 
argument is seen as special, as the function/procedure that is being called – 
aha! I do not know, whether the syntax for vector creation #(...) is the same in 
all Scheme dialects, which have vectors, in general. Perhaps it would require a 
specific GNU Guile mode for Emacs, if it is not the same in all Scheme dialects.

Best regards,
Zelphir

-- 
repositories: https://notabug.org/ZelphirKaltstahl




  reply	other threads:[~2022-04-17 11:06 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-16 12:12 Indentation with inline comments in Emacs Zelphir Kaltstahl
2022-04-16 14:57 ` Jérémy Korwin-Zmijowski
2022-04-17 10:49   ` Zelphir Kaltstahl
2022-04-17 13:44     ` Luis Felipe
2022-04-18 10:48       ` Zelphir Kaltstahl
2022-04-18 13:33         ` Ricardo G. Herdt
2022-04-18 14:09           ` Luis Felipe
2022-04-18 14:05         ` Luis Felipe
2022-04-17  3:03 ` Taylan Kammer
2022-04-17 11:06   ` Zelphir Kaltstahl [this message]
2022-04-17 14:58     ` Maxime Devos
2022-04-18 10:49       ` Zelphir Kaltstahl

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=15968029-3c0c-9ced-ea8f-3bbc8446d96d@posteo.de \
    --to=zelphirkaltstahl@posteo.de \
    --cc=guile-user@gnu.org \
    --cc=taylan.kammer@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).