update of packages
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
(define-package "magit-section" "20221127.2227" "Sections for read-only buffers."
|
||||
(define-package "magit-section" "20231014.1405" "Sections for read-only buffers."
|
||||
'((emacs "25.1")
|
||||
(compat "28.1.1.2")
|
||||
(dash "20210826"))
|
||||
:commit "3cf308c1c4cdb9404e3d3c6f9935ad9f628311d9" :authors
|
||||
(compat "29.1.3.4")
|
||||
(dash "20221013"))
|
||||
:commit "22c99839c9fad89461412f153a290779cf3af82c" :authors
|
||||
'(("Jonas Bernoulli" . "jonas@bernoul.li"))
|
||||
:maintainer
|
||||
'("Jonas Bernoulli" . "jonas@bernoul.li")
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
;;; magit-section.el --- Sections for read-only buffers -*- lexical-binding:t; coding:utf-8 -*-
|
||||
|
||||
;; Copyright (C) 2008-2022 The Magit Project Contributors
|
||||
;; Copyright (C) 2008-2023 The Magit Project Contributors
|
||||
|
||||
;; Author: Jonas Bernoulli <jonas@bernoul.li>
|
||||
;; Maintainer: Jonas Bernoulli <jonas@bernoul.li>
|
||||
@@ -9,7 +9,11 @@
|
||||
;; Keywords: tools
|
||||
|
||||
;; Package-Version: 3.3.0.50-git
|
||||
;; Package-Requires: ((emacs "25.1") (compat "28.1.1.2") (dash "2.19.1"))
|
||||
;; Package-Requires: (
|
||||
;; (emacs "25.1")
|
||||
;; (compat "29.1.3.4")
|
||||
;; (dash "2.19.1")
|
||||
;; (seq "2.24"))
|
||||
|
||||
;; SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
@@ -40,14 +44,21 @@
|
||||
|
||||
(require 'cl-lib)
|
||||
(require 'compat)
|
||||
(require 'compat-26)
|
||||
(require 'compat-27)
|
||||
(require 'dash)
|
||||
(require 'eieio)
|
||||
(require 'format-spec)
|
||||
(require 'seq)
|
||||
(require 'subr-x)
|
||||
|
||||
;; For older Emacs releases we depend on an updated `seq' release from GNU
|
||||
;; ELPA, for `seq-keep'. Unfortunately something else may require `seq'
|
||||
;; before `package' had a chance to put this version on the `load-path'.
|
||||
(when (and (featurep' seq)
|
||||
(not (fboundp 'seq-keep)))
|
||||
(unload-feature 'seq 'force))
|
||||
(require 'seq)
|
||||
|
||||
(require 'cursor-sensor)
|
||||
(require 'format-spec)
|
||||
|
||||
(eval-when-compile (require 'benchmark))
|
||||
|
||||
;; For `magit-section-get-relative-position'
|
||||
@@ -78,7 +89,7 @@ diff-related sections being the only exception.")
|
||||
"Hook used to set the initial visibility of a section.
|
||||
Stop at the first function that returns non-nil. The returned
|
||||
value should be `show', `hide' or nil. If no function returns
|
||||
non-nil, determine the visibility as usual, i.e. use the
|
||||
non-nil, determine the visibility as usual, i.e., use the
|
||||
hardcoded section specific default (see `magit-insert-section').")
|
||||
|
||||
;;; Options
|
||||
@@ -189,7 +200,8 @@ Otherwise the value has to have one of these two forms:
|
||||
(const :tag "No (kinda ugly)" nil)))))
|
||||
|
||||
(define-obsolete-variable-alias 'magit-keep-region-overlay
|
||||
'magit-section-keep-region-overlay "Magit-Section 3.4.0")
|
||||
'magit-section-keep-region-overlay "Magit-Section 4.0.0")
|
||||
|
||||
(defcustom magit-section-keep-region-overlay nil
|
||||
"Whether to keep the region overlay when there is a valid selection.
|
||||
|
||||
@@ -256,12 +268,14 @@ but that ship has sailed, thus this option."
|
||||
This has to be set before loading `magit-section' or it has
|
||||
no effect. This also has no effect for Emacs >= 28, where
|
||||
`context-menu-mode' should be enabled instead."
|
||||
:package-version '(magit-section . "3.4.0")
|
||||
:package-version '(magit-section . "4.0.0")
|
||||
:group 'magit-section
|
||||
:type 'boolean)
|
||||
|
||||
;;; Variables
|
||||
|
||||
(defvar-local magit-section-preserve-visibility t)
|
||||
|
||||
(defvar-local magit-section-pre-command-region-p nil)
|
||||
(defvar-local magit-section-pre-command-section nil)
|
||||
(defvar-local magit-section-highlight-force-update nil)
|
||||
@@ -269,6 +283,9 @@ no effect. This also has no effect for Emacs >= 28, where
|
||||
(defvar-local magit-section-highlighted-sections nil)
|
||||
(defvar-local magit-section-unhighlight-sections nil)
|
||||
|
||||
(defvar-local magit-section-inhibit-markers nil)
|
||||
(defvar-local magit-section-insert-in-reverse nil)
|
||||
|
||||
;;; Faces
|
||||
|
||||
(defgroup magit-section-faces nil
|
||||
@@ -344,24 +361,22 @@ no effect. This also has no effect for Emacs >= 28, where
|
||||
|
||||
(defvar symbol-overlay-inhibit-map)
|
||||
|
||||
(defvar magit-section-heading-map
|
||||
(let ((map (make-sparse-keymap)))
|
||||
(define-key map [double-down-mouse-1] #'ignore)
|
||||
(define-key map [double-mouse-1] #'magit-mouse-toggle-section)
|
||||
(define-key map [double-mouse-2] #'magit-mouse-toggle-section)
|
||||
map)
|
||||
"Keymap used in the heading line of all expandable sections.
|
||||
(defvar-keymap magit-section-heading-map
|
||||
:doc "Keymap used in the heading line of all expandable sections.
|
||||
This keymap is used in addition to the section-specific keymap,
|
||||
if any.")
|
||||
if any."
|
||||
"<double-down-mouse-1>" #'ignore
|
||||
"<double-mouse-1>" #'magit-mouse-toggle-section
|
||||
"<double-mouse-2>" #'magit-mouse-toggle-section)
|
||||
|
||||
(defvar magit-section-mode-map
|
||||
(let ((map (make-keymap)))
|
||||
(suppress-keymap map t)
|
||||
(when (and magit-section-show-context-menu-for-emacs<28
|
||||
(< emacs-major-version 28))
|
||||
(define-key map [mouse-3] nil)
|
||||
(define-key
|
||||
map [down-mouse-3]
|
||||
(keymap-set map "<mouse-3>" nil)
|
||||
(keymap-set
|
||||
map "<down-mouse-3>"
|
||||
`( menu-item "" ,(make-sparse-keymap)
|
||||
:filter ,(lambda (_)
|
||||
(let ((menu (make-sparse-keymap)))
|
||||
@@ -370,26 +385,26 @@ if any.")
|
||||
(magit--context-menu-local menu last-input-event))
|
||||
(magit-section-context-menu menu last-input-event)
|
||||
menu)))))
|
||||
(define-key map [left-fringe mouse-1] #'magit-mouse-toggle-section)
|
||||
(define-key map [left-fringe mouse-2] #'magit-mouse-toggle-section)
|
||||
(define-key map (kbd "TAB") #'magit-section-toggle)
|
||||
(define-key map [C-tab] #'magit-section-cycle)
|
||||
(define-key map [M-tab] #'magit-section-cycle)
|
||||
;; [backtab] is the most portable binding for Shift+Tab.
|
||||
(define-key map [backtab] #'magit-section-cycle-global)
|
||||
(define-key map (kbd "^") #'magit-section-up)
|
||||
(define-key map (kbd "p") #'magit-section-backward)
|
||||
(define-key map (kbd "n") #'magit-section-forward)
|
||||
(define-key map (kbd "M-p") #'magit-section-backward-sibling)
|
||||
(define-key map (kbd "M-n") #'magit-section-forward-sibling)
|
||||
(define-key map (kbd "1") #'magit-section-show-level-1)
|
||||
(define-key map (kbd "2") #'magit-section-show-level-2)
|
||||
(define-key map (kbd "3") #'magit-section-show-level-3)
|
||||
(define-key map (kbd "4") #'magit-section-show-level-4)
|
||||
(define-key map (kbd "M-1") #'magit-section-show-level-1-all)
|
||||
(define-key map (kbd "M-2") #'magit-section-show-level-2-all)
|
||||
(define-key map (kbd "M-3") #'magit-section-show-level-3-all)
|
||||
(define-key map (kbd "M-4") #'magit-section-show-level-4-all)
|
||||
(keymap-set map "<left-fringe> <mouse-1>" #'magit-mouse-toggle-section)
|
||||
(keymap-set map "<left-fringe> <mouse-2>" #'magit-mouse-toggle-section)
|
||||
(keymap-set map "TAB" #'magit-section-toggle)
|
||||
(keymap-set map "C-<tab>" #'magit-section-cycle)
|
||||
(keymap-set map "M-<tab>" #'magit-section-cycle)
|
||||
;; <backtab> is the most portable binding for Shift+Tab.
|
||||
(keymap-set map "<backtab>" #'magit-section-cycle-global)
|
||||
(keymap-set map "^" #'magit-section-up)
|
||||
(keymap-set map "p" #'magit-section-backward)
|
||||
(keymap-set map "n" #'magit-section-forward)
|
||||
(keymap-set map "M-p" #'magit-section-backward-sibling)
|
||||
(keymap-set map "M-n" #'magit-section-forward-sibling)
|
||||
(keymap-set map "1" #'magit-section-show-level-1)
|
||||
(keymap-set map "2" #'magit-section-show-level-2)
|
||||
(keymap-set map "3" #'magit-section-show-level-3)
|
||||
(keymap-set map "4" #'magit-section-show-level-4)
|
||||
(keymap-set map "M-1" #'magit-section-show-level-1-all)
|
||||
(keymap-set map "M-2" #'magit-section-show-level-2-all)
|
||||
(keymap-set map "M-3" #'magit-section-show-level-3-all)
|
||||
(keymap-set map "M-4" #'magit-section-show-level-4-all)
|
||||
map)
|
||||
"Parent keymap for all keymaps of modes derived from `magit-section-mode'.")
|
||||
|
||||
@@ -419,6 +434,8 @@ Magit-Section is documented in info node `(magit-section)'."
|
||||
#'magit-section--highlight-region)
|
||||
(setq-local redisplay-unhighlight-region-function
|
||||
#'magit-section--unhighlight-region)
|
||||
(add-function :filter-return (local 'filter-buffer-substring-function)
|
||||
#'magit-section--remove-text-properties)
|
||||
(when (fboundp 'magit-section-context-menu)
|
||||
(add-hook 'context-menu-functions #'magit-section-context-menu 10 t))
|
||||
(when magit-section-disable-line-numbers
|
||||
@@ -434,6 +451,12 @@ Magit-Section is documented in info node `(magit-section)'."
|
||||
(when (fboundp 'magit-preserve-section-visibility-cache)
|
||||
(add-hook 'kill-buffer-hook #'magit-preserve-section-visibility-cache)))
|
||||
|
||||
(defun magit-section--remove-text-properties (string)
|
||||
"Remove all text-properties from STRING.
|
||||
Most importantly `magit-section'."
|
||||
(set-text-properties 0 (length string) nil string)
|
||||
string)
|
||||
|
||||
;;; Core
|
||||
|
||||
(defvar-local magit-root-section nil
|
||||
@@ -568,7 +591,7 @@ The return value has the form (TYPE...)."
|
||||
(setq magit--context-menu-section section)
|
||||
(magit-section-update-highlight t)))
|
||||
(when (magit-section-content-p section)
|
||||
(define-key-after menu [magit-section-toggle]
|
||||
(keymap-set-after menu "<magit-section-toggle>"
|
||||
`(menu-item
|
||||
,(if (oref section hidden) "Expand section" "Collapse section")
|
||||
magit-section-toggle))
|
||||
@@ -576,18 +599,18 @@ The return value has the form (TYPE...)."
|
||||
(when-let ((children (oref section children)))
|
||||
(when (seq-some #'magit-section-content-p children)
|
||||
(when (seq-some (lambda (c) (oref c hidden)) children)
|
||||
(define-key-after menu [magit-section-show-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)
|
||||
(define-key-after menu [magit-section-hide-children]
|
||||
(keymap-set-after menu "<magit-section-hide-children>"
|
||||
`(menu-item "Collapse children"
|
||||
magit-section-hide-children))))))
|
||||
(define-key-after menu [separator-magit-1] menu-bar-separator))
|
||||
(define-key-after menu [magit-describe-section]
|
||||
(keymap-set-after menu "<separator-magit-1>" menu-bar-separator))
|
||||
(keymap-set-after menu "<magit-describe-section>"
|
||||
`(menu-item "Describe section" magit-describe-section))
|
||||
(when-let ((map (oref section keymap)))
|
||||
(define-key-after menu [separator-magit-2] menu-bar-separator)
|
||||
(keymap-set-after menu "<separator-magit-2>" menu-bar-separator)
|
||||
(when (symbolp map)
|
||||
(setq map (symbol-value map)))
|
||||
(setq magit-menu-common-value (magit-menu-common-value section))
|
||||
@@ -601,55 +624,33 @@ The return value has the form (TYPE...)."
|
||||
(magit--menu-bar-keymap map)))))
|
||||
menu)
|
||||
|
||||
(defun magit-menu-set (keymap key def desc &optional props after)
|
||||
"In KEYMAP, define KEY and a menu entry for DEF.
|
||||
(defun magit-menu-item (desc def &optional props)
|
||||
"Return a menu item named DESC binding DEF and using PROPS.
|
||||
|
||||
Add the menu item (menu-item DESC DEF . PROPS) at the end of
|
||||
KEYMAP, or if optional AFTER is non-nil, then after that.
|
||||
If DESC contains a supported %-spec, substitute the
|
||||
expression (magit-menu-format-desc DESC) for that.
|
||||
See `magit-menu-format-desc'."
|
||||
`(menu-item
|
||||
,(if (and (stringp desc) (string-match-p "%[tTvsmMx]" desc))
|
||||
(list 'magit-menu-format-desc desc)
|
||||
desc)
|
||||
,def
|
||||
;; Without this, the keys for point would be shown instead
|
||||
;; of the relevant ones from where the click occurred.
|
||||
:keys ,(apply-partially #'magit--menu-position-keys def)
|
||||
,@props))
|
||||
|
||||
Because it is so common, and would otherwise result in overlong
|
||||
lines or else unsightly line wrapping, a definition [remap CMD]
|
||||
can be written as just [CMD]. As a result KEY might have to be
|
||||
a string when otherwise a vector would have worked.
|
||||
|
||||
If DESC is a string that contains a support %-spec, substitute
|
||||
the expression (magit-menu-format-desc DESC) for that. See
|
||||
`magit-menu-format-desc'."
|
||||
(declare (indent defun))
|
||||
(when (vectorp key)
|
||||
;; Expand the short-hand.
|
||||
(unless (eq (aref key 0) 'remap)
|
||||
(setq key (vconcat [remap] key)))
|
||||
;; The default binding is RET, but in my configuration it
|
||||
;; is <return>. In that case the displayed binding would
|
||||
;; be <CMD> instead of <return>, for unknown reasons. The
|
||||
;; same does not happen for similar events, such as <tab>.
|
||||
(when (and (equal key [remap magit-visit-thing])
|
||||
(boundp 'magit-mode-map)
|
||||
(ignore-errors (eq (lookup-key magit-mode-map [return])
|
||||
'magit-visit-thing)))
|
||||
(setq key [return]))
|
||||
;; `define-key-after' cannot deal with [remap CMD],
|
||||
;; so we have to add the key binding separately.
|
||||
(define-key keymap key def)
|
||||
(unless (symbolp def)
|
||||
(error "When KEY is a remapping, then DEF must be a symbol: %s" def))
|
||||
(setq key (vector def)))
|
||||
(when (and (stringp desc) (string-match-p "%[tTvsmMx]" desc))
|
||||
(setq desc (list 'magit-menu-format-desc desc)))
|
||||
(define-key-after keymap key
|
||||
`( menu-item ,desc ,def ,@props
|
||||
;; Without this, the keys for point would be shown instead
|
||||
;; of the relevant ones from where the click occurred.
|
||||
,@(and (not (region-active-p))
|
||||
(list :keys
|
||||
(lambda ()
|
||||
(or (ignore-errors
|
||||
(save-excursion
|
||||
(goto-char (magit-menu-position))
|
||||
(key-description (where-is-internal def nil t))))
|
||||
"")))))
|
||||
after))
|
||||
(defun magit--menu-position-keys (def)
|
||||
(or (ignore-errors
|
||||
(save-excursion
|
||||
(goto-char (magit-menu-position))
|
||||
(and-let* ((key (cl-find-if-not
|
||||
(lambda (key)
|
||||
(string-match-p "\\`<[0-9]+>\\'"
|
||||
(key-description key)))
|
||||
(where-is-internal def))))
|
||||
(key-description key))))
|
||||
""))
|
||||
|
||||
(defun magit-menu-position ()
|
||||
"Return the position where the context-menu was invoked.
|
||||
@@ -726,7 +727,7 @@ Slight trimmed down."
|
||||
(defun magit--context-menu-local (menu _click)
|
||||
"Backport of `context-menu-local' for Emacs < 28."
|
||||
(run-hooks 'activate-menubar-hook 'menu-bar-update-hook)
|
||||
(define-key-after menu [separator-local] menu-bar-separator)
|
||||
(keymap-set-after menu "<separator-local>" menu-bar-separator)
|
||||
(let ((keymap (local-key-binding [menu-bar])))
|
||||
(when keymap
|
||||
(map-keymap (lambda (key binding)
|
||||
@@ -806,8 +807,8 @@ the beginning of the current section."
|
||||
(defun magit-section-up ()
|
||||
"Move to the beginning of the parent section."
|
||||
(interactive)
|
||||
(--if-let (oref (magit-current-section) parent)
|
||||
(magit-section-goto it)
|
||||
(if-let ((parent (oref (magit-current-section) parent)))
|
||||
(magit-section-goto parent)
|
||||
(user-error "No parent section")))
|
||||
|
||||
(defun magit-section-forward-sibling ()
|
||||
@@ -816,8 +817,8 @@ If there is no next sibling section, then move to the parent."
|
||||
(interactive)
|
||||
(let ((current (magit-current-section)))
|
||||
(if (oref current parent)
|
||||
(--if-let (car (magit-section-siblings current 'next))
|
||||
(magit-section-goto it)
|
||||
(if-let ((next (car (magit-section-siblings current 'next))))
|
||||
(magit-section-goto next)
|
||||
(magit-section-forward))
|
||||
(magit-section-goto 1))))
|
||||
|
||||
@@ -827,8 +828,8 @@ If there is no previous sibling section, then move to the parent."
|
||||
(interactive)
|
||||
(let ((current (magit-current-section)))
|
||||
(if (oref current parent)
|
||||
(--if-let (car (magit-section-siblings current 'prev))
|
||||
(magit-section-goto it)
|
||||
(if-let ((previous (car (magit-section-siblings current 'prev))))
|
||||
(magit-section-goto previous)
|
||||
(magit-section-backward))
|
||||
(magit-section-goto -1))))
|
||||
|
||||
@@ -849,18 +850,18 @@ If there is no previous sibling section, then move to the parent."
|
||||
Together TYPE and VALUE identify the section.
|
||||
HEADING is the displayed heading of the section."
|
||||
(declare (indent defun))
|
||||
`(defun ,name (&optional expand) ,(format "\
|
||||
Jump to the section \"%s\".
|
||||
`(defun ,name (&optional expand)
|
||||
,(format "Jump to the section \"%s\".
|
||||
With a prefix argument also expand it." heading)
|
||||
(interactive "P")
|
||||
(--if-let (magit-get-section
|
||||
(cons (cons ',type ,value)
|
||||
(magit-section-ident magit-root-section)))
|
||||
(progn (goto-char (oref it start))
|
||||
(when expand
|
||||
(with-local-quit (magit-section-show it))
|
||||
(recenter 0)))
|
||||
(message ,(format "Section \"%s\" wasn't found" heading)))))
|
||||
(interactive "P")
|
||||
(if-let ((section (magit-get-section
|
||||
(cons (cons ',type ,value)
|
||||
(magit-section-ident magit-root-section)))))
|
||||
(progn (goto-char (oref section start))
|
||||
(when expand
|
||||
(with-local-quit (magit-section-show section))
|
||||
(recenter 0)))
|
||||
(message ,(format "Section \"%s\" wasn't found" heading)))))
|
||||
|
||||
;;;; Visibility
|
||||
|
||||
@@ -906,7 +907,8 @@ With a prefix argument also expand it." heading)
|
||||
(remove-overlays beg end 'invisible t)
|
||||
(let ((o (make-overlay beg end)))
|
||||
(overlay-put o 'evaporate t)
|
||||
(overlay-put o 'invisible t))))
|
||||
(overlay-put o 'invisible t)
|
||||
(overlay-put o 'cursor-intangible t))))
|
||||
(magit-section-maybe-update-visibility-indicator section)
|
||||
(magit-section-maybe-cache-visibility section)))
|
||||
|
||||
@@ -993,8 +995,8 @@ hidden."
|
||||
(mapc #'magit-section-hide children)))))
|
||||
|
||||
(defun magit-section-hidden-body (section &optional pred)
|
||||
(--if-let (oref section children)
|
||||
(funcall (or pred #'-any-p) #'magit-section-hidden-body it)
|
||||
(if-let ((children (oref section children)))
|
||||
(funcall (or pred #'-any-p) #'magit-section-hidden-body children)
|
||||
(and (oref section content)
|
||||
(oref section hidden))))
|
||||
|
||||
@@ -1088,11 +1090,12 @@ silently ignored."
|
||||
|
||||
;;;; Auxiliary
|
||||
|
||||
(defun magit-describe-section-briefly (section &optional ident)
|
||||
(defun magit-describe-section-briefly (section &optional ident interactive)
|
||||
"Show information about the section at point.
|
||||
With a prefix argument show the section identity instead of the
|
||||
section lineage. This command is intended for debugging purposes."
|
||||
(interactive (list (magit-current-section) current-prefix-arg))
|
||||
section lineage. This command is intended for debugging purposes.
|
||||
\n(fn SECTION &optional IDENT)"
|
||||
(interactive (list (magit-current-section) current-prefix-arg t))
|
||||
(let ((str (format "#<%s %S %S %s-%s%s>"
|
||||
(eieio-object-class section)
|
||||
(let ((val (oref section value)))
|
||||
@@ -1113,9 +1116,9 @@ section lineage. This command is intended for debugging purposes."
|
||||
"")
|
||||
(and-let* ((m (oref section end)))
|
||||
(marker-position m)))))
|
||||
(if (called-interactively-p 'any)
|
||||
(message "%s" str)
|
||||
str)))
|
||||
(when interactive
|
||||
(message "%s" str))
|
||||
str))
|
||||
|
||||
(cl-defmethod cl-print-object ((section magit-section) stream)
|
||||
"Print `magit-describe-section' result of SECTION."
|
||||
@@ -1236,30 +1239,6 @@ See `magit-section-match' for the forms CONDITION can take."
|
||||
(and (magit-section-match condition section)
|
||||
(oref section value))))
|
||||
|
||||
(defmacro magit-section-when (condition &rest body)
|
||||
"If the section at point matches CONDITION, evaluate BODY.
|
||||
|
||||
If the section matches, then evaluate BODY forms sequentially
|
||||
with `it' bound to the section and return the value of the last
|
||||
form. If there are no BODY forms, then return the value of the
|
||||
section. If the section does not match or if there is no section
|
||||
at point, then return nil.
|
||||
|
||||
See `magit-section-match' for the forms CONDITION can take."
|
||||
(declare (obsolete
|
||||
"instead use `magit-section-match' or `magit-section-value-if'."
|
||||
"Magit 2.90.0")
|
||||
(indent 1)
|
||||
(debug (sexp body)))
|
||||
`(--when-let (magit-current-section)
|
||||
;; Quoting CONDITION here often leads to double-quotes, which
|
||||
;; isn't an issue because `magit-section-match-1' implicitly
|
||||
;; deals with that. We shouldn't force users of this function
|
||||
;; to not quote CONDITION because that would needlessly break
|
||||
;; backward compatibility.
|
||||
(when (magit-section-match ',condition it)
|
||||
,@(or body '((oref it value))))))
|
||||
|
||||
(defmacro magit-section-case (&rest clauses)
|
||||
"Choose among clauses on the type of the section at point.
|
||||
|
||||
@@ -1304,7 +1283,7 @@ Create a section object of type CLASS, storing VALUE in its
|
||||
`value' slot, and insert the section at point. CLASS is a
|
||||
subclass of `magit-section' or has the form `(eval FORM)', in
|
||||
which case FORM is evaluated at runtime and should return a
|
||||
subclass. In other places a sections class is oftern referred
|
||||
subclass. In other places a sections class is often referred
|
||||
to as its \"type\".
|
||||
|
||||
Many commands behave differently depending on the class of the
|
||||
@@ -1319,7 +1298,7 @@ appropriate package prefix. This works due to some undocumented
|
||||
kludges, which are not available to other packages.
|
||||
|
||||
When optional HIDE is non-nil collapse the section body by
|
||||
default, i.e. when first creating the section, but not when
|
||||
default, i.e., when first creating the section, but not when
|
||||
refreshing the buffer. Else expand it by default. This can be
|
||||
overwritten using `magit-section-set-visibility-hook'. When a
|
||||
section is recreated during a refresh, then the visibility of
|
||||
@@ -1365,34 +1344,34 @@ anything this time around.
|
||||
(car (rassq ,tp magit--section-type-alist)))
|
||||
,tp)
|
||||
:value ,(nth 1 (car args))
|
||||
:start (point-marker)
|
||||
:start (if magit-section-inhibit-markers
|
||||
(point)
|
||||
(point-marker))
|
||||
:parent magit-insert-section--parent)))
|
||||
(oset ,s hidden
|
||||
(let ((value (run-hook-with-args-until-success
|
||||
'magit-section-set-visibility-hook ,s)))
|
||||
(if value
|
||||
(eq value 'hide)
|
||||
(let ((incarnation (and magit-insert-section--oldroot
|
||||
(magit-get-section
|
||||
(magit-section-ident ,s)
|
||||
magit-insert-section--oldroot))))
|
||||
(if incarnation
|
||||
(oref incarnation hidden)
|
||||
(let ((value (magit-section-match-assoc
|
||||
,s magit-section-initial-visibility-alist)))
|
||||
(if value
|
||||
(progn
|
||||
(when (functionp value)
|
||||
(setq value (funcall value ,s)))
|
||||
(eq value 'hide))
|
||||
,(nth 2 (car args)))))))))
|
||||
(if-let ((value (run-hook-with-args-until-success
|
||||
'magit-section-set-visibility-hook ,s)))
|
||||
(eq value 'hide)
|
||||
(if-let ((incarnation
|
||||
(and (not magit-section-preserve-visibility)
|
||||
magit-insert-section--oldroot
|
||||
(magit-get-section
|
||||
(magit-section-ident ,s)
|
||||
magit-insert-section--oldroot))))
|
||||
(oref incarnation hidden)
|
||||
(if-let ((value (magit-section-match-assoc
|
||||
,s magit-section-initial-visibility-alist)))
|
||||
(progn (when (functionp value)
|
||||
(setq value (funcall value ,s)))
|
||||
(eq value 'hide))
|
||||
,(nth 2 (car args))))))
|
||||
(let ((magit-insert-section--current ,s)
|
||||
(magit-insert-section--parent ,s)
|
||||
(magit-insert-section--oldroot
|
||||
(or magit-insert-section--oldroot
|
||||
(unless magit-insert-section--parent
|
||||
(prog1 magit-root-section
|
||||
(setq magit-root-section ,s))))))
|
||||
(and (not magit-insert-section--parent)
|
||||
(prog1 magit-root-section
|
||||
(setq magit-root-section ,s))))))
|
||||
(catch 'cancel-section
|
||||
,@(if s*
|
||||
`((let ((,s* ,s))
|
||||
@@ -1403,8 +1382,12 @@ anything this time around.
|
||||
;; on section insertion, not a section inserting hook.
|
||||
(run-hooks 'magit-insert-section-hook)
|
||||
(magit-insert-child-count ,s)
|
||||
(set-marker-insertion-type (oref ,s start) t)
|
||||
(let* ((end (oset ,s end (point-marker)))
|
||||
(unless magit-section-inhibit-markers
|
||||
(set-marker-insertion-type (oref ,s start) t))
|
||||
(let* ((end (oset ,s end
|
||||
(if magit-section-inhibit-markers
|
||||
(point)
|
||||
(point-marker))))
|
||||
(class-map (oref ,s keymap))
|
||||
(magit-map (intern (format "magit-%s-section-map"
|
||||
(oref ,s type))))
|
||||
@@ -1427,12 +1410,25 @@ anything this time around.
|
||||
(put-text-property (point) next 'keymap map)))
|
||||
(magit-section-maybe-add-heading-map ,s)
|
||||
(goto-char next)))))
|
||||
(if (eq ,s magit-root-section)
|
||||
(let ((magit-section-cache-visibility nil))
|
||||
(magit-section-show ,s))
|
||||
(oset (oref ,s parent) children
|
||||
(nconc (oref (oref ,s parent) children)
|
||||
(list ,s)))))
|
||||
(cond
|
||||
((eq ,s magit-root-section)
|
||||
(when (eq magit-section-inhibit-markers 'delay)
|
||||
(setq magit-section-inhibit-markers nil)
|
||||
(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 ,s)))
|
||||
(magit-section-insert-in-reverse
|
||||
(push ,s (oref (oref ,s parent) children)))
|
||||
((let ((parent (oref ,s parent)))
|
||||
(oset parent children
|
||||
(nconc (oref parent children)
|
||||
(list ,s)))))))
|
||||
(when magit-section-insert-in-reverse
|
||||
(setq magit-section-insert-in-reverse nil)
|
||||
(oset ,s children (nreverse (oref ,s children))))
|
||||
,s))))
|
||||
|
||||
(defun magit-cancel-section ()
|
||||
@@ -1486,7 +1482,8 @@ insert a newline character if necessary."
|
||||
(insert ?\n))
|
||||
(when (fboundp 'magit-maybe-make-margin-overlay)
|
||||
(magit-maybe-make-margin-overlay))
|
||||
(oset magit-insert-section--current content (point-marker)))
|
||||
(oset magit-insert-section--current content
|
||||
(if magit-section-inhibit-markers (point) (point-marker))))
|
||||
|
||||
(defmacro magit-insert-section-body (&rest body)
|
||||
"Use BODY to insert the section body, once the section is expanded.
|
||||
@@ -1578,8 +1575,7 @@ evaluated its BODY. Admittedly that's a bit of a hack."
|
||||
;;; Highlight
|
||||
|
||||
(defun magit-section-pre-command-hook ()
|
||||
(when (and (not (bound-and-true-p transient--prefix))
|
||||
(or magit--context-menu-buffer
|
||||
(when (and (or magit--context-menu-buffer
|
||||
magit--context-menu-section)
|
||||
(not (eq (ignore-errors
|
||||
(event-basic-type (aref (this-command-keys) 0)))
|
||||
@@ -1595,12 +1591,12 @@ evaluated its BODY. Admittedly that's a bit of a hack."
|
||||
(setq magit-section-pre-command-section (magit-current-section)))
|
||||
|
||||
(defun magit-section-post-command-hook ()
|
||||
(unless (bound-and-true-p transient--prefix)
|
||||
(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))))
|
||||
(cursor-sensor-move-to-tangible (selected-window))
|
||||
(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)))
|
||||
|
||||
(defun magit-section-deactivate-mark ()
|
||||
(setq magit-section-highlight-force-update t))
|
||||
@@ -1619,12 +1615,15 @@ evaluated its BODY. Admittedly that's a bit of a hack."
|
||||
(setq magit-section-unhighlight-sections
|
||||
magit-section-highlighted-sections)
|
||||
(setq magit-section-highlighted-sections nil)
|
||||
(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))
|
||||
(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)))
|
||||
(restore-buffer-modified-p nil)))
|
||||
(setq magit-section-highlight-force-update nil)
|
||||
(magit-section-maybe-paint-visibility-ellipses)))
|
||||
@@ -1688,6 +1687,29 @@ invisible."
|
||||
(push ov magit-section-highlight-overlays)
|
||||
ov))
|
||||
|
||||
(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 "\
|
||||
Emacs has enabled redisplay shortcuts
|
||||
in this buffer because there are lines whose length go beyond
|
||||
`long-line-treshhold' \(%s characters). As a result, section
|
||||
highlighting and the special appearance of the region has been
|
||||
disabled. Some existing highlighting might remain in effect.
|
||||
|
||||
These shortcuts remain enabled, even once there no longer are
|
||||
any long lines in this buffer. To disable them again, kill
|
||||
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." :warning)))
|
||||
|
||||
(cl-defgeneric magit-section-get-relative-position (section))
|
||||
|
||||
(cl-defmethod magit-section-get-relative-position ((section magit-section))
|
||||
@@ -1770,15 +1792,18 @@ invisible."
|
||||
(put 'magit-section-visibility-cache 'permanent-local t)
|
||||
|
||||
(defun magit-section-cached-visibility (section)
|
||||
"Set SECTION's visibility to the cached value."
|
||||
(cdr (assoc (magit-section-ident section)
|
||||
magit-section-visibility-cache)))
|
||||
"Set SECTION's visibility to the cached value.
|
||||
When `magit-section-preserve-visibility' is nil, do nothing."
|
||||
(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))
|
||||
(setf (compat-alist-get (magit-section-ident section)
|
||||
magit-section-visibility-cache
|
||||
nil nil #'equal)
|
||||
(setf (compat-call alist-get
|
||||
(magit-section-ident section)
|
||||
magit-section-visibility-cache
|
||||
nil nil #'equal)
|
||||
(if (oref section hidden) 'hide 'show)))
|
||||
|
||||
(cl-defun magit-section-maybe-cache-visibility
|
||||
@@ -1985,6 +2010,16 @@ forms CONDITION can take."
|
||||
(--all-p (magit-section-match condition it) sections))
|
||||
sections)))))))
|
||||
|
||||
(defun magit-map-sections (function &optional section)
|
||||
"Apply FUNCTION to all sections for side effects only, depth first.
|
||||
If optional SECTION is non-nil, only map over that section and
|
||||
its descendants, otherwise map over all sections in the current
|
||||
buffer, ending with `magit-root-section'."
|
||||
(let ((section (or section magit-root-section)))
|
||||
(mapc (lambda (child) (magit-map-sections function child))
|
||||
(oref section children))
|
||||
(funcall function section)))
|
||||
|
||||
(defun magit-section-position-in-heading-p (&optional section pos)
|
||||
"Return t if POSITION is inside the heading of SECTION.
|
||||
POSITION defaults to point and SECTION defaults to the
|
||||
@@ -1993,11 +2028,12 @@ current section."
|
||||
(setq section (magit-current-section)))
|
||||
(unless pos
|
||||
(setq pos (point)))
|
||||
(and section
|
||||
(>= pos (oref section start))
|
||||
(< pos (or (oref section content)
|
||||
(oref section end)))
|
||||
t))
|
||||
(ignore-errors ; Allow navigating broken sections.
|
||||
(and section
|
||||
(>= pos (oref section start))
|
||||
(< pos (or (oref section content)
|
||||
(oref section end)))
|
||||
t)))
|
||||
|
||||
(defun magit-section-internal-region-p (&optional section)
|
||||
"Return t if the region is active and inside SECTION's body.
|
||||
@@ -2090,11 +2126,11 @@ Configuration'."
|
||||
(let ((entries (symbol-value hook)))
|
||||
(unless (listp entries)
|
||||
(setq entries (list entries)))
|
||||
(--when-let (-remove #'functionp entries)
|
||||
(when-let ((invalid (seq-remove #'functionp entries)))
|
||||
(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)) it "\n"))
|
||||
(mapconcat (lambda (sym) (format " `%s'" sym)) invalid "\n"))
|
||||
(sit-for 5)
|
||||
(setq entries (eval (car (get hook 'standard-value)))))
|
||||
(dolist (entry entries)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
This is magit-section.info, produced by makeinfo version 7.0.1 from
|
||||
This is magit-section.info, produced by makeinfo version 6.8 from
|
||||
magit-section.texi.
|
||||
|
||||
Copyright (C) 2015-2022 Jonas Bernoulli <jonas@bernoul.li>
|
||||
Copyright (C) 2015-2023 Jonas Bernoulli <jonas@bernoul.li>
|
||||
|
||||
You can redistribute this document and/or modify it under the terms
|
||||
of the GNU General Public License as published by the Free Software
|
||||
@@ -35,7 +35,7 @@ you can use sections in your own packages.
|
||||
|
||||
This manual is for Magit-Section version 3.3.0.50-git.
|
||||
|
||||
Copyright (C) 2015-2022 Jonas Bernoulli <jonas@bernoul.li>
|
||||
Copyright (C) 2015-2023 Jonas Bernoulli <jonas@bernoul.li>
|
||||
|
||||
You can redistribute this document and/or modify it under the terms
|
||||
of the GNU General Public License as published by the Free Software
|
||||
@@ -85,7 +85,7 @@ File: magit-section.info, Node: Creating Sections, Next: Core Functions, Prev
|
||||
slot, and insert the section at point. CLASS is a subclass of
|
||||
‘magit-section’ or has the form ‘(eval FORM)’, in which case FORM
|
||||
is evaluated at runtime and should return a subclass. In other
|
||||
places a sections class is oftern referred to as its "type".
|
||||
places a sections class is often referred to as its "type".
|
||||
|
||||
Many commands behave differently depending on the class of the
|
||||
current section and sections of a certain class can have their own
|
||||
@@ -98,7 +98,7 @@ File: magit-section.info, Node: Creating Sections, Next: Core Functions, Prev
|
||||
kludges, which are not available to other packages.
|
||||
|
||||
When optional HIDE is non-nil collapse the section body by default,
|
||||
i.e. when first creating the section, but not when refreshing the
|
||||
i.e., when first creating the section, but not when refreshing the
|
||||
buffer. Else expand it by default. This can be overwritten using
|
||||
‘magit-section-set-visibility-hook’. When a section is recreated
|
||||
during a refresh, then the visibility of predecessor is inherited
|
||||
@@ -293,11 +293,11 @@ File: magit-section.info, Node: Matching Functions, Prev: Core Functions, Up:
|
||||
|
||||
|
||||
Tag Table:
|
||||
Node: Top790
|
||||
Node: Introduction2078
|
||||
Node: Creating Sections2848
|
||||
Node: Core Functions7357
|
||||
Node: Matching Functions10409
|
||||
Node: Top788
|
||||
Node: Introduction2076
|
||||
Node: Creating Sections2846
|
||||
Node: Core Functions7354
|
||||
Node: Matching Functions10406
|
||||
|
||||
End Tag Table
|
||||
|
||||
|
||||
Reference in New Issue
Block a user