update packages

This commit is contained in:
2025-06-22 17:08:08 +02:00
parent 54e5633369
commit 16a0a6db93
558 changed files with 68349 additions and 26568 deletions

View File

@@ -1,17 +1,13 @@
(define-package "magit-section" "20250307.1739" "Sections for read-only buffers"
'((emacs "27.1")
(compat "30.0.2.0")
(llama "0.6.1")
(seq "2.24"))
:commit "3f79700f1b9a6f5f6fd6a77fd1e812c1b8e6463b" :authors
'(("Jonas Bernoulli" . "emacs.magit@jonas.bernoulli.dev"))
:maintainers
'(("Jonas Bernoulli" . "emacs.magit@jonas.bernoulli.dev"))
:maintainer
'("Jonas Bernoulli" . "emacs.magit@jonas.bernoulli.dev")
:keywords
'("tools")
:url "https://github.com/magit/magit")
;; Local Variables:
;; no-byte-compile: t
;; End:
;; -*- no-byte-compile: t; lexical-binding: nil -*-
(define-package "magit-section" "20250610.1522"
"Sections for read-only buffers."
'((emacs "27.1")
(compat "30.1")
(llama "0.6.3")
(seq "2.24"))
:url "https://github.com/magit/magit"
:commit "0daafe08149b406ca0bf200a1ed0a8e4b1c1054a"
:revdesc "0daafe08149b"
:keywords '("tools")
:authors '(("Jonas Bernoulli" . "emacs.magit@jonas.bernoulli.dev"))
:maintainers '(("Jonas Bernoulli" . "emacs.magit@jonas.bernoulli.dev")))

View File

