doomemacs/modules/emacs/vc/autoload/vc.el

48 lines
1.5 KiB
EmacsLisp
Raw Normal View History

;;; emacs/vc/autoload/vc.el -*- lexical-binding: t; -*-
2017-02-03 20:29:09 -05:00
(autoload 'browse-at-remote-get-url "browse-at-remote")
(autoload 'browse-at-remote--file-url "browse-at-remote")
2020-01-11 17:29:16 -05:00
(defun +vc--remote-file-or-region-link ()
(if (or (doom-region-active-p) (not buffer-file-name))
(browse-at-remote-get-url)
(browse-at-remote--file-url (buffer-file-name))))
2017-02-03 20:29:09 -05:00
;;;###autoload
(defun +vc/browse-at-remote-file-or-region ()
"Open the current file at remote in your browser.
If a selection is active, highlight them. Otherwise omits the #L<N> suffix in
the URL."
(interactive)
2020-01-11 17:29:16 -05:00
(browse-url (+vc--remote-file-or-region-link)))
2017-02-03 20:29:09 -05:00
;;;###autoload
(defun +vc/browse-at-remote-kill-file-or-region ()
"Copy the current file's remote URL to your clipboard.
If a selection is active, highlight them. Otherwise omits the #L<N> suffix in
the URL."
(interactive)
2020-01-11 17:29:16 -05:00
(let ((url (+vc--remote-file-or-region-link)))
(kill-new url)
(message "Copied to clipboard: %S" url)))
(defun +vc--remote-homepage ()
(or (let ((url (browse-at-remote--remote-ref)))
(cdr (browse-at-remote--get-url-from-remote (car url))))
(user-error "Can't find homepage for current project")))
2017-02-03 20:29:09 -05:00
2017-06-10 11:52:07 +02:00
;;;###autoload
(defun +vc/browse-at-remote-homepage ()
"Open homepage for current project in browser."
(interactive)
(browse-url (+vc--remote-homepage)))
;;;###autoload
(defun +vc/browse-at-remote-kill-homepage ()
"Copy homepage URL of current project to clipboard."
(interactive)
(let ((url (+vc--remote-homepage)))
(kill-new url)
(message "Copied to clipboard: %S" url)))