unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Matthias Meulien <orontee@gmail.com>
To: Juri Linkov <juri@linkov.net>
Cc: Lars Ingebrigtsen <larsi@gnus.org>, 51809@debbugs.gnu.org
Subject: bug#51809: 29.0.50; [PATCH] Support for outline default state in Diff buffers
Date: Mon, 14 Feb 2022 22:33:49 +0100	[thread overview]
Message-ID: <87sfslyvya.fsf@gmail.com> (raw)
In-Reply-To: <871r0517jf.fsf@gmail.com> (Matthias Meulien's message of "Mon, 14 Feb 2022 22:07:32 +0100")

[-- Attachment #1: Type: text/plain, Size: 683 bytes --]

Matthias Meulien <orontee@gmail.com> writes:

> My first impression is that setting `outline-level' to
> `diff--outline-level' inconditionnaly should work but since I don't
> understand why `diff-outline-regex' hasn't been defined in terms of
> `diff-file-header-re' and `diff-hunk-header-re' I guess I am missing
> some subtleties.
>
> (Note that there's another minor bug when `diff-buffer-type` isn't equal
> to 'git: `diff--font-lock-prettify` should be a no-op since the regexp
> written there match only Git generated diffs, confirmed by the FIXME
> string "This has only been tested with Git's diff output." written in
> the implementation).

Here's the corresponding patch:


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Fix-computation-of-outline-heading-level-for-non-git.patch --]
[-- Type: text/x-diff, Size: 1471 bytes --]

From 4cf31f61caa50ba97e67847b175d598387fabba4 Mon Sep 17 00:00:00 2001
From: Matthias Meulien <orontee@gmail.com>
Date: Mon, 14 Feb 2022 22:29:49 +0100
Subject: [PATCH] Fix computation of outline heading level for non-git diff

* lisp/vc/diff-mode.el (diff-setup-buffer-type): Compute outline heading level
using diff-hunk-header-re.
(diff--font-lock-prettify): Disable prettify in non-git diff.
---
 lisp/vc/diff-mode.el | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/lisp/vc/diff-mode.el b/lisp/vc/diff-mode.el
index 0bf7899246..d0c05d3204 100644
--- a/lisp/vc/diff-mode.el
+++ b/lisp/vc/diff-mode.el
@@ -1596,8 +1596,8 @@ diff-setup-buffer-type
                   nil)))
   (when (eq diff-buffer-type 'git)
     (setq diff-outline-regexp
-          (concat "\\(^diff --git.*\n\\|" diff-hunk-header-re "\\)"))
-    (setq-local outline-level #'diff--outline-level))
+          (concat "\\(^diff --git.*\n\\|" diff-hunk-header-re "\\)")))
+  (setq-local outline-level #'diff--outline-level)
   (setq-local outline-regexp diff-outline-regexp))
 
 (defun diff-delete-if-empty ()
@@ -2599,7 +2599,8 @@ 'diff-fringe-nul
   nil nil 'center)
 
 (defun diff--font-lock-prettify (limit)
-  (when diff-font-lock-prettify
+  (when (and diff-font-lock-prettify
+             (eq diff-buffer-type 'git))
     (save-excursion
       ;; FIXME: Include the first space for context-style hunks!
       (while (re-search-forward "^[-+! ]" limit t)
-- 
2.30.2


[-- Attachment #3: Type: text/plain, Size: 85 bytes --]


Without this patch when I visit the reported woman.patch file I see the
following:


[-- Attachment #4: without_patch.png --]
[-- Type: image/png, Size: 4681 bytes --]

[-- Attachment #5: Type: text/plain, Size: 28 bytes --]


but with the patch I see:


[-- Attachment #6: with_patch.png --]
[-- Type: image/png, Size: 67278 bytes --]

[-- Attachment #7: Type: text/plain, Size: 14 bytes --]


-- 
Matthias

  parent reply	other threads:[~2022-02-14 21:33 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-13 13:04 bug#51809: 29.0.50; [PATCH] Support for outline default state in Diff buffers Matthias Meulien
2021-11-13 17:45 ` Juri Linkov
2021-11-13 18:08   ` Matthias Meulien
2021-11-13 18:27     ` Juri Linkov
2021-11-13 18:41     ` Matthias Meulien
2021-11-13 19:29       ` Juri Linkov
2021-11-13 21:27         ` Matthias Meulien
2021-11-13 23:29         ` Matthias Meulien
2021-11-29 17:06           ` Juri Linkov
2021-11-30 19:33             ` Matthias Meulien
2021-12-11 18:18             ` Matthias Meulien
2021-12-12  8:43               ` Juri Linkov
2021-12-13  7:55                 ` Matthias Meulien
2021-12-13  8:58                   ` Juri Linkov
2021-12-26 16:05                   ` Matthias Meulien
2021-12-26 16:21                     ` Eli Zaretskii
2021-12-26 19:19                       ` Matthias Meulien
2021-12-26 20:32                     ` Matthias Meulien
2021-12-26 20:55                       ` Matthias Meulien
2021-12-27 19:52                         ` Juri Linkov
2021-12-28 18:37                         ` Juri Linkov
2021-12-28 21:46                           ` Matthias Meulien
2021-12-28 22:28                           ` Matthias Meulien
2022-01-11 17:46                             ` Juri Linkov
2022-01-14 16:41                               ` Matthias Meulien
2022-01-16 18:14                                 ` Juri Linkov
2022-01-17 21:10                                 ` Matthias Meulien
2022-01-29 19:12                                   ` Juri Linkov
2022-02-05 18:45                                   ` Juri Linkov
2022-02-05 22:00                                     ` Lars Ingebrigtsen
2022-02-12 17:09                                       ` Juri Linkov
2022-02-12 17:26                                         ` Matthias Meulien
2022-02-14 21:07                                         ` Matthias Meulien
2022-02-14 21:13                                           ` Matthias Meulien
2022-02-14 21:33                                           ` Matthias Meulien [this message]
2022-02-14 21:39                                             ` Matthias Meulien
2022-02-16 19:20                                             ` Juri Linkov
2021-12-28 18:32                     ` Juri Linkov
2021-12-28 21:45                       ` Matthias Meulien
2021-11-14 18:25     ` Juri Linkov
2021-11-14 19:35       ` Matthias Meulien
2021-11-14 19:46         ` Juri Linkov
2021-11-14 19:54       ` Matthias Meulien
2021-11-14 20:31         ` Juri Linkov
2021-12-28  8:09 ` Matthias Meulien

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=87sfslyvya.fsf@gmail.com \
    --to=orontee@gmail.com \
    --cc=51809@debbugs.gnu.org \
    --cc=juri@linkov.net \
    --cc=larsi@gnus.org \
    /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).