feat(inbox): add command-log-mode with toggle binding

This commit is contained in:
2026-04-04 14:11:56 +08:00
parent 95b50b3a10
commit 7bfdf5c028
+32
View File
@@ -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*")))))