Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|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
up vote 1 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.

share|improve this answer

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))
    (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.

share|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

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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