From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#73872: 30.0.91; emacs-lisp-mode-syntax-table active when calling `describe-variable' on variable with textually large value. Date: Sat, 21 Dec 2024 10:10:11 -0500 Message-ID: References: <86wmhlyhng.fsf@gnu.org> <867c8l9hlz.fsf@gnu.org> <86ikrviqoy.fsf@gnu.org> Reply-To: Stefan Monnier Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="29736"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: sigurddam@hotmail.com, 73872@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Dec 21 16:11:28 2024 Return-path: Envelope-to: geb-bug-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 1tP18Z-0007Z6-F5 for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 21 Dec 2024 16:11:27 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tP18E-0002Q1-KZ; Sat, 21 Dec 2024 10:11:09 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tP18A-0002Pj-Nk for bug-gnu-emacs@gnu.org; Sat, 21 Dec 2024 10:11:03 -0500 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tP18A-0001nP-Fo for bug-gnu-emacs@gnu.org; Sat, 21 Dec 2024 10:11:02 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:Date:References:In-Reply-To:From:To:Subject; bh=lILYJuu3bNOiUhIix43iaN8x+u1KWyaW5b8GPBMOgXY=; b=K2qsuidwjlMff18WcNXyPt4y2FqsTkwV0u1bkorAFFy7Rdy/tOMvavRp4mDrIVvN/F+ORvzkGRIBsHVJfT4zaMTbtX4e9OZoZdh/vC2+m6fIn65yZ1ZjNVTrNfu7WgcF/ijkYrUvZX9nO/i4P6jCCvYNx+znmChWvAoZ6UtB3d6eE1zYzviNeENiPEJnn7SLCB0Z0nDLVlrmP7Q+bJz7+c8hYPEq5lyfdcZNZqZ9kQQZtzbwJvYuWYdEv9dl+JDQZk+wgR6mH6AzbbN9lHPRSD2Hl4y0ZnTmhfwyVOiEABjZsuROPhYhvXFLtgznP2UDchegNNo6zfhGbNPQlOWcDw==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tP18A-0008Pu-2t for bug-gnu-emacs@gnu.org; Sat, 21 Dec 2024 10:11:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 21 Dec 2024 15:11:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 73872 X-GNU-PR-Package: emacs Original-Received: via spool by 73872-submit@debbugs.gnu.org id=B73872.173479382132292 (code B ref 73872); Sat, 21 Dec 2024 15:11:02 +0000 Original-Received: (at 73872) by debbugs.gnu.org; 21 Dec 2024 15:10:21 +0000 Original-Received: from localhost ([127.0.0.1]:47284 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tP17V-0008Ol-BK for submit@debbugs.gnu.org; Sat, 21 Dec 2024 10:10:21 -0500 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:12819) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tP17U-0008M0-9E for 73872@debbugs.gnu.org; Sat, 21 Dec 2024 10:10:20 -0500 Original-Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id A30FA80837; Sat, 21 Dec 2024 10:10:13 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1734793812; bh=gC31gGr+AdOtYxCCwrmog+KjPucwAqAV4WF2R6P6Jjs=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=Hi/RNABk/TuD6WRqNYKQUjVy9DQ7MsXFezFB+KKv5iEFObyj8zPa13XdjLbsxj5g6 u/dy4qNeNuAJQu6N6pne2NKlmpEXAAomTlF6bJEsKUi/b3Dqgxhj/xrqzrqiLeO4Ye Mjt5MJyff3KSjqLYCg8hQ0vXkYNwO8pzTC6yLEv7KtqCPePEu+1rdbY1PGnpa3ul5L AjBeWtvWCuU2/lr0xM/WIY09YluSHos2rCLSbGpQJlKAcZGt9MEx3HpgnsCDJAGepY s4Foyud1Xm2g4xQhayrXnrP/rarWgytjGGu5NCR7TE+K6PFZdYfTvLzpir4CyJ5mvT 1Ng4jvUBg4rTg== Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 86956804BC; Sat, 21 Dec 2024 10:10:12 -0500 (EST) Original-Received: from asado (unknown [199.119.74.1]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 410FB1205F4; Sat, 21 Dec 2024 10:10:12 -0500 (EST) In-Reply-To: <86ikrviqoy.fsf@gnu.org> (Eli Zaretskii's message of "Sat, 07 Dec 2024 15:10:53 +0200") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:297529 Archived-At: >> Aahhhh! >> So the underlying problem already bite in the usual case but you worked >> around it by changing `help-mode-syntax-table`. >> I think your change to `help-mode-syntax-table` is about right, so we >> should include it in any fix to this bug. > I was going to install that change, but then I noticed that it removed > the call to terpri. Is that intentional? [ I don't think the `terpri` was meant to be removed, no. ] Here's the patch I suggest we install (obviously not on `emacs-30`). Stefan 2024-12-21 Stefan Monnier * lisp/help-mode.el (help-mode-syntax-table): Mark `;` as punctuation. (help-make-xrefs): Use `with-syntax-table`. * lisp/help-fns.el (describe-variable): Don't change the buffer's syntax-table when moving the var's value to the end (bug#73872). Put a `syntax-table` property on the var's value so sexp navigation does not depend on the help-mode-syntax-table. diff --git a/lisp/help-fns.el b/lisp/help-fns.el index c87c86bae84..ae6b77e7849 100644 --- a/lisp/help-fns.el +++ b/lisp/help-fns.el @@ -1437,21 +1437,29 @@ describe-variable (format-message "`%s'" rep) rep))) (start (point))) - (if (< (+ (length print-rep) (point) (- line-beg)) 68) - (insert " " print-rep) - (terpri) - (let ((buf (current-buffer))) - (with-temp-buffer - (lisp-data-mode) - (set-syntax-table emacs-lisp-mode-syntax-table) - (insert print-rep) - (pp-buffer) - (font-lock-ensure) - (let ((pp-buffer (current-buffer))) - (with-current-buffer buf - (insert-buffer-substring pp-buffer))))) - ;; Remove trailing newline. - (and (=3D (char-before) ?\n) (delete-char -1))) + (let (beg) + (if (< (+ (length print-rep) (point) (- line-beg)) 68) + (progn + (setq beg (1+ (point))) + (insert " " print-rep)) + (terpri) + (setq beg (point)) + (let ((buf (current-buffer))) + (with-temp-buffer + (lisp-data-mode) + (insert print-rep) + (pp-buffer) + (font-lock-ensure) + (let ((pp-buffer (current-buffer))) + (with-current-buffer buf + (insert-buffer-substring pp-buffer)))))) + ;; Remove trailing newline. + (and (=3D (char-before) ?\n) (delete-char -1)) + ;; Put a `syntax-table' property on the data, as + ;; a kind of poor man's multi-major-mode support here. + (put-text-property beg (point) + 'syntax-table + lisp-data-mode-syntax-table)) (help-fns--editable-variable start (point) variable val buffer) (let* ((sv (get variable 'standard-value)) @@ -1515,10 +1523,6 @@ describe-variable ;; If the value is large, move it to the end. (with-current-buffer standard-output (when (> (count-lines (point-min) (point-max)) 10) - ;; Note that setting the syntax table like below - ;; makes forward-sexp move over a `'s' at the end - ;; of a symbol. - (set-syntax-table emacs-lisp-mode-syntax-table) (goto-char val-start-pos) (when (looking-at "value is") (replace-match "")) (save-excursion diff --git a/lisp/help-mode.el b/lisp/help-mode.el index 33b8eccab2c..aa705bf56d1 100644 --- a/lisp/help-mode.el +++ b/lisp/help-mode.el @@ -143,6 +143,8 @@ help-mode-syntax-table ;; break when a quoted string contains punctuation. (modify-syntax-entry ?=E2=80=98 "(=E2=80=99 " table) (modify-syntax-entry ?=E2=80=99 ")=E2=80=98 " table) + ;; `;' doesn't start a comment (bug#73872). + (modify-syntax-entry ?\; "." table) table) "Syntax table used in `help-mode'.") =20 @@ -587,13 +587,10 @@ ;; Skip the first bit, which has already been buttonized. (forward-paragraph) (let ((old-modified (buffer-modified-p))) - (let ((stab (syntax-table)) - (case-fold-search t) + (let ((case-fold-search t) (inhibit-read-only t)) - (set-syntax-table help-mode-syntax-table) + (with-syntax-table help-mode-syntax-table ;; The following should probably be abstracted out. - (unwind-protect - (progn ;; Info references (save-excursion (while (re-search-forward help-xref-info-regexp nil t) @@ -679,7 +676,6 @@ (let ((sym (intern-soft (match-string 1)))) (if (fboundp sym) (help-xref-button 1 'help-function sym)))))) - (set-syntax-table stab)) ;; Delete extraneous newlines at the end of the docstring (goto-char (point-max)) (while (and (not (bobp)) (bolp))