aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEugene Triguba <hello@eugenetriguba.com>2026-04-01 15:46:12 -0400
committerEugene Triguba <hello@eugenetriguba.com>2026-04-01 15:46:12 -0400
commit3b319fff9f28668e3c4020e985e5c72a1d10f3f2 (patch)
tree4ccefaeec465290fa781c108fc34e78412f8042e
parentAdjust emacs config (diff)
downloaddotfiles-3b319fff9f28668e3c4020e985e5c72a1d10f3f2.zip
Remove unnecessary use of shell-command-to-string
-rw-r--r--.emacs.d/modules/et-vc.el34
1 files changed, 16 insertions, 18 deletions
diff --git a/.emacs.d/modules/et-vc.el b/.emacs.d/modules/et-vc.el
index 4236a50..9d110f3 100644
--- a/.emacs.d/modules/et-vc.el
+++ b/.emacs.d/modules/et-vc.el
@@ -14,20 +14,17 @@
(if (not buffer-file-name)
(message "Not visiting a file.")
- (let* ((git-remote-url-cmd "git config --get remote.origin.url")
- (remote-url (string-trim
- (shell-command-to-string git-remote-url-cmd)))
- (git-head-sha-cmd "git rev-parse HEAD")
- (head-sha (string-trim (shell-command-to-string git-head-sha-cmd)))
+ (let* ((remote-url (vc-git-repository-url buffer-file-name "origin"))
+ (head-sha (vc-git-working-revision buffer-file-name))
(relative-file-path (file-relative-name buffer-file-name
- (vc-git-root buffer-file-name)))
+ (vc-git-root buffer-file-name)))
(line-num (line-number-at-pos)))
(if (et--is-supported-provider-p remote-url)
- (progn
- (kill-new (et--generate-remote-git-url remote-url head-sha relative-file-path line-num))
- (message "Copied remote git URL"))
- (message (format "%s is not a supported git hosting provider." remote-url))))))
+ (progn
+ (kill-new (et--generate-remote-git-url remote-url head-sha relative-file-path line-num))
+ (message "Copied remote git URL"))
+ (message (format "%s is not a supported git hosting provider." remote-url))))))
(defun et--is-supported-provider-p (url)
"Check whether url is a supported git hosting provider for URL generation."
@@ -57,10 +54,10 @@
(defun et--gh-generate-remote-git-url (remote-url head-sha relative-file-path line-num)
(format "https://github.com/%s/blob/%s/%s#L%d"
- (et--extract-repo-path "https://github.com" remote-url)
- head-sha
- relative-file-path
- line-num))
+ (et--extract-repo-path "https://github.com" remote-url)
+ head-sha
+ relative-file-path
+ line-num))
(defun et--extract-repo-path (base-url remote-url)
(if (et--git-ssh-url-p remote-url)
@@ -75,9 +72,10 @@
(defun et--sh-generate-remote-git-url (remote-url head-sha relative-file-path line-num)
(format "https://git.sr.ht/%s/tree/%s/item/%s#L%d"
- (et--extract-repo-path "https://git.sr.ht" remote-url)
- head-sha
- relative-file-path
- line-num))
+ (et--extract-repo-path "https://git.sr.ht" remote-url)
+ head-sha
+ relative-file-path
+ line-num))
(provide 'et-vc)
+