@@ -8,11 +8,12 @@
;; Homepage: https://github.com/magit/magit
;; Keywords: tools
;; Package-Version: 4.3.1
;; Package-Version: 20250610.1522
;; Package-Revision: 0daafe08149b
;; Package-Requires: (
;; (emacs "27.1")
;; (compat "30.0.2.0")
;; (llama "0.6.1")
;; (compat "30.1")
;; (llama "0.6.3")
;; (seq "2.24"))
;; SPDX-License-Identifier: GPL-3.0-or-later
@@ -106,21 +107,8 @@ similar defect.")
(defvar magit-section-movement-hook nil
"Hook run by `magit-section-goto'.
That function in turn is used by all section movement commands.")
(defvar magit-section-highlight-hook
(list #'magit-section-highlight
#'magit-section-highlight-selection)
"Functions used to highlight the current section.
Each function is run with the current section as only argument
until one of them returns non-nil.")
(defvar magit-section-unhighlight-hook nil
"Functions used to unhighlight the previously current section.
Each function is run with the current section as only argument
until one of them returns non-nil. Most sections are properly
unhighlighted without requiring a specialized unhighlighter,
diff-related sections being the only exception.")
That function in turn is used by all section movement commands.
See also info node `(magit)Section Movement'.")
(defvar magit-section-set-visibility-hook
(list #'magit-section-cached-visibility)
@@ -137,6 +125,21 @@ hardcoded section specific default (see `magit-insert-section').")
:link '(info-link "(magit)Sections")
:group 'extensions)
(defcustom magit-section-highlight-current t
"Whether to highlight the current section."
:package-version '(magit-section . "4.3.6")
:group 'magit-section
:type 'boolean)
(defcustom magit-section-highlight-selection t
"Whether to highlight the selected sections.
If you disable this, you probably also want to disable
`magit-section-highlight-current' to get the region to
always look as it would be in non-magit buffers."
:package-version '(magit-section . "4.3.6")
:group 'magit-section
:type 'boolean)
(defcustom magit-section-show-child-count t
"Whether to append the number of children to section headings.
This only applies to sections for which doing so makes sense."
@@ -240,6 +243,8 @@ Otherwise the value has to have one of these two forms:
(defcustom magit-section-keep-region-overlay nil
"Whether to keep the region overlay when there is a valid selection.
We strongly suggest that you keep the default value, nil.
By default Magit removes the regular region overlay if, and only
if, that region constitutes a valid selection as understood by
Magit commands. Otherwise it does not remove that overlay, and
@@ -265,21 +270,10 @@ does *not* constitute a valid selection, then the region is
circumstances that you want to use a non-magit command to act on
the region.
Besides keeping the region overlay, setting this option to t also
causes all face properties, except for `:foreground', to be
ignored for the faces used to highlight headings of selected
sections. This avoids the worst conflicts that result from
displaying the region and the selection overlays at the same
time. We are not interested in dealing with other conflicts.
In fact we *already* provide a way to avoid all of these
conflicts: *not* changing the value of this option.
It should be clear by now that we consider it a mistake to set
this to display the region when the Magit selection is also
visualized, but since it has been requested a few times and
because it doesn't cost much to offer this option we do so.
However that might change. If the existence of this option
starts complicating other things, then it will be removed."
Depending on the used theme, the `magit-*-highlight-selection'
faces might conflict with the `region' face. If that happens and
it bothers you, then you have to customize these faces to address
the conflicts."
:package-version '(magit-section . "2.3.0")
:group 'magit-section
:type 'boolean)
@@ -315,12 +309,17 @@ no effect. This also has no effect for Emacs >= 28, where
(defvar-local magit-section-pre-command-section nil)
(defvar-local magit-section-highlight-force-update nil)
(defvar-local magit-section-highlight-overlays nil)
(defvar-local magit-section-highlighted-sections nil)
(defvar-local magit-section-unhighlight-sections nil)
(defvar-local magit-section-selection-overlays nil)
(defvar-local magit-section-highlighted-sections nil
"List of highlighted sections that may have to be repainted on focus change.")
(defvar-local magit-section-focused-sections nil)
(defvar-local magit-section-inhibit-markers nil)
(defvar-local magit-section-insert-in-reverse nil)
(defvar-local magit--refreshing-buffer-p nil
"Whether the current buffer is presently being refreshed.")
;;; Faces
(defgroup magit-section-faces nil
@@ -384,9 +383,12 @@ no effect. This also has no effect for Emacs >= 28, where
(content :initform nil)
(end :initform nil)
(hidden)
(painted)
(washer :initform nil :initarg :washer)
(inserter :initform (symbol-value 'magit--current-section-hook))
(selective-highlight :initform nil :initarg :selective-highlight)
(heading-highlight-face :initform nil :initarg :heading-highlight-face)
(heading-selection-face :initform nil :initarg :heading-selection-face)
(parent :initform nil)
(children :initform nil)))
@@ -587,10 +589,8 @@ instead of in the one whose root `magit-root-section' is."
(pcase-let ((`(,type . ,value) (car ident)))
(setq section
(cl-find-if
(lambda (section)
(and (eq (oref section type) type)
(equal (magit-section-ident-value section)
value)))
(##and (eq (oref % type) type)
(equal (magit-section-ident-value %) value))
(oref section children)))))
(pop ident))
section)))
@@ -635,11 +635,11 @@ with SECTION, otherwise return a list of section types."
(when-let (((not (oref section hidden)))
(children (oref section children)))
(when (seq-some #'magit-section-content-p children)
(when (seq-some (lambda (c) (oref c hidden)) children)
(when (seq-some (##oref % hidden) children)
(keymap-set-after menu "<magit-section-show-children>"
`(menu-item "Expand children"
magit-section-show-children)))
(when (seq-some (lambda (c) (not (oref c hidden))) children)
(when (seq-some (##not (oref % hidden)) children)
(keymap-set-after menu "<magit-section-hide-children>"
`(menu-item "Collapse children"
magit-section-hide-children)))))
@@ -869,7 +869,15 @@ If there is no previous sibling section, then move to the parent."
(magit-section-backward))
(magit-section-goto -1))))
(defun magit-mouse-set-point (event &optional promote-to-region)
"Like `mouse-set-point' but also call `magit-section-movement-hook'."
(interactive "e\np")
(mouse-set-point event promote-to-region)
(run-hook-with-args 'magit-section-movement-hook (magit-current-section)))
(defun magit-section-goto (arg)
"Run `magit-section-movement-hook'.
See info node `(magit)Section Movement'."
(if (integerp arg)
(progn (forward-line arg)
(setq arg (magit-current-section)))
@@ -894,11 +902,11 @@ With a prefix argument also expand it." heading)
,@(and (not (plist-member properties :description))
(list :description heading))
,@(and inserter
`(:if (lambda () (memq ',inserter
(bound-and-true-p magit-status-sections-hook)))))
:inapt-if-not (lambda () (magit-get-section
(cons (cons ',type ,value)
(magit-section-ident magit-root-section))))
`(:if (##memq ',inserter
(bound-and-true-p magit-status-sections-hook))))
:inapt-if-not (##magit-get-section
(cons (cons ',type ,value)
(magit-section-ident magit-root-section)))
(interactive "P")
(if-let ((section (magit-get-section
(cons (cons ',type ,value)
@@ -915,7 +923,8 @@ With a prefix argument also expand it." heading)
"Show the body of the current section."
(interactive (list (magit-current-section)))
(oset section hidden nil)
(magit-section--maybe-wash section)
(magit-section--opportunistic-wash section)
(magit-section--opportunistic-paint section)
(when-let ((beg (oref section content)))
(remove-overlays beg (oref section end) 'invisible t))
(magit-section-maybe-update-visibility-indicator section)
@@ -925,22 +934,6 @@ With a prefix argument also expand it." heading)
(magit-section-hide child)
(magit-section-show child))))
(defun magit-section--maybe-wash (section)
(when-let ((washer (oref section washer)))
(oset section washer nil)
(let ((inhibit-read-only t)
(magit-insert-section--parent section)
(magit-insert-section--current section)
(content (oref section content)))
(save-excursion
(if (and content (< content (oref section end)))
(funcall washer section) ; already partially washed (hunk)
(goto-char (oref section end))
(oset section content (point-marker))
(funcall washer)
(oset section end (point-marker)))))
(setq magit-section-highlight-force-update t)))
(defun magit-section-hide (section)
"Hide the body of the current section."
(interactive (list (magit-current-section)))
@@ -1032,6 +1025,8 @@ global map, this involves advising `tab-bar--define-keys'."
(eq (global-key-binding [C-tab]) 'tab-next)
(fboundp 'tab-bar-switch-to-next-tab))
(tab-bar-switch-to-next-tab current-prefix-arg))
((eq section magit-root-section)
(magit-section-cycle-global))
((oref section hidden)
(magit-section-show section)
(magit-section-hide-children section))
@@ -1055,7 +1050,14 @@ global map, this involves advising `tab-bar--define-keys'."
(t
(mapc #'magit-section-hide children)))))
(defun magit-section-hidden (section)
"Return t if SECTION and/or an ancestor is hidden."
(or (oref section hidden)
(and-let* ((parent (oref section parent)))
(magit-section-hidden parent))))
(defun magit-section-hidden-body (section &optional pred)
"Return t if the content of SECTION or of any children is hidden."
(if-let ((children (oref section children)))
(funcall (or pred #'seq-some) #'magit-section-hidden-body children)
(and (oref section content)
@@ -1076,8 +1078,10 @@ SECTION's body (and heading) obviously cannot be visible."
(defun magit-section-show-level (level)
"Show surrounding sections up to LEVEL.
If LEVEL is negative, show up to the absolute value.
Sections at higher levels are hidden."
Likewise hide sections at higher levels. If the region selects multiple
sibling sections, act on all marked trees. If LEVEL is negative, show
all sections up to the absolute value of that, not just surrounding
sections."
(if (< level 0)
(let ((s (magit-current-section)))
(setq level (- level))
@@ -1085,13 +1089,15 @@ Sections at higher levels are hidden."
(setq s (oref s parent))
(goto-char (oref s start)))
(magit-section-show-children magit-root-section (1- level)))
(cl-do* ((s (magit-current-section)
(oref s parent))
(i (1- (length (magit-section-ident s)))
(cl-decf i)))
((cond ((< i level) (magit-section-show-children s (- level i 1)) t)
((= i level) (magit-section-hide s) t))
(magit-section-goto s)))))
(dolist (section (or (magit-region-sections)
(list (magit-current-section))))
(cl-do* ((s section
(oref s parent))
(i (1- (length (magit-section-ident s)))
(cl-decf i)))
((cond ((< i level) (magit-section-show-children s (- level i 1)) t)
((= i level) (magit-section-hide s) t))
(magit-section-goto s))))))
(defun magit-section-show-level-1 ()
"Show surrounding sections on first level."
@@ -1458,9 +1464,7 @@ anything this time around.
(magit-map-sections
(lambda (section)
(oset section start (copy-marker (oref section start) t))
(oset section end (copy-marker (oref section end) t)))))
(let ((magit-section-cache-visibility nil))
(magit-section-show obj)))
(oset section end (copy-marker (oref section end) t))))))
(t
(magit-section--set-section-properties obj)
(magit-section-maybe-add-heading-map obj)
@@ -1580,7 +1584,7 @@ is explicitly expanded."
(defun magit-insert-headers (hook)
(let* ((header-sections nil)
(fn (lambda () (push magit-insert-section--current header-sections))))
(fn (##push magit-insert-section--current header-sections)))
(unwind-protect
(progn
(add-hook 'magit-insert-section-hook fn -90 t)
@@ -1667,8 +1671,23 @@ evaluated its BODY. Admittedly that's a bit of a hack."
(delete-char 1)
(insert (format "%s" count)))))))
(defun magit-section--opportunistic-wash (section)
(when-let ((washer (oref section washer)))
(oset section washer nil)
(let ((inhibit-read-only t)
(magit-insert-section--parent section)
(magit-insert-section--current section))
(save-excursion
(goto-char (oref section end))
(oset section content (point-marker))
(funcall washer)
(oset section end (point-marker))))
(setq magit-section-highlight-force-update t)))
;;; Highlight
(defvar magit-section--refreshed-buffers nil)
(defun magit-section-pre-command-hook ()
(when (and (or magit--context-menu-buffer
magit--context-menu-section)
@@ -1682,8 +1701,10 @@ evaluated its BODY. Admittedly that's a bit of a hack."
;; after the menu is aborted. Here we can only make sure it is
;; updated afterwards.
(magit-menu-highlight-point-section))
(setq magit-section--refreshed-buffers nil)
(setq magit-section-pre-command-region-p (region-active-p))
(setq magit-section-pre-command-section (magit-current-section)))
(setq magit-section-pre-command-section (magit-current-section))
(setq magit-section-focused-sections nil))
(defun magit-section-post-command-hook ()
(let ((window (selected-window)))
@@ -1694,112 +1715,166 @@ evaluated its BODY. Admittedly that's a bit of a hack."
(when (or magit--context-menu-buffer
magit--context-menu-section)
(magit-menu-highlight-point-section))))
(unless (memq this-command '(magit-refresh magit-refresh-all))
(magit-section-update-highlight)))
(unless (memq (current-buffer) magit-section--refreshed-buffers)
(magit-section-update-highlight))
(setq magit-section--refreshed-buffers nil))
(defun magit-section-deactivate-mark ()
(setq magit-section-highlight-force-update t))
(defun magit-section-update-highlight (&optional force)
(let ((section (magit-current-section)))
(when (or force
magit-section-highlight-force-update
(xor magit-section-pre-command-region-p (region-active-p))
(not (eq magit-section-pre-command-section section)))
(let ((section (magit-current-section))
(focused (magit-focused-sections)))
(cond
((or force
magit-section-highlight-force-update
(xor magit-section-pre-command-region-p (region-active-p))
(not (eq magit-section-pre-command-section section)))
(let ((inhibit-read-only t)
(deactivate-mark nil)
(selection (magit-region-sections)))
(mapc #'delete-overlay magit-section-highlight-overlays)
(mapc #'delete-overlay magit-section-selection-overlays)
(setq magit-section-highlight-overlays nil)
(setq magit-section-unhighlight-sections
magit-section-highlighted-sections)
(setq magit-section-highlighted-sections nil)
(if (and (fboundp 'long-line-optimizations-p)
(long-line-optimizations-p))
(magit-section--enable-long-lines-shortcuts)
(unless (eq section magit-root-section)
(run-hook-with-args-until-success
'magit-section-highlight-hook section selection))
(dolist (s magit-section-unhighlight-sections)
(run-hook-with-args-until-success
'magit-section-unhighlight-hook s selection)))
(setq magit-section-selection-overlays nil)
(cond ((magit-section--maybe-enable-long-lines-shortcuts))
((eq section magit-root-section))
((not magit-section-highlight-current)
(when selection
(magit-section-highlight-selection selection)))
((not selection)
(magit-section-highlight section))
(t
(mapc #'magit-section-highlight selection)
(magit-section-highlight-selection selection)))
(dolist (section (cl-union magit-section-highlighted-sections focused))
(when (slot-boundp section 'painted)
(magit-section-update-paint section focused)))
(restore-buffer-modified-p nil)))
((and (eq magit-section-pre-command-section section)
magit-section-selection-overlays
(region-active-p)
(not (magit-region-sections)))
(mapc #'delete-overlay magit-section-selection-overlays)
(setq magit-section-selection-overlays nil)))
(setq magit-section-highlight-force-update nil)
(magit-section-maybe-paint-visibility-ellipses)))
(defun magit-section-highlight (section selection)
"Highlight SECTION and if non-nil all sections in SELECTION.
This function works for any section but produces undesirable
effects for diff related sections, which by default are
highlighted using `magit-diff-highlight'. Return t."
(when-let ((face (oref section heading-highlight-face)))
(dolist (section (or selection (list section)))
(magit-section-make-overlay
(oref section start)
(or (oref section content)
(oref section end))
face)))
(cond (selection
(magit-section-make-overlay (oref (car selection) start)
(oref (car (last selection)) end)
'magit-section-highlight)
(magit-section-highlight-selection nil selection))
(t
(magit-section-make-overlay (oref section start)
(oref section end)
'magit-section-highlight)))
t)
(cl-defmethod magit-section-highlight ((section magit-section))
(pcase-let*
(((eieio start content end children heading-highlight-face) section)
(headlight heading-highlight-face)
(selective (magit-section-selective-highlight-p section)))
(cond
(selective
(magit-section-highlight-range start (or content end) headlight)
(cond (children
(let ((child-start (oref (car children) start)))
(when (and content (< content child-start))
(magit-section-highlight-range content child-start)))
(mapc #'magit-section-highlight children))
((and content (not (slot-boundp section 'painted)))
(magit-section-highlight-range content end))
;; Unfortunate kludge for delayed hunk refinement.
((magit-section--refine section))))
(headlight
(magit-section-highlight-range start (or content end) headlight)
(when content
(magit-section-highlight-range (if headlight content start) end)))
((magit-section-highlight-range start end)))))
(defun magit-section-highlight-selection (_ selection)
"Highlight the section-selection region.
If SELECTION is non-nil, then it is a list of sections selected by
the region. The headings of these sections are then highlighted.
(defun magit-section-highlight-selection (selection)
(when magit-section-highlight-selection
(dolist (sibling selection)
(with-slots (start content end heading-selection-face) sibling
(let ((ov (make-overlay start (or content end) nil t)))
(overlay-put ov 'font-lock-face
(or heading-selection-face
'magit-section-heading-selection))
(overlay-put ov 'evaporate t)
(overlay-put ov 'priority '(nil . 9))
(push ov magit-section-selection-overlays)
ov)))))
This is a fallback for people who don't want to highlight the
current section and therefore removed `magit-section-highlight'
from `magit-section-highlight-hook'.
This function is necessary to ensure that a representation of
such a region is visible. If neither of these functions were
part of the hook variable, then such a region would be
invisible."
(when (and selection
(not (and (eq this-command 'mouse-drag-region))))
(dolist (section selection)
(magit-section-make-overlay (oref section start)
(or (oref section content)
(oref section end))
'magit-section-heading-selection))
t))
(defun magit-section-make-overlay (start end face)
;; Yes, this doesn't belong here. But the alternative of
;; spreading this hack across the code base is even worse.
(when (and magit-section-keep-region-overlay
(memq face '(magit-section-heading-selection
magit-diff-file-heading-selection
magit-diff-hunk-heading-selection)))
(setq face (list :foreground (face-foreground face))))
(defun magit-section-highlight-range (start end &optional face)
(let ((ov (make-overlay start end nil t)))
(overlay-put ov 'font-lock-face face)
(overlay-put ov 'font-lock-face (or face 'magit-section-highlight))
(overlay-put ov 'evaporate t)
(push ov magit-section-highlight-overlays)
ov))
(defun magit-section-selective-highlight-p (section &optional as-child)
(or (oref section selective-highlight)
(and as-child
(oref section heading-highlight-face))
(slot-boundp section 'painted)
(and-let* ((children (oref section children)))
(magit-section-selective-highlight-p (car children) t))))
;;; Paint
(defun magit-section-update-paint (section focused-sections)
(cl-flet ((paint (highlight)
(let ((inhibit-read-only t))
(save-excursion
(goto-char (oref section start))
(magit-section-paint section highlight))))
(unregister ()
(setq magit-section-highlighted-sections
(delq section magit-section-highlighted-sections))))
(if (magit-section-hidden section)
;; If the section is highlighted but unfocused, it remains
;; highlighted, but `magit-section--opportunistic-paint' via
;; `magit-section-show' will unhighlight on expansion, and
;; before then (or if a refresh occurs first) it doesn't matter.
(unregister)
(pcase (list (if (memq section focused-sections) 'focus 'unfocus)
(oref section painted))
(`(focus ,(or 'nil 'plain))
(paint t)
(cl-pushnew section magit-section-highlighted-sections))
(`(focus highlight)
(cl-pushnew section magit-section-highlighted-sections))
(`(unfocus ,(or 'nil 'highlight))
(paint nil)
(unregister))
('(unfocus plain)
(unregister))))))
(cl-defmethod magit-section-paint ((section magit-section) _highlight)
(error "Slot `paint' bound but `magit-section-paint' not implemented for `%s'"
(eieio-object-class-name section)))
(defun magit-section--opportunistic-paint (section)
(when (and (not (oref section hidden))
(slot-boundp section 'painted))
(if magit--refreshing-buffer-p
;; Defer to `magit-section-update-highlight'.
(unless (oref section painted)
(cl-pushnew section magit-section-highlighted-sections))
(magit-section-update-paint section (magit-focused-sections)))))
(cl-defmethod magit-section--refine ((_section magit-section)))
;;; Long Lines
(defvar magit-show-long-lines-warning t)
(defun magit-section--enable-long-lines-shortcuts ()
(message "Enabling long lines shortcuts in %S" (current-buffer))
(kill-local-variable 'redisplay-highlight-region-function)
(kill-local-variable 'redisplay-unhighlight-region-function)
(when magit-show-long-lines-warning
(setq magit-show-long-lines-warning nil)
(display-warning 'magit (format "\
(defun magit-section--maybe-enable-long-lines-shortcuts ()
(and (fboundp 'long-line-optimizations-p)
(long-line-optimizations-p)
(prog1 t
(message "Enabling long lines shortcuts in %S" (current-buffer))
(kill-local-variable 'redisplay-highlight-region-function)
(kill-local-variable 'redisplay-unhighlight-region-function)
(when magit-show-long-lines-warning
(setq magit-show-long-lines-warning nil)
(display-warning 'magit (format "\
Emacs has enabled redisplay shortcuts
in this buffer because there are lines whose length go beyond
`long-line-threshold' \(%s characters). As a result, section
`long-line-threshold' (%s characters). As a result, section
highlighting and the special appearance of the region has been
disabled. Some existing highlighting might remain in effect.
disabled.
These shortcuts remain enabled, even once there no longer are
any long lines in this buffer. To disable them again, kill
@@ -1807,7 +1882,9 @@ and recreate the buffer.
This message won't be shown for this session again. To disable
it for all future sessions, set `magit-show-long-lines-warning'
to nil." (bound-and-true-p long-line-threshold)) :warning)))
to nil." (bound-and-true-p long-line-threshold)) :warning)))))
;;; Successor
(cl-defgeneric magit-section-get-relative-position (section))
@@ -1869,7 +1946,8 @@ to nil." (bound-and-true-p long-line-threshold)) :warning)))
(defun magit-section--highlight-region (start end window rol)
(magit-section--delete-region-overlays)
(if (and (not magit-section-keep-region-overlay)
(if (and magit-section-highlight-selection
(not magit-section-keep-region-overlay)
(or (magit-region-sections)
(run-hook-with-args-until-success 'magit-region-highlight-hook
(magit-current-section)))
@@ -1891,14 +1969,15 @@ to nil." (bound-and-true-p long-line-threshold)) :warning)))
(put 'magit-section-visibility-cache 'permanent-local t)
(defun magit-section-cached-visibility (section)
"Set SECTION's visibility to the cached value.
When `magit-section-preserve-visibility' is nil, do nothing."
"Return the visibility cached for SECTION.
When `magit-section-preserve-visibility' is nil, return nil."
(and magit-section-preserve-visibility
(cdr (assoc (magit-section-ident section)
magit-section-visibility-cache))))
(cl-defun magit-section-cache-visibility
(&optional (section magit-insert-section--current))
"Cache SECTION's current visibility."
(setf (compat-call alist-get
(magit-section-ident section)
magit-section-visibility-cache
@@ -2047,6 +2126,23 @@ excluding SECTION itself."
('next (cdr (member section siblings)))
(_ (remq section siblings)))))
(defun magit-focused-sections ()
"Return a list of the selected sections and all their descendants.
If no sections are selected return a list of the current section and
its descendants, except if that is the root section, in which case
return nil."
(or magit-section-focused-sections
(setq magit-section-focused-sections
(let ((current (magit-current-section)))
(and (not (eq current magit-root-section))
(let (sections)
(letrec ((collect (lambda (section)
(mapc collect (oref section children))
(push section sections))))
(mapc collect
(or (magit-region-sections) (list current))))
sections))))))
(defun magit-region-values (&optional condition multiple)
"Return a list of the values of the selected sections.
@@ -2085,9 +2181,18 @@ forms CONDITION can take."
(rend (region-end))
(sbeg (magit-section-at rbeg))
(send (magit-section-at rend)))
(and send
;; It should be possible to select a single section using
;; `set-mark-command', so don't use `use-region-p' above.
;; We still have to prevent the selection overlay from
;; being flashed when clicking inside a section, which
;; the first condition accomplishes:
(and (or (not (eq this-command #'mouse-drag-region))
(> rend rbeg))
send
(not (eq send magit-root-section))
(not (and multiple (eq send sbeg)))
(not (and (eq send sbeg)
(or multiple
(> rend rbeg))))
(let ((siblings (cons sbeg (magit-section-siblings sbeg 'next)))
(sections ()))
(and (memq send siblings)
@@ -2225,7 +2330,7 @@ Configuration'."
(message "`%s' contains entries that are no longer valid.
%s\nUsing standard value instead. Please re-configure hook variable."
hook
(mapconcat (lambda (sym) (format " `%s'" sym)) invalid "\n"))
(mapconcat (##format " `%s'" %) invalid "\n"))
(sit-for 5)
(setq entries (eval (car (get hook 'standard-value)))))
(dolist (entry entries)
@@ -2344,9 +2449,8 @@ This is like moving to POS and then calling `pos-eol'."
(magit-section-match magit--imenu-group-types section))
(and-let* ((children (oref section children)))
`((,(magit--imenu-index-name section)
,@(mapcar (lambda (s)
(cons (magit--imenu-index-name s)
(oref s start)))
,@(mapcar (##cons (magit--imenu-index-name %)
(oref % start))
children))))))
(magit--imenu-item-types
(and (magit-section-match magit--imenu-item-types section)
@@ -2399,6 +2503,8 @@ necessary. For use as `imenu-default-goto-function' in
(cl-defgeneric magit-bookmark-get-filename ()
(or (buffer-file-name) (buffer-name)))
(cl-defgeneric magit-bookmark-get-value (bookmark mode))
(cl-defgeneric magit-bookmark--get-child-value (section)
(oref section value))
@@ -2420,8 +2526,7 @@ and the buffer-local values of the variables referenced in its
(bookmark-prop-set bookmark 'mode major-mode)
(bookmark-prop-set bookmark 'filename (magit-bookmark-get-filename))
(bookmark-prop-set bookmark 'defaults (list (magit-bookmark-name)))
(dolist (var (get major-mode 'magit-bookmark-variables))
(bookmark-prop-set bookmark var (symbol-value var)))
(magit-bookmark-get-value bookmark)
(bookmark-prop-set
bookmark 'magit-hidden-sections
(seq-keep (##and (oref % hidden)
@@ -2466,7 +2571,7 @@ with the variables' values as arguments, which were recorded by
(format "%s%s"
(substring (symbol-name major-mode) 0 -5)
(if-let ((vars (get major-mode 'magit-bookmark-variables)))
(mapcan (lambda (var) (ensure-list (symbol-value var))) vars)
(mapcan (##ensure-list (symbol-value %)) vars)
"")))
;;; Bitmaps

View File

@@ -34,7 +34,7 @@ packages that have nothing to do with Magit or Git.
and user options see *note (magit)Sections::. This manual documents how
you can use sections in your own packages.
This manual is for Magit-Section version 4.3.1.
This manual is for Magit-Section version 4.3.6.
Copyright (C) 2015-2025 Jonas Bernoulli
<emacs.magit@jonas.bernoulli.dev>