[17972] in Athena Bugs

home help back first fref pref prev next nref lref last post

Re: emacs: cc-mode brace-elseif-brace cleanup broken

daemon@ATHENA.MIT.EDU (Tom Yu)
Sat Jul 8 22:40:44 2000

Date: Sat, 8 Jul 2000 22:40:40 -0400 (EDT)
Message-Id: <200007090240.WAA22173@saint-elmos-fire.mit.edu>
To: bugs@MIT.EDU
In-Reply-To: "[17971] in Athena Bugs"
From: Tom Yu <tlyu@MIT.EDU>

Ok so I made some errors in that patch.  This one should be correct.

---Tom

*** /usr/athena/share/emacs/20.3/lisp/progmodes/cc-cmds.el	Wed Dec 16 15:00:48 1998
--- cc-cmds.el	Sat Jul  8 22:37:14 2000
***************
*** 316,322 ****
  	  (if (and c-auto-newline
  		   (memq 'brace-else-brace c-cleanup-list)
  		   (eq last-command-char ?\{)
! 		   (re-search-backward "}[ \t\n]*else[ \t\n]*{" nil t)
  		   (progn
  		     (setq mbeg (match-beginning 0)
  			   mend (match-end 0))
--- 316,323 ----
  	  (if (and c-auto-newline
  		   (memq 'brace-else-brace c-cleanup-list)
  		   (eq last-command-char ?\{)
! 		   (save-excursion
! 		     (re-search-backward "}[ \t\n]*else[ \t\n]*{" nil t))
  		   (progn
  		     (setq mbeg (match-beginning 0)
  			   mend (match-end 0))
***************
*** 323,328 ****
--- 324,330 ----
  		     (= mend here))
  		   (not (c-in-literal)))
  	      (progn
+ 		(goto-char mbeg)
  		(delete-region mbeg mend)
  		(insert "} else {")))
  	  ;; clean up brace-elseif-brace
***************
*** 329,335 ****
  	  (if (and c-auto-newline
  		   (memq 'brace-elseif-brace c-cleanup-list)
  		   (eq last-command-char ?\{)
! 		   (re-search-backward "}[ \t\n]*else[ \t\n]+if[ \t\n]*" nil t)
  		   (save-excursion
  		     (goto-char (match-end 0))
  		     (c-safe (forward-sexp 1))
--- 331,339 ----
  	  (if (and c-auto-newline
  		   (memq 'brace-elseif-brace c-cleanup-list)
  		   (eq last-command-char ?\{)
! 		   (save-excursion (re-search-backward
! 				    "}[ \t\n]*else[ \t\n]+if[ \t\n]*"
! 				    nil t))
  		   (save-excursion
  		     (goto-char (match-end 0))
  		     (c-safe (forward-sexp 1))
***************
*** 339,344 ****
--- 343,349 ----
  		     (= here (1+ (point))))
  		   (not (c-in-literal)))
  	      (progn
+ 		(goto-char mbeg)
  		(delete-region mbeg mend)
  		(insert "} else if ")))
  	  (goto-char (- (point-max) pos))

home help back first fref pref prev next nref lref last post