[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/git-commit 4de514b84c 07/18: magit-section-content-p: New
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/git-commit 4de514b84c 07/18: magit-section-content-p: New function |
Date: |
Fri, 25 Mar 2022 13:58:20 -0400 (EDT) |
branch: elpa/git-commit
commit 4de514b84cfe45d5847f2b26dae9600bcdfbf63e
Author: Jonas Bernoulli <jonas@bernoul.li>
Commit: Jonas Bernoulli <jonas@bernoul.li>
magit-section-content-p: New function
---
docs/magit-section.org | 4 +++
docs/magit-section.texi | 4 +++
lisp/magit-section.el | 81 +++++++++++++++++++++++++------------------------
3 files changed, 50 insertions(+), 39 deletions(-)
diff --git a/docs/magit-section.org b/docs/magit-section.org
index 292512887f..ce8d47b134 100644
--- a/docs/magit-section.org
+++ b/docs/magit-section.org
@@ -184,6 +184,10 @@ source for suitable examples before asking me for help.
Thanks!
Return the lineage of SECTION.
The return value has the form ~(TYPE...)~.
+- Function: magit-section-content-p section ::
+
+ Return non-nil if SECTION has content or an unused washer function.
+
* Matching Functions
- Function: magit-section-match condition &optional (section
(magit-current-section)) ::
diff --git a/docs/magit-section.texi b/docs/magit-section.texi
index 05d22b1f97..9fb8a09546 100644
--- a/docs/magit-section.texi
+++ b/docs/magit-section.texi
@@ -230,6 +230,10 @@ Return the lineage of SECTION@.
The return value has the form @code{(TYPE...)}.
@end defun
+@defun magit-section-content-p section
+Return non-nil if SECTION has content or an unused washer function.
+@end defun
+
@node Matching Functions
@chapter Matching Functions
diff --git a/lisp/magit-section.el b/lisp/magit-section.el
index 89b75e4eb9..519550928d 100644
--- a/lisp/magit-section.el
+++ b/lisp/magit-section.el
@@ -722,6 +722,11 @@ hidden."
(and (oref section content)
(oref section hidden))))
+(defun magit-section-content-p (section)
+ "Return non-nil if SECTION has content or an unused washer function."
+ (with-slots (content end washer) section
+ (and content (or (not (= content end)) washer))))
+
(defun magit-section-invisible-p (section)
"Return t if the SECTION's body is invisible.
When the body of an ancestor of SECTION is collapsed then
@@ -1445,45 +1450,43 @@ invisible."
(magit-section-cache-visibility section)))
(defun magit-section-maybe-update-visibility-indicator (section)
- (when magit-section-visibility-indicator
- (let ((beg (oref section start))
- (cnt (oref section content))
- (end (oref section end)))
- (when (and cnt (or (not (= cnt end)) (oref section washer)))
- (let ((eoh (save-excursion
- (goto-char beg)
- (line-end-position))))
- (cond
- ((symbolp (car-safe magit-section-visibility-indicator))
- ;; It would make more sense to put the overlay only on the
- ;; location we actually don't put it on, but then inserting
- ;; before that location (while taking care not to mess with
- ;; the overlay) would cause the fringe bitmap to disappear
- ;; (but not other effects of the overlay).
- (let ((ov (magit--overlay-at (1+ beg) 'magit-vis-indicator
'fringe)))
- (unless ov
- (setq ov (make-overlay (1+ beg) eoh))
- (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)))))))))))
+ (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))
+ ;; It would make more sense to put the overlay only on the
+ ;; location we actually don't put it on, but then inserting
+ ;; before that location (while taking care not to mess with
+ ;; the overlay) would cause the fringe bitmap to disappear
+ ;; (but not other effects of the overlay).
+ (let ((ov (magit--overlay-at (1+ beg) 'magit-vis-indicator 'fringe)))
+ (unless ov
+ (setq ov (make-overlay (1+ beg) eoh))
+ (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)
- [nongnu] elpa/git-commit 94aca04dc8 02/18: magit-module-section: Use correct keymap, (continued)
- [nongnu] elpa/git-commit 94aca04dc8 02/18: magit-module-section: Use correct keymap, ELPA Syncer, 2022/03/25
- [nongnu] elpa/git-commit 70b34f08ab 03/18: Increase use of section type, keymap and binding inheritance, ELPA Syncer, 2022/03/25
- [nongnu] elpa/git-commit be371711f5 06/18: magit-section-at: New function, ELPA Syncer, 2022/03/25
- [nongnu] elpa/git-commit 949b4a47a4 10/18: magit-mouse-toggle-section: New command, ELPA Syncer, 2022/03/25
- [nongnu] elpa/git-commit 5641d3749c 12/18: Completely rework magit-mode-menu, ELPA Syncer, 2022/03/25
- [nongnu] elpa/git-commit 0168be9366 14/18: Add basic context-menu, ELPA Syncer, 2022/03/25
- [nongnu] elpa/git-commit 38cb9372dc 17/18: Add section-specific context-menus, ELPA Syncer, 2022/03/25
- [nongnu] elpa/git-commit f3afc117c2 18/18: Bump dependencies on Melpa, ELPA Syncer, 2022/03/25
- [nongnu] elpa/git-commit 91ef0822d3 04/18: magit-get-section: Compare constant values, ELPA Syncer, 2022/03/25
- [nongnu] elpa/git-commit 8c53997121 05/18: magit-section-ident-value: Split up into more methods, ELPA Syncer, 2022/03/25
- [nongnu] elpa/git-commit 4de514b84c 07/18: magit-section-content-p: New function,
ELPA Syncer <=
- [nongnu] elpa/git-commit 8eb43f8b23 13/18: Store keymap detected based on name in section object, ELPA Syncer, 2022/03/25
- [nongnu] elpa/git-commit bc065246b4 01/18: Remove duplicated command magit-help, ELPA Syncer, 2022/03/25
- [nongnu] elpa/git-commit 5da6122160 08/18: magit-section-mode-map: Add docstring, ELPA Syncer, 2022/03/25
- [nongnu] elpa/git-commit 73a2cbe61f 09/18: magit-section-heading-map: New keymap, ELPA Syncer, 2022/03/25
- [nongnu] elpa/git-commit 7d15b1a041 11/18: magit-diff--region-range: New function, ELPA Syncer, 2022/03/25
- [nongnu] elpa/git-commit b7294344e3 15/18: Add context-menu utilities, ELPA Syncer, 2022/03/25
- [nongnu] elpa/git-commit 95b432530a 16/18: Do not set point when invoking context-menu, ELPA Syncer, 2022/03/25