From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: =?UTF-8?Q?K=C3=A9vin?= Le Gouguec Newsgroups: gmane.emacs.bugs Subject: bug#59141: 28.1.90; Face :extend when all the line but trailing \n is invisible Date: Mon, 14 Nov 2022 23:22:11 +0100 Message-ID: <87cz9prxbg.fsf@gmail.com> References: <871qqcdfvr.fsf@localhost> <83h6z5psqe.fsf@gnu.org> <83bkpdpf92.fsf@gnu.org> <8335app826.fsf@gnu.org> <831qq9p7b7.fsf@gnu.org> <87bkpc4e06.fsf@gmail.com> <865yfkoz1n.fsf@mail.linkov.net> <87mt8vnn6h.fsf@gmail.com> <86leoebv1q.fsf@mail.linkov.net> <87leoev6j0.fsf@gmail.com> <864jv26l0g.fsf@mail.linkov.net> <87zgctajf5.fsf@gmail.com> <86fsely0q3.fsf@mail.linkov.net> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="22839"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: 59141@debbugs.gnu.org, Eli Zaretskii , Abdul-Lateef Haji-Ali , yantar92@posteo.net To: Juri Linkov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Nov 15 01:50:35 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ouk9r-0005ie-LD for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 15 Nov 2022 01:50:35 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ouifD-0005SB-CN; Mon, 14 Nov 2022 18:14:51 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ouidy-0001eb-GY for bug-gnu-emacs@gnu.org; Mon, 14 Nov 2022 18:13:34 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ouhr5-0007Gu-HP for bug-gnu-emacs@gnu.org; Mon, 14 Nov 2022 17:23:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ouhr4-0006wh-CU for bug-gnu-emacs@gnu.org; Mon, 14 Nov 2022 17:23:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: =?UTF-8?Q?K=C3=A9vin?= Le Gouguec Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 14 Nov 2022 22:23:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 59141 X-GNU-PR-Package: emacs Original-Received: via spool by 59141-submit@debbugs.gnu.org id=B59141.166846454226638 (code B ref 59141); Mon, 14 Nov 2022 22:23:02 +0000 Original-Received: (at 59141) by debbugs.gnu.org; 14 Nov 2022 22:22:22 +0000 Original-Received: from localhost ([127.0.0.1]:50928 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ouhqP-0006vZ-8w for submit@debbugs.gnu.org; Mon, 14 Nov 2022 17:22:21 -0500 Original-Received: from mail-wm1-f54.google.com ([209.85.128.54]:36659) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ouhqM-0006vJ-Up for 59141@debbugs.gnu.org; Mon, 14 Nov 2022 17:22:19 -0500 Original-Received: by mail-wm1-f54.google.com with SMTP id c3-20020a1c3503000000b003bd21e3dd7aso11805790wma.1 for <59141@debbugs.gnu.org>; Mon, 14 Nov 2022 14:22:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:user-agent:message-id:date :references:in-reply-to:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=pO3kNral0bSCIfHWmJKPXOV0erBFAecmIXzBuuvvAhM=; b=bbrJydRJ8np0OZGLPfz9T+q11SOBPiz3BaTLYkXHOb1TrFlUZWgDg4VdxuSHY2dFwg jdO7gsjgP8YdSH6lV5q3LskNDDL7UpxkG0wd984AAxg34vogiltG6rWFduJSve9CfqYM chcUPEdvMHyYisD+MfT65TGEGrWqo4RKmE2R6aqTFIGHPcYrdKWvtwhYz2mII7NqtBf6 b/7mZnx2w6rX85wLKpRj3KKBOmzsrB5W55fJ2fqEbq9drYQ/xf5o7M5nmEEGuRJMOkti DWEyAUUXfaVWKB3LBNILnezzcU2fgUnA39iJ+PJ3sAGFV4t4FtZXlRzfIxgBxAX+93ne UKUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:user-agent:message-id:date :references:in-reply-to:subject:cc:to:from:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=pO3kNral0bSCIfHWmJKPXOV0erBFAecmIXzBuuvvAhM=; b=LcmLIf8ruaul9RGshXdE6zcKUTSJJfAYU2D2WILEjfovXbZFU9MLwghI/IrPlW1Bis TuJ75eU2bAjKK6n/SgPoBpm5QiKqMAalyhF3mmg2TLU/xOIyAUGX9UCx7bP2rzvAtuu1 Bxz11Na6wfeqzdh1YLi7wjQV6ZU+4xWZdc8ZcMY1zstOtzK4jDarfx+7oYkVc09QeoFC ykJYnd3ECpj6qcuZRT7/H5Ryn5It79vltKSCzc9AyPIK0gfkiG5hwR/6hEN26ghHIdCm Cl2TThfnI/70KX++dptitzNQniKOiRBYfp7CoXNIhRt9KE6nlaVlfrfa+dJC2MS+LWfG fe5A== X-Gm-Message-State: ANoB5pmhkC8UssHCY6184uBicphU9APYs6Ws873GBcY99fVMc5CuNhyt oJ3ZyruR+QeDUcD2p3aR1e8= X-Google-Smtp-Source: AA0mqf4DtwO26Wa0zUNS5Q49StreohiVU0nwNCc5dfIStDPafYCjn34Iu5UijxJ/BYg67R0GJmymrQ== X-Received: by 2002:a05:600c:4896:b0:3cf:a627:e660 with SMTP id j22-20020a05600c489600b003cfa627e660mr9452105wmp.128.1668464532907; Mon, 14 Nov 2022 14:22:12 -0800 (PST) Original-Received: from amdahl30 ([2a01:e0a:253:fe0:2ef0:5dff:fed2:7b49]) by smtp.gmail.com with ESMTPSA id ay19-20020a05600c1e1300b003c6bbe910fdsm23901115wmb.9.2022.11.14.14.22.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Nov 2022 14:22:12 -0800 (PST) In-Reply-To: <86fsely0q3.fsf@mail.linkov.net> (Juri Linkov's message of "Mon, 14 Nov 2022 19:32:04 +0200") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:247873 Archived-At: Juri Linkov writes: >> My point with this comparison is to show that an outline-like UI with >> :extended backgrounds is obviously possible; in my previous messages, I >> tried to highlight the relevant code in magit-section that handles >> delimiting section headings vs content and setting the overlays. >> >> I did that mainly FTR, so that Someone=E2=84=A2 with motivation and time= can see >> if outline.el could grow a user option to support a similar way to >> display outlines, thus solving the problem of :extended backgrounds. > > I haven't looked at the magit-section source code. I once tried > to copy the syntax highlighting code from diff-mode to magit-diff, > but magit code is such a mess that I abandoned the attempt. > > But from your screenshots it's clear what is needed to do > to achieve the same in outline(-minor)-mode: I don't think I found anything particularly messy about magit-section, but piecing together the logic responsible for delimiting section headings and content certainly took me enough time that I felt it was worth summarizing. Glad the screenshots helped. > 3. Your screenshot shows that magit doesn't use an ellipsis. > And indeed, ellipses get in the way. But we need to find a way > to disable them without breaking this feature. The line > > (overlay-put o 'invisible 'outline) > > either should be replaced with > > (overlay-put o 'invisible t) > > or the ellipsis glyph to be disabled with something like: > > (or standard-display-table (setq standard-display-table (make-display-t= able))) > (set-char-table-extra-slot standard-display-table 4 (vector)) As I mentioned, magit supports replacing its fringe bitmaps with ellipses. See the magit-section-visibility-indicator user option, and the functions that act on it[1]. tl;dr the option can be set to * (SYMBOL1 . SYMBOL2): each symbol describes a fringe bitmap to be used for expandable (1) or collapsible (2) sections, * (STRING . BOOLEAN): STRING is appended at the end of collapsed sections. IIUC magit-section sets these ellipses via 'after-string overlays on the last character before a heading's newline, rather than adjusting display tables. Thanks for weighing in on how outline.el could be adapted, Juri. Can't promise I'll be able to act on your advice and turn it into a patch anytime soon, but finally hashing out the implementation details between these two packages has made me more hopeful outline.el can be taught more tricks without resorting to ugly hacks. [1] (defcustom magit-section-visibility-indicator (if (window-system) '(magit-fringe-bitmap> . magit-fringe-bitmapv) (cons (if (char-displayable-p ?=E2=80=A6) "=E2=80=A6" "...") t)) "Whether and how to indicate that a section can be expanded/collapsed. If nil, then don't show any indicators. Otherwise the value has to have one of these two forms: \(EXPANDABLE-BITMAP . COLLAPSIBLE-BITMAP) Both values have to be variables whose values are fringe bitmaps. In this case every section that can be expanded or collapsed gets an indicator in the left fringe. To provide extra padding around the indicator, set `left-fringe-width' in `magit-mode-hook'. \(STRING . BOOLEAN) In this case STRING (usually an ellipsis) is shown at the end of the heading of every collapsed section. Expanded sections get no indicator. The cdr controls whether the appearance of these ellipsis take section highlighting into account. Doing so might potentially have an impact on performance, while not doing so is kinda ugly." :package-version '(magit-section . "3.0.0") :group 'magit-section :type '(choice (const :tag "No indicators" nil) (cons :tag "Use +- fringe indicators" (const magit-fringe-bitmap+) (const magit-fringe-bitmap-)) (cons :tag "Use >v fringe indicators" (const magit-fringe-bitmap>) (const magit-fringe-bitmapv)) (cons :tag "Use bold >v fringe indicators)" (const magit-fringe-bitmap-bold>) (const magit-fringe-bitmap-boldv)) (cons :tag "Use custom fringe indicators" (variable :tag "Expandable bitmap variable") (variable :tag "Collapsible bitmap variable")) (cons :tag "Use ellipses at end of headings" (string :tag "Ellipsis" "=E2=80=A6") (choice :tag "Use face kludge" (const :tag "Yes (potentially slow)" t) (const :tag "No (kinda ugly)" nil))))) (defun magit-section-maybe-update-visibility-indicator (section) (when (and magit-section-visibility-indicator (magit-section-content-p section)) (let* ((beg (oref section start)) (eoh (save-excursion (goto-char beg) (line-end-position)))) (cond ((symbolp (car-safe magit-section-visibility-indicator)) (let ((ov (magit--overlay-at beg 'magit-vis-indicator 'fringe))) (unless ov (setq ov (make-overlay beg eoh nil t)) (overlay-put ov 'evaporate t) (overlay-put ov 'magit-vis-indicator 'fringe)) (overlay-put ov 'before-string (propertize "fringe" 'display (list 'left-fringe (if (oref section hidden) (car magit-section-visibility-indicator) (cdr magit-section-visibility-indicator)) 'fringe))))) ((stringp (car-safe magit-section-visibility-indicator)) (let ((ov (magit--overlay-at (1- eoh) 'magit-vis-indicator 'eoh))) (cond ((oref section hidden) (unless ov (setq ov (make-overlay (1- eoh) eoh)) (overlay-put ov 'evaporate t) (overlay-put ov 'magit-vis-indicator 'eoh)) (overlay-put ov 'after-string (car magit-section-visibility-indicator))) (ov (delete-overlay ov))))))))) (defvar-local magit--ellipses-sections nil) (defun magit-section-maybe-paint-visibility-ellipses () ;; This is needed because we hide the body instead of "the body ;; except the final newline and additionally the newline before ;; the body"; otherwise we could use `buffer-invisibility-spec'. (when (stringp (car-safe magit-section-visibility-indicator)) (let* ((sections (append magit--ellipses-sections (setq magit--ellipses-sections (or (magit-region-sections) (list (magit-current-section)))))) (beg (--map (oref it start) sections)) (end (--map (oref it end) sections))) (when (region-active-p) ;; This ensures that the region face is removed from ellipses ;; when the region becomes inactive, but fails to ensure that ;; all ellipses within the active region use the region face, ;; because the respective overlay has not yet been updated at ;; this time. The magit-selection face is always applied. (push (region-beginning) beg) (push (region-end) end)) (setq beg (apply #'min beg)) (setq end (apply #'max end)) (dolist (ov (overlays-in beg end)) (when (eq (overlay-get ov 'magit-vis-indicator) 'eoh) (overlay-put ov 'after-string (propertize (car magit-section-visibility-indicator) 'font-lock-face (let ((pos (overlay-start ov))) (delq nil (nconc (--map (overlay-get it 'font-lock-face) (overlays-at pos)) (list (get-char-property pos 'font-lock-face)))))))))))) (defun magit-section-maybe-remove-visibility-indicator (section) (when (and magit-section-visibility-indicator (=3D (oref section content) (oref section end))) (dolist (o (overlays-in (oref section start) (save-excursion (goto-char (oref section start)) (1+ (line-end-position))))) (when (overlay-get o 'magit-vis-indicator) (delete-overlay o)))))