]> git.eshelyaron.com Git - emacs.git/commitdiff
Use 'outline-heading-end-regexp' consistently.
authorJuri Linkov <juri@linkov.net>
Thu, 29 May 2025 16:52:20 +0000 (19:52 +0300)
committerEshel Yaron <me@eshelyaron.com>
Sat, 7 Jun 2025 19:53:18 +0000 (21:53 +0200)
* lisp/outline.el (outline-font-lock-keywords):
For non-nil 'outline-search-function' also search for
'outline-heading-end-regexp' afterwards like there is
'outline-heading-end-regexp' at the end of the regexp counterpart.
(outline-minor-mode-highlight-buffer): Use 'outline-heading-end-regexp'
like in 'outline-font-lock-keywords' instead of "$".
For non-nil 'outline-search-function' also use
'outline-heading-end-regexp' the same way.

* lisp/help.el (describe-bindings): Remove unnecessary
buffer-local 'outline-heading-end-regexp'.

(cherry picked from commit c9cb89edd500e8a142a7e7cc44a4f8335795d038)

lisp/help.el
lisp/outline.el

index 213b5de4c50570a9a90ca821617576bde09aae91..8e65ec19fe32f98b1874639419b61648ecbdc96d 100644 (file)
@@ -939,7 +939,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
index 9db47cdaf21a53095784a160bda9960142ebeefa..71aa33c8b0468dcea8f8f0379b9aba98f5cab460 100644 (file)
@@ -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))))