unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Continuing existing comment, with proper identation
@ 2023-10-21 21:57 Spencer Baugh
  2023-10-22 10:38 ` Nikolay Kudryavtsev
  0 siblings, 1 reply; 2+ messages in thread
From: Spencer Baugh @ 2023-10-21 21:57 UTC (permalink / raw)
  To: help-gnu-emacs


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?




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-10-22 10:38 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-21 21:57 Continuing existing comment, with proper identation Spencer Baugh
2023-10-22 10:38 ` Nikolay Kudryavtsev

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).