all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Kévin Le Gouguec" <kevin.legouguec@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 59141@debbugs.gnu.org, yantar92@posteo.net,
	Abdul-Lateef Haji-Ali <abdo.haji.ali@gmail.com>,
	juri@linkov.net
Subject: bug#59141: 28.1.90; Face :extend when all the line but trailing \n is invisible
Date: Sat, 12 Nov 2022 12:18:49 +0100	[thread overview]
Message-ID: <87bkpc4e06.fsf@gmail.com> (raw)
In-Reply-To: <831qq9p7b7.fsf@gnu.org> (Eli Zaretskii's message of "Fri, 11 Nov 2022 22:25:32 +0200")

Eli Zaretskii <eliz@gnu.org> writes:

> You are basically suggesting to hide the entire buffer text and
> instead display something else via display properties.  That's not
> what outline modes do.
>
> The solution to this problem is simple: don't use the :extend
> attribute for these faces.  That's all.  This attribute is not
> intended for what you want to achieve here.  A whole bunch of problems
> automatically gets resolved if you don't use :extend.

Can't speak to what :extend is intended for, but I think it's worth
noting that magit-section successfully combines overlays with :extend to
do exactly what outline.el does (a hierarchy of collapsable buffer
sections), without the problem under discussion.

If someone came up with a patch to allow outline.el to delimit and hide
sections using a logic closer to magit-section's[1] (via an opt-in
variable, to be set e.g. by major modes, so that users happy with the
status quo are not affected), would that patch be given any
consideration?

Asking because OT1H, it seems to me that this kind of change would be on
par with Juri's proposed outline-search-function in bug#53981, i.e. an
opt-in change to a core part of outline.el's design; OTOH the above
sounds quite final, so I don't want to waste anyone's time.


[1] Here are the relevant parts AFAIU, based on a cursory exploration.

Obviously nothing can be ported verbatim to outline.el: e.g. the eieio
idioms are not suited, neither are the parts that manipulate buffer
content directly (like magit-diff-wash-hunk deleting then re-inserting
the hunk heading).

Still, I'm hopeful we could teach outline.el the logic of where headings
end and content starts, and how to set overlays to hide the latter.

* magit-section.el:

(defclass magit-section ()
  ([…]
   (start    :initform nil :initarg :start)
   (content  :initform nil)
   (end      :initform nil)
   […]))

