From: Nikolay Kudryavtsev <nikolay.kudryavtsev@gmail.com>
To: Spencer Baugh <sbaugh@janestreet.com>, help-gnu-emacs@gnu.org
Subject: Re: Continuing existing comment, with proper identation
Date: Sun, 22 Oct 2023 13:38:22 +0300 [thread overview]
Message-ID: <32745012-2072-4bab-8c17-5d3ee68521a4@gmail.com> (raw)
In-Reply-To: <ier8r7vfxkf.fsf@janestreet.com>
Honestly, your best bet is probably implementing literally all of the
logic yourself, maybe reusing some code from whatever mode you're
willing to support.
In a perfect world Emacs would understand comments as proper syntax tree
expressions and have some kind of high level API to deal with those. But
it does not and there isn't one.
Also, extending comments is not your only problem. Indentation is a
factor too. Again, there's no unified API. Some major modes use homebrew
indentation logic, few use SMIE, now there's tree-sitter too.
For example elisp-mode won't indent comments:
;; The next line should indent up to here(according to the OP
rules)
;; But it won't!
Then there's also the elephant in the room - comments can be code too.
Lets say you want to comment out a very basic C-like if:
/* if(){
* whatever
*/
How would your code know that offset is warranted here? You'd have to
run the major mode's normal indentation logic to see it, right? That's
why code that comments out stuff generally tries to avoid messing with
indentation.
prev parent reply other threads:[~2023-10-22 10:38 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-21 21:57 Continuing existing comment, with proper identation Spencer Baugh
2023-10-22 10:38 ` Nikolay Kudryavtsev [this message]
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/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=32745012-2072-4bab-8c17-5d3ee68521a4@gmail.com \
--to=nikolay.kudryavtsev@gmail.com \
--cc=help-gnu-emacs@gnu.org \
--cc=sbaugh@janestreet.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).