pkg update and first config fix
org-brain not working, add org-roam
This commit is contained in:
@@ -1,19 +1,16 @@
|
||||
;;; magit-blame.el --- blame support for Magit -*- lexical-binding: t -*-
|
||||
;;; magit-blame.el --- Blame support for Magit -*- lexical-binding:t -*-
|
||||
|
||||
;; Copyright (C) 2012-2022 The Magit Project Contributors
|
||||
;;
|
||||
;; You should have received a copy of the AUTHORS.md file which
|
||||
;; lists all contributors. If not, see http://magit.vc/authors.
|
||||
;; Copyright (C) 2008-2022 The Magit Project Contributors
|
||||
|
||||
;; Author: Jonas Bernoulli <jonas@bernoul.li>
|
||||
;; Maintainer: Jonas Bernoulli <jonas@bernoul.li>
|
||||
|
||||
;; SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
;; Magit is free software; you can redistribute it and/or modify it
|
||||
;; Magit is free software: you can redistribute it and/or modify it
|
||||
;; under the terms of the GNU General Public License as published by
|
||||
;; the Free Software Foundation; either version 3, or (at your option)
|
||||
;; any later version.
|
||||
;; the Free Software Foundation, either version 3 of the License, or
|
||||
;; (at your option) any later version.
|
||||
;;
|
||||
;; Magit is distributed in the hope that it will be useful, but WITHOUT
|
||||
;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
@@ -21,7 +18,7 @@
|
||||
;; License for more details.
|
||||
;;
|
||||
;; You should have received a copy of the GNU General Public License
|
||||
;; along with Magit. If not, see http://www.gnu.org/licenses.
|
||||
;; along with Magit. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
@@ -42,11 +39,6 @@
|
||||
(defcustom magit-blame-styles
|
||||
'((headings
|
||||
(heading-format . "%-20a %C %s\n"))
|
||||
(margin
|
||||
(margin-format . (" %s%f" " %C %a" " %H"))
|
||||
(margin-width . 42)
|
||||
(margin-face . magit-blame-margin)
|
||||
(margin-body-face . (magit-blame-dimmed)))
|
||||
(highlight
|
||||
(highlight-face . magit-blame-highlight))
|
||||
(lines
|
||||
@@ -54,6 +46,10 @@
|
||||
(show-message . t)))
|
||||
"List of styles used to visualize blame information.
|
||||
|
||||
The style used in the current buffer can be cycled from the blame
|
||||
popup. Blame commands (except `magit-blame-echo') use the first
|
||||
style as the initial style when beginning to blame in a buffer.
|
||||
|
||||
Each entry has the form (IDENT (KEY . VALUE)...). IDENT has
|
||||
to be a symbol uniquely identifying the style. The following
|
||||
KEYs are recognized:
|
||||
@@ -76,7 +72,8 @@ KEYs are recognized:
|
||||
This can also be a list of formats used for the lines at
|
||||
the same positions within the chunk. If the chunk has
|
||||
more lines than formats are specified, then the last is
|
||||
repeated.
|
||||
repeated. WARNING: Adding this key affects performance;
|
||||
see the note at the end of this docstring.
|
||||
`margin-width'
|
||||
Width of the margin, provided `margin-format' is non-nil.
|
||||
`margin-face'
|
||||
@@ -108,9 +105,22 @@ that is displayed in the margin is made at least `margin-width'
|
||||
characters wide, which may be desirable if the used face sets
|
||||
the background color.
|
||||
|
||||
The style used in the current buffer can be cycled from the blame
|
||||
popup. Blame commands (except `magit-blame-echo') use the first
|
||||
style as the initial style when beginning to blame in a buffer."
|
||||
Blame information is displayed using overlays. Such extensive
|
||||
use of overlays is known to slow down even basic operations, such
|
||||
as moving the cursor. To reduce the number of overlays the margin
|
||||
style had to be removed from the default value of this option.
|
||||
|
||||
Note that the margin overlays are created even if another style
|
||||
is currently active. This can only be prevented by not even
|
||||
defining a style that uses the margin. If you want to use this
|
||||
style anyway, you can restore this definition, which used to be
|
||||
part of the default value:
|
||||
|
||||
(margin
|
||||
(margin-format . (\" %s%f\" \" %C %a\" \" %H\"))
|
||||
(margin-width . 42)
|
||||
(margin-face . magit-blame-margin)
|
||||
(margin-body-face . (magit-blame-dimmed)))"
|
||||
:package-version '(magit . "2.13.0")
|
||||
:group 'magit-blame
|
||||
:type 'string)
|
||||
@@ -153,7 +163,7 @@ and then turned on again when turning off the latter."
|
||||
:package-version '(magit . "2.13.0")
|
||||
:group 'magit-blame
|
||||
:type 'hook
|
||||
:get 'magit-hook-custom-get
|
||||
:get #'magit-hook-custom-get
|
||||
:options '(magit-blame-maybe-update-revision-buffer
|
||||
magit-blame-maybe-show-message))
|
||||
|
||||
@@ -213,6 +223,20 @@ Also see option `magit-blame-styles'."
|
||||
"Face used for dates when blaming."
|
||||
:group 'magit-faces)
|
||||
|
||||
;;; Variables
|
||||
|
||||
(defvar-local magit-blame-buffer-read-only nil)
|
||||
(defvar-local magit-blame-cache nil)
|
||||
(defvar-local magit-blame-disabled-modes nil)
|
||||
(defvar-local magit-blame-process nil)
|
||||
(defvar-local magit-blame-recursive-p nil)
|
||||
(defvar-local magit-blame-type nil)
|
||||
(defvar-local magit-blame-separator nil)
|
||||
(defvar-local magit-blame-previous-chunk nil)
|
||||
|
||||
(defvar-local magit-blame--make-margin-overlays nil)
|
||||
(defvar-local magit-blame--style nil)
|
||||
|
||||
;;; Chunks
|
||||
|
||||
(defclass magit-blame-chunk ()
|
||||
@@ -245,7 +269,10 @@ Also see option `magit-blame-styles'."
|
||||
(magit-blame-arguments))
|
||||
"-L" line rev "--" file)
|
||||
(goto-char (point-min))
|
||||
(car (magit-blame--parse-chunk type)))))
|
||||
(if (eobp)
|
||||
(unless noerror
|
||||
(error "Cannot get blame chunk at eob"))
|
||||
(car (magit-blame--parse-chunk type))))))
|
||||
(noerror nil)
|
||||
(t (error "Buffer does not visit a tracked file")))))))
|
||||
|
||||
@@ -272,41 +299,25 @@ in `magit-blame-read-only-mode-map' instead.")
|
||||
|
||||
(defvar magit-blame-read-only-mode-map
|
||||
(let ((map (make-sparse-keymap)))
|
||||
(define-key map (kbd "C-m") 'magit-show-commit)
|
||||
(define-key map (kbd "p") 'magit-blame-previous-chunk)
|
||||
(define-key map (kbd "P") 'magit-blame-previous-chunk-same-commit)
|
||||
(define-key map (kbd "n") 'magit-blame-next-chunk)
|
||||
(define-key map (kbd "N") 'magit-blame-next-chunk-same-commit)
|
||||
(define-key map (kbd "b") 'magit-blame-addition)
|
||||
(define-key map (kbd "r") 'magit-blame-removal)
|
||||
(define-key map (kbd "f") 'magit-blame-reverse)
|
||||
(define-key map (kbd "B") 'magit-blame)
|
||||
(define-key map (kbd "c") 'magit-blame-cycle-style)
|
||||
(define-key map (kbd "q") 'magit-blame-quit)
|
||||
(define-key map (kbd "M-w") 'magit-blame-copy-hash)
|
||||
(define-key map (kbd "SPC") 'magit-diff-show-or-scroll-up)
|
||||
(define-key map (kbd "S-SPC") 'magit-diff-show-or-scroll-down)
|
||||
(define-key map (kbd "DEL") 'magit-diff-show-or-scroll-down)
|
||||
(define-key map (kbd "C-m") #'magit-show-commit)
|
||||
(define-key map (kbd "p") #'magit-blame-previous-chunk)
|
||||
(define-key map (kbd "P") #'magit-blame-previous-chunk-same-commit)
|
||||
(define-key map (kbd "n") #'magit-blame-next-chunk)
|
||||
(define-key map (kbd "N") #'magit-blame-next-chunk-same-commit)
|
||||
(define-key map (kbd "b") #'magit-blame-addition)
|
||||
(define-key map (kbd "r") #'magit-blame-removal)
|
||||
(define-key map (kbd "f") #'magit-blame-reverse)
|
||||
(define-key map (kbd "B") #'magit-blame)
|
||||
(define-key map (kbd "c") #'magit-blame-cycle-style)
|
||||
(define-key map (kbd "q") #'magit-blame-quit)
|
||||
(define-key map (kbd "M-w") #'magit-blame-copy-hash)
|
||||
(define-key map (kbd "SPC") #'magit-diff-show-or-scroll-up)
|
||||
(define-key map (kbd "S-SPC") #'magit-diff-show-or-scroll-down)
|
||||
(define-key map (kbd "DEL") #'magit-diff-show-or-scroll-down)
|
||||
map)
|
||||
"Keymap for `magit-blame-read-only-mode'.")
|
||||
|
||||
;;; Modes
|
||||
;;;; Variables
|
||||
|
||||
(defvar-local magit-blame-buffer-read-only nil)
|
||||
(defvar-local magit-blame-cache nil)
|
||||
(defvar-local magit-blame-disabled-modes nil)
|
||||
(defvar-local magit-blame-process nil)
|
||||
(defvar-local magit-blame-recursive-p nil)
|
||||
(defvar-local magit-blame-type nil)
|
||||
(defvar-local magit-blame-separator nil)
|
||||
(defvar-local magit-blame-previous-chunk nil)
|
||||
|
||||
(defvar-local magit-blame--style nil)
|
||||
|
||||
(defsubst magit-blame--style-get (key)
|
||||
(cdr (assoc key (cdr magit-blame--style))))
|
||||
|
||||
;;;; Base Mode
|
||||
|
||||
(define-minor-mode magit-blame-mode
|
||||
@@ -318,11 +329,11 @@ in `magit-blame-read-only-mode-map' instead.")
|
||||
(user-error
|
||||
(concat "Don't call `magit-blame-mode' directly; "
|
||||
"instead use `magit-blame'")))
|
||||
(add-hook 'after-save-hook 'magit-blame--refresh t t)
|
||||
(add-hook 'post-command-hook 'magit-blame-goto-chunk-hook t t)
|
||||
(add-hook 'before-revert-hook 'magit-blame--remove-overlays t t)
|
||||
(add-hook 'after-revert-hook 'magit-blame--refresh t t)
|
||||
(add-hook 'read-only-mode-hook 'magit-blame-toggle-read-only t t)
|
||||
(add-hook 'after-save-hook #'magit-blame--refresh t t)
|
||||
(add-hook 'post-command-hook #'magit-blame-goto-chunk-hook t t)
|
||||
(add-hook 'before-revert-hook #'magit-blame--remove-overlays t t)
|
||||
(add-hook 'after-revert-hook #'magit-blame--refresh t t)
|
||||
(add-hook 'read-only-mode-hook #'magit-blame-toggle-read-only t t)
|
||||
(setq magit-blame-buffer-read-only buffer-read-only)
|
||||
(when (or magit-blame-read-only magit-buffer-file-name)
|
||||
(read-only-mode 1))
|
||||
@@ -333,17 +344,21 @@ in `magit-blame-read-only-mode-map' instead.")
|
||||
(setq magit-blame-separator (magit-blame--format-separator))
|
||||
(unless magit-blame--style
|
||||
(setq magit-blame--style (car magit-blame-styles)))
|
||||
(setq magit-blame--make-margin-overlays
|
||||
(and (cl-find-if (lambda (style)
|
||||
(assq 'margin-format (cdr style)))
|
||||
magit-blame-styles)))
|
||||
(magit-blame--update-margin))
|
||||
(t
|
||||
(when (process-live-p magit-blame-process)
|
||||
(kill-process magit-blame-process)
|
||||
(while magit-blame-process
|
||||
(sit-for 0.01))) ; avoid racing the sentinel
|
||||
(remove-hook 'after-save-hook 'magit-blame--refresh t)
|
||||
(remove-hook 'post-command-hook 'magit-blame-goto-chunk-hook t)
|
||||
(remove-hook 'before-revert-hook 'magit-blame--remove-overlays t)
|
||||
(remove-hook 'after-revert-hook 'magit-blame--refresh t)
|
||||
(remove-hook 'read-only-mode-hook 'magit-blame-toggle-read-only t)
|
||||
(remove-hook 'after-save-hook #'magit-blame--refresh t)
|
||||
(remove-hook 'post-command-hook #'magit-blame-goto-chunk-hook t)
|
||||
(remove-hook 'before-revert-hook #'magit-blame--remove-overlays t)
|
||||
(remove-hook 'after-revert-hook #'magit-blame--refresh t)
|
||||
(remove-hook 'read-only-mode-hook #'magit-blame-toggle-read-only t)
|
||||
(unless magit-blame-buffer-read-only
|
||||
(read-only-mode -1))
|
||||
(magit-blame-read-only-mode -1)
|
||||
@@ -411,17 +426,17 @@ modes is toggled, then this mode also gets toggled automatically.
|
||||
(list (line-number-at-pos (window-start))
|
||||
(line-number-at-pos (1- (window-end nil t)))))
|
||||
(set-process-sentinel magit-this-process
|
||||
'magit-blame-process-quickstart-sentinel)))
|
||||
#'magit-blame-process-quickstart-sentinel)))
|
||||
|
||||
(defun magit-blame-run-process (revision file args &optional lines)
|
||||
(let ((process (magit-parse-git-async
|
||||
"blame" "--incremental" args
|
||||
(and lines (list "-L" (apply #'format "%s,%s" lines)))
|
||||
revision "--" file)))
|
||||
(set-process-filter process 'magit-blame-process-filter)
|
||||
(set-process-sentinel process 'magit-blame-process-sentinel)
|
||||
(set-process-filter process #'magit-blame-process-filter)
|
||||
(set-process-sentinel process #'magit-blame-process-sentinel)
|
||||
(process-put process 'arguments (list revision file args))
|
||||
(setq magit-blame-cache (make-hash-table :test 'equal))
|
||||
(setq magit-blame-cache (make-hash-table :test #'equal))
|
||||
(setq magit-blame-process process)))
|
||||
|
||||
(defun magit-blame-process-quickstart-sentinel (process event)
|
||||
@@ -476,7 +491,7 @@ modes is toggled, then this mode also gets toggled automatically.
|
||||
|
||||
(defun magit-blame--parse-chunk (type)
|
||||
(let (chunk revinfo)
|
||||
(unless (looking-at "^\\(.\\{40\\}\\) \\([0-9]+\\) \\([0-9]+\\) \\([0-9]+\\)")
|
||||
(unless (looking-at "^\\(.\\{40,\\}\\) \\([0-9]+\\) \\([0-9]+\\) \\([0-9]+\\)")
|
||||
(error "Blaming failed due to unexpected output: %s"
|
||||
(buffer-substring-no-properties (point) (line-end-position))))
|
||||
(with-slots (orig-rev orig-file prev-rev prev-file)
|
||||
@@ -491,7 +506,7 @@ modes is toggled, then this mode also gets toggled automatically.
|
||||
(cond ((looking-at "^filename \\(.+\\)")
|
||||
(setq done t)
|
||||
(setf orig-file (magit-decode-git-path (match-string 1))))
|
||||
((looking-at "^previous \\(.\\{40\\}\\) \\(.+\\)")
|
||||
((looking-at "^previous \\(.\\{40,\\}\\) \\(.+\\)")
|
||||
(setf prev-rev (match-string 1))
|
||||
(setf prev-file (magit-decode-git-path (match-string 2))))
|
||||
((looking-at "^\\([^ ]+\\) \\(.+\\)")
|
||||
@@ -520,25 +535,42 @@ modes is toggled, then this mode also gets toggled automatically.
|
||||
|
||||
;;; Display
|
||||
|
||||
(defsubst magit-blame--style-get (key)
|
||||
(cdr (assoc key (cdr magit-blame--style))))
|
||||
|
||||
(defun magit-blame--make-overlays (buf chunk revinfo)
|
||||
(with-current-buffer buf
|
||||
(save-excursion
|
||||
(save-restriction
|
||||
(widen)
|
||||
(goto-char (point-min))
|
||||
(forward-line (1- (oref chunk final-line)))
|
||||
(let ((beg (point))
|
||||
(end (save-excursion
|
||||
(forward-line (oref chunk num-lines))
|
||||
(point))))
|
||||
(let* ((line (oref chunk final-line))
|
||||
(beg (magit-blame--line-beginning-position line))
|
||||
(end (magit-blame--line-beginning-position
|
||||
(+ line (oref chunk num-lines))))
|
||||
(before (magit-blame-chunk-at (1- beg))))
|
||||
(when (and before
|
||||
(equal (oref before orig-rev)
|
||||
(oref chunk orig-rev)))
|
||||
(setq beg (magit-blame--line-beginning-position
|
||||
(oset chunk final-line (oref before final-line))))
|
||||
(cl-incf (oref chunk num-lines)
|
||||
(oref before num-lines)))
|
||||
(magit-blame--remove-overlays beg end)
|
||||
(magit-blame--make-margin-overlays chunk revinfo beg end)
|
||||
(when magit-blame--make-margin-overlays
|
||||
(magit-blame--make-margin-overlays chunk revinfo beg end))
|
||||
(magit-blame--make-heading-overlay chunk revinfo beg end)
|
||||
(magit-blame--make-highlight-overlay chunk beg))))))
|
||||
(magit-blame--make-highlight-overlay chunk beg))))))
|
||||
|
||||
(defun magit-blame--make-margin-overlays (chunk revinfo _beg end)
|
||||
(defun magit-blame--line-beginning-position (line)
|
||||
(save-excursion
|
||||
(goto-char (point-min))
|
||||
(forward-line (1- line))
|
||||
(point)))
|
||||
|
||||
(defun magit-blame--make-margin-overlays (chunk revinfo beg end)
|
||||
(save-excursion
|
||||
(let ((line 0))
|
||||
(goto-char beg)
|
||||
(while (< (point) end)
|
||||
(magit-blame--make-margin-overlay chunk revinfo line)
|
||||
(forward-line)
|
||||
@@ -563,7 +595,9 @@ modes is toggled, then this mode also gets toggled automatically.
|
||||
(magit-blame--update-heading-overlay ov)))
|
||||
|
||||
(defun magit-blame--make-highlight-overlay (chunk beg)
|
||||
(let ((ov (make-overlay beg (1+ (line-end-position)))))
|
||||
(let ((ov (make-overlay beg (save-excursion
|
||||
(goto-char beg)
|
||||
(1+ (line-end-position))))))
|
||||
(overlay-put ov 'magit-blame-chunk chunk)
|
||||
(overlay-put ov 'magit-blame-highlight t)
|
||||
(magit-blame--update-highlight-overlay ov)))
|
||||
@@ -638,7 +672,7 @@ modes is toggled, then this mode also gets toggled automatically.
|
||||
|
||||
(defun magit-blame--format-string-1 (rev revinfo format face)
|
||||
(let ((str
|
||||
(if (equal rev "0000000000000000000000000000000000000000")
|
||||
(if (string-match-p "\\`0\\{40,\\}\\'" rev)
|
||||
(propertize (concat (if (string-prefix-p "\s" format) "\s" "")
|
||||
"Not Yet Committed"
|
||||
(if (string-suffix-p "\n" format) "\n" ""))
|
||||
@@ -646,19 +680,19 @@ modes is toggled, then this mode also gets toggled automatically.
|
||||
(magit--format-spec
|
||||
(propertize format 'font-lock-face face)
|
||||
(cl-flet* ((p0 (s f)
|
||||
(propertize s 'font-lock-face
|
||||
(if face
|
||||
(if (listp face)
|
||||
face
|
||||
(list f face))
|
||||
f)))
|
||||
(propertize s 'font-lock-face
|
||||
(if face
|
||||
(if (listp face)
|
||||
face
|
||||
(list f face))
|
||||
f)))
|
||||
(p1 (k f)
|
||||
(p0 (cdr (assoc k revinfo)) f))
|
||||
(p0 (cdr (assoc k revinfo)) f))
|
||||
(p2 (k1 k2 f)
|
||||
(p0 (magit-blame--format-time-string
|
||||
(cdr (assoc k1 revinfo))
|
||||
(cdr (assoc k2 revinfo)))
|
||||
f)))
|
||||
(p0 (magit-blame--format-time-string
|
||||
(cdr (assoc k1 revinfo))
|
||||
(cdr (assoc k2 revinfo)))
|
||||
f)))
|
||||
`((?H . ,(p0 rev 'magit-blame-hash))
|
||||
(?s . ,(p1 "summary" 'magit-blame-summary))
|
||||
(?a . ,(p1 "author" 'magit-blame-name))
|
||||
@@ -685,7 +719,7 @@ modes is toggled, then this mode also gets toggled automatically.
|
||||
(defun magit-blame--format-time-string (time tz)
|
||||
(let* ((time-format (or (magit-blame--style-get 'time-format)
|
||||
magit-blame-time-format))
|
||||
(tz-in-second (and (string-match "%z" time-format)
|
||||
(tz-in-second (and (string-search "%z" time-format)
|
||||
(car (last (parse-time-string tz))))))
|
||||
(format-time-string time-format
|
||||
(seconds-to-time (string-to-number time))
|
||||
@@ -850,8 +884,8 @@ then also kill the buffer."
|
||||
(not (= pos (if previous (point-min) (point-max))))
|
||||
(setq pos (funcall
|
||||
(if previous
|
||||
'previous-single-char-property-change
|
||||
'next-single-char-property-change)
|
||||
#'previous-single-char-property-change
|
||||
#'next-single-char-property-change)
|
||||
pos 'magit-blame-chunk)))
|
||||
(--when-let (magit-blame--overlay-at pos)
|
||||
(when (equal (oref (magit-blame-chunk-at pos) orig-rev) rev)
|
||||
@@ -864,7 +898,7 @@ then also kill the buffer."
|
||||
(defun magit-blame-previous-chunk-same-commit ()
|
||||
"Move to the previous chunk from the same commit."
|
||||
(interactive)
|
||||
(magit-blame-next-chunk-same-commit 'previous-single-char-property-change))
|
||||
(magit-blame-next-chunk-same-commit #'previous-single-char-property-change))
|
||||
|
||||
(defun magit-blame-cycle-style ()
|
||||
"Change how blame information is visualized.
|
||||
@@ -918,21 +952,21 @@ instead of the hash, like `kill-ring-save' would."
|
||||
:class 'transient-option
|
||||
:argument "-M"
|
||||
:allow-empty t
|
||||
:reader 'transient-read-number-N+)
|
||||
:reader #'transient-read-number-N+)
|
||||
|
||||
(transient-define-argument magit-blame:-C ()
|
||||
:description "Detect lines moved or copied between files"
|
||||
:class 'transient-option
|
||||
:argument "-C"
|
||||
:allow-empty t
|
||||
:reader 'transient-read-number-N+)
|
||||
:reader #'transient-read-number-N+)
|
||||
|
||||
;;; Utilities
|
||||
|
||||
(defun magit-blame-maybe-update-revision-buffer ()
|
||||
(when-let ((chunk (magit-current-blame-chunk))
|
||||
(commit (oref chunk orig-rev))
|
||||
(buffer (magit-get-mode-buffer 'magit-revision-mode nil t)))
|
||||
(when-let* ((chunk (magit-current-blame-chunk))
|
||||
(commit (oref chunk orig-rev))
|
||||
(buffer (magit-get-mode-buffer 'magit-revision-mode nil t)))
|
||||
(if magit--update-revision-buffer
|
||||
(setq magit--update-revision-buffer (list commit buffer))
|
||||
(setq magit--update-revision-buffer (list commit buffer))
|
||||
|
||||
Reference in New Issue
Block a user