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: Re: Proposed changes to text-mode.el Date: Sun, 31 Mar 2019 22:42:33 +0100 Message-ID: <87bm1q90vq.fsf@tcd.ie> References: <87o95yxvtt.fsf@tcd.ie> <8736n9vuv1.fsf@tcd.ie> <83ef6sl3tr.fsf@gnu.org> 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="200859"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) Cc: monnier@iro.umontreal.ca, emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Mar 31 23:43:58 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 1hAiFA-000q3j-KU for ged-emacs-devel@m.gmane.org; Sun, 31 Mar 2019 23:43:56 +0200 Original-Received: from localhost ([127.0.0.1]:47473 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hAiF9-0002Cq-N4 for ged-emacs-devel@m.gmane.org; Sun, 31 Mar 2019 17:43:55 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:53317) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hAiDw-0001w2-EK for emacs-devel@gnu.org; Sun, 31 Mar 2019 17:42:42 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hAiDu-00017O-M9 for emacs-devel@gnu.org; Sun, 31 Mar 2019 17:42:40 -0400 Original-Received: from mail-ed1-x531.google.com ([2a00:1450:4864:20::531]:40020) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hAiDt-00015m-Lt for emacs-devel@gnu.org; Sun, 31 Mar 2019 17:42:38 -0400 Original-Received: by mail-ed1-x531.google.com with SMTP id h22so6449268edw.7 for ; Sun, 31 Mar 2019 14:42:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tcd-ie.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=RTm3Txi61hCwxalycIDfQQTWrDB0eKr/GIfUCrvEQ7Q=; b=iGNkZYee51WBSVOI6hUmcsnCElDK7ss+VdBsQDkNIZiF75ufWVYT5eompfamDAJ0yh wWZjd82etCylbyygMvwzBaTgtorAAEMQfPvwnxdfoDn4ZqrD6c9+zpdzv9IDvr6Y1nhp 9BIsVFXgIlm00ObGnNS/uNUGja+BH2iQksCiZ3PemCm6Dq1P2y9FPwS0Hua9hoQjjjBB LijRw7OqTGGgPmHEWI0QMHGUQCTWJVOXH5pFkCkBFsK6mIKFyNNob1lHjMIT3U/NcW0Z MV/95uzjkqmw5TKfzh4H/+jX5N8ADw89nbD8lfArNtCXADR/PVK/iRIJxpe3VzfuGwYa eNtA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=RTm3Txi61hCwxalycIDfQQTWrDB0eKr/GIfUCrvEQ7Q=; b=L3qbe9dUj30nVmAiGPCQf8rawG6a2lRrYk7YWAKXr+WFtjUa8qvI4s9xlBz4SF/j5h N95szYPMrd7xe4AvQvdi0uTm1V/puFskrKVLEWnrWVqTrOunig5w7zaAckThQnpSTa0K eUKj9P47aU/Irlr8t0r8OWFdUa7Nkkyi7EXhqcanO81mwyUNK5ChUJ9N9++5eGVRqvUF hPPuV5BelgTzx31m605oKtvRJW9f/H9ejJraSkRPG82IEETgDYTIz6Be9Ky0j4OXJWX+ BUHYGPxhx8rBY4G25N+E4OVgU9A7dnM578mHrFfoCJkCMYscndiLxRhDGh+UYJlWTIvP 2LHA== X-Gm-Message-State: APjAAAXXj+rqgj7ZwTNSM6+XJMN3AN2HXDHSLhFtI3qcwNiNkq8qX5NN BrSo7EOXmzFhCbp5VsLLXdT8AA== X-Google-Smtp-Source: APXvYqwg4xOWl8tVNrib4/l0bUbik7LYye2gkE+67lITh1ssitENump0qBYO+mdmwmN7g/CbcLErnw== X-Received: by 2002:a50:e78a:: with SMTP id b10mr41193687edn.45.1554068556161; Sun, 31 Mar 2019 14:42:36 -0700 (PDT) Original-Received: from localhost ([2a02:8084:20e2:c380:f786:805d:f4ab:1006]) by smtp.gmail.com with ESMTPSA id f25sm2576753eds.80.2019.03.31.14.42.34 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sun, 31 Mar 2019 14:42:34 -0700 (PDT) In-Reply-To: <83ef6sl3tr.fsf@gnu.org> (Eli Zaretskii's message of "Wed, 27 Mar 2019 17:44:32 +0200") X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::531 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:234844 Archived-At: --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Use-lexical-binding-in-text-mode.el.patch >From 4c9950d015fdb520d29f04c6b1eb7418a442fc60 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 2e3deb09bd42d22a9b354937ce63b151fb493d8a Mon Sep 17 00:00:00 2001 From: "Basil L. Contovounesios" 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). + * 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 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0003-Do-not-set-indent-line-function-in-text-mode.patch >From 63471c837dde50179f3c7bb6d316d61160e9e825 Mon Sep 17 00:00:00 2001 From: "Basil L. Contovounesios" 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. + * 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 Eli Zaretskii writes: >> From: "Basil L. Contovounesios" >> 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 --=-=-=--