Emacs: Another pass on the leetcode capture template

This commit is contained in:
Joseph Ferano 2023-08-24 16:35:10 +07:00
parent 5cb67f3585
commit 5a297e694d

View File

@ -2363,18 +2363,25 @@ and there's no need for a middle-man when it's already been implemented.
** Org-capture
#+begin_src emacs-lisp
;; (defun my-org-capture-today ()
;; (concat "<" (format-time-string "%Y-%m-%d %a") ">"))
(defun joe/capture-leetcode-newfile ()
(let* ((title (read-string "Title: "))
(title (string-replace " " "-" title))
(title (string-replace "." "" title)))
(expand-file-name (format "%s.org" title) "~/Development/coding-challenges/leetcode/")))
(defun joe/capture-leetcode-template ()
(mapconcat
'identity
'("#+TITLE: Leetcode %?: "
'(":PROPERTIES:"
":DIFFICULTY: medium"
":END:"
""
"#+TITLE: Leetcode %?: "
"#+AUTHOR: Joseph Ferano"
"#+STARTUP: show2levels"
"#+TAGS: "
""
"* Python Solution :python:"
"* Python Solution"
":PROPERTIES:"
":CompletionTime: 7m"
":TimeComplexity: O(logn)"
@ -2389,34 +2396,28 @@ and there's no need for a middle-man when it's already been implemented.
"** Techniques & Patterns")
"\n"))
(defun joe/capture-leetcode-newfile ()
(let* ((title (read-string "Title: "))
(title (string-replace " " "-" title))
(title (string-replace "." "" title)))
(expand-file-name (format "%s.org" title) "~/Development/coding-challenges/leetcode/")))
(defun my-org-capture-today ()
(concat "<" (format-time-string "%Y-%m-%d %a") ">"))
(defun joe/capture-daily ()
(concat
"* " "%^t" "\n"
"** Schedule" "\n"
"** Notes" "\n"
"** Resources" "\n"))
(setq org-capture-templates
`(
("l" "Leetcode Solution" plain
(function ,(lambda () (find-file (joe/capture-leetcode-newfile))))
#'joe/capture-leetcode-template)
("d" "Demo of adding to a daily.org" entry
;; A relative file name is interpreted based on
;; `org-directory'.
(file+headline "/tmp/daily.org" "Daily notes")
#'my-org-capture-daily-note)
("D" "Demo of adding to a daily.org with a prompt" entry
;; A relative file name is interpreted based on
;; `org-directory'.
(file+headline "/tmp/daily.org" "Daily notes")
,(concat
"** " "%^t" "\n"
"*** Schedule" "\n"
"*** Notes" "\n"
"*** Resources" "\n"))))
#+end_src
("d" "Daily Entry" entry
;; A relative file name is interpreted based on
;; `org-directory'.
(file "~/Notes/Daily.org")
#'joe/capture-daily)
))
#+end_src
** Magit
The best git porcelain/client I've ever used. Also kill stray magit buffers left