emacs-diffs
[Top][All Lists]
Advanced

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

master 9901868: Make nil value of fill-column obsolete


From: Lars Ingebrigtsen
Subject: master 9901868: Make nil value of fill-column obsolete
Date: Fri, 23 Jul 2021 08:58:42 -0400 (EDT)

branch: master
commit 99018681c40f5854dd8fad8e226b6dc1609cafe2
Author: Stefan Kangas <stefan@marxist.se>
Commit: Lars Ingebrigtsen <larsi@gnus.org>

    Make nil value of fill-column obsolete
    
    * lisp/textmodes/fill.el (current-fill-column): Make nil value of
    'fill-column' obsolete.  (Bug#22847)
    (current-fill-column--has-warned): New variable to track warning.
    * lisp/simple.el (do-auto-fill): Remove handling of nil return value
    from 'current-fill-column'.
    * etc/NEWS: Announce obsoletion of this usage.
---
 etc/NEWS               | 10 ++++++++++
 lisp/simple.el         |  2 +-
 lisp/textmodes/fill.el | 11 ++++++++++-
 3 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/etc/NEWS b/etc/NEWS
index 4987e5c..29953a8 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -118,6 +118,16 @@ avoid security issues when executing untrusted code.  See 
the manual
 page for 'seccomp' system call, for details about Secure Computing
 filters.
 
+** Setting 'fill-column' to nil is obsolete.
+This undocumented use of 'fill-column' is now obsolete.  If you have
+set this value to nil disable auto filling, instead disable
+'auto-fill-mode' in the relevant mode instead.
+
+For instance, you could add something like the following to your init
+file:
+
+    (add-hook 'foo-mode-hook (lambda () (auto-fill-mode -1))
+
 
 * Changes in Emacs 28.1
 
diff --git a/lisp/simple.el b/lisp/simple.el
index 1a49fe2..ee2698d 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -8057,7 +8057,7 @@ Returns t if it really did any work."
   (let (fc justify give-up
           (fill-prefix fill-prefix))
     (if (or (not (setq justify (current-justification)))
-           (null (setq fc (current-fill-column)))
+           (setq fc (current-fill-column))
            (and (eq justify 'left)
                 (<= (current-column) fc))
            (and auto-fill-inhibit-regexp
diff --git a/lisp/textmodes/fill.el b/lisp/textmodes/fill.el
index 3914bde..f394171 100644
--- a/lisp/textmodes/fill.el
+++ b/lisp/textmodes/fill.el
@@ -133,6 +133,8 @@ A nil return value means the function has not determined 
the fill prefix."
 (defvar fill-indent-according-to-mode nil ;Screws up CC-mode's filling tricks.
   "Whether or not filling should try to use the major mode's indentation.")
 
+(defvar current-fill-column--has-warned nil)
+
 (defun current-fill-column ()
   "Return the fill-column to use for this line.
 The fill-column to use for a buffer is stored in the variable `fill-column',
@@ -158,7 +160,14 @@ number equals or exceeds the local fill-column - 
right-margin difference."
                             (< col fill-col)))
            (setq here change
                  here-col col))
-         (max here-col fill-col)))))
+         (max here-col fill-col))
+      ;; This warning was added in 28.1.  It should be removed later,
+      ;; and this function changed to never return nil.
+      (unless current-fill-column--has-warned
+        (lwarn '(fill-column) :warning
+               "Setting this variable to nil is obsolete; use `(auto-fill-mode 
-1)' instead")
+        (setq current-fill-column--has-warned t))
+      most-positive-fixnum)))
 
 (defun canonically-space-region (beg end)
   "Remove extra spaces between words in region.



reply via email to

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