update of packages
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
;;; magit-base.el --- Early birds -*- 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>
|
||||
@@ -21,7 +21,7 @@
|
||||
;; along with Magit. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
;; This file contains code taken from GNU Emacs, which is
|
||||
;; Copyright (C) 1976-2022 Free Software Foundation, Inc.
|
||||
;; Copyright (C) 1976-2023 Free Software Foundation, Inc.
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
@@ -37,13 +37,19 @@
|
||||
|
||||
(require 'cl-lib)
|
||||
(require 'compat)
|
||||
(require 'compat-26)
|
||||
(require 'compat-27)
|
||||
(require 'dash)
|
||||
(require 'eieio)
|
||||
(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 already
|
||||
;; have required `seq', before `package' had a chance to put the more
|
||||
;; recent version earlier on the `load-path'.
|
||||
(when (and (featurep' seq)
|
||||
(not (fboundp 'seq-keep)))
|
||||
(unload-feature 'seq 'force))
|
||||
(require 'seq)
|
||||
|
||||
(require 'crm)
|
||||
|
||||
(require 'magit-section)
|
||||
@@ -89,26 +95,7 @@ alphabetical order, depending on your version of Ivy."
|
||||
(magit-stash-branch-here nil t)
|
||||
(magit-stash-format-patch nil t)
|
||||
(magit-stash-drop nil ask)
|
||||
(magit-stash-pop nil ask)
|
||||
(forge-browse-dwim nil t)
|
||||
(forge-browse-commit nil t)
|
||||
(forge-browse-branch nil t)
|
||||
(forge-browse-remote nil t)
|
||||
(forge-browse-issue nil t)
|
||||
(forge-browse-pullreq nil t)
|
||||
(forge-edit-topic-title nil t)
|
||||
(forge-edit-topic-state nil t)
|
||||
(forge-edit-topic-draft nil t)
|
||||
(forge-edit-topic-milestone nil t)
|
||||
(forge-edit-topic-labels nil t)
|
||||
(forge-edit-topic-marks nil t)
|
||||
(forge-edit-topic-assignees nil t)
|
||||
(forge-edit-topic-review-requests nil t)
|
||||
(forge-edit-topic-note nil t)
|
||||
(forge-pull-pullreq nil t)
|
||||
(forge-visit-issue nil t)
|
||||
(forge-visit-pullreq nil t)
|
||||
(forge-visit-topic nil t))
|
||||
(magit-stash-pop nil ask))
|
||||
"When not to offer alternatives and ask for confirmation.
|
||||
|
||||
Many commands by default ask the user to select from a list of
|
||||
@@ -171,6 +158,7 @@ The value has the form ((COMMAND nil|PROMPT DEFAULT)...).
|
||||
(const remove-modules)
|
||||
(const remove-dirty-modules)
|
||||
(const trash-module-gitdirs)
|
||||
(const stash-apply-3way)
|
||||
(const kill-process)
|
||||
(const safe-with-wip)))
|
||||
|
||||
@@ -186,7 +174,7 @@ so we don't use the command names but more generic symbols.
|
||||
|
||||
Applying changes:
|
||||
|
||||
`discard' Discarding one or more changes (i.e. hunks or the
|
||||
`discard' Discarding one or more changes (i.e., hunks or the
|
||||
complete diff for a file) loses that change, obviously.
|
||||
|
||||
`reverse' Reverting one or more changes can usually be undone
|
||||
@@ -320,6 +308,11 @@ Removing modules:
|
||||
|
||||
Various:
|
||||
|
||||
`stash-apply-3way' When a stash cannot be applied using \"git
|
||||
stash apply\", then Magit uses \"git apply\" instead, possibly
|
||||
using the \"--3way\" argument, which isn't always perfectly
|
||||
safe. See also `magit-stash-apply'.
|
||||
|
||||
`kill-process' There seldom is a reason to kill a process.
|
||||
|
||||
Global settings:
|
||||
@@ -387,21 +380,50 @@ Messages which can currently be suppressed using this option are:
|
||||
:group 'magit-miscellaneous
|
||||
:type '(repeat string))
|
||||
|
||||
(defcustom magit-ellipsis (if (char-displayable-p ?…) "…" "...")
|
||||
"String used to abbreviate text in process buffers.
|
||||
(defcustom magit-verbose-messages nil
|
||||
"Whether to make certain prompts and messages more verbose.
|
||||
|
||||
Currently this is only used to elide `magit-git-global-arguments'
|
||||
in process buffers. In the future it may be used in other places
|
||||
as well, but not the following:
|
||||
Occasionally a user suggests that a certain prompt or message
|
||||
should be more verbose, but I would prefer to keep it as-is
|
||||
because I don't think that the fact that that one user did not
|
||||
understand the existing prompt/message means that a large number
|
||||
of users would have the same difficulty, and that making it more
|
||||
verbose would actually do a disservice to users who understand
|
||||
the shorter prompt well enough.
|
||||
|
||||
- Author names in the log margin are always abbreviated using
|
||||
\"…\" or if that is not displayable, then \">\".
|
||||
|
||||
- Whether collapsed sections are indicated using ellipsis is
|
||||
controlled by `magit-section-visibility-indicator'."
|
||||
:package-version '(magit . "3.0.0")
|
||||
Going forward I will start offering both messages when I feel the
|
||||
suggested longer message is reasonable enough, and the value of
|
||||
this option decides which will be used. Note that changing the
|
||||
value of this option affects all such messages and that I do not
|
||||
intend to add an option per prompt."
|
||||
:package-version '(magit . "4.0.0")
|
||||
:group 'magit-miscellaneous
|
||||
:type 'string)
|
||||
:type 'boolean)
|
||||
|
||||
(defcustom magit-ellipsis
|
||||
'((margin (?… . ">"))
|
||||
(t (?… . "...")))
|
||||
"Characters or strings used to abbreviate text in some buffers.
|
||||
|
||||
Each element has the form (WHERE (FANCY . UNIVERSAL)).
|
||||
|
||||
FANCY is a single character or nil whereas UNIVERSAL is a string
|
||||
of any length. The ellipsis produced by `magit--ellipsis' will
|
||||
be FANCY if it's a non-nil character that can be displayed with
|
||||
the available fonts, otherwise UNIVERSAL will be used. FANCY is
|
||||
meant to be a rich character like a horizontal ellipsis symbol or
|
||||
an emoji whereas UNIVERSAL something simpler available in a less
|
||||
rich environment like the CLI. WHERE determines the use-case for
|
||||
the ellipsis definition. Currently the only acceptable values
|
||||
for WHERE are `margin' or t (representing the default).
|
||||
|
||||
Whether collapsed sections are indicated using ellipsis is
|
||||
controlled by `magit-section-visibility-indicator'."
|
||||
:package-version '(magit . "4.0.0")
|
||||
:group 'magit-miscellaneous
|
||||
:type '(repeat (list (symbol :tag "Where")
|
||||
(cons (choice :tag "Fancy" character (const nil))
|
||||
(string :tag "Universal")))))
|
||||
|
||||
(defcustom magit-update-other-window-delay 0.2
|
||||
"Delay before automatically updating the other window.
|
||||
@@ -449,7 +471,8 @@ and delay of your graphical environment or operating system."
|
||||
(defclass magit-file-section (magit-diff-section)
|
||||
((keymap :initform 'magit-file-section-map)
|
||||
(source :initform nil)
|
||||
(header :initform nil)))
|
||||
(header :initform nil)
|
||||
(binary :initform nil)))
|
||||
|
||||
(defclass magit-module-section (magit-file-section)
|
||||
((keymap :initform 'magit-module-section-map)
|
||||
@@ -486,9 +509,9 @@ and delay of your graphical environment or operating system."
|
||||
|
||||
(defvar magit-completing-read--silent-default nil)
|
||||
|
||||
(defun magit-completing-read (prompt collection &optional
|
||||
predicate require-match initial-input
|
||||
hist def fallback)
|
||||
(defun magit-completing-read ( prompt collection &optional
|
||||
predicate require-match initial-input
|
||||
hist def fallback)
|
||||
"Read a choice in the minibuffer, or use the default choice.
|
||||
|
||||
This is the function that Magit commands use when they need the
|
||||
@@ -534,11 +557,11 @@ acts similarly to `completing-read', except for the following:
|
||||
`magit-builtin-completing-read'."
|
||||
(setq magit-completing-read--silent-default nil)
|
||||
(if-let ((dwim (and def
|
||||
(nth 2 (-first (pcase-lambda (`(,cmd ,re ,_))
|
||||
(and (eq this-command cmd)
|
||||
(or (not re)
|
||||
(string-match-p re prompt))))
|
||||
magit-dwim-selection)))))
|
||||
(nth 2 (seq-find (pcase-lambda (`(,cmd ,re ,_))
|
||||
(and (eq this-command cmd)
|
||||
(or (not re)
|
||||
(string-match-p re prompt))))
|
||||
magit-dwim-selection)))))
|
||||
(if (eq dwim 'ask)
|
||||
(if (y-or-n-p (format "%s %s? " prompt def))
|
||||
def
|
||||
@@ -589,48 +612,13 @@ acts similarly to `completing-read', except for the following:
|
||||
predicate require-match
|
||||
initial-input hist def))))
|
||||
|
||||
(define-obsolete-function-alias 'magit-completing-read-multiple*
|
||||
'magit-completing-read-multiple "Magit-Section 4.0.0")
|
||||
|
||||
(defun magit-completing-read-multiple
|
||||
(prompt choices &optional sep default hist keymap)
|
||||
"Read multiple items from CHOICES, separated by SEP.
|
||||
|
||||
Set up the `crm' variables needed to read multiple values with
|
||||
`read-from-minibuffer'.
|
||||
|
||||
SEP is a regexp matching characters that can separate choices.
|
||||
When SEP is nil, it defaults to `crm-separator'. DEFAULT, HIST,
|
||||
and KEYMAP are passed to `read-from-minibuffer'. When KEYMAP is
|
||||
nil, it defaults to `crm-local-completion-map'.
|
||||
|
||||
Unlike `completing-read-multiple', the return value is not split
|
||||
into a list."
|
||||
(declare (obsolete magit-completing-read-multiple* "Magit 3.1.0"))
|
||||
(let* ((crm-separator (or sep crm-separator))
|
||||
(crm-completion-table (magit--completion-table choices))
|
||||
(choose-completion-string-functions
|
||||
'(crm--choose-completion-string))
|
||||
(minibuffer-completion-table #'crm--collection-fn)
|
||||
(minibuffer-completion-confirm t)
|
||||
(helm-completion-in-region-default-sort-fn nil)
|
||||
(helm-crm-default-separator nil)
|
||||
(ivy-sort-matches-functions-alist nil)
|
||||
(input
|
||||
(cl-letf (((symbol-function #'completion-pcm--all-completions)))
|
||||
(when (< emacs-major-version 26)
|
||||
(fset 'completion-pcm--all-completions
|
||||
'magit-completion-pcm--all-completions))
|
||||
(read-from-minibuffer
|
||||
(concat prompt (and default (format " (%s)" default)) ": ")
|
||||
nil (or keymap crm-local-completion-map)
|
||||
nil hist default))))
|
||||
(when (string-equal input "")
|
||||
(or (setq input default)
|
||||
(user-error "Nothing selected")))
|
||||
input))
|
||||
|
||||
(defun magit-completing-read-multiple*
|
||||
(prompt table &optional predicate require-match initial-input
|
||||
hist def inherit-input-method
|
||||
no-split)
|
||||
( prompt table &optional predicate require-match initial-input
|
||||
hist def inherit-input-method
|
||||
no-split)
|
||||
"Read multiple strings in the minibuffer, with completion.
|
||||
Like `completing-read-multiple' but don't mess with order of
|
||||
TABLE and take an additional argument NO-SPLIT, which causes
|
||||
@@ -703,12 +691,10 @@ back to built-in `completing-read' for now." :error)
|
||||
(format "%s (default %s): " (substring prompt 0 -2) def)
|
||||
prompt))
|
||||
|
||||
(defvar magit-minibuffer-local-ns-map
|
||||
(let ((map (make-sparse-keymap)))
|
||||
(set-keymap-parent map minibuffer-local-map)
|
||||
(define-key map "\s" #'magit-whitespace-disallowed)
|
||||
(define-key map "\t" #'magit-whitespace-disallowed)
|
||||
map))
|
||||
(defvar-keymap magit-minibuffer-local-ns-map
|
||||
:parent minibuffer-local-map
|
||||
"SPC" #'magit-whitespace-disallowed
|
||||
"TAB" #'magit-whitespace-disallowed)
|
||||
|
||||
(defun magit-whitespace-disallowed ()
|
||||
"Beep to tell the user that whitespace is not allowed."
|
||||
@@ -718,8 +704,8 @@ back to built-in `completing-read' for now." :error)
|
||||
(setq defining-kbd-macro nil)
|
||||
(force-mode-line-update))
|
||||
|
||||
(defun magit-read-string (prompt &optional initial-input history default-value
|
||||
inherit-input-method no-whitespace)
|
||||
(defun magit-read-string ( prompt &optional initial-input history default-value
|
||||
inherit-input-method no-whitespace)
|
||||
"Read a string from the minibuffer, prompting with string PROMPT.
|
||||
|
||||
This is similar to `read-string', but
|
||||
@@ -755,8 +741,8 @@ This is similar to `read-string', but
|
||||
(user-error "Input contains whitespace"))
|
||||
(t val))))
|
||||
|
||||
(defun magit-read-string-ns (prompt &optional initial-input history
|
||||
default-value inherit-input-method)
|
||||
(defun magit-read-string-ns ( prompt &optional initial-input history
|
||||
default-value inherit-input-method)
|
||||
"Call `magit-read-string' with non-nil NO-WHITESPACE."
|
||||
(magit-read-string prompt initial-input history default-value
|
||||
inherit-input-method t))
|
||||
@@ -765,11 +751,11 @@ This is similar to `read-string', but
|
||||
(declare (indent 2)
|
||||
(debug (form form &rest (characterp form body))))
|
||||
`(prog1 (pcase (read-char-choice
|
||||
(concat ,prompt
|
||||
(mapconcat #'identity
|
||||
(list ,@(mapcar #'cadr clauses))
|
||||
", ")
|
||||
,(if verbose ", or [C-g] to abort " " "))
|
||||
(let ((parts (nconc (list ,@(mapcar #'cadr clauses))
|
||||
,(and verbose '(list "[C-g] to abort")))))
|
||||
(concat ,prompt
|
||||
(mapconcat #'identity (butlast parts) ", ")
|
||||
", or " (car (last parts)) " "))
|
||||
',(mapcar #'car clauses))
|
||||
,@(--map `(,(car it) ,@(cddr it)) clauses))
|
||||
(message "")))
|
||||
@@ -787,13 +773,15 @@ ACTION is a member of option `magit-slow-confirm'."
|
||||
'((safe-with-wip magit-wip-before-change-mode
|
||||
discard reverse stage-all-changes unstage-all-changes)))
|
||||
|
||||
(cl-defun magit-confirm (action &optional prompt prompt-n noabort
|
||||
(items nil sitems))
|
||||
(cl-defun magit-confirm ( action &optional prompt prompt-n noabort
|
||||
(items nil sitems) prompt-suffix)
|
||||
(declare (indent defun))
|
||||
(setq prompt-n (format (concat (or prompt-n prompt) "? ") (length items)))
|
||||
(setq prompt (format (concat (or prompt (magit-confirm-make-prompt action))
|
||||
"? ")
|
||||
(car items)))
|
||||
(when prompt-suffix
|
||||
(setq prompt (concat prompt prompt-suffix)))
|
||||
(or (cond ((and (not (eq action t))
|
||||
(or (eq magit-no-confirm t)
|
||||
(memq action magit-no-confirm)
|
||||
@@ -816,14 +804,14 @@ ACTION is a member of option `magit-slow-confirm'."
|
||||
items)))
|
||||
(if noabort nil (user-error "Abort"))))
|
||||
|
||||
(defun magit-confirm-files (action files &optional prompt)
|
||||
(defun magit-confirm-files (action files &optional prompt prompt-suffix noabort)
|
||||
(when files
|
||||
(unless prompt
|
||||
(setq prompt (magit-confirm-make-prompt action)))
|
||||
(magit-confirm action
|
||||
(concat prompt " %s")
|
||||
(concat prompt " %i files")
|
||||
nil files)))
|
||||
(concat prompt " \"%s\"")
|
||||
(concat prompt " %d files")
|
||||
noabort files prompt-suffix)))
|
||||
|
||||
(defun magit-confirm-make-prompt (action)
|
||||
(let ((prompt (symbol-name action)))
|
||||
@@ -985,7 +973,7 @@ with the text area."
|
||||
|
||||
This combines the benefits of `buffer-string', `buffer-substring'
|
||||
and `buffer-substring-no-properties' into one function that is
|
||||
not as painful to use as the latter. I.e. you can write
|
||||
not as painful to use as the latter. I.e., you can write
|
||||
(magit--buffer-string)
|
||||
instead of
|
||||
(buffer-substring-no-properties (point-min)
|
||||
@@ -1255,6 +1243,22 @@ Like `message', except that `message-log-max' is bound to nil."
|
||||
(goto-char (or ,pos 1))
|
||||
,@body))))
|
||||
|
||||
(defun magit--ellipsis (&optional where)
|
||||
"Build an ellipsis always as string, depending on WHERE."
|
||||
(if (stringp magit-ellipsis)
|
||||
magit-ellipsis
|
||||
(if-let ((pair (car (or
|
||||
(alist-get (or where t) magit-ellipsis)
|
||||
(alist-get t magit-ellipsis)))))
|
||||
(pcase-let ((`(,fancy . ,universal) pair))
|
||||
(let ((ellipsis (if (and fancy (char-displayable-p fancy))
|
||||
fancy
|
||||
universal)))
|
||||
(if (characterp ellipsis)
|
||||
(char-to-string ellipsis)
|
||||
ellipsis)))
|
||||
(user-error "Variable magit-ellipsis is invalid"))))
|
||||
|
||||
;;; _
|
||||
(provide 'magit-base)
|
||||
;;; magit-base.el ends here
|
||||
|
||||
Reference in New Issue
Block a user