1
0
Fork 0

feat(emacs): add start-grading and grade-next

Signed-off-by: Lucas Sta Maria <lucas@priime.dev>
This commit is contained in:
Lucas Sta Maria 2024-01-24 22:35:11 -05:00
parent 15582b42a6
commit aaef389ed1
No known key found for this signature in database
GPG key ID: F07FB16A826E3B47

View file

@ -151,5 +151,33 @@
(add-hook 'markdown-mode-hook #'markdown-toggle-fontify-code-blocks-natively) (add-hook 'markdown-mode-hook #'markdown-toggle-fontify-code-blocks-natively)
(add-hook 'markdown-mode-hook #'olivetti-mode) (add-hook 'markdown-mode-hook #'olivetti-mode)
;; Grading
(defun grade-next (&optional inc)
"Go to the next homework by INC to grade."
(interactive)
(let ((inc (or inc 1))
(grading-directory "pl-grading")
(extension ".rkt")
(filepath (buffer-file-name (current-buffer))))
(if (not (and (string-match-p grading-directory filepath)
(string-match-p extension filepath)))
(message (format "not in %s!" grading-directory))
(let* ((target-directory (file-name-directory filepath))
(filename-parts (string-split filepath "/"))
(source-filename (-last-item filename-parts))
(source-number-str (file-name-sans-extension source-filename))
(source-number (string-to-number source-number-str))
(target-number (+ inc source-number))
(target-number-str (format "%02d" target-number))
(target-filename (format "%s.rkt" target-number-str))
(target-filepath (concat target-directory target-filename)))
(find-file target-filepath)))))
(defun start-grading ()
"Start grading."
(interactive)
(keymap-global-set "C-c f" #'grade-next)
(keymap-global-set "C-c b" (lambda () (interactive) (grade-next -1))))
(provide 'misc) (provide 'misc)
;;; misc.el ends here ;;; misc.el ends here