This commit is contained in:
2026-06-05 22:32:49 +08:00
parent 14d05011d5
commit c67841fe07
202 changed files with 498 additions and 403 deletions
+24 -4
View File
@@ -51,10 +51,6 @@ Returns a plist (:problem :lang :input :code) or signals an error."
(user-error "No :lc-problem header arg on this source block"))
(list :problem (format "%s" problem) :lang lc-lang :input input :code body)))
(defun lc-org--lc-command (&rest args)
"Build shell command string from lc-org-bin and ARGS."
(mapconcat #'shell-quote-argument (cons lc-org-bin (list-to-vector args)) " "))
(defun lc-org--run-command (cmd)
"Run CMD in a compilation buffer named *lc*."
(let ((buf (get-buffer-create "*lc*")))
@@ -75,6 +71,30 @@ Returns a plist (:problem :lang :input :code) or signals an error."
(display-buffer (process-buffer proc)))))
(display-buffer buf)))
(defvar lc-org-mode-map
(let ((map (make-sparse-keymap))
(prefix (make-sparse-keymap)))
(define-key prefix (kbd "s") #'lc-org-submit)
(define-key prefix (kbd "r") #'lc-org-run)
(define-key prefix (kbd "t") #'lc-org-status)
(define-key prefix (kbd "p") #'lc-org-show-problem)
(define-key prefix (kbd "d") #'lc-org-daily)
(define-key map (kbd "C-c l") prefix)
map)
"Keymap for `lc-org-mode'.")
;;;###autoload
(define-minor-mode lc-org-mode
"Minor mode for LeetCode CLI integration in org source blocks.
Keybindings under C-c l:
s submit — submit current block
r run — run with test input
t status — check submission status
p problem — show problem description
d daily — today's daily challenge"
:lighter " LC"
:keymap lc-org-mode-map)
;;;###autoload
(defun lc-org-submit ()
"Submit the current org source block to LeetCode."