pkg update and first config fix
org-brain not working, add org-roam
This commit is contained in:
@@ -1,19 +1,16 @@
|
||||
;;; magit-extras.el --- additional functionality for Magit -*- lexical-binding: t -*-
|
||||
;;; magit-extras.el --- Additional functionality for Magit -*- lexical-binding:t -*-
|
||||
|
||||
;; Copyright (C) 2008-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:
|
||||
|
||||
@@ -31,12 +28,11 @@
|
||||
|
||||
(require 'magit)
|
||||
|
||||
(declare-function change-log-insert-entries "add-log" (changelogs))
|
||||
(declare-function diff-add-log-current-defuns "diff-mode" ())
|
||||
;; For `magit-do-async-shell-command'.
|
||||
(declare-function dired-read-shell-command "dired-aux" (prompt arg files))
|
||||
;; For `magit-project-status'.
|
||||
(declare-function project-root "project" (project))
|
||||
(declare-function vc-git-command "vc-git" (buffer okstatus file-or-list &rest flags))
|
||||
(declare-function vc-git-command "vc-git"
|
||||
(buffer okstatus file-or-list &rest flags))
|
||||
|
||||
(defvar ido-exit)
|
||||
(defvar ido-fallback)
|
||||
@@ -47,25 +43,89 @@
|
||||
"Additional functionality for Magit."
|
||||
:group 'magit-extensions)
|
||||
|
||||
;;; External Tools
|
||||
;;; Git Tools
|
||||
;;;; Git-Mergetool
|
||||
|
||||
(defcustom magit-gitk-executable
|
||||
(or (and (eq system-type 'windows-nt)
|
||||
(let ((exe (magit-git-string
|
||||
"-c" "alias.X=!x() { which \"$1\" | cygpath -mf -; }; x"
|
||||
"X" "gitk.exe")))
|
||||
(and exe (file-executable-p exe) exe)))
|
||||
(executable-find "gitk") "gitk")
|
||||
"The Gitk executable."
|
||||
:group 'magit-extras
|
||||
:set-after '(magit-git-executable)
|
||||
:type 'string)
|
||||
;;;###autoload (autoload 'magit-git-mergetool "magit-extras" nil t)
|
||||
(transient-define-prefix magit-git-mergetool (file args &optional transient)
|
||||
"Resolve conflicts in FILE using \"git mergetool --gui\".
|
||||
With a prefix argument allow changing ARGS using a transient
|
||||
popup. See info node `(magit) Ediffing' for information about
|
||||
alternative commands."
|
||||
:man-page "git-mergetool"
|
||||
["Settings"
|
||||
("-t" magit-git-mergetool:--tool)
|
||||
("=t" magit-merge.guitool)
|
||||
("=T" magit-merge.tool)
|
||||
("-r" magit-mergetool.hideResolved)
|
||||
("-b" magit-mergetool.keepBackup)
|
||||
("-k" magit-mergetool.keepTemporaries)
|
||||
("-w" magit-mergetool.writeToTemp)]
|
||||
["Actions"
|
||||
(" m" "Invoke mergetool" magit-git-mergetool)]
|
||||
(interactive
|
||||
(if (and (not (eq transient-current-prefix 'magit-git-mergetool))
|
||||
current-prefix-arg)
|
||||
(list nil nil t)
|
||||
(list (magit-read-unmerged-file "Resolve")
|
||||
(transient-args 'magit-git-mergetool))))
|
||||
(if transient
|
||||
(transient-setup 'magit-git-mergetool)
|
||||
(magit-run-git-async "mergetool" "--gui" args "--" file)))
|
||||
|
||||
;;;###autoload
|
||||
(defun magit-run-git-gui ()
|
||||
"Run `git gui' for the current git repository."
|
||||
(interactive)
|
||||
(magit-with-toplevel (magit-process-git 0 "gui")))
|
||||
(transient-define-infix magit-git-mergetool:--tool ()
|
||||
:description "Override mergetool"
|
||||
:class 'transient-option
|
||||
:shortarg "-t"
|
||||
:argument "--tool="
|
||||
:reader #'magit--read-mergetool)
|
||||
|
||||
(transient-define-infix magit-merge.guitool ()
|
||||
:class 'magit--git-variable
|
||||
:variable "merge.guitool"
|
||||
:global t
|
||||
:reader #'magit--read-mergetool)
|
||||
|
||||
(transient-define-infix magit-merge.tool ()
|
||||
:class 'magit--git-variable
|
||||
:variable "merge.tool"
|
||||
:global t
|
||||
:reader #'magit--read-mergetool)
|
||||
|
||||
(defun magit--read-mergetool (prompt _initial-input history)
|
||||
(let ((choices nil)
|
||||
(lines (cdr (magit-git-lines "mergetool" "--tool-help"))))
|
||||
(while (string-prefix-p "\t\t" (car lines))
|
||||
(push (substring (pop lines) 2) choices))
|
||||
(setq choices (nreverse choices))
|
||||
(magit-completing-read (or prompt "Select mergetool")
|
||||
choices nil t nil history)))
|
||||
|
||||
(transient-define-infix magit-mergetool.hideResolved ()
|
||||
:class 'magit--git-variable:boolean
|
||||
:variable "mergetool.hideResolved"
|
||||
:default "false"
|
||||
:global t)
|
||||
|
||||
(transient-define-infix magit-mergetool.keepBackup ()
|
||||
:class 'magit--git-variable:boolean
|
||||
:variable "mergetool.keepBackup"
|
||||
:default "true"
|
||||
:global t)
|
||||
|
||||
(transient-define-infix magit-mergetool.keepTemporaries ()
|
||||
:class 'magit--git-variable:boolean
|
||||
:variable "mergetool.keepTemporaries"
|
||||
:default "false"
|
||||
:global t)
|
||||
|
||||
(transient-define-infix magit-mergetool.writeToTemp ()
|
||||
:class 'magit--git-variable:boolean
|
||||
:variable "mergetool.writeToTemp"
|
||||
:default "false"
|
||||
:global t)
|
||||
|
||||
;;;; Git-Gui
|
||||
|
||||
;;;###autoload
|
||||
(defun magit-run-git-gui-blame (commit filename &optional linenum)
|
||||
@@ -92,6 +152,26 @@ blame to center around the line point is on."
|
||||
commit
|
||||
filename)))
|
||||
|
||||
;;;; Gitk
|
||||
|
||||
(defcustom magit-gitk-executable
|
||||
(or (and (eq system-type 'windows-nt)
|
||||
(let ((exe (magit-git-string
|
||||
"-c" "alias.X=!x() { which \"$1\" | cygpath -mf -; }; x"
|
||||
"X" "gitk.exe")))
|
||||
(and exe (file-executable-p exe) exe)))
|
||||
(executable-find "gitk") "gitk")
|
||||
"The Gitk executable."
|
||||
:group 'magit-extras
|
||||
:set-after '(magit-git-executable)
|
||||
:type 'string)
|
||||
|
||||
;;;###autoload
|
||||
(defun magit-run-git-gui ()
|
||||
"Run `git gui' for the current git repository."
|
||||
(interactive)
|
||||
(magit-with-toplevel (magit-process-git 0 "gui")))
|
||||
|
||||
;;;###autoload
|
||||
(defun magit-run-gitk ()
|
||||
"Run `gitk' in the current repository."
|
||||
@@ -135,15 +215,17 @@ like pretty much every other keymap:
|
||||
(kbd \"C-x g\") \\='ido-enter-magit-status)"
|
||||
(interactive)
|
||||
(setq ido-exit 'fallback)
|
||||
(setq ido-fallback 'magit-status) ; for Emacs >= 26.2
|
||||
(with-no-warnings (setq fallback 'magit-status)) ; for Emacs 25
|
||||
(setq ido-fallback #'magit-status) ; for Emacs >= 26.2
|
||||
(with-no-warnings (setq fallback #'magit-status)) ; for Emacs 25
|
||||
(exit-minibuffer))
|
||||
|
||||
;;;###autoload
|
||||
(defun magit-project-status ()
|
||||
"Run `magit-status' in the current project's root."
|
||||
(interactive)
|
||||
(magit-status-setup-buffer (project-root (project-current t))))
|
||||
(if (fboundp 'project-root)
|
||||
(magit-status-setup-buffer (project-root (project-current t)))
|
||||
(user-error "`magit-project-status' requires `project' 0.3.0 or greater")))
|
||||
|
||||
(defvar magit-bind-magit-project-status t
|
||||
"Whether to bind \"m\" to `magit-project-status' in `project-prefix-map'.
|
||||
@@ -170,7 +252,7 @@ With a prefix argument, visit in another window. If there
|
||||
is no file at point, then instead visit `default-directory'."
|
||||
(interactive "P")
|
||||
(dired-jump other-window
|
||||
(when-let ((file (magit-file-at-point)))
|
||||
(and-let* ((file (magit-file-at-point)))
|
||||
(expand-file-name (if (file-directory-p file)
|
||||
(file-name-as-directory file)
|
||||
file)))))
|
||||
@@ -181,9 +263,9 @@ is no file at point, then instead visit `default-directory'."
|
||||
(interactive "P")
|
||||
(if-let ((topdir (magit-toplevel default-directory)))
|
||||
(let ((args (car (magit-log-arguments)))
|
||||
(files (dired-get-marked-files nil nil #'magit-file-tracked-p)))
|
||||
(unless files
|
||||
(user-error "No marked file is being tracked by Git"))
|
||||
(files (compat-dired-get-marked-files
|
||||
nil nil #'magit-file-tracked-p nil
|
||||
"No marked file is being tracked by Git")))
|
||||
(when (and follow
|
||||
(not (member "--follow" args))
|
||||
(not (cdr files)))
|
||||
@@ -204,10 +286,7 @@ for a repository."
|
||||
(interactive (list (or (magit-toplevel)
|
||||
(magit-read-repository t))
|
||||
current-prefix-arg))
|
||||
;; Note: The ERROR argument of `dired-get-marked-files' isn't
|
||||
;; available until Emacs 27.
|
||||
(let ((files (or (dired-get-marked-files nil arg)
|
||||
(user-error "No files specified"))))
|
||||
(let ((files (compat-dired-get-marked-files nil arg nil nil t)))
|
||||
(magit-status-setup-buffer repo)
|
||||
(magit-am-apply-patches files)))
|
||||
|
||||
@@ -310,31 +389,32 @@ in HEAD as well as staged changes in the diff to check."
|
||||
(require 'diff-mode) ; `diff-add-log-current-defuns'.
|
||||
(require 'vc-git) ; `vc-git-diff'.
|
||||
(require 'add-log) ; `change-log-insert-entries'.
|
||||
(unless (and (fboundp 'change-log-insert-entries)
|
||||
(fboundp 'diff-add-log-current-defuns))
|
||||
(user-error "`magit-generate-changelog' requires Emacs 27 or better"))
|
||||
(setq default-directory
|
||||
(if (and (file-regular-p "gitdir")
|
||||
(not (magit-git-true "rev-parse" "--is-inside-work-tree"))
|
||||
(magit-git-true "rev-parse" "--is-inside-git-dir"))
|
||||
(file-name-directory (magit-file-line "gitdir"))
|
||||
(magit-toplevel)))
|
||||
(let ((rev1 (if amending "HEAD^1" "HEAD"))
|
||||
(rev2 nil))
|
||||
;; Magit may have updated the files without notifying vc, but
|
||||
;; `diff-add-log-current-defuns' relies on vc being up-to-date.
|
||||
(mapc #'vc-file-clearprops (magit-staged-files))
|
||||
(change-log-insert-entries
|
||||
(with-temp-buffer
|
||||
(vc-git-command (current-buffer) 1 nil
|
||||
"diff-index" "--exit-code" "--patch"
|
||||
(and (magit-anything-staged-p) "--cached")
|
||||
rev1 "--")
|
||||
;; `diff-find-source-location' consults these vars.
|
||||
(defvar diff-vc-revisions)
|
||||
(setq-local diff-vc-revisions (list rev1 rev2))
|
||||
(setq-local diff-vc-backend 'Git)
|
||||
(diff-add-log-current-defuns)))))
|
||||
(cond
|
||||
((and (fboundp 'change-log-insert-entries)
|
||||
(fboundp 'diff-add-log-current-defuns))
|
||||
(setq default-directory
|
||||
(if (and (file-regular-p "gitdir")
|
||||
(not (magit-git-true "rev-parse" "--is-inside-work-tree"))
|
||||
(magit-git-true "rev-parse" "--is-inside-git-dir"))
|
||||
(file-name-directory (magit-file-line "gitdir"))
|
||||
(magit-toplevel)))
|
||||
(let ((rev1 (if amending "HEAD^1" "HEAD"))
|
||||
(rev2 nil))
|
||||
;; Magit may have updated the files without notifying vc, but
|
||||
;; `diff-add-log-current-defuns' relies on vc being up-to-date.
|
||||
(mapc #'vc-file-clearprops (magit-staged-files))
|
||||
(change-log-insert-entries
|
||||
(with-temp-buffer
|
||||
(vc-git-command (current-buffer) 1 nil
|
||||
"diff-index" "--exit-code" "--patch"
|
||||
(and (magit-anything-staged-p) "--cached")
|
||||
rev1 "--")
|
||||
;; `diff-find-source-location' consults these vars.
|
||||
(defvar diff-vc-revisions)
|
||||
(setq-local diff-vc-revisions (list rev1 rev2))
|
||||
(setq-local diff-vc-backend 'Git)
|
||||
(diff-add-log-current-defuns)))))
|
||||
(t (user-error "`magit-generate-changelog' requires Emacs 27 or greater"))))
|
||||
|
||||
;;;###autoload
|
||||
(defun magit-add-change-log-entry (&optional whoami file-name other-window)
|
||||
@@ -377,7 +457,7 @@ points at it) otherwise."
|
||||
(interactive (list (and current-prefix-arg 'removal)))
|
||||
(let* ((chunk (magit-current-blame-chunk (or type 'addition)))
|
||||
(rev (oref chunk orig-rev)))
|
||||
(if (equal rev "0000000000000000000000000000000000000000")
|
||||
(if (string-match-p "\\`0\\{40,\\}\\'" rev)
|
||||
(message "This line has not been committed yet")
|
||||
(let ((rebase (magit-rev-ancestor-p rev "HEAD"))
|
||||
(file (expand-file-name (oref chunk orig-file)
|
||||
@@ -475,11 +555,11 @@ list returned by `magit-rebase-arguments'."
|
||||
"Type %p on a commit to reshelve it and the commits above it,"))
|
||||
(t
|
||||
(cl-flet ((adjust (time offset)
|
||||
(format-time-string
|
||||
"%F %T %z"
|
||||
(+ (floor time)
|
||||
(* offset 60)
|
||||
(- (car (decode-time time)))))))
|
||||
(format-time-string
|
||||
"%F %T %z"
|
||||
(+ (floor time)
|
||||
(* offset 60)
|
||||
(- (car (decode-time time)))))))
|
||||
(let* ((start (concat rev "^"))
|
||||
(range (concat start ".." current))
|
||||
(time-rev (adjust (float-time (string-to-number
|
||||
@@ -494,38 +574,38 @@ list returned by `magit-rebase-arguments'."
|
||||
(float-time
|
||||
(date-to-time
|
||||
(read-string "Date for first commit: "
|
||||
time-now 'magit--reshelve-history)))))
|
||||
(process-environment process-environment))
|
||||
(push "FILTER_BRANCH_SQUELCH_WARNING=1" process-environment)
|
||||
(magit-with-toplevel
|
||||
(magit-run-git-async
|
||||
"filter-branch" "--force" "--env-filter"
|
||||
(format
|
||||
"case $GIT_COMMIT in %s\nesac"
|
||||
(mapconcat
|
||||
(lambda (rev)
|
||||
(prog1 (concat
|
||||
(format "%s) " rev)
|
||||
(and (not magit-reshelve-since-committer-only)
|
||||
(format "export GIT_AUTHOR_DATE=\"%s\"; " date))
|
||||
(format "export GIT_COMMITTER_DATE=\"%s\";;" date))
|
||||
(cl-incf date 60)))
|
||||
(magit-git-lines "rev-list" "--reverse" range)
|
||||
" "))
|
||||
(and keyid
|
||||
(list "--commit-filter"
|
||||
(format "git commit-tree --gpg-sign=%s \"$@\";"
|
||||
keyid)))
|
||||
range "--"))
|
||||
(set-process-sentinel
|
||||
magit-this-process
|
||||
(lambda (process event)
|
||||
(when (memq (process-status process) '(exit signal))
|
||||
(if (> (process-exit-status process) 0)
|
||||
time-now 'magit--reshelve-history))))))
|
||||
(with-environment-variables (("FILTER_BRANCH_SQUELCH_WARNING" "1"))
|
||||
(magit-with-toplevel
|
||||
(magit-run-git-async
|
||||
"filter-branch" "--force" "--env-filter"
|
||||
(format
|
||||
"case $GIT_COMMIT in %s\nesac"
|
||||
(mapconcat
|
||||
(lambda (rev)
|
||||
(prog1
|
||||
(concat
|
||||
(format "%s) " rev)
|
||||
(and (not magit-reshelve-since-committer-only)
|
||||
(format "export GIT_AUTHOR_DATE=\"%s\"; " date))
|
||||
(format "export GIT_COMMITTER_DATE=\"%s\";;" date))
|
||||
(cl-incf date 60)))
|
||||
(magit-git-lines "rev-list" "--reverse" range)
|
||||
" "))
|
||||
(and keyid
|
||||
(list "--commit-filter"
|
||||
(format "git commit-tree --gpg-sign=%s \"$@\";"
|
||||
keyid)))
|
||||
range "--"))
|
||||
(set-process-sentinel
|
||||
magit-this-process
|
||||
(lambda (process event)
|
||||
(when (memq (process-status process) '(exit signal))
|
||||
(if (> (process-exit-status process) 0)
|
||||
(magit-process-sentinel process event)
|
||||
(process-put process 'inhibit-refresh t)
|
||||
(magit-process-sentinel process event)
|
||||
(process-put process 'inhibit-refresh t)
|
||||
(magit-process-sentinel process event)
|
||||
(magit-run-git "update-ref" "-d" backup))))))))))))
|
||||
(magit-run-git "update-ref" "-d" backup)))))))))))))
|
||||
|
||||
;;; Revision Stack
|
||||
|
||||
@@ -611,10 +691,10 @@ the minibuffer too."
|
||||
(interactive
|
||||
(if (or current-prefix-arg (not magit-revision-stack))
|
||||
(let ((default-directory
|
||||
(or (and (not (= (prefix-numeric-value current-prefix-arg) 16))
|
||||
(or (magit-toplevel)
|
||||
(cadr (car magit-revision-stack))))
|
||||
(magit-read-repository))))
|
||||
(or (and (not (= (prefix-numeric-value current-prefix-arg) 16))
|
||||
(or (magit-toplevel)
|
||||
(cadr (car magit-revision-stack))))
|
||||
(magit-read-repository))))
|
||||
(list (magit-read-branch-or-commit "Insert revision")
|
||||
default-directory))
|
||||
(push (caar magit-revision-stack) magit-revision-history)
|
||||
@@ -639,13 +719,13 @@ the minibuffer too."
|
||||
(when pnt-format
|
||||
(when idx-format
|
||||
(setq pnt-format
|
||||
(replace-regexp-in-string "%N" idx pnt-format t t)))
|
||||
(string-replace "%N" idx pnt-format)))
|
||||
(magit-rev-insert-format pnt-format rev pnt-args)
|
||||
(backward-delete-char 1))
|
||||
(when eob-format
|
||||
(when idx-format
|
||||
(setq eob-format
|
||||
(replace-regexp-in-string "%N" idx eob-format t t)))
|
||||
(string-replace "%N" idx eob-format)))
|
||||
(save-excursion
|
||||
(goto-char (point-max))
|
||||
(skip-syntax-backward ">s-")
|
||||
@@ -662,7 +742,7 @@ the minibuffer too."
|
||||
(user-error "Revision stack is empty")))
|
||||
|
||||
(define-key git-commit-mode-map
|
||||
(kbd "C-c C-w") 'magit-pop-revision-stack)
|
||||
(kbd "C-c C-w") #'magit-pop-revision-stack)
|
||||
|
||||
;;;###autoload
|
||||
(defun magit-copy-section-value (arg)
|
||||
@@ -704,8 +784,8 @@ argument."
|
||||
((use-region-p)
|
||||
(call-interactively #'copy-region-as-kill))
|
||||
(t
|
||||
(when-let ((section (magit-current-section))
|
||||
(value (oref section value)))
|
||||
(when-let* ((section (magit-current-section))
|
||||
(value (oref section value)))
|
||||
(magit-section-case
|
||||
((branch commit module-commit tag)
|
||||
(let ((default-directory default-directory) ref)
|
||||
|
||||
Reference in New Issue
Block a user