update packages
This commit is contained in:
+40
-25
@@ -101,7 +101,6 @@ Non-interactively REV can also be a blob object."
|
||||
(rev rev)))
|
||||
(topdir (magit-toplevel))
|
||||
(file (expand-file-name file topdir))
|
||||
(file-relative (file-relative-name file topdir))
|
||||
(buffer
|
||||
(cond-let
|
||||
((equal rev "{worktree}")
|
||||
@@ -118,7 +117,7 @@ Non-interactively REV can also be a blob object."
|
||||
(unless (file-in-directory-p file topdir)
|
||||
(error "%s is not inside Git repository %s" file topdir))
|
||||
(with-current-buffer
|
||||
(magit--get-blob-buffer rev file-relative volatile)
|
||||
(magit--get-blob-buffer rev file volatile)
|
||||
(if (magit-blob-p rev)
|
||||
(setq magit-buffer-blob-oid--init (magit-rev-parse rev))
|
||||
(setq magit-buffer-revision rev))
|
||||
@@ -126,18 +125,20 @@ Non-interactively REV can also be a blob object."
|
||||
(setq default-directory
|
||||
(if (file-exists-p defdir) defdir topdir))
|
||||
(setq-local revert-buffer-function #'magit--revert-blob-buffer)
|
||||
(setq-local buffer-read-only t)
|
||||
(setq-local read-only-mode--state t)
|
||||
(magit--refresh-blob-buffer)
|
||||
(current-buffer)))
|
||||
((error "Unexpected error")))))
|
||||
(when (and (not no-restore-position)
|
||||
(equal (magit-file-relative-name) file-relative))
|
||||
(equal magit-buffer-file-name file))
|
||||
(let ((pos (magit-find-file--position)))
|
||||
(with-current-buffer buffer
|
||||
(apply #'magit-find-file--restore-position pos))))
|
||||
buffer))
|
||||
|
||||
(defun magit--get-blob-buffer (obj file &optional volatile)
|
||||
;; If OBJ is a commit, is assummed to be abbreviated.
|
||||
;; If OBJ is a commit, is assumed to be abbreviated.
|
||||
;; FILE is assumed to be relative to the top-level.
|
||||
(cond-let
|
||||
([buf (if (magit-blob-p obj)
|
||||
@@ -215,7 +216,6 @@ Non-interactively REV can also be a blob object."
|
||||
;; The FIND-FILE argument wasn't designed for our use case,
|
||||
;; so we have to use this strange invocation to achieve that.
|
||||
(normal-mode (not enable-local-variables)))
|
||||
(setq buffer-read-only t)
|
||||
(set-buffer-modified-p nil)
|
||||
(run-hooks 'magit-find-blob-hook)))
|
||||
|
||||
@@ -303,10 +303,10 @@ Age is tracked in seconds. If nil, only use `magit--blob-cache-limit'.")
|
||||
(when-let* ((_ magit--blob-cache-limit)
|
||||
(ceiling (- magit--blob-cache-limit (length active)))
|
||||
(_ (length> rest ceiling)))
|
||||
(let ((sorted (static-if (>= emacs-major-version 30)
|
||||
(sort rest :key (##float-time (cdr %))
|
||||
:lessp #'< :reverse t)
|
||||
(cl-sort rest #'> :key (##float-time (cdr %))))))
|
||||
(let ((sorted (compat-call sort rest
|
||||
:key (##float-time (cdr %))
|
||||
:lessp #'<
|
||||
:reverse t)))
|
||||
(dolist (kill (nthcdr ceiling sorted))
|
||||
(kill-buffer (car kill)))
|
||||
(setq rest (ntake ceiling sorted))))
|
||||
@@ -472,6 +472,7 @@ to `magit-dispatch'."
|
||||
|
||||
(defvar-keymap magit-blob-mode-map
|
||||
:doc "Keymap for `magit-blob-mode'."
|
||||
"<remap> <read-only-mode>" #'magit-blob-mode
|
||||
"g" #'revert-buffer
|
||||
"p" #'magit-blob-previous
|
||||
"n" #'magit-blob-next
|
||||
@@ -481,11 +482,22 @@ to `magit-dispatch'."
|
||||
"q" #'magit-bury-or-kill-buffer)
|
||||
|
||||
(define-minor-mode magit-blob-mode
|
||||
"Enable some Magit features in blob-visiting buffers.
|
||||
"Enable key bindings, which are useful in blob-visiting buffers.
|
||||
|
||||
Currently this only adds the following key bindings.
|
||||
\n\\{magit-blob-mode-map}"
|
||||
:package-version '(magit . "2.3.0"))
|
||||
\\{magit-blob-mode-map}
|
||||
When the user disables `read-only-mode', these bindings would conflict
|
||||
with bindings for `self-insert-command'. To avoid this conflict,
|
||||
`read-only-mode' is remapped to `magit-blob-mode' and disabling the
|
||||
latter disables both modes. Likewise, enabling it, also enables
|
||||
`read-only-mode'.
|
||||
|
||||
When this mode is disabled, many of the commands, for which it would
|
||||
single-character bindings, are accessible via \\[magit-file-dispatch]."
|
||||
:package-version '(magit . "2.3.0")
|
||||
;; Don't actually call `read-only-mode'. Because
|
||||
;; that could enable the incompatible `view-mode'.
|
||||
(setq-local buffer-read-only magit-blob-mode)
|
||||
(setq-local read-only-mode--state magit-blob-mode))
|
||||
|
||||
(defun magit-bury-buffer (&optional kill-buffer)
|
||||
"Bury the current buffer, or with a prefix argument kill it.
|
||||
@@ -710,15 +722,14 @@ Git, then fallback to using `delete-file'."
|
||||
(car (member (or default (magit-current-file)) files)))))
|
||||
|
||||
(defun magit-read-file (prompt &optional tracked-only)
|
||||
(magit-with-toplevel
|
||||
(let ((choices (nconc (magit-list-files)
|
||||
(and (not tracked-only)
|
||||
(magit-untracked-files)))))
|
||||
(magit-completing-read
|
||||
prompt choices nil t nil nil
|
||||
(car (member (or (magit-section-value-if '(file submodule))
|
||||
(magit-file-relative-name nil tracked-only))
|
||||
choices))))))
|
||||
(let ((choices (nconc (magit-list-files)
|
||||
(and (not tracked-only)
|
||||
(magit-untracked-files)))))
|
||||
(magit-completing-read
|
||||
prompt choices nil t nil nil
|
||||
(car (member (or (magit-section-value-if '(file submodule))
|
||||
(magit-file-relative-name nil tracked-only))
|
||||
choices)))))
|
||||
|
||||
(defun magit-read-tracked-file (prompt)
|
||||
(magit-read-file prompt t))
|
||||
@@ -781,11 +792,15 @@ If DEFAULT is non-nil, use this as the default value instead of
|
||||
;; Local Variables:
|
||||
;; read-symbol-shorthands: (
|
||||
;; ("and$" . "cond-let--and$")
|
||||
;; ("and>" . "cond-let--and>")
|
||||
;; ("and-let" . "cond-let--and-let")
|
||||
;; ("if-let" . "cond-let--if-let")
|
||||
;; ("thread$" . "cond-let--thread$")
|
||||
;; ("when$" . "cond-let--when$")
|
||||
;; ("and-let*" . "cond-let--and-let*")
|
||||
;; ("and-let" . "cond-let--and-let")
|
||||
;; ("if-let*" . "cond-let--if-let*")
|
||||
;; ("if-let" . "cond-let--if-let")
|
||||
;; ("when-let*" . "cond-let--when-let*")
|
||||
;; ("when-let" . "cond-let--when-let")
|
||||
;; ("while-let*" . "cond-let--while-let*")
|
||||
;; ("while-let" . "cond-let--while-let")
|
||||
;; ("match-string" . "match-string")
|
||||
;; ("match-str" . "match-string-no-properties"))
|
||||
|
||||
Reference in New Issue
Block a user