From: Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: Eli Zaretskii <eliz@gnu.org>
Cc: sigurddam@hotmail.com, 73872@debbugs.gnu.org
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 [thread overview]
Message-ID: <jwv5xndgjw8.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <86ikrviqoy.fsf@gnu.org> (Eli Zaretskii's message of "Sat, 07 Dec 2024 15:10:53 +0200")
>> 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 <monnier@iro.umontreal.ca>
* 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 (= (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 (= (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 ?‘ "(’ " table)
(modify-syntax-entry ?’ ")‘ " table)
+ ;; `;' doesn't start a comment (bug#73872).
+ (modify-syntax-entry ?\; "." table)
table)
"Syntax table used in `help-mode'.")
@@ -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))
prev parent reply other threads:[~2024-12-21 15:10 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-18 22:14 bug#73872: 30.0.91; emacs-lisp-mode-syntax-table active when calling `describe-variable' on variable with textually large value Sigurd Dam Sonniks
2024-11-02 11:55 ` Eli Zaretskii
[not found] ` <jwvsertuche.fsf-monnier+emacs@gnu.org>
2024-11-30 9:49 ` Eli Zaretskii
[not found] ` <DBAP195MB104976F58C31051E74A4F05CB92B2@DBAP195MB1049.EURP195.PROD.OUTLOOK.COM>
[not found] ` <jwvh67nvuta.fsf-monnier+emacs@gnu.org>
2024-12-07 13:10 ` Eli Zaretskii
2024-12-21 9:12 ` Eli Zaretskii
2024-12-21 15:10 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=jwv5xndgjw8.fsf-monnier+emacs@gnu.org \
--to=bug-gnu-emacs@gnu.org \
--cc=73872@debbugs.gnu.org \
--cc=eliz@gnu.org \
--cc=monnier@iro.umontreal.ca \
--cc=sigurddam@hotmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).