From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Ergus Newsgroups: gmane.emacs.help Subject: Re: Cycle Auto-Fill Date: Sat, 5 Dec 2020 15:39:16 +0100 Message-ID: <20201205143916.wqnijdtng3vwxeiu@Ergus> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="3964"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Help Gnu Emacs To: Christopher Dimech Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Sat Dec 05 15:40:26 2020 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1klYjZ-0000wq-UJ for geh-help-gnu-emacs@m.gmane-mx.org; Sat, 05 Dec 2020 15:40:26 +0100 Original-Received: from localhost ([::1]:45552 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1klYjY-00066R-Vc for geh-help-gnu-emacs@m.gmane-mx.org; Sat, 05 Dec 2020 09:40:24 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:53886) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1klYiq-00064w-Mr for help-gnu-emacs@gnu.org; Sat, 05 Dec 2020 09:39:44 -0500 Original-Received: from sonic302-2.consmr.mail.bf2.yahoo.com ([74.6.135.41]:40801) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1klYin-0000kR-1v for help-gnu-emacs@gnu.org; Sat, 05 Dec 2020 09:39:39 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aol.com; s=a2048; t=1607179173; bh=WStFKMk+KOZgfCc9/lv9+nRbUaWfEO496BjxNTgPiTQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From:Subject; b=UthBEQtyDGMPnMuYXnFjvB77gD9aPheIiPRFVhH4kDFbUcWQE8t5iYdt9kZKA7JQTiQntLOZFMuY4RdwYEwSDCM6RfT9Oku3s892jPFrFuu5KO1fiYzPWCx3EF+35bC5deQgGIhVcEp6f2oVfrz/xYO0brdZgwYrbtjtxOe9zttrMGVTpDNfv24BIY6KsqQG+Pu50V1asRb+K9x+Bm/citfOU2fZS+tTO36LH69gtpvUyOvi5ojSZmMOJv0U+HSMhVmkabtQbSnf3474XAAOb/lrA6MSyCwYjrHVDeRmUHRA5ingKK3W2NcuUTmNcgL/v94/nrOrHNnaXSxxyMku8g== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1607179173; bh=sD4Fths2QSHq70gXH5zW5+jJU62GeeFQIQEjKf5EJ/+=; h=Date:From:To:Subject:From:Subject; b=eCgEEJN9jUT7A9inuRe7Vg+pxzxBn26uwOZBv78IpPnGkYspN37p+pSzhT7l/fZjp9TqBsXChY+oFsXXCOV2Fm0o96+XA77COqqAlqZO0LCnWfUTtFyQoqMJYo3OZ1J6UqgUM8w84v14ZrRrdJ0n4RWHm+bh65JO3oZW6BoSG2hTJ7fBdREdXZxjdeA9O+VwOA6JJDgpD4AVSssRQSIK/QoTwv7cqeaAqF7s6zq+viHVd7Pr2DiPp8+Dzs2VwZHq1qR5hMPnPlBAS1PLJ5cnvWkXhJMgoHWNSB+hDF7Lw8kodZhjiu8dbMeY2FrLX7/wuIFqBM6RAHBbEbawglJR3w== X-YMail-OSG: thgUDPQVM1l76tlYD9OFjGteTUQ4a3vxa2Ynulw8UkIsIIbMUB5gLA8RItlSVP. 86LdObrj4ZW1dYhKGuYxgvLCU3q9Np3i_2DpIxvxl4CO1WjHe4aqI7F5o_hrsgm16eoWEdnDSACl gz.0cJBVqjU03Y0qGG5v7nWrBO6Fev_ArczFrN3QxvTwq.81mDUKaav0ryLy5pv03pCwDuGu3Ccx ZODbFKutuSN51CYis2N7G0Gcwus379.oBuHwBAKRpJpgsSDMN0vjUkgazycWca.QIHE6A_c5GzB9 k3UOan5tsE0P8ovzMijMabhYw9fl2ymaCGLvUbmIPLF_c7Yp0QFiM2kJo9JX6S1NkZ2a2slaa1_7 LAADFr62ZbHN9PmnXlz3KmUN_v140hMFicdw2OuI5VMuptDhojZ8bJNBJR_YHosNXwGNbKRzcAKx UGd.BTXDVUKUZMK6awLCLqO_blL2TDAvKzsYZYFQHvdYba1J2N3yTaVwivjos_OWqz6BGcFxU8j3 CXMlVEmF094BhOglNxLZJXeKuXQhF3S0TqZsdqPWhuAbu3mevoxP7hQI.t3vqf8UNpw8WoeIPluU OYFsc44uDwwwKxFgt0FMdEQVWnSg.lGwdrhW7nvW0LxWTw_BfLDwcQ0V5NvuViDgZUNbKPGdvBt9 RfdRxobPBMCJ6IxLogc.dRcvIUqYRETcn7qk.TH9MniAzqwu710Vd0yFFmESi0hhuPkIMwUkw78Q eSioRJZ4q7G9kQQsd.Ua5Dg88LTXMHyl0W71h648op3xdFpZyqF2KaC2eqgJG0Dg2HGbywJPJCc_ MjWsmCfsVMNxZfMgr5spxi9tzS2y7MPlwI1BZdW5ME Original-Received: from sonic.gate.mail.ne1.yahoo.com by sonic302.consmr.mail.bf2.yahoo.com with HTTP; Sat, 5 Dec 2020 14:39:33 +0000 Original-Received: by smtp421.mail.ir2.yahoo.com (VZM Hermes SMTP Server) with ESMTPA ID 8c49ae2a75c7aff72faf519e07b07d9a; Sat, 05 Dec 2020 14:39:30 +0000 (UTC) Content-Disposition: inline In-Reply-To: X-Mailer: WebService/1.1.17111 mail.backend.jedi.jws.acl:role.jedi.acl.token.atz.jws.hermes.aol Apache-HttpAsyncClient/4.1.4 (Java/11.0.8) Received-SPF: pass client-ip=74.6.135.41; envelope-from=spacibba@aol.com; helo=sonic302-2.consmr.mail.bf2.yahoo.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.io gmane.emacs.help:126026 Archived-At: 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 > >