Skip to content

Commit

Permalink
Add option to not add to kill ring.
Browse files Browse the repository at this point in the history
Additionally return the string from the `git-link--new` function. This
makes it simpler to automatically call git-link functions from other
code.
  • Loading branch information
mijoharas committed Apr 4, 2024
1 parent 1415629 commit a5b87c3
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions git-link.el
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,11 @@ function set to that function's symbol."
:type '(choice boolean function)
:group 'git-link)

(defcustom git-link-add-to-kill-ring t
"if t also add the link to the kill-ring"
:type 'boolean
:group 'git-link)

(defcustom git-link-use-commit nil
"If non-nil use the latest commit's hash in the link instead of the branch name."
:type 'boolean
Expand Down Expand Up @@ -541,14 +546,18 @@ return (FILENAME . REVISION) otherwise nil."
(list line-start line-end)))))

(defun git-link--new (link)
(kill-new link)
(if git-link-add-to-kill-ring
(kill-new link))

;; prevent URL escapes from being interpreted as format strings
(message (replace-regexp-in-string "%" "%%" link t t))
(setq deactivate-mark t)
(when git-link-open-in-browser
(if (fboundp git-link-open-in-browser)
(funcall git-link-open-in-browser link)
(browse-url link))))
(browse-url link)))
link
)

(defun git-link-codeberg (hostname dirname filename branch commit start end)
(format "https://%s/%s/src/%s/%s"
Expand Down

0 comments on commit a5b87c3

Please sign in to comment.