🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.emacs.bug
Article #99789

c-comment-indent misbehaves at the beginning of a line

#99789
From: Ulf Cahn von Seelen
Date: Tue, 01 May 1990 18:17
31 lines
1949 bytes
(in the emacs version 18.52.12 on berkeley-unix).

It inserts a space before the comment start string when comment-column
is 0.  I think c-comment-indent is only called from indent-for-comment,
but anyway, if you use indent-new-comment-line (M-j) in a comment that 
starts at the beginning of a line, the new comment line is indented one
space.  This space can easily be removed by <tab>, of course, but the 
real fix goes like this:

;;; old code (in c-mode.el)
(defun c-comment-indent ()
  (if (looking-at "^/\\*")
      0				;Existing comment at bol stays there.
    (save-excursion
      (skip-chars-backward " \t")
      (max (1+ (current-column))	;Else indent at comment column
	   comment-column))))	; except leave at least one space.

;;; fixed code
(defun c-comment-indent ()
  (if (looking-at "^/\\*")
      0					; Existing comment at bol stays there.
    (save-excursion
      (skip-chars-backward " \t")
      (if (bolp)			; <= fixed here:
	  comment-column		; no extra space at beginning of line
	(max (1+ (current-column))	; Else indent at comment column
	     comment-column)))))	; except leave at least one space.


Sorry if you all knew that already.
Technical Details
Message-ID: <24359@netnews.upenn.edu>
Path: arc1-ca.pugleaf.net!gmdzi!unido!fauern!ira.uka.de!sol.ctr.columbia.edu!emory!samsung!zaphod.mps.ohio-state.edu!unix.cis.pitt.edu!dsinc!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,d52a19fcd379b00d,start
X-Google-Attributes: gidfb2f1,public
X-Google-ArrivalTime: 1990-05-01 11:17:06 PST
Path: arc1-ca.pugleaf.net!gmdzi!unido!fauern!ira.uka.de!sol.ctr.columbia.edu!emory!samsung!zaphod.mps.ohio-state.edu!unix.cis.pitt.edu!dsinc!netnews.upenn.edu!grasp.cis.upenn.edu!cahn
From: cahn@grasp.cis.upenn.edu (Ulf Cahn von Seelen)
Newsgroups: gnu.emacs.bug
Subject: c-comment-indent misbehaves at the beginning of a line
Message-ID: <24359@netnews.upenn.edu>
Date: 1 May 90 18:17:06 GMT
Sender: news@netnews.upenn.edu
Reply-To: cahn@grasp.cis.upenn.edu (Ulf Cahn von Seelen)
Distribution: gnu
Organization: University of Pennsylvania
Lines: 31
Posted: Tue May  1 19:17:06 1990