(defun magit-section-hide (section)
  "Hide the body of the current section."
  (interactive (list (magit-current-section)))
  (if (eq section magit-root-section)
      (user-error "Cannot hide root section")
    (oset section hidden t)
    (when-let ((beg (oref section content)))
      (let ((end (oref section end)))
        (when (< beg (point) end)
          (goto-char (oref section start)))
        (remove-overlays beg end 'invisible t)
        (let ((o (make-overlay beg end)))
          (overlay-put o 'evaporate t)
          (overlay-put o 'invisible t))))
    […]))

(defmacro magit-insert-section (&rest args)
  "Insert a section at point.
[…]"
  […]
                         :start (point-marker)
  […])

* magit-diff.el:

(defun magit-diff-wash-hunk ()
  (when (looking-at "^@\\{2,\\} \\(.+?\\) @\\{2,\\}\\(?: \\(.*\\)\\)?")
    (let* ((heading  (match-string 0))
           (ranges   (mapcar
                      (lambda (str)
                        (let ((range
                               (mapcar #'string-to-number
                                       (split-string (substring str 1) ","))))
                          ;; A single line is +1 rather than +1,1.
                          (if (length= range 1)
                              (nconc range (list 1))
                            range)))
                      (split-string (match-string 1))))
           (about    (match-string 2))
           (combined (length= ranges 3))
           (value    (cons about ranges)))
      (magit-delete-line)
      (magit-insert-section section (hunk value)
        (insert (propertize (concat heading "\n")
                            'font-lock-face 'magit-diff-hunk-heading))
        (magit-insert-heading)
        (while (not (or (eobp) (looking-at "^[^-+\s\\]")))
          (forward-line))
        (oset section end (point))
        (oset section washer #'magit-diff-paint-hunk)
        (oset section combined combined)
        […]))
    t))

JS-less, text/plain references:

https://raw.githubusercontent.com/magit/magit/master/lisp/magit-section.el
https://raw.githubusercontent.com/magit/magit/master/lisp/magit-diff.el





  reply	other threads:[~2022-11-12 11:18 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-09  2:24 bug#59141: 28.1.90; Face :extend when all the line but trailing \n is invisible Ihor Radchenko
2022-11-09  7:49 ` Kévin Le Gouguec
2022-11-09 12:36   ` Eli Zaretskii
2022-11-09 17:12   ` Juri Linkov
2022-11-10  1:36     ` Ihor Radchenko
2022-11-10  7:45       ` Juri Linkov
2022-11-11  1:58         ` Ihor Radchenko
2022-11-11  7:46           ` Eli Zaretskii
2022-11-12 12:44             ` Ihor Radchenko
2022-11-11  8:13           ` Juri Linkov
2022-11-13  4:31             ` Ihor Radchenko
2022-11-11 12:30           ` Al Haji-Ali
2022-11-11 12:42             ` Eli Zaretskii
2022-11-11 16:00               ` Al Haji-Ali
2022-11-11 17:34                 ` Eli Zaretskii
2022-11-11 19:47                   ` Abdul-Lateef Haji-Ali
2022-11-11 20:09                     ` Eli Zaretskii
2022-11-11 20:17                       ` Abdul-Lateef Haji-Ali
2022-11-11 20:25                         ` Eli Zaretskii
2022-11-12 11:18                           ` Kévin Le Gouguec [this message]
2022-11-12 17:46                             ` Juri Linkov
2022-11-13 10:50                               ` Kévin Le Gouguec
2022-11-13 17:53                                 ` Juri Linkov
2022-11-13 22:22                                   ` Kévin Le Gouguec
2022-11-14  7:43                                     ` Juri Linkov
2022-11-14 11:02                                       ` Kévin Le Gouguec
2022-11-14 17:32                                         ` Juri Linkov
2022-11-14 17:44                                           ` Eli Zaretskii
2022-11-15  8:02                                             ` Juri Linkov
2022-11-15 14:42                                               ` Eli Zaretskii
2022-11-15 15:01                                                 ` Ihor Radchenko
2022-11-15 15:05                                                   ` Eli Zaretskii
2022-11-16  1:38                                                     ` Ihor Radchenko
2022-11-16 13:01                                                       ` Eli Zaretskii
2022-11-20 18:42                                                       ` Juri Linkov
2022-11-14 22:22                                           ` Kévin Le Gouguec
2022-11-20 18:38                                             ` Juri Linkov
2022-11-22  7:52                                               ` Juri Linkov
2022-11-22 15:02                                                 ` Eli Zaretskii
2022-11-22 17:35                                                   ` Juri Linkov
2022-11-22 18:42                                                     ` Eli Zaretskii
2022-11-22 19:16                                                       ` Juri Linkov
2022-11-22 19:36                                                         ` Eli Zaretskii
2022-11-12 17:52                           ` Juri Linkov
2022-11-12 18:31                             ` Eli Zaretskii
2024-01-25 22:53   ` Ihor Radchenko
2024-01-26  7:08     ` Eli Zaretskii
2024-01-26  7:08       ` bug#52587: " Eli Zaretskii
2022-11-09 12:29 ` Eli Zaretskii
2022-11-09 22:19   ` Kévin Le Gouguec
2022-11-10  7:10     ` Eli Zaretskii
2022-11-10 23:41       ` Kévin Le Gouguec

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87bkpc4e06.fsf@gmail.com \
    --to=kevin.legouguec@gmail.com \
    --cc=59141@debbugs.gnu.org \
    --cc=abdo.haji.ali@gmail.com \
    --cc=eliz@gnu.org \
    --cc=juri@linkov.net \
    --cc=yantar92@posteo.net \
    /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 external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.