unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Proposed changes to text-mode.el
@ 2019-03-26  1:34 Basil L. Contovounesios
  2019-03-26 13:00 ` Stefan Monnier
  0 siblings, 1 reply; 5+ messages in thread
From: Basil L. Contovounesios @ 2019-03-26  1:34 UTC (permalink / raw)
  To: emacs-devel

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: 0001-Use-lexical-binding-in-text-mode.el.patch --]
[-- Type: text/x-diff, Size: 4988 bytes --]

From 36a7cded27791a26cc4979a1a27a6fa59d9a46f5 Mon Sep 17 00:00:00 2001
From: "Basil L. Contovounesios" <contovob@tcd.ie>
Date: Mon, 18 Mar 2019 23:45:55 +0000
Subject: [PATCH 1/3] Use lexical-binding in text-mode.el

* lisp/textmodes/text-mode.el: Use lexical-binding.
(text-mode, paragraph-indent-minor-mode, text-mode-hook-identify):
Use setq-local.
(toggle-text-mode-auto-fill): Quote function symbols as such.
(center-line): Minor simplification.

* doc/lispref/modes.texi (Example Major Modes): Update code example
for these changes to text-mode.
---
 doc/lispref/modes.texi      |  7 +++----
 lisp/textmodes/text-mode.el | 34 +++++++++++++++-------------------
 2 files changed, 18 insertions(+), 23 deletions(-)

diff --git a/doc/lispref/modes.texi b/doc/lispref/modes.texi
index 1afbc5a5ce..7b64a56b19 100644
--- a/doc/lispref/modes.texi
+++ b/doc/lispref/modes.texi
@@ -1291,10 +1291,9 @@ Example Major Modes
 Turning on Text mode runs the normal hook `text-mode-hook'."
 @end group
 @group
