Add support for generating source hut links.
This commit is contained in:
parent
c2a0f90b4f
commit
9d118078ae
@ -55,6 +55,14 @@
|
|||||||
))
|
))
|
||||||
(mapc load-it (directory-files dir nil "\\.el$"))))
|
(mapc load-it (directory-files dir nil "\\.el$"))))
|
||||||
|
|
||||||
|
(defun generate-vc-link ()
|
||||||
|
(interactive)
|
||||||
|
(or
|
||||||
|
(generate-github-link)
|
||||||
|
(generate-source-hut-link)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
(defun generate-github-link ()
|
(defun generate-github-link ()
|
||||||
"Generate a permalink to the current line."
|
"Generate a permalink to the current line."
|
||||||
(interactive)
|
(interactive)
|
||||||
@ -73,6 +81,33 @@
|
|||||||
)
|
)
|
||||||
(message "%s" full-url)
|
(message "%s" full-url)
|
||||||
(kill-new full-url)
|
(kill-new full-url)
|
||||||
|
t
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
(defun generate-source-hut-link ()
|
||||||
|
"Generate a permalink to the current line."
|
||||||
|
(interactive)
|
||||||
|
(let (
|
||||||
|
(current-rev (vc-working-revision buffer-file-name))
|
||||||
|
(line-number (line-number-at-pos))
|
||||||
|
(repository-url (vc-git-repository-url buffer-file-name))
|
||||||
|
(relative-path (file-relative-name buffer-file-name (vc-root-dir)))
|
||||||
|
)
|
||||||
|
(message "Using repo url %s" repository-url)
|
||||||
|
(save-match-data
|
||||||
|
(and (string-match "https://git.sr.ht/\\([^/]+\\)/\\([^/]+\\)" repository-url)
|
||||||
|
(let* (
|
||||||
|
(sh-org (match-string 1 repository-url))
|
||||||
|
(sh-repo (match-string 2 repository-url))
|
||||||
|
(full-url (format "https://git.sr.ht/%s/%s/tree/%s/%s#L%s" sh-org sh-repo current-rev relative-path line-number))
|
||||||
|
)
|
||||||
|
(message "%s" full-url)
|
||||||
|
(kill-new full-url)
|
||||||
|
t
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
@ -7,6 +7,6 @@
|
|||||||
;; dabbrev-expand. Seems to be some sort of dumb-expand. Accidentally hitting it when trying to use M-?
|
;; dabbrev-expand. Seems to be some sort of dumb-expand. Accidentally hitting it when trying to use M-?
|
||||||
(global-unset-key (kbd "M-/"))
|
(global-unset-key (kbd "M-/"))
|
||||||
|
|
||||||
(global-set-key (kbd "C-x g l") 'generate-github-link)
|
(global-set-key (kbd "C-x g l") 'generate-vc-link)
|
||||||
|
|
||||||
(provide 'base-global-keys)
|
(provide 'base-global-keys)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user