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 01:56:45 +0100

The biggest problem is how to call autofill parameters as the three list
options change.

> Sent: Tuesday, November 24, 2020 at 9:53 PM
> From: "Christopher Dimech" <dimech@gmx.com>
> To: "Christopher Dimech" <dimech@gmx.com>
> Cc: "Help Gnu Emacs" <help-gnu-emacs@gnu.org>
> Subject: Re: Auto Fill Comments
>
> Have started doing something, but am quite stuck now.  Somehow I need to
> fill the list for the three options: (1) autofill comments; (2) autofill
> buffer; and (3) disable autofill.
>
> (setq autofill-list
>    '( ))
>
> (defun break-line-cycle (@n)
>    (interactive "p")
>    ;; Sets property 'state', an integer. Possible values are any index
>    ;; to autofill-list.
>    (let ($fill-selector $cnd-before $cnd-after)
>       (setq $cnd-before
>          (if (get 'break-line-cycle 'state)
>            (get 'break-line-cycle 'state)
>            0) )
>       (setq $cnd-after
>          (% (+ $cnd-before (length font-list) @n) (length autofill-list)))
>       (setq $fill-selector (nth $cnd-after autofill-list))
>       (put 'break-line-cycle 'state $cnd-after)))
>
> > Sent: Tuesday, November 24, 2020 at 8:52 PM
> > From: "Christopher Dimech" <dimech@gmx.com>
> > To: daniela-spit@gmx.it
> > Cc: "Help Gnu Emacs" <help-gnu-emacs@gnu.org>
> > Subject: Re: Auto Fill Comments
> >
> > Looks quite nice.  I could try to cycle through three states:
> > (1) auto fill comments; (2) auto fill buffer; and (3) disable
> > auto fill.
> >
> > Anybody done this before?
> >
> > Regards
> > Christopher
> >
> >
> >
> > > Sent: Tuesday, November 24, 2020 at 8:42 PM
> > > From: daniela-spit@gmx.it
> > > To: "Christopher Dimech" <dimech@gmx.com>
> > > Cc: "Help Gnu Emacs" <help-gnu-emacs@gnu.org>
> > > Subject: Re: Auto Fill Comments
> > >
> > > This is what I use.  I find no good reason to use c-mode-common-hook.
> > >
> > > (defun break-comment ()
> > >    (setq-local comment-auto-fill-only-comments t)
> > >    (auto-fill-mode 1))
> > >
> > > (add-hook 'sh-mode-hook          #'break-comment)
> > > (add-hook 'fortran-mode-hook     #'break-comment)
> > > (add-hook 'emacs-lisp-mode-hook  #'break-comment)
> > > (add-hook 'texinfo-mode-hook     #'break-comment)
> > >
> > > (add-hook 'c-mode-hook       #'break-comment)
> > > (add-hook 'c++-mode-hook     #'break-comment)
> > > (add-hook 'awk-mode-hook     #'break-comment)
> > > (add-hook 'R-mode-hook       #'break-comment)
> > > (add-hook 'octave-mode-hook  #'break-comment)
> > > (add-hook 'text-mode-hook    #'break-comment)
> > >
> > >
> > > > Sent: Tuesday, November 24, 2020 at 6:05 PM
> > > > From: "Christopher Dimech" <dimech@gmx.com>
> > > > To: "Help Gnu Emacs" <help-gnu-emacs@gnu.org>
> > > > Subject: Auto Fill Comments
> > > >
> > > > 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)))) ))
> > > >
> > > >
> > > >
> > >
> >
>
> ---------------------
> Christopher Dimech
> General Administrator - Naiad Informatics - GNU Project (Geocomputation)
> - Geophysical Simulation
> - Geological Subsurface Mapping
> - Disaster Preparedness and Mitigation
> - Natural Resource Exploration and Production
> - Free Software Advocacy
>



reply via email to

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