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

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

Re: Cycle Auto-Fill


From: Pankaj Jangid
Subject: Re: Cycle Auto-Fill
Date: Sat, 05 Dec 2020 19:29:51 +0530
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (darwin)

Christopher Dimech <dimech@gmx.com> writes:

> (defun gungadin-auto-fill-cycle ()
>    "Cycles Auto Fill.  Automatically breaks lines that get beyond
> variable fill-column."
>    (interactive)

-    (unless (get 'gungadin-auto-fill-cycle 'state)
-       (put 'gungadin-auto-fill-cycle 'state 1))

>
>    (setq n (get 'gungadin-auto-fill-cycle 'state))
>

-    (when (= n 1)
+    (when (or (not n) (= n 1))

>       (message "Auto Fill Comments Only")
>       (set (make-local-variable 'comment-auto-fill-only-comments) t)
>       (auto-fill-mode 1)
>       (put 'gungadin-auto-fill-cycle 'state 2))
>    (when (= n 2)
>       (message "Auto Fill Buffer")
>       (set (make-local-variable 'comment-auto-fill-only-comments) nil)
>       (put 'gungadin-auto-fill-cycle 'state 3))
>    (when (= n 3)
>       (message "Disable Auto Fill")
>       (auto-fill-mode 0)
>       (put 'gungadin-auto-fill-cycle 'state 1)) )
>
> (global-set-key (kbd "H-a") #'gungadin-auto-fill-cycle)

Will this work?

Removed one (get) call and a conditional test. Added one conditional
test.



reply via email to

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