-  (set (make-local-variable 'text-mode-variant) t)
-  (set (make-local-variable 'require-final-newline)
-       mode-require-final-newline)
-  (set (make-local-variable 'indent-line-function) 'indent-relative))
+  (setq-local text-mode-variant t)
+  (setq-local require-final-newline mode-require-final-newline)
+  (setq-local indent-line-function #'indent-relative))
 @end group
 @end smallexample
 
diff --git a/lisp/textmodes/text-mode.el b/lisp/textmodes/text-mode.el
index 931faadb5b..90bb3eb3b5 100644
--- a/lisp/textmodes/text-mode.el
+++ b/lisp/textmodes/text-mode.el
@@ -1,4 +1,4 @@
-;;; text-mode.el --- text mode, and its idiosyncratic commands
+;;; text-mode.el --- text mode, and its idiosyncratic commands  -*- lexical-binding: t -*-
 
 ;; Copyright (C) 1985, 1992, 1994, 2001-2019 Free Software Foundation,
 ;; Inc.
@@ -104,10 +104,9 @@ text-mode
  (see the variable `adaptive-fill-mode').
 \\{text-mode-map}
 Turning on Text mode runs the normal hook `text-mode-hook'."
-  (set (make-local-variable 'text-mode-variant) t)
-  (set (make-local-variable 'require-final-newline)
-       mode-require-final-newline)
-  (set (make-local-variable 'indent-line-function) 'indent-relative))
+  (setq-local text-mode-variant t)
+  (setq-local require-final-newline mode-require-final-newline)
+  (setq-local indent-line-function #'indent-relative))
 
 (define-derived-mode paragraph-indent-text-mode text-mode "Parindent"
   "Major mode for editing text, with leading spaces starting a paragraph.
@@ -131,14 +130,12 @@ paragraph-indent-minor-mode
   :initial-value nil
   ;; Change the definition of a paragraph start.
   (let ((ps-re "[ \t\n\f]\\|"))
-    (if (eq t (compare-strings ps-re nil nil
-                               paragraph-start nil (length ps-re)))
+    (if (string-prefix-p ps-re paragraph-start)
         (if (not paragraph-indent-minor-mode)
-            (set (make-local-variable 'paragraph-start)
-                 (substring paragraph-start (length ps-re))))
+            (setq-local paragraph-start
+                        (substring paragraph-start (length ps-re))))
       (if paragraph-indent-minor-mode
-          (set (make-local-variable 'paragraph-start)
-               (concat ps-re paragraph-start)))))
+          (setq-local paragraph-start (concat ps-re paragraph-start)))))
   ;; Change the indentation function.
   (if paragraph-indent-minor-mode
       (add-function :override (local 'indent-line-function)
@@ -154,7 +151,7 @@ 'indented-text-mode
 (defun text-mode-hook-identify ()
   "Mark that this mode has run `text-mode-hook'.
 This is how `toggle-text-mode-auto-fill' knows which buffers to operate on."
-  (set (make-local-variable 'text-mode-variant) t))
+  (setq-local text-mode-variant t))
 
 (defun toggle-text-mode-auto-fill ()
   "Toggle whether to use Auto Fill in Text mode and related modes.
@@ -163,8 +160,8 @@ toggle-text-mode-auto-fill
   (interactive)
   (let ((enable-mode (not (memq 'turn-on-auto-fill text-mode-hook))))
     (if enable-mode
-	(add-hook 'text-mode-hook 'turn-on-auto-fill)
-      (remove-hook 'text-mode-hook 'turn-on-auto-fill))
+        (add-hook 'text-mode-hook #'turn-on-auto-fill)
+      (remove-hook 'text-mode-hook #'turn-on-auto-fill))
     (dolist (buffer (buffer-list))
       (with-current-buffer buffer
 	(if (or (derived-mode-p 'text-mode) text-mode-variant)
@@ -214,15 +211,14 @@ center-line
   (while (not (eq nlines 0))
     (save-excursion
       (let ((lm (current-left-margin))
-	    line-length)
+            space)
 	(beginning-of-line)
 	(delete-horizontal-space)
 	(end-of-line)
 	(delete-horizontal-space)
-	(setq line-length (current-column))
-	(if (> (- fill-column lm line-length) 0)
-	    (indent-line-to
-	     (+ lm (/ (- fill-column lm line-length) 2))))))
+        (setq space (- fill-column lm (current-column)))
+        (if (> space 0)
+            (indent-line-to (+ lm (/ space 2))))))
     (cond ((null nlines)
 	   (setq nlines 0))
 	  ((> nlines 0)
-- 
2.20.1


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0002-Do-not-set-indent-line-function-in-text-mode.patch --]
[-- Type: text/x-diff, Size: 2779 bytes --]

From fa3f26d44c746fdf52520d18bded7e8b7987852a Mon Sep 17 00:00:00 2001
From: "Basil L. Contovounesios" <contovob@tcd.ie>
Date: Tue, 26 Feb 2019 16:13:23 +0000
Subject: [PATCH 2/3] Do not set indent-line-function in text-mode

* lisp/textmodes/text-mode.el (text-mode): Do not reset
indent-line-function to its global default value of indent-relative.
* doc/lispref/modes.texi (Example Major Modes):
* etc/NEWS: Document change accordingly.
---
 doc/lispref/modes.texi      |  7 +------
 etc/NEWS                    | 11 +++++++++++
 lisp/textmodes/text-mode.el |  3 +--
 3 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/doc/lispref/modes.texi b/doc/lispref/modes.texi
index 7b64a56b19..4315b70ed7 100644
--- a/doc/lispref/modes.texi
+++ b/doc/lispref/modes.texi
@@ -1292,15 +1292,10 @@ Example Major Modes
 @end group
 @group
   (setq-local text-mode-variant t)
-  (setq-local require-final-newline mode-require-final-newline)
-  (setq-local indent-line-function #'indent-relative))
+  (setq-local require-final-newline mode-require-final-newline))
 @end group
 @end smallexample
 
-@noindent
-(The last line is redundant nowadays, since @code{indent-relative} is
-the default value, and we'll delete it in a future version.)
-
 @cindex @file{lisp-mode.el}
   The three Lisp modes (Lisp mode, Emacs Lisp mode, and Lisp Interaction
 mode) have more features than Text mode and the code is correspondingly
diff --git a/etc/NEWS b/etc/NEWS
index afee1e1dca..69af0447b2 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -1233,6 +1233,17 @@ near the current column in Tabulated Lists (see variables
 'tabulated-list-tty-sort-indicator-asc', and
 'tabulated-list-tty-sort-indicator-desc').
 
+** Text mode
+
++++
+*** 'text-mode' no longer sets the value of 'indent-line-function'.
+The global value of 'indent-line-function', which defaults to
+'indent-relative', will no longer be reset locally when turning on
+'text-mode'.
+
+To get back the old behavior, add a function to 'text-mode-hook' which
+performs (setq-local indent-line-function #'indent-relative).
+
 \f
 * New Modes and Packages in Emacs 27.1
 
diff --git a/lisp/textmodes/text-mode.el b/lisp/textmodes/text-mode.el
index 90bb3eb3b5..6114490208 100644
--- a/lisp/textmodes/text-mode.el
+++ b/lisp/textmodes/text-mode.el
@@ -105,8 +105,7 @@ text-mode
 \\{text-mode-map}
 Turning on Text mode runs the normal hook `text-mode-hook'."
   (setq-local text-mode-variant t)
-  (setq-local require-final-newline mode-require-final-newline)
-  (setq-local indent-line-function #'indent-relative))
+  (setq-local require-final-newline mode-require-final-newline))
 
 (define-derived-mode paragraph-indent-text-mode text-mode "Parindent"
   "Major mode for editing text, with leading spaces starting a paragraph.
-- 
2.20.1


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: 0003-Make-text-mode-variant-obsolete.patch --]
[-- Type: text/x-diff, Size: 1529 bytes --]

From 1bc70af0bca2d1cb9e6d8799748bf5c262b9a5eb Mon Sep 17 00:00:00 2001
From: "Basil L. Contovounesios" <contovob@tcd.ie>
Date: Mon, 25 Mar 2019 23:10:59 +0000
Subject: [PATCH 3/3] Make text-mode-variant obsolete

* lisp/textmodes/text-mode.el (text-mode-variant): Make obsolete,
suggesting derived-mode-p as a better alternative.
* etc/NEWS: Announce obsolescence.
---
 etc/NEWS                    | 3 +++
 lisp/textmodes/text-mode.el | 4 ++--
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/etc/NEWS b/etc/NEWS
index 69af0447b2..f3d09bc3dc 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -1244,6 +1244,9 @@ The global value of 'indent-line-function', which defaults to
 To get back the old behavior, add a function to 'text-mode-hook' which
 performs (setq-local indent-line-function #'indent-relative).
 
++++
+*** 'text-mode-variant' is now obsolete, use 'derived-mode-p' instead.
+
 \f
 * New Modes and Packages in Emacs 27.1
 
diff --git a/lisp/textmodes/text-mode.el b/lisp/textmodes/text-mode.el
index 6114490208..e676a5dae2 100644
--- a/lisp/textmodes/text-mode.el
+++ b/lisp/textmodes/text-mode.el
@@ -38,8 +38,8 @@ text-mode-hook
   :group 'text)
 
 (defvar text-mode-variant nil
-  "Non-nil if this buffer's major mode is a variant of Text mode.
-Use (derived-mode-p \\='text-mode) instead.")
+  "Non-nil if this buffer's major mode is a variant of Text mode.")
+(make-obsolete-variable 'text-mode-variant 'derived-mode-p "27.1")
 
 (defvar text-mode-syntax-table
   (let ((st (make-syntax-table)))
-- 
2.20.1


[-- Attachment #4: Type: text/plain, Size: 941 bytes --]


I attach three patches for lisp/textmodes/text-mode.el arising from the
discussion in bug#34671.

The first enables lexical-binding and makes some minor simplifications.

The second makes text-mode no longer reset indent-line-function to
indent-relative locally, a change (info "(elisp) Example Major Modes")
has been promising for many moons.  AFAICT, text-mode works even when
indent-line-function is not set to indent-relative (as I'd hope).  I've
had a quick look through all the modes derived from text-mode in
emacs.git and nothing strikes me as an obvious incompatibility with the
proposed change.  Are there any significant reasons to keep the current
setting of indent-line-function in text-mode?

The third obsoletes the variable text-mode-variant, which is unused in
both emacs.git and elpa.git, and has been recommending derived-mode-p as
a better alternative in its docstring for almost two decades.

WDYT?

Thanks,

-- 
Basil

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: Proposed changes to text-mode.el
  2019-03-26  1:34 Proposed changes to text-mode.el Basil L. Contovounesios
@ 2019-03-26 13:00 ` Stefan Monnier
  2019-03-27  3:50   ` Basil L. Contovounesios
  0 siblings, 1 reply; 5+ messages in thread
From: Stefan Monnier @ 2019-03-26 13:00 UTC (permalink / raw)
  To: emacs-devel

> I attach three patches for lisp/textmodes/text-mode.el arising from the
> discussion in bug#34671.
>
> The first enables lexical-binding and makes some minor simplifications.
>
> The second makes text-mode no longer reset indent-line-function to
> indent-relative locally, a change (info "(elisp) Example Major Modes")
> has been promising for many moons.  AFAICT, text-mode works even when
> indent-line-function is not set to indent-relative (as I'd hope).  I've
> had a quick look through all the modes derived from text-mode in
> emacs.git and nothing strikes me as an obvious incompatibility with the
> proposed change.  Are there any significant reasons to keep the current
> setting of indent-line-function in text-mode?

The reason why I kept the `setq-local` when I changed the default to
`indent-relative` was simply to be conservative.

> The third obsoletes the variable text-mode-variant, which is unused in
> both emacs.git and elpa.git, and has been recommending derived-mode-p as
> a better alternative in its docstring for almost two decades.
> WDYT?

LGTM,


        Stefan




^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Proposed changes to text-mode.el
  2019-03-26 13:00 ` Stefan Monnier
@ 2019-03-27  3:50   ` Basil L. Contovounesios
  2019-03-27 15:44     ` Eli Zaretskii
  0 siblings, 1 reply; 5+ messages in thread
From: Basil L. Contovounesios @ 2019-03-27  3:50 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel

Stefan Monnier <monnier@iro.umontreal.ca> writes:

>> I attach three patches for lisp/textmodes/text-mode.el arising from the
>> discussion in bug#34671.
>>
>> The first enables lexical-binding and makes some minor simplifications.
>>
>> The second makes text-mode no longer reset indent-line-function to
>> indent-relative locally, a change (info "(elisp) Example Major Modes")
>> has been promising for many moons.  AFAICT, text-mode works even when
>> indent-line-function is not set to indent-relative (as I'd hope).  I've
>> had a quick look through all the modes derived from text-mode in
>> emacs.git and nothing strikes me as an obvious incompatibility with the
>> proposed change.  Are there any significant reasons to keep the current
>> setting of indent-line-function in text-mode?
>
> The reason why I kept the `setq-local` when I changed the default to
> `indent-relative` was simply to be conservative.
>
>> The third obsoletes the variable text-mode-variant, which is unused in
>> both emacs.git and elpa.git, and has been recommending derived-mode-p as
>> a better alternative in its docstring for almost two decades.
>> WDYT?
>
> LGTM,

Thanks for the clarification and review.
I'll wait a few more days for others to comment before pushing.

-- 
Basil



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Proposed changes to text-mode.el
  2019-03-27  3:50   ` Basil L. Contovounesios
@ 2019-03-27 15:44     ` Eli Zaretskii
  2019-03-31 21:42       ` Basil L. Contovounesios
  0 siblings, 1 reply; 5+ messages in thread
From: Eli Zaretskii @ 2019-03-27 15:44 UTC (permalink / raw)
  To: Basil L. Contovounesios; +Cc: monnier, emacs-devel

> From: "Basil L. Contovounesios" <contovob@tcd.ie>
> Date: Wed, 27 Mar 2019 03:50:26 +0000
> Cc: emacs-devel@gnu.org
> 
> Thanks for the clarification and review.
> I'll wait a few more days for others to comment before pushing.

My only comment is that the NEWS item that describes an incompatible
change should be in the section dedicated to incompatible changes.

Thanks.



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Proposed changes to text-mode.el
  2019-03-27 15:44     ` Eli Zaretskii
@ 2019-03-31 21:42       ` Basil L. Contovounesios
  0 siblings, 0 replies; 5+ messages in thread
From: Basil L. Contovounesios @ 2019-03-31 21:42 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: monnier, emacs-devel

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: 0001-Use-lexical-binding-in-text-mode.el.patch --]
[-- Type: text/x-diff, Size: 4987 bytes --]

From 4c9950d015fdb520d29f04c6b1eb7418a442fc60 Mon Sep 17 00:00:00 2001
From: "Basil L. Contovounesios" <contovob@tcd.ie>
Date: Mon, 18 Mar 2019 23:45:55 +0000
Subject: [PATCH 1/3] Use lexical-binding in text-mode.el

* lisp/textmodes/text-mode.el: Use lexical-binding.
(text-mode, paragraph-indent-minor-mode, text-mode-hook-identify):
Use setq-local.
(toggle-text-mode-auto-fill): Quote function symbols as such.
(center-line): Minor simplification.
* doc/lispref/modes.texi (Example Major Modes): Update code example
for these changes to text-mode.
---
 doc/lispref/modes.texi      |  7 +++----
 lisp/textmodes/text-mode.el | 34 +++++++++++++++-------------------
 2 files changed, 18 insertions(+), 23 deletions(-)

diff --git a/doc/lispref/modes.texi b/doc/lispref/modes.texi
index 1afbc5a5ce..7b64a56b19 100644
--- a/doc/lispref/modes.texi
+++ b/doc/lispref/modes.texi
@@ -1291,10 +1291,9 @@ Example Major Modes
 Turning on Text mode runs the normal hook `text-mode-hook'."
 @end group
 @group
-  (set (make-local-variable 'text-mode-variant) t)
-  (set (make-local-variable 'require-final-newline)
-       mode-require-final-newline)
-  (set (make-local-variable 'indent-line-function) 'indent-relative))
+  (setq-local text-mode-variant t)
+  (setq-local require-final-newline mode-require-final-newline)
+  (setq-local indent-line-function #'indent-relative))
 @end group
 @end smallexample
 
diff --git a/lisp/textmodes/text-mode.el b/lisp/textmodes/text-mode.el
index 931faadb5b..90bb3eb3b5 100644
--- a/lisp/textmodes/text-mode.el
+++ b/lisp/textmodes/text-mode.el
@@ -1,4 +1,4 @@
-;;; text-mode.el --- text mode, and its idiosyncratic commands
+;;; text-mode.el --- text mode, and its idiosyncratic commands  -*- lexical-binding: t -*-
 
 ;; Copyright (C) 1985, 1992, 1994, 2001-2019 Free Software Foundation,
 ;; Inc.
@@ -104,10 +104,9 @@ text-mode
  (see the variable `adaptive-fill-mode').
 \\{text-mode-map}
 Turning on Text mode runs the normal hook `text-mode-hook'."
-  (set (make-local-variable 'text-mode-variant) t)
-  (set (make-local-variable 'require-final-newline)
-       mode-require-final-newline)
-  (set (make-local-variable 'indent-line-function) 'indent-relative))
+  (setq-local text-mode-variant t)
+  (setq-local require-final-newline mode-require-final-newline)
+  (setq-local indent-line-function #'indent-relative))
 
 (define-derived-mode paragraph-indent-text-mode text-mode "Parindent"
   "Major mode for editing text, with leading spaces starting a paragraph.
@@ -131,14 +130,12 @@ paragraph-indent-minor-mode
   :initial-value nil
   ;; Change the definition of a paragraph start.
   (let ((ps-re "[ \t\n\f]\\|"))
-    (if (eq t (compare-strings ps-re nil nil
-                               paragraph-start nil (length ps-re)))
+    (if (string-prefix-p ps-re paragraph-start)
         (if (not paragraph-indent-minor-mode)
-            (set (make-local-variable 'paragraph-start)
-                 (substring paragraph-start (length ps-re))))
+            (setq-local paragraph-start
+                        (substring paragraph-start (length ps-re))))
       (if paragraph-indent-minor-mode
-          (set (make-local-variable 'paragraph-start)
-               (concat ps-re paragraph-start)))))
+          (setq-local paragraph-start (concat ps-re paragraph-start)))))
   ;; Change the indentation function.
   (if paragraph-indent-minor-mode
       (add-function :override (local 'indent-line-function)
@@ -154,7 +151,7 @@ 'indented-text-mode
 (defun text-mode-hook-identify ()
   "Mark that this mode has run `text-mode-hook'.
 This is how `toggle-text-mode-auto-fill' knows which buffers to operate on."
-  (set (make-local-variable 'text-mode-variant) t))
+  (setq-local text-mode-variant t))
 
 (defun toggle-text-mode-auto-fill ()
   "Toggle whether to use Auto Fill in Text mode and related modes.
@@ -163,8 +160,8 @@ toggle-text-mode-auto-fill
   (interactive)
   (let ((enable-mode (not (memq 'turn-on-auto-fill text-mode-hook))))
     (if enable-mode
-	(add-hook 'text-mode-hook 'turn-on-auto-fill)
-      (remove-hook 'text-mode-hook 'turn-on-auto-fill))
+        (add-hook 'text-mode-hook #'turn-on-auto-fill)
+      (remove-hook 'text-mode-hook #'turn-on-auto-fill))
     (dolist (buffer (buffer-list))
       (with-current-buffer buffer
 	(if (or (derived-mode-p 'text-mode) text-mode-variant)
@@ -214,15 +211,14 @@ center-line
   (while (not (eq nlines 0))
     (save-excursion
       (let ((lm (current-left-margin))
-	    line-length)
+            space)
 	(beginning-of-line)
 	(delete-horizontal-space)
 	(end-of-line)
 	(delete-horizontal-space)
-	(setq line-length (current-column))
-	(if (> (- fill-column lm line-length) 0)
-	    (indent-line-to
-	     (+ lm (/ (- fill-column lm line-length) 2))))))
+        (setq space (- fill-column lm (current-column)))
+        (if (> space 0)
+            (indent-line-to (+ lm (/ space 2))))))
     (cond ((null nlines)
 	   (setq nlines 0))
 	  ((> nlines 0)
-- 
2.20.1


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0002-Do-not-set-indent-line-function-in-text-mode.patch --]
[-- Type: text/x-diff, Size: 2859 bytes --]

From 2e3deb09bd42d22a9b354937ce63b151fb493d8a Mon Sep 17 00:00:00 2001
From: "Basil L. Contovounesios" <contovob@tcd.ie>
Date: Sun, 31 Mar 2019 19:39:54 +0100
Subject: [PATCH 2/3] Do not set indent-line-function in text-mode

For discussion, see thread starting at:
https://lists.gnu.org/archive/html/emacs-devel/2019-03/msg01012.html
* lisp/textmodes/text-mode.el (text-mode): Do not reset
indent-line-function to its global default value of indent-relative.
* doc/lispref/modes.texi (Example Major Modes):
* etc/NEWS: Document change accordingly.
---
 doc/lispref/modes.texi      | 7 +------
 etc/NEWS                    | 9 +++++++++
 lisp/textmodes/text-mode.el | 3 +--
 3 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/doc/lispref/modes.texi b/doc/lispref/modes.texi
index 7b64a56b19..4315b70ed7 100644
--- a/doc/lispref/modes.texi
+++ b/doc/lispref/modes.texi
@@ -1292,15 +1292,10 @@ Example Major Modes
 @end group
 @group
   (setq-local text-mode-variant t)
-  (setq-local require-final-newline mode-require-final-newline)
-  (setq-local indent-line-function #'indent-relative))
+  (setq-local require-final-newline mode-require-final-newline))
 @end group
 @end smallexample
 
-@noindent
-(The last line is redundant nowadays, since @code{indent-relative} is
-the default value, and we'll delete it in a future version.)
-
 @cindex @file{lisp-mode.el}
   The three Lisp modes (Lisp mode, Emacs Lisp mode, and Lisp Interaction
 mode) have more features than Text mode and the code is correspondingly
diff --git a/etc/NEWS b/etc/NEWS
index 7486d6bcfe..89e07a2f4d 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -1371,6 +1371,15 @@ ending character were silently omitted.
 For example, '(rx (any "@z-a" (?9 . ?0)))' would match '@' only.
 Now, such rx expressions generate an error.
 
++++
+** 'text-mode' no longer sets the value of 'indent-line-function'.
+The global value of 'indent-line-function', which defaults to
+'indent-relative', will no longer be reset locally when turning on
+'text-mode'.
+
+To get back the old behavior, add a function to 'text-mode-hook' which
+performs (setq-local indent-line-function #'indent-relative).
+
 \f
 * Lisp Changes in Emacs 27.1
 
diff --git a/lisp/textmodes/text-mode.el b/lisp/textmodes/text-mode.el
index 90bb3eb3b5..6114490208 100644
--- a/lisp/textmodes/text-mode.el
+++ b/lisp/textmodes/text-mode.el
@@ -105,8 +105,7 @@ text-mode
 \\{text-mode-map}
 Turning on Text mode runs the normal hook `text-mode-hook'."
   (setq-local text-mode-variant t)
-  (setq-local require-final-newline mode-require-final-newline)
-  (setq-local indent-line-function #'indent-relative))
+  (setq-local require-final-newline mode-require-final-newline))
 
 (define-derived-mode paragraph-indent-text-mode text-mode "Parindent"
   "Major mode for editing text, with leading spaces starting a paragraph.
-- 
2.20.1


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: 0003-Do-not-set-indent-line-function-in-text-mode.patch --]
[-- Type: text/x-diff, Size: 1574 bytes --]

From 63471c837dde50179f3c7bb6d316d61160e9e825 Mon Sep 17 00:00:00 2001
From: "Basil L. Contovounesios" <contovob@tcd.ie>
Date: Mon, 25 Mar 2019 23:10:59 +0000
Subject: [PATCH 3/3] Do not set indent-line-function in text-mode

* lisp/textmodes/text-mode.el (text-mode): Do not reset
indent-line-function to its global default value of indent-relative.
* doc/lispref/modes.texi (Example Major Modes):
* etc/NEWS: Document change accordingly.
---
 etc/NEWS                    | 5 +++++
 lisp/textmodes/text-mode.el | 4 ++--
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/etc/NEWS b/etc/NEWS
index 89e07a2f4d..836dd2bb1a 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -1233,6 +1233,11 @@ near the current column in Tabulated Lists (see variables
 'tabulated-list-tty-sort-indicator-asc', and
 'tabulated-list-tty-sort-indicator-desc').
 
+** Text mode
+
++++
+*** 'text-mode-variant' is now obsolete, use 'derived-mode-p' instead.
+
 \f
 * New Modes and Packages in Emacs 27.1
 
diff --git a/lisp/textmodes/text-mode.el b/lisp/textmodes/text-mode.el
index 6114490208..e676a5dae2 100644
--- a/lisp/textmodes/text-mode.el
+++ b/lisp/textmodes/text-mode.el
@@ -38,8 +38,8 @@ text-mode-hook
   :group 'text)
 
 (defvar text-mode-variant nil
-  "Non-nil if this buffer's major mode is a variant of Text mode.
-Use (derived-mode-p \\='text-mode) instead.")
+  "Non-nil if this buffer's major mode is a variant of Text mode.")
+(make-obsolete-variable 'text-mode-variant 'derived-mode-p "27.1")
 
 (defvar text-mode-syntax-table
   (let ((st (make-syntax-table)))
-- 
2.20.1


[-- Attachment #4: Type: text/plain, Size: 494 bytes --]


Eli Zaretskii <eliz@gnu.org> writes:

>> From: "Basil L. Contovounesios" <contovob@tcd.ie>
>> Date: Wed, 27 Mar 2019 03:50:26 +0000
>> Cc: emacs-devel@gnu.org
>> 
>> Thanks for the clarification and review.
>> I'll wait a few more days for others to comment before pushing.
>
> My only comment is that the NEWS item that describes an incompatible
> change should be in the section dedicated to incompatible changes.

I did so and pushed the three updated patches attached.

Thanks,

-- 
Basil

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-03-31 21:42 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-26  1:34 Proposed changes to text-mode.el Basil L. Contovounesios
2019-03-26 13:00 ` Stefan Monnier
2019-03-27  3:50   ` Basil L. Contovounesios
2019-03-27 15:44     ` Eli Zaretskii
2019-03-31 21:42       ` Basil L. Contovounesios

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

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