🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.emacs.bug
Article #99799

A small bug in indent-new-comment-line

#99799
From: Ulf Cahn von Seelen
Date: Fri, 04 May 1990 19:40
65 lines
2244 bytes
(Version 18.52.5 on Berkeley Unix)

As you know, indent-new-comment-line is used to break a comment line
at point, close the comment, and open a new comment line.  Now in
the case that no comment end is inserted into the new comment line
(e.g. if there is trailing text on the broken line after point),
the command works fine.  However, it misbehaves in the other case.
Let's assume the following buffer situation (in C-mode):

++++++++++++++++++++++++++++++++++++++
/* current comment line

foo
++++++++++++++++++++++++++++++++++++++

Now we want to close the current comment line and begin a new one.
After executing indent-new-comment-line, we end up with:

++++++++++++++++++++++++++++++++++++++
/* current comment line */
/* */


foo
++++++++++++++++++++++++++++++++++++++

instead of:

++++++++++++++++++++++++++++++++++++++
/* current comment line */
/*  */

foo
++++++++++++++++++++++++++++++++++++++

So the command has deleted a space in the new comment line and
at the same time not deleted an (originally temporary) new line
underneath it.

Here is the fix in the file simple.el:

(defun indent-new-comment-line ()
  (interactive ...)
  (let (...)
    (...)
    (if comcol
	(let (...)
	  (...)
  	  (if (not (eolp))
	      (setq comment-end ""))
	  (insert ?\n)
	  (forward-char -1)
	  (indent-for-comment)
	  (save-excursion		; <= keep point
	    (end-of-line)		; <= skip over inserted comment end
	    (delete-char 1)))
      (if fill-prefix
	  (insert fill-prefix)
	(indent-according-to-mode)))))




-Ulf
Technical Details
Message-ID: <24543@netnews.upenn.edu>
Path: arc1-ca.pugleaf.net!gmdzi!unido!mcsun!uunet!shelby!rutgers!netnews.upenn.edu!grasp.cis.upenn.edu!cahn

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: fb2f1,74fd2ec61654bb47,start
X-Google-Attributes: gidfb2f1,public
X-Google-ArrivalTime: 1990-05-04 15:58:15 PST
Path: arc1-ca.pugleaf.net!gmdzi!unido!mcsun!uunet!shelby!rutgers!netnews.upenn.edu!grasp.cis.upenn.edu!cahn
From: cahn@grasp.cis.upenn.edu (Ulf Cahn von Seelen)
Newsgroups: gnu.emacs.bug
Subject: A small bug in indent-new-comment-line
Message-ID: <24543@netnews.upenn.edu>
Date: 4 May 90 19:40:18 GMT
Sender: news@netnews.upenn.edu
Reply-To: cahn@grasp.cis.upenn.edu (Ulf Cahn von Seelen)
Distribution: gnu
Organization: University of Pennsylvania
Lines: 65
Posted: Fri May  4 20:40:18 1990