Emacs: First org-capture templates for Leetcode

This commit is contained in:
Joseph Ferano 2023-08-24 06:53:17 +07:00
parent c60c7ed631
commit cd217883df

View File

@ -1553,6 +1553,7 @@ When called interactively, prompt for BUFFER."
("b" "~/Documents/Books/" "Books")
("p" "~/Development/" "Dev")
("t" "~/TYCS/" "Teachyourselfcs")
("n" "~/Notes/" "OrgNotes")
("r" "~/Repositories" "Repos")
("B" "~/pCloudDrive/" "pCloud")))
@ -1837,7 +1838,6 @@ the right frame, I'm going to use the frame's name to close and remove the hook
(add-hook 'delete-frame-functions #'joe/kill-vterm-scratch)
(add-hook 'kill-buffer-hook #'joe/kill-frame))))
#+end_src
** Undo Fu
#+begin_src emacs-lisp
(require 'undo-fu)
@ -2295,6 +2295,7 @@ and there's no need for a middle-man when it's already been implemented.
(defun joe/org-init ()
(setq org-todo-keywords '((sequence "TODO" "IN-PROGRESS" "|" "DONE" "BACKLOG")))
(setq org-agenda-files '("~/Notes/Schedule.org"))
(setq org-directory "~/Notes/")
(org-babel-do-load-languages
'org-babel-load-languages
@ -2356,16 +2357,64 @@ and there's no need for a middle-man when it's already been implemented.
(evil-define-key 'normal calendar-mode-map (kbd "RET") #'org-calendar-select)
(defun org-capture-today()
(concat "<" (format-time-string "%Y-%m-%d") ">"))
;; (setq org-capture-templates
;; '(("d" "New Coding Challenge" entry
;; (file+headline "~/Notes/Daily.org")
;; (concat "* Today's Date" "\n"
;; "** Schedule" "\n"
;; "** Notes & Resources" "\n"))))
#+end_src
** Org-capture
#+begin_src emacs-lisp
;; (defun my-org-capture-today ()
;; (concat "<" (format-time-string "%Y-%m-%d %a") ">"))
(defun joe/capture-leetcode-template ()
(mapconcat
'identity
'("#+TITLE: Leetcode %?: "
"#+AUTHOR: Joseph Ferano"
"#+STARTUP: show2levels"
"#+TAGS: "
""
"* Python Solution :python:"
":PROPERTIES:"
":CompletionTime: 7m"
":TimeComplexity: O(logn)"
":MemoryComplexity: O(h)"
":END:"
":LOGBOOK:"
":END:"
""
"#+begin_src python"
"#+end_src"
"** Review"
"** 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/")))
(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
** Magit