From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: "Basil L. Contovounesios" Newsgroups: gmane.emacs.devel Subject: Proposed changes to text-mode.el Date: Tue, 26 Mar 2019 01:34:22 +0000 Message-ID: <87o95yxvtt.fsf@tcd.ie> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="131772"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) To: Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Mar 26 02:34:38 2019 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1h8az8-000Y9G-Ed for ged-emacs-devel@m.gmane.org; Tue, 26 Mar 2019 02:34:38 +0100 Original-Received: from localhost ([127.0.0.1]:51050 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h8az7-0006aZ-Aa for ged-emacs-devel@m.gmane.org; Mon, 25 Mar 2019 21:34:37 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:49437) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h8az0-0006aS-73 for emacs-devel@gnu.org; Mon, 25 Mar 2019 21:34:31 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h8ayy-00005s-DH for emacs-devel@gnu.org; Mon, 25 Mar 2019 21:34:30 -0400 Original-Received: from mail-ed1-x52a.google.com ([2a00:1450:4864:20::52a]:45747) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h8ayx-000056-DV for emacs-devel@gnu.org; Mon, 25 Mar 2019 21:34:28 -0400 Original-Received: by mail-ed1-x52a.google.com with SMTP id m16so9277249edd.12 for ; Mon, 25 Mar 2019 18:34:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tcd-ie.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:user-agent:mime-version; bh=i5LLOmCoe22OK+ESjypvMIXv9161ar2YikJ95oyWvoc=; b=AakHzyGDIJUZAyc8VEDISjzHi9e0GgiLTUZLy7W7ee+a10hdL2PSeuligWhzhRGuYE NqhhfQ0gBxzgExz9b9xRH4rAtari10EwxlPBzmpXiUyxxW0jC/6mRlE9loAhNwgs/pzS ij/86Xj4k9/wMyJvRCL0d4xa0dIGTGAW+YdUCpTpMULBkKvJ87vxWk07CbFj1TQBfmxt znukXyXoGRHoA+JOJw663j3vkch2cPtx1E4lh1oqbF6rIolM6gdH/Ce9/td8QxRIABLk FR78caGmvK0tykd8u+tj5Q5gwTlzZ/uvEmIXsXUm2RU+NyHmYr7pPkXDJDZJashmq/lA ICJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:user-agent :mime-version; bh=i5LLOmCoe22OK+ESjypvMIXv9161ar2YikJ95oyWvoc=; b=APQUK9vFBKR8mDF837e1FzCX3cGXYbM/jslw3M7Kjurf8CtHxauZd3gaTIIEBegpRn 6CtotXafqGcT0dH4sr60Y7Rtt10oFVfvrI1kkIz7RUf8bOKdT/Sygy188KQ2IP1SbHBf cjKO8XcHW0qx8jaA6b9BsO9HgVqZBMFEWdFXDfs37rjHfD/fMleFAlpDfXP/qKPhK78D WXq8YJNwEzXmc0RXXbUjsoun3TABEyFqEZHu+CQNarEWu61o/iHe1zVU4VaTHarfaeH5 uCyjkZDZnjLwXc9mUxQxZnYfPRjlxgB6HQR6K56g7fjRUUltw2oGAS1d0a6dd03xzyH6 gf6g== X-Gm-Message-State: APjAAAUtTUs+pjWRk2mvP9UGqAmcc8wWrsxDujQPVJjsucvDzhn7fwVB 5vCTHuQ/pP8VkOiefr+0SgXF8z6F+GCryg== X-Google-Smtp-Source: APXvYqwp1jX4Uos0Ppyu6gvJzjHQkcleIJ9lHvA/pr1G49pZab+ibHepGQRmi4WRC7sg8QTr5RujSg== X-Received: by 2002:a17:906:e5a:: with SMTP id q26mr12173970eji.50.1553564065108; Mon, 25 Mar 2019 18:34:25 -0700 (PDT) Original-Received: from localhost ([2a02:8084:20e2:c380:20c2:134e:4f3a:683a]) by smtp.gmail.com with ESMTPSA id g32sm5918794ede.78.2019.03.25.18.34.23 for (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 25 Mar 2019 18:34:24 -0700 (PDT) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::52a X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:234736 Archived-At: --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Use-lexical-binding-in-text-mode.el.patch >From 36a7cded27791a26cc4979a1a27a6fa59d9a46f5 Mon Sep 17 00:00:00 2001 From: "Basil L. Contovounesios" 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 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0002-Do-not-set-indent-line-function-in-text-mode.patch >From fa3f26d44c746fdf52520d18bded7e8b7987852a Mon Sep 17 00:00:00 2001 From: "Basil L. Contovounesios" 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). + * 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 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0003-Make-text-mode-variant-obsolete.patch >From 1bc70af0bca2d1cb9e6d8799748bf5c262b9a5eb Mon Sep 17 00:00:00 2001 From: "Basil L. Contovounesios" 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. + * 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 --=-=-= Content-Type: text/plain 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 --=-=-=--