🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.emacs.bug
Article #99893

formatting functions

#99893
From: Hal Peterson
Date: Tue, 27 Mar 1990 22:54
89 lines
3676 bytes
				Problem one:

The GNU coding conventions call for function names to be in column zero,
flush with the left margin.  But if a function has a declared return type,
then Emacs 18.55 (and every other version I can remember using) treats the
function name as a continued statement and gives it a
c-continued-statement-offset bump to the right, so here's what happens:

==================================================
char *
  why_am_i_here ()
{
  /* . . . */
}
==================================================

It's possible to work around this by setting c-continued-statement-offset to
zero, but that messes up the formatting of continued statements in the body
of the function.

A solution is to treat continued statements at the top level (i.e., not
within a function) as a special case to which the
c-continued-statement-offset does not apply.


				Problem two:

The C indention code can be fooled into spuriously inserting c-argdecl-indent
by nested parentheses in a global declaration:

==================================================
const int x = A(B(C));
     static char *why_am_i_there;
==================================================


				  Solution:

The following patch to c-mode.el, produced with diff -c -b, fixes both of
these problems.

==================================================
*** c-mode.el.orig	Tue Mar 27 16:30:43 1990
--- c-mode.el	Tue Mar 27 16:31:08 1990
***************
*** 370,380 ****
  	       ;; Look at previous line that's at column 0
  	       ;; to determine whether we are in top-level decls
  	       ;; or function's arg decls.  Set basic-indent accordinglu.
- 	       (let ((basic-indent
  		      (save-excursion
  			(re-search-backward "^[^ \^L\t\n#]" nil 'move)
  			(if (and (looking-at "\\sw\\|\\s_")
! 				 (looking-at ".*(")
  				 (progn
  				   (goto-char (1- (match-end 0)))
  				   (forward-sexp 1)
--- 370,379 ----
  	       ;; Look at previous line that's at column 0
  	       ;; to determine whether we are in top-level decls
  	       ;; or function's arg decls.  Set basic-indent accordinglu.
  	       (save-excursion
  		 (re-search-backward "^[^ \^L\t\n#]" nil 'move)
  		 (if (and (looking-at "\\sw\\|\\s_")
! 			  (looking-at "[^(]*(")
  			  (progn
  			    (goto-char (1- (match-end 0)))
  			    (forward-sexp 1)
***************
*** 382,391 ****
  					(not (memq (following-char)
  						   '(?\, ?\;))))))
  			    c-argdecl-indent 0))))
- 		 ;; Now add a little if this is a continuation line.
- 		 (+ basic-indent (if (or (bobp)
- 					 (memq (preceding-char) '(?\) ?\; ?\})))
- 				     0 c-continued-statement-offset)))))
  	    ((/= (char-after containing-sexp) ?{)
  	     ;; line is expression, not statement:
  	     ;; indent to just after the surrounding open.
--- 381,386 ----
==================================================

--
Hal Peterson			Domain:  hrp@cray.com
Cray Research			Old style:  hrp%cray.com@uc.msc.umn.edu
1440 Northland Dr.		UUCP:  uunet!cray!hrp
Mendota Hts, MN  55120  USA	Telephone:  +1 612 681 3145
Technical Details
Message-ID: <9003272254.AA08885@rothko.cray.com>
Path: arc1-ca.pugleaf.net!gmdzi!unido!mcsun!uunet!tut.cis.ohio-state.edu!BORING.CRAY.COM!hrp

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: fb2f1,9154a65732367960,start
X-Google-Attributes: gidfb2f1,public
X-Google-ArrivalTime: 1990-03-27 14:54:00 PST
Path: arc1-ca.pugleaf.net!gmdzi!unido!mcsun!uunet!tut.cis.ohio-state.edu!BORING.CRAY.COM!hrp
From: hrp@BORING.CRAY.COM (Hal Peterson)
Newsgroups: gnu.emacs.bug
Subject: formatting functions
Message-ID: <9003272254.AA08885@rothko.cray.com>
Date: 27 Mar 90 22:54:00 GMT
Sender: daemon@tut.cis.ohio-state.edu
Distribution: gnu
Organization: GNUs Not Usenet
Lines: 89
Posted: Tue Mar 27 23:54:00 1990