欢迎大家试用我的 magithub-browse-file

magithub 是一个可以直接在 Emacs 中直接打开 github 连接的插件, 特别方便分享代码给别人.

但是一直只能分享 git 仓库地址

十几天前写了一个补丁 Add magithub-browse-file by manateelazycat · Pull Request #377 · vermiculus/magithub · GitHub , 今天终于合并了.

当你打开一个 Git 文件, 直接用命令 magithub-browse-file 可以打开 github 对应的那一行的连接, 就像这样 . magithub/magithub.el at 46e6ea5c561787ccb9136e2edbafa9932f951741 · vermiculus/magithub · GitHub

2 个赞

這個類似git-link (不依賴github token)

我常用的非github repo是musl和sourceware系列(glibc,binutils-gdb,…):

(after! git-link
  (defun git-link-llvm (hostname dirname filename branch commit start end)
      (format "https://github.com/llvm-mirror/%s/tree/%s/%s"
              (file-name-base dirname)
                (or branch commit)
              (concat filename
                      (when start
                        (concat "#"
                                (if end
                                    (format "L%s-%s" start end)
                                  (format "L%s" start)))))))
  (defun git-link-musl (hostname dirname filename branch commit start end)
      (format "http://git.musl-libc.org/cgit/%s/tree/%s%s%s"
              (file-name-base dirname)
              filename
              (if branch
                  ""
                (format "?id=%s" commit))
              (if start
                  (concat "#" (format "n%s" start)) "")))
  (defun git-link-sourceware (hostname dirname filename branch commit start end)
    (format "https://sourceware.org/git/?p=%s.git;a=blob;hb=%s;f=%s"
            (file-name-base dirname)
            commit
            (concat filename
                    (when start
                      (concat "#" (format "l%s" start))))))
  (add-to-list 'git-link-remote-alist '("git.llvm.org" git-link-llvm))
  (add-to-list 'git-link-remote-alist '("git.musl-libc.org" git-link-musl))
  (add-to-list 'git-link-remote-alist '("sourceware.org" git-link-sourceware))
  )
2 个赞