[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Cycle Auto-Fill
From: |
Ergus |
Subject: |
Re: Cycle Auto-Fill |
Date: |
Sat, 5 Dec 2020 15:39:16 +0100 |
Hi Christopher:
I am not a big lisper, but I had a similar code. I modified yours to
look similar in case you find anything interesting on it
```
(defvar gungadin-auto-fill-cycle 0)
(defun gungadin-auto-fill-cycle ()
"Cycles Auto Fill.
Automatically breaks lines that get beyond variable fill-column."
(interactive)
(pcase gungadin-auto-fill-cycle
(0
(message "Auto Fill Comments Only")
(setq-local comment-auto-fill-only-comments t)
(auto-fill-mode 1))
(1
(message "Auto Fill Buffer")
(setq-local comment-auto-fill-only-comments nil))
(2
(message "Disable Auto Fill")
(auto-fill-mode 0)))
(setq gungadin-auto-fill-cycle (% (1+ gungadin-auto-fill-cycle) 3)))
```
On Sat, Dec 05, 2020 at 02:25:06PM +0100, Christopher Dimech wrote:
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
- Cycle Auto-Fill, Christopher Dimech, 2020/12/05
- Re: Cycle Auto-Fill, Pankaj Jangid, 2020/12/05
- Re: Cycle Auto-Fill,
Ergus <=
- Re: Cycle Auto-Fill, Michael Heerdegen, 2020/12/05
- RE: Cycle Auto-Fill, Drew Adams, 2020/12/05
- Re: Cycle Auto-Fill, Christopher Dimech, 2020/12/05
- Re: Cycle Auto-Fill, Michael Heerdegen, 2020/12/05
- Message not available
- Message not available
- Re: Cycle Auto-Fill, Christopher Dimech, 2020/12/05
- Re: Cycle Auto-Fill, Michael Heerdegen, 2020/12/05
- Re: Cycle Auto-Fill, Christopher Dimech, 2020/12/05
- Re: Cycle Auto-Fill, Robert Thorpe, 2020/12/06
- Re: Cycle Auto-Fill, Michael Heerdegen, 2020/12/06
- Re: Cycle Auto-Fill, Christopher Dimech, 2020/12/06