From 00fdf80e21909366fcba0eab84fe68c803a3a3eb Mon Sep 17 00:00:00 2001 From: Michalis V Date: Tue, 17 Aug 2021 14:20:57 +0200 Subject: [PATCH] Improve `forward-sexp' in *Help* buffers * lisp/help-mode.el (help-mode-syntax-table): New variable (bug#39134). (help-make-xrefs): Use it to make picking out symbols in curved quotes work reliably. (help-xref-on-pp): Ditto. --- lisp/help-mode.el | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/lisp/help-mode.el b/lisp/help-mode.el index e2d8ee0f591..b53d00d0fb8 100644 --- a/lisp/help-mode.el +++ b/lisp/help-mode.el @@ -140,6 +140,15 @@ The format is (FUNCTION ARGS...).") (setq-default help-xref-stack nil help-xref-stack-item nil) (setq-default help-xref-forward-stack nil help-xref-forward-stack-item nil) +(defvar help-mode-syntax-table + (let ((table (make-syntax-table emacs-lisp-mode-syntax-table))) + ;; treat single quotes as parens so that forward-sexp does not + ;; break when quoted string contains punctuation + (modify-syntax-entry ?‘ "(’ " table) + (modify-syntax-entry ?’ ")‘ " table) + table) + "Syntax table used in `help-mode'.") + (defcustom help-mode-hook nil "Hook run by `help-mode'." :type 'hook @@ -520,7 +529,7 @@ that." (let ((stab (syntax-table)) (case-fold-search t) (inhibit-read-only t)) - (set-syntax-table emacs-lisp-mode-syntax-table) + (set-syntax-table help-mode-syntax-table) ;; The following should probably be abstracted out. (unwind-protect (progn @@ -673,7 +682,7 @@ See `help-make-xrefs'." (defun help-xref-on-pp (from to) "Add xrefs for symbols in `pp's output between FROM and TO." (if (> (- to from) 5000) nil - (with-syntax-table emacs-lisp-mode-syntax-table + (with-syntax-table help-mode-syntax-table (save-excursion (save-restriction (narrow-to-region from to) -- 2.39.2