I just upgraded to emacs 23.2.1 when I finally upgraded to ubuntu 10.10, but the first thing I noticed is that c-fill-paragraph (M-q) doesnt work nicely with comments anymore or at least do not work the way they did in emacs 23.1.? that I had before the upgrade.

The main issue is that if I have a commented line such as

//This is a long comment to illustrate an issue I have with emacs lorem ipsum

and then do fill-paragraph (M-q) afterwards, I get

//This is a long comment to illustrate an issue I have with
emacs lorem ipsum

whereas I should get

//This is a long comment to illustrate an issue I have with
//emacs lorem ipsum

I've killed my .emacs file to try and narrow down where the issue is popping up, but this still pops up even in vanilla emacs.

link|improve this question
I just tested in Gnu Emacs 23.2.1, and I am not seeing a problem. Are you sure in the right editing mode (i.e. c-mode, c++-mode)? – jwernerny Feb 25 '11 at 20:35
boo, I suspected as much. ok that's good to know. I thought it might be one of the modes I was using (cc-mode, nxhtml) but I guess I didnt get to as vanilla a state as I thought. – Silfheed Feb 25 '11 at 22:51
feedback

2 Answers

Do you have longlines-mode on by any chance? Auto-fill and longlines don't mix well (but I have a hack for it):

(defadvice fill-paragraph (around fill-paragraph-ignore-longlines act)
  "Ignore longlines-mode when calling fill-paragraph."
  (let ((restore-ll-mode nil))
    (when (boundp 'longlines-mode)
      (setq restore-ll-mode longlines-mode))
    (when restore-ll-mode
      (longlines-mode 0))
    ad-do-it
    (when restore-ll-mode
      (longlines-mode t))))

In order to get to plain-vanilla emacs, type emacs -q --no-site-init at the shell prompt.

link|improve this answer
I dont use longlines-mode, and even with emacs q --no-site-file (--no-site-init isnt recognized) it still doesnt comment correctly. – Silfheed Feb 28 '11 at 19:51
feedback
up vote 0 down vote accepted

Found the answer here with a patch that can be used if recompiling emacs from scratch. Turns out it's a bug in cc-mode that hopefully is fixed in the next version of emacs.

Another somewhat easier solution is to simply use fill-paragraph rather than c-fill-paragraph.

EDIT: and from the php mode emacs page, it appears you have to manually apply the patch since the line #'s don't line up with the current emacs source.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.