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

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

Cycle Auto-Fill


From: Christopher Dimech
Subject: Cycle Auto-Fill
Date: Sat, 5 Dec 2020 14:25:06 +0100

Have written the following function to use one key binding
to cycle auto-fill (only-comments, whole-buffer, disable)

Who would like to criticise this little bugger?

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



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