GNU bug report logs - #78269
diff-outline-regexp

Previous Next

Package: emacs;

Reported by: Juri Linkov <juri <at> linkov.net>

Date: Mon, 5 May 2025 19:12:01 UTC

Severity: normal

Fixed in version 31.0.50

Done: Juri Linkov <juri <at> linkov.net>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Juri Linkov <juri <at> linkov.net>
Cc: 78269 <at> debbugs.gnu.org
Subject: bug#78269: diff-outline-regexp
Date: Mon, 05 May 2025 18:42:07 -0400
> diff --git a/lisp/vc/diff-mode.el b/lisp/vc/diff-mode.el
> index a5f4169a7f3..76703526b63 100644
> --- a/lisp/vc/diff-mode.el
> +++ b/lisp/vc/diff-mode.el
> @@ -1719,7 +1719,7 @@ diff-setup-buffer-type
>                        'hg
>                      nil))))
>    (when (eq diff-buffer-type 'git)
> -    (setq diff-outline-regexp
> +    (setq-local diff-outline-regexp
>            (concat "\\(^diff --git.*\\|" diff-hunk-header-re "\\)")))
>    (setq-local outline-level #'diff--outline-level)
>    (setq-local outline-regexp diff-outline-regexp))

LGTM, thanks.

> Probably no one noticed this problem because its current default value
> is not useful to anyone:
>
>   (defvar diff-outline-regexp
>     "\\([*+][*+][*+] [^0-9]\\|@@ ...\\|\\*\\*\\* [0-9].\\|--- [0-9]..\\)")

I think the idea was to recognize file header and hunk headers, in the
case where the "diff" command itself is absent (as is the case in the
output of the (non-recursive) `diff` command).

> Maybe the default should be replaced with something like
>
>   (defvar diff-outline-regexp
>     (concat "\\(^diff -.*\\|" diff-hunk-header-re "\\)"))

LGTM (I'd even drop the `-` after `diff`).  AFAICT nowadays the "diff
..." command is absent only in cases where there's only one file in the
diff, so matching the file header is not very useful, indeed.


        Stefan





This bug report was last modified 10 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.