From: Spencer Baugh <sbaugh@janestreet.com>
To: help-gnu-emacs@gnu.org
Subject: Continuing existing comment, with proper identation
Date: Sat, 21 Oct 2023 17:57:36 -0400 [thread overview]
Message-ID: <ier8r7vfxkf.fsf@janestreet.com> (raw)
I'm writing a function to manipulate an existing commnet. It should
insert a blank line, and then some data, at the end of a comment,
without creating a new comment. I want it to work in a
major-mode-independent way, but I'm having a bit of trouble figuring out
what functions to call to get the same behavior across major-mode.
In Lisp, I'd like:
;; ...existing comment...
;; ...existing comment...
to be turned into
;; ...existing comment...
;; ...existing comment...
;;
;; new data
and in C:
/* ...existing comment...
...existing comment... */
to be turned into
/* ...existing comment...
...existing comment...
new data */
(Keeping the same indentation level as the previous lines, of course, if
it's already in an indented block.)
The obvious thing to do is to put point at the end of the comment and
comment-indent-new-line twice.
But this behaves differently in Lisp and C - it's a one character
difference, but that's enough to break my major-mode-independence.
In C, I get
/* ...existing comment...
...existing comment...
<point> */
so I can just go ahead and (insert "new data")
In Lisp though, I get:
;; ...existing comment...
;; ...existing comment...
;;
;;<point>
Note the lack of a space before <point>. So if I (insert "new data"), I get
;; ...existing comment...
;; ...existing comment...
;;
;;new data
which is not what I want. I want a space before ";;" and "new data", as
is normal in Lisp.
What should I do to get the behavior that I see in C, in Lisp
major-modes?
next reply other threads:[~2023-10-21 21:57 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-21 21:57 Spencer Baugh [this message]
2023-10-22 10:38 ` Continuing existing comment, with proper identation Nikolay Kudryavtsev
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=ier8r7vfxkf.fsf@janestreet.com \
--to=sbaugh@janestreet.com \
--cc=help-gnu-emacs@gnu.org \
/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).