diff --git a/lisp/help.el b/lisp/help.el index 49394fea2cd..8b29a10e0cf 100644 --- a/lisp/help.el +++ b/lisp/help.el @@ -793,7 +793,6 @@ or a buffer name." (when describe-bindings-outline (setq-local outline-regexp ".*:$") - (setq-local outline-heading-end-regexp ":\n") (setq-local outline-level (lambda () 1)) (setq-local outline-minor-mode-cycle t outline-minor-mode-highlight t diff --git a/lisp/outline.el b/lisp/outline.el index 61e9b0f3289..9d453881b7e 100644 --- a/lisp/outline.el +++ b/lisp/outline.el @@ -259,14 +259,19 @@ non-nil and point is located on the heading line.") map)) (defvar outline-font-lock-keywords - '( + `( ;; Highlight headings according to the level. (eval . (list (or (when outline-search-function - (lambda (limit) - (when-let* ((ret (funcall outline-search-function limit))) - ;; This is equivalent to adding ".*" in the regexp below. - (set-match-data (list (match-beginning 0) (pos-eol))) - ret))) + ,(lambda (limit) + (when-let* ((ret (funcall outline-search-function limit))) + ;; This is equivalent to adding ".*" in the regexp below. + (set-match-data + (list (match-beginning 0) + (save-excursion + (save-match-data + (re-search-forward + (concat ".*" outline-heading-end-regexp) nil t))))) + ret))) (concat "^\\(?:" outline-regexp "\\).*" outline-heading-end-regexp)) 0 '(if outline-minor-mode (if outline-minor-mode-highlight @@ -520,11 +525,16 @@ outline font-lock faces to those of major mode." (save-excursion (goto-char (point-min)) (let ((regexp (unless outline-search-function - (concat "^\\(?:" outline-regexp "\\).*$")))) + (concat "^\\(?:" outline-regexp "\\).*" outline-heading-end-regexp)))) (while (if outline-search-function (when-let* ((ret (funcall outline-search-function))) ;; This is equivalent to adding ".*" in the regexp above. - (set-match-data (list (match-beginning 0) (pos-eol))) + (set-match-data + (list (match-beginning 0) + (save-excursion + (save-match-data + (re-search-forward + (concat ".*" outline-heading-end-regexp) nil t))))) ret) (re-search-forward regexp nil t)) (let ((overlay (make-overlay (match-beginning 0) (match-end 0))))