From 9dd77d4c5f87b3b3c53b7b214a344933125dd150 Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Wed, 26 Jul 2023 00:05:04 +1000 Subject: minor fixes --- emacs/.emacs.d/lisp/my/my-editing.el | 3 ++- emacs/.emacs.d/lisp/my/my-prog.el | 22 ++++++++++++++++++---- 2 files changed, 20 insertions(+), 5 deletions(-) (limited to 'emacs/.emacs.d/lisp') diff --git a/emacs/.emacs.d/lisp/my/my-editing.el b/emacs/.emacs.d/lisp/my/my-editing.el index b0af50f..1604e32 100644 --- a/emacs/.emacs.d/lisp/my/my-editing.el +++ b/emacs/.emacs.d/lisp/my/my-editing.el @@ -359,7 +359,8 @@ Basically move the line up (interactive "P") (if arg (my-kill-backward) - (kill-line 0))) + (if (bolp) (delete-char -1) + (kill-line 0)))) (defun my-kill-backward () "Kill towards beginning of line, but not out of sexp." diff --git a/emacs/.emacs.d/lisp/my/my-prog.el b/emacs/.emacs.d/lisp/my/my-prog.el index cb90ca0..96ffac2 100644 --- a/emacs/.emacs.d/lisp/my/my-prog.el +++ b/emacs/.emacs.d/lisp/my/my-prog.el @@ -355,12 +355,26 @@ left and the source buffer on the right. (defun my-file-loc-to-github (file-loc &optional revision) "Convert a file location to a github url." (pcase-let* ((`(,file ,line-no) (split-string file-loc ":")) - (revision (or revision (vc-working-revision file))) - (repo-url (vc-git-repository-url file)) - (repo-root (vc-git-root file)) - (path (file-relative-name file repo-root))) + (revision (or revision (vc-working-revision file)))) + (my-file-loc-to-github-internal file line-no revision))) + +(defun my-file-loc-to-github-internal (file line-no revision) + "Convert a FILE location at LINE-NO to a github url. + +REVISION is the commit hash." + (let* ((repo-url (vc-git-repository-url file)) + (repo-root (vc-git-root file)) + (path (file-relative-name file repo-root))) (format "%s/blob/%s/%s#L%s" repo-url revision path line-no))) +(defun my-kill-github-url-current-file-loc () + "Kill the github url from where the point is at." + (interactive) + (kill-new (my-file-loc-to-github-internal + (buffer-file-name) + (1+ (current-line)) + (vc-working-revision (buffer-file-name))))) + (defun my-org-backtrace-to-github (bt &optional revision) (string-join (mapcar -- cgit v1.2.3