unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Juri Linkov <juri@linkov.net>
To: Matthias Meulien <orontee@gmail.com>
Cc: 51809@debbugs.gnu.org
Subject: bug#51809: 29.0.50; [PATCH] Support for outline default state in Diff buffers
Date: Mon, 29 Nov 2021 19:06:40 +0200	[thread overview]
Message-ID: <86y256uc0v.fsf@mail.linkov.net> (raw)
In-Reply-To: <878rxrmy7q.fsf@gmail.com> (Matthias Meulien's message of "Sun, 14 Nov 2021 00:29:13 +0100")

Hi Matthias,

> Updated patch that takes Juri comments into account.

I didn't forget about your patch.  Actually, I have been using it all the time,
and it saved me in many cases when long lines in diffs make Emacs unresponsive.
With your patch, there are only slight delays for 2-3 seconds while scrolling
a lot of hidden outlines, but this is not a problem, thank you very much.

I have the same problem of too long outline-body lines in xref buffers,
so need to use a similar feature with:

#+begin_src emacs-lisp
(add-hook 'xref-after-update-hook
          (lambda ()
            (setq-local outline-regexp (if (eq xref-file-name-display 'abs)
                                           "/" "[^ 0-9]"))
            (outline-minor-mode +1)
            (outline-map-region
             (lambda ()
               (when (string-match-p "ChangeLog\\|test/manual/etags"
                                     (buffer-substring
                                      (line-beginning-position)
                                      (line-end-position)))
                 (outline-hide-entry)))
             (point-min) (point-max))))
#+end_src

It would be nice to move this feature completely to outline.el,
so it could be used by other modes, not only in diff-mode.
Please see bug#49731 that will be closed after this feature
will be supported generally by outline-minor-mode.

Then there are two variants: to add customizable variables
to outline-minor-mode like outline-default-state or
outline-hide-initial, or allow hiding initial heading
with a hook like

  (add-hook 'outline-minor-mode-hook 'outline-hide-file-headings)

that could use a regexp from e.g. outline-hide-heading-regexp
or some better name.

> +(defun outline-map-sublevel-overlay (level fun)

Instead of adding a new function, you can use outline-map-region
after adding a new argument, e.g.

  (defun outline-map-region (fun beg end &optional next-heading-fun)

By default, outline-map-region uses outline-next-heading to move to the
next heading, but a new argument could allow to use
outline-next-visible-heading or outline-forward-same-level, etc.
with (or (and next-heading-fun (funcall next-heading-fun)) (outline-next-heading))

> +(defcustom diff-outline-file-heading-regexp "ChangeLog\\|package-lock\\.json"

There is no need to add arbitrary default values.
The users know better what values are needed.
For example, I customized it to "public/packs",
so it hides the outline headings for compiled assets like:
"public/packs-pro/js/application-fa9d8202220130e40f46.js"

> +(defun diff-outline-apply-default-state ()
> +  (when diff-outline-default-state
> +    (when (not outline-minor-mode)
> +      (outline-minor-mode))

Actually, the above lines are not needed because the same can be achieved by:

  (add-hook 'diff-mode-hook 'outline-minor-mode)

> +    (cond
> +     ((eq diff-outline-default-state 'outline-hunks)
> +      (outline-hide-body))

These lines are not needed too, because the same can be achieved by:

  (add-hook 'outline-minor-mode-hook 'outline-hide-body)

> +     ((when (functionp diff-outline-default-state)
> +        (funcall diff-outline-default-state))))))

And this can be achieved by:

  (add-hook 'outline-minor-mode-hook 'custom-function)

> +(defun diff--outline-set-file-heading-visibility (overlay)
> +  (cond
> +   ((and
> +     (memq 'file-heading-regexp
> +           diff-outline-default-state)
> +     (string-match-p
> +      diff-outline-file-heading-regexp
> +      (match-string 0)))

Here (match-string 0) is unusable in most values of outline-regexp
that don't contain the whole heading line.  A better way
to get the whole heading line usable in modes other than diff-mode
would be:

  (buffer-substring (line-beginning-position) (line-end-position))





  reply	other threads:[~2021-11-29 17:06 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 [this message]
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
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=86y256uc0v.fsf@mail.linkov.net \
    --to=juri@linkov.net \
    --cc=51809@debbugs.gnu.org \
    --cc=orontee@gmail.com \
    /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).