[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/orgit 976f3c7d25 32/76: Support storing link(s) to selecte
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/orgit 976f3c7d25 32/76: Support storing link(s) to selected commit(s) |
Date: |
Thu, 13 Jan 2022 13:58:45 -0500 (EST) |
branch: elpa/orgit
commit 976f3c7d25ad92c57341b52dad9af89b49c37f0c
Author: Jonas Bernoulli <jonas@bernoul.li>
Commit: Jonas Bernoulli <jonas@bernoul.li>
Support storing link(s) to selected commit(s)
Closes #22.
---
orgit.el | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++-------------
1 file changed, 50 insertions(+), 13 deletions(-)
diff --git a/orgit.el b/orgit.el
index c2b8ff80cc..2935b83850 100644
--- a/orgit.el
+++ b/orgit.el
@@ -174,6 +174,26 @@ If all of the above fails then `orgit-export' raises an
error."
:group 'orgit
:type 'boolean)
+;;; Command
+
+;;;###autoload
+(eval-after-load "magit"
+ '(define-key magit-mode-map [remap org-store-link] 'orgit-store-link))
+
+;;;###autoload
+(defun orgit-store-link (arg)
+ "Like `org-store-link' but store links to all selected commits, if any."
+ (interactive "P")
+ (-if-let (sections (magit-region-sections 'commit))
+ (save-excursion
+ (dolist (section sections)
+ (goto-char (oref section start))
+ (set-mark (point))
+ (activate-mark)
+ (call-interactively 'org-store-link))
+ (deactivate-mark))
+ (call-interactively 'org-store-link)))
+
;;; Status
;;;###autoload
@@ -186,7 +206,11 @@ If all of the above fails then `orgit-export' raises an
error."
;;;###autoload
(defun orgit-status-store ()
- (when (eq major-mode 'magit-status-mode)
+ "Store a link to a Magit-Status mode buffer.
+When the region selects one or more commits, then do nothing.
+In that case `orgit-rev-store' stores one or more links instead."
+ (when (and (eq major-mode 'magit-status-mode)
+ (not (magit-region-sections 'commit)))
(let ((repo (abbreviate-file-name default-directory)))
(org-store-link-props
:type "orgit"
@@ -217,7 +241,11 @@ If all of the above fails then `orgit-export' raises an
error."
;;;###autoload
(defun orgit-log-store ()
- (when (eq major-mode 'magit-log-mode)
+ "Store a link to a Magit-Log mode buffer.
+When the region selects one or more commits, then do nothing.
+In that case `orgit-rev-store' stores one or more links instead."
+ (when (and (eq major-mode 'magit-log-mode)
+ (not (magit-region-sections 'commit)))
(let ((repo (abbreviate-file-name default-directory)))
(if orgit-log-save-arguments
(let ((args (if (car (last magit-refresh-args))
@@ -274,17 +302,26 @@ If all of the above fails then `orgit-export' raises an
error."
(defun orgit-rev-store ()
"Store a link to a Magit-Revision mode buffer.
With a prefix argument instead store the name of the branch that
-points at the revision, if any."
- (when (eq major-mode 'magit-revision-mode)
- (let ((repo (abbreviate-file-name default-directory))
- (rev (car magit-refresh-args)))
- (unless (and current-prefix-arg
- (magit-ref-p rev))
- (setq rev (magit-rev-abbrev rev)))
- (org-store-link-props
- :type "orgit-rev"
- :link (format "orgit-rev:%s::%s" repo rev)
- :description (format "%s (magit-rev %s)" repo rev)))))
+points at the revision, if any.
+
+When the region selects one or more commits, e.g. in a log, then
+store links to the Magit-Revision mode buffers for these commits."
+ (cond ((eq major-mode 'magit-revision-mode)
+ (orgit-rev-store-1 (car magit-refresh-args)))
+ ((and (derived-mode-p 'magit-mode)
+ (magit-region-sections 'commit))
+ (orgit-rev-store-1 (oref (magit-current-section) value)))))
+
+(defun orgit-rev-store-1 (rev)
+ (let ((repo (abbreviate-file-name default-directory)))
+ (unless (magit-ref-p rev)
+ (setq rev (if current-prefix-arg
+ (magit-get-shortname rev)
+ (magit-rev-abbrev rev))))
+ (org-store-link-props
+ :type "orgit-rev"
+ :link (format "orgit-rev:%s::%s" repo rev)
+ :description (format "%s (magit-rev %s)" repo rev))))
;;;###autoload
(defun orgit-rev-open (path)
- [nongnu] branch elpa/orgit created (now 66367d6bfc), ELPA Syncer, 2022/01/13
- [nongnu] elpa/orgit 5b71214a35 01/76: initial import, ELPA Syncer, 2022/01/13
- [nongnu] elpa/orgit 2008116bd1 02/76: orgit-status-open: use magit-status-internal, ELPA Syncer, 2022/01/13
- [nongnu] elpa/orgit 3747e49964 24/76: orgit-rev-store: only resolve rev with prefix argument, ELPA Syncer, 2022/01/13
- [nongnu] elpa/orgit a9d0c74659 14/76: bump dependencies, ELPA Syncer, 2022/01/13
- [nongnu] elpa/orgit aa193c045b 21/76: orgit-export: use -let*, ELPA Syncer, 2022/01/13
- [nongnu] elpa/orgit ca93e9ec56 25/76: orgit-export: ensure default-directory ends with a slash, ELPA Syncer, 2022/01/13
- [nongnu] elpa/orgit cbce5871fe 29/76: Store all revisions and optionally all arguments in log links, ELPA Syncer, 2022/01/13
- [nongnu] elpa/orgit 976f3c7d25 32/76: Support storing link(s) to selected commit(s),
ELPA Syncer <=
- [nongnu] elpa/orgit 692256bac9 33/76: Add Makefile, ELPA Syncer, 2022/01/13
- [nongnu] elpa/orgit d909f92d3b 35/76: Bump copyright years, ELPA Syncer, 2022/01/13
- [nongnu] elpa/orgit ea79e0567a 39/76: orgit-export-alist: Update kernel.org entry, ELPA Syncer, 2022/01/13
- [nongnu] elpa/orgit ddb830c38c 43/76: make: Add new indirect dependencies, ELPA Syncer, 2022/01/13
- [nongnu] elpa/orgit 8a65bd2750 42/76: Favor pcase and subr-x over dash, ELPA Syncer, 2022/01/13
- [nongnu] elpa/orgit a2d3937040 49/76: Adapt to changes in Magit, ELPA Syncer, 2022/01/13
- [nongnu] elpa/orgit e23c7a6776 46/76: orgit--repository-directory: Error on non-existent directory, ELPA Syncer, 2022/01/13
- [nongnu] elpa/orgit 9598d71682 55/76: Revert "Add .github/FUNDING.yml", ELPA Syncer, 2022/01/13
- [nongnu] elpa/orgit c110371202 57/76: orgit--repository-directory: Support relative paths again, ELPA Syncer, 2022/01/13
- [nongnu] elpa/orgit e147f05577 61/76: eval-after-load: replace string feature w/ symbol, ELPA Syncer, 2022/01/13