help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Auto Fill Comments


From: Christopher Dimech
Subject: Re: Auto Fill Comments
Date: Wed, 25 Nov 2020 08:59:07 +0100

M-q was what I have been doing.  Want to try out auto fill, see if it can save 
me
using the key binding.  I usually keep code quite compact, but will check out
what you discussed.


> Sent: Wednesday, November 25, 2020 at 8:11 AM
> From: "Robert Thorpe" <rt@robertthorpeconsulting.com>
> To: "Christopher Dimech" <dimech@gmx.com>
> Cc: help-gnu-emacs@gnu.org
> Subject: Re: Auto Fill Comments
>
> Christopher Dimech <dimech@gmx.com> writes:
>
> > Would this be good enough  to Auto Fill Comments in c language.
> > What can I use for Auto Fill Comments for other languages, e.g.
> > fortran, elisp, c++, texinfo, bash, awk, org, R.
> >
> > ;; Apply Auto Fill to comments but not code in programming language modes.
> > (add-hook 'c-mode-common-hook
> >    (lambda ()
> >       (auto-fill-mode 1)
> >       (set
> >          (make-local-variable 'fill-nobreak-predicate)
> >          (lambda ()
> >             (not (eq (get-text-property (point) 'face)
> >                     'font-lock-comment-face)))) ))
>
> Notice that "M-q" performs paragraph filling for comments in C and other
> languages.  It is not *auto* filling certainly, but it's very useful.
>
> I've found that to be the best myself.  That's because of commenting out
> code.  The problem is if you comment out code then modify it when it's a
> comment.  If you set Emacs to auto-fill comments, then it will auto-fill
> those code comments as though they're text.  That's wrong when you want
> to uncomment the block and make it back into code, it removes the
> indentation.
>
> BR,
> Robert Thorpe
>
>
>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]