From 7bfdf5c028a98d095ea855f9074015b3570fdb7f Mon Sep 17 00:00:00 2001 From: Wong Ding Feng Date: Sat, 4 Apr 2026 14:11:56 +0800 Subject: [PATCH] feat(inbox): add command-log-mode with toggle binding --- inbox.el | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/inbox.el b/inbox.el index a0164a4..65355da 100644 --- a/inbox.el +++ b/inbox.el @@ -3,3 +3,35 @@ ;; Use this file for new packages and configuration snippets ;; before sorting them into their proper places. +(defun df/copy-file-line-ref () + "Copy absolute file path with line reference as @/path#Lline or @/path#Lstart-end." + (interactive) + (let* ((file (or (buffer-file-name) (buffer-name))) + (abs-file (if (file-name-absolute-p file) file (expand-file-name file))) + (ref + (if (use-region-p) + (let* ((start (region-beginning)) + (end (region-end)) + (start-line (line-number-at-pos start)) + (end-line (line-number-at-pos (max start (1- end))))) + (format "@%s#L%d-%d" abs-file start-line end-line)) + (format "@%s#L%d" abs-file (line-number-at-pos (point)))))) + (kill-new ref) + (when (fboundp 'gui-set-selection) + (gui-set-selection 'CLIPBOARD ref)) + (message "%s" ref))) + +(global-set-key (kbd "M-S w") #'df/copy-file-line-ref) + +(defun load-current-file () + (interactive) + (load (buffer-file-name))) + +(global-set-key (kbd "C-c l") #'load-current-file) + +(use-package! command-log-mode + :config + (map! "C-c L" #'(lambda () (interactive) + (command-log-mode (if command-log-mode -1 +1)) + (when command-log-mode + (switch-to-buffer "*Command Log*")))))