update packages and add valign
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
;;; magit-base.el --- Early birds -*- lexical-binding:t; coding:utf-8 -*-
|
||||
|
||||
;; Copyright (C) 2008-2025 The Magit Project Contributors
|
||||
;; Copyright (C) 2008-2026 The Magit Project Contributors
|
||||
|
||||
;; Author: Jonas Bernoulli <emacs.magit@jonas.bernoulli.dev>
|
||||
;; Maintainer: Jonas Bernoulli <emacs.magit@jonas.bernoulli.dev>
|
||||
@@ -494,7 +494,7 @@ and delay of your graphical environment or operating system."
|
||||
(defclass magit-hunk-section (magit-diff-section)
|
||||
((keymap :initform 'magit-hunk-section-map)
|
||||
(painted :initform nil)
|
||||
(fontified :initform nil) ;TODO
|
||||
(fontified :initform nil)
|
||||
(refined :initform nil)
|
||||
(combined :initform nil :initarg :combined)
|
||||
(from-range :initform nil :initarg :from-range)
|
||||
@@ -824,13 +824,13 @@ ACTION is a member of option `magit-slow-confirm'."
|
||||
(or (cond ((and (not (eq action t))
|
||||
(or (eq magit-no-confirm t)
|
||||
(memq action magit-no-confirm)
|
||||
(cl-member-if (pcase-lambda (`(,key ,var . ,sub))
|
||||
(and (memq key magit-no-confirm)
|
||||
(memq action sub)
|
||||
(or (not var)
|
||||
(and (boundp var)
|
||||
(symbol-value var)))))
|
||||
magit--no-confirm-alist)))
|
||||
(magit--any (pcase-lambda (`(,key ,var . ,sub))
|
||||
(and (memq key magit-no-confirm)
|
||||
(memq action sub)
|
||||
(or (not var)
|
||||
(and (boundp var)
|
||||
(symbol-value var)))))
|
||||
magit--no-confirm-alist)))
|
||||
(or (not sitems) items))
|
||||
((not sitems)
|
||||
(magit-y-or-n-p prompt action))
|
||||
@@ -963,32 +963,32 @@ Pad the left side of STRING so that it aligns with the text area."
|
||||
(goto-char (point-min))
|
||||
(while (search-forward "%" nil t)
|
||||
(cond
|
||||
;; Quoted percent sign.
|
||||
((eq (char-after) ?%)
|
||||
(delete-char 1))
|
||||
;; Valid format spec.
|
||||
((looking-at "\\([-0-9.]*\\)\\([a-zA-Z]\\)")
|
||||
(let* ((num (match-str 1))
|
||||
(spec (string-to-char (match-str 2)))
|
||||
(val (assq spec specification)))
|
||||
(unless val
|
||||
(error "Invalid format character: `%%%c'" spec))
|
||||
(setq val (cdr val))
|
||||
;; Pad result to desired length.
|
||||
(let ((text (format (concat "%" num "s") val)))
|
||||
;; Insert first, to preserve text properties.
|
||||
(if (next-property-change 0 (concat " " text))
|
||||
;; If the inserted text has properties, then preserve those.
|
||||
(insert text)
|
||||
;; Otherwise preserve FORMAT's properties, like `format-spec'.
|
||||
(insert-and-inherit text))
|
||||
;; Delete the specifier body.
|
||||
(delete-region (+ (match-beginning 0) (length text))
|
||||
(+ (match-end 0) (length text)))
|
||||
;; Delete the percent sign.
|
||||
(delete-region (1- (match-beginning 0)) (match-beginning 0)))))
|
||||
;; Signal an error on bogus format strings.
|
||||
((error "Invalid format string"))))
|
||||
;; Quoted percent sign.
|
||||
((eq (char-after) ?%)
|
||||
(delete-char 1))
|
||||
;; Valid format spec.
|
||||
((looking-at "\\([-0-9.]*\\)\\([a-zA-Z]\\)")
|
||||
(let* ((num (match-str 1))
|
||||
(spec (string-to-char (match-str 2)))
|
||||
(val (assq spec specification)))
|
||||
(unless val
|
||||
(error "Invalid format character: `%%%c'" spec))
|
||||
(setq val (cdr val))
|
||||
;; Pad result to desired length.
|
||||
(let ((text (format (concat "%" num "s") val)))
|
||||
;; Insert first, to preserve text properties.
|
||||
(if (next-property-change 0 (concat " " text))
|
||||
;; If the inserted text has properties, then preserve those.
|
||||
(insert text)
|
||||
;; Otherwise preserve FORMAT's properties, like `format-spec'.
|
||||
(insert-and-inherit text))
|
||||
;; Delete the specifier body.
|
||||
(delete-region (+ (match-beginning 0) (length text))
|
||||
(+ (match-end 0) (length text)))
|
||||
;; Delete the percent sign.
|
||||
(delete-region (1- (match-beginning 0)) (match-beginning 0)))))
|
||||
;; Signal an error on bogus format strings.
|
||||
((error "Invalid format string"))))
|
||||
(buffer-string)))
|
||||
|
||||
;;; Missing from Emacs
|
||||
@@ -1013,6 +1013,24 @@ This function should be named `version>' and be part of Emacs."
|
||||
This function should be named `version>=' and be part of Emacs."
|
||||
(version-list-<= (version-to-list v2) (version-to-list v1)))
|
||||
|
||||
(defun magit--delete-text-properties (string &optional props)
|
||||
"Delete text properties PROPS from STRING and return it.
|
||||
If PROPS is nil, remove all properties. To leave STRING unchanged
|
||||
and return a new string, instead use `magit--remove-text-properties'."
|
||||
(set-text-properties 0 (length string) props string)
|
||||
string)
|
||||
|
||||
(defun magit--remove-text-properties (string &optional props)
|
||||
"Return a copy of STRING with text properties PROPS removed.
|
||||
If PROPS is nil, remove all properties."
|
||||
(magit--delete-text-properties (copy-sequence string) props))
|
||||
|
||||
;;; Emacs Compatibility
|
||||
|
||||
(static-if (fboundp 'member-if) ; Emacs 31.1
|
||||
(defalias 'magit--any 'member-if)
|
||||
(defalias 'magit--any 'cl-member-if))
|
||||
|
||||
;;; Kludges for Emacs Bugs
|
||||
|
||||
(defun magit-which-function ()
|
||||
@@ -1187,6 +1205,16 @@ Like `message', except that `message-log-max' is bound to nil."
|
||||
(push char quoted))
|
||||
(concat (nreverse quoted))))
|
||||
|
||||
(defun magit--find-buffer (&rest plist)
|
||||
"Like `find-buffer' but take multiple VARIABLE-VALUE pairs."
|
||||
(seq-find (lambda (buf)
|
||||
(while (and plist
|
||||
(equal (buffer-local-value (car plist) buf)
|
||||
(cadr plist)))
|
||||
(setq plist (cddr plist)))
|
||||
(not plist))
|
||||
(buffer-list)))
|
||||
|
||||
;;; _
|
||||
(provide 'magit-base)
|
||||
;; Local Variables:
|
||||
@@ -1195,6 +1223,7 @@ Like `message', except that `message-log-max' is bound to nil."
|
||||
;; ("and>" . "cond-let--and>")
|
||||
;; ("and-let" . "cond-let--and-let")
|
||||
;; ("if-let" . "cond-let--if-let")
|
||||
;; ("when$" . "cond-let--when$")
|
||||
;; ("when-let" . "cond-let--when-let")
|
||||
;; ("while-let" . "cond-let--while-let")
|
||||
;; ("match-string" . "match-string")
|
||||
|
||||
Reference in New Issue
Block a user