refactor(emacs): rewrite git link
This commit is contained in:
parent
a553794083
commit
29c0e79b8c
1 changed files with 27 additions and 8 deletions
|
|
@ -48,18 +48,37 @@
|
|||
(kill-new target-link)
|
||||
target-link))
|
||||
|
||||
(defun git-link-priime-dev (hostname dirname filename branch commit start end)
|
||||
(defun git-link--format-line-prefix (filepath)
|
||||
"Format the prefix for line spec using FILEPATH."
|
||||
(concat
|
||||
(when (git-link--should-render-plain filepath)
|
||||
"?plain=1")
|
||||
"#"))
|
||||
|
||||
(defun git-link--format-line-range (start end)
|
||||
"Format the line from START to END."
|
||||
(format "L%s-L%s" start end))
|
||||
|
||||
(defun git-link--format-line-start (start)
|
||||
"Format the line START."
|
||||
(format "L%s" start))
|
||||
|
||||
(defun git-link--format-line-suffix (filepath start end)
|
||||
"Common helper function for formatting the line suffix at the end of a URL."
|
||||
(when start
|
||||
(concat (git-link--format-line-prefix filepath)
|
||||
(if end
|
||||
(git-link--format-line-range start end)
|
||||
(git-link--format-line-start start)))))
|
||||
|
||||
(defun git-link-priime-dev (hostname projname filepath branch commit start end)
|
||||
"git-link configuration for my own forge."
|
||||
(format "%s/%s/src/commit/%s/%s"
|
||||
hostname
|
||||
dirname
|
||||
projname
|
||||
(or branch commit)
|
||||
(concat filename
|
||||
(when start
|
||||
(concat (if (git-link--should-render-plain filename) "?plain=1#" "#")
|
||||
(if end
|
||||
(format "L%s-L%s" start end)
|
||||
(format "L%s" start)))))))
|
||||
(concat filepath
|
||||
(git-link--format-line-suffix filepath start end))))
|
||||
|
||||
(add-to-list 'git-link-remote-alist '("git.priime.dev" git-link-priime-dev))
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue