unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Ergus <spacibba@aol.com>
To: Christopher Dimech <dimech@gmx.com>
Cc: Help Gnu Emacs <help-gnu-emacs@gnu.org>
Subject: Re: Cycle Auto-Fill
Date: Sat, 5 Dec 2020 15:39:16 +0100	[thread overview]
Message-ID: <20201205143916.wqnijdtng3vwxeiu@Ergus> (raw)
In-Reply-To: <trinity-47f01091-8552-4fcf-a618-67e3203f5781-1607174706434@3c-app-mailcom-bs04>

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



  parent reply	other threads:[~2020-12-05 14:39 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-05 13:25 Cycle Auto-Fill Christopher Dimech
2020-12-05 13:59 ` Pankaj Jangid
2020-12-05 14:16   ` Christopher Dimech
2020-12-05 16:57     ` Pankaj Jangid
2020-12-05 14:39 ` Ergus [this message]
2020-12-05 22:00 ` Michael Heerdegen
2020-12-05 22:06   ` Drew Adams
2020-12-05 22:38   ` Christopher Dimech
2020-12-05 23:53     ` Michael Heerdegen
     [not found]       ` <trinity-3598b15c-19a1-41d1-92ed-96e7f10f1fd9-1607213433613@3c-app-mailcom-bs06>
     [not found]         ` <87v9dfhj2e.fsf@web.de>
2020-12-06  0:49           ` Christopher Dimech
2020-12-06  2:33             ` Michael Heerdegen
2020-12-06  3:35               ` Christopher Dimech
2020-12-06  5:23                 ` Robert Thorpe
2020-12-06 23:01                 ` Michael Heerdegen
2020-12-06 23:43                   ` Christopher Dimech
2020-12-07  0:36                     ` Michael Heerdegen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201205143916.wqnijdtng3vwxeiu@Ergus \
    --to=spacibba@aol.com \
    --cc=dimech@gmx.com \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).