141 lines
4.7 KiB
Org Mode
141 lines
4.7 KiB
Org Mode
* evil
|
|
#+begin_src emacs-lisp
|
|
(use-package evil
|
|
:demand t
|
|
:config
|
|
(progn
|
|
(evil-mode +1)))
|
|
|
|
(use-package evil-leader
|
|
:demand t
|
|
:config
|
|
(global-evil-leader-mode))
|
|
|
|
(use-package evil-org
|
|
:demand t
|
|
:after (org evil-leader)
|
|
:config
|
|
(progn
|
|
(add-hook 'org-mode-hook 'evil-org-mode)))
|
|
#+end_src
|
|
|
|
This makes evil-mode play nice with org-fc
|
|
#+begin_src emacs-lisp
|
|
(use-package org-fc
|
|
:demand t
|
|
:config
|
|
(progn
|
|
(evil-define-minor-mode-key '(normal insert emacs) 'org-fc-review-flip-mode
|
|
(kbd "RET") 'org-fc-review-flip
|
|
(kbd "n") 'org-fc-review-flip
|
|
(kbd "s") 'org-fc-review-suspend-card
|
|
(kbd "q") 'org-fc-review-quit)
|
|
|
|
(evil-define-minor-mode-key '(normal insert emacs) 'org-fc-review-rate-mode
|
|
(kbd "a") 'org-fc-review-rate-again
|
|
(kbd "h") 'org-fc-review-rate-hard
|
|
(kbd "g") 'org-fc-review-rate-good
|
|
(kbd "e") 'org-fc-review-rate-easy
|
|
(kbd "s") 'org-fc-review-suspend-card
|
|
(kbd "q") 'org-fc-review-quit)))
|
|
#+end_src
|
|
|
|
* Appearance
|
|
#+begin_src emacs-lisp
|
|
(setq imalison:dark-theme 'dracula)
|
|
#+end_src
|
|
|
|
* org-mode
|
|
#+begin_src emacs-lisp
|
|
(setq imalison:org-whoami "Kat Huang")
|
|
(setq org-directory "~/org/") ; This is the directory where you want to save your Org files. Change as necessary.
|
|
(add-to-list 'org-capture-templates
|
|
'("j" "Journal" entry (file+datetree "~/org/daily-journal.org")
|
|
"* %?\nEntered on %U\n %i\n %a"))
|
|
(setq org-capture-templates
|
|
(append org-capture-templates
|
|
'(("r" "Weekly Review" entry
|
|
(file+datetree "~/org/weekly_reviews.org")
|
|
(file "~/org/weekly_review_template.org")))))
|
|
#+end_src
|
|
|
|
** Daily Journal Entries
|
|
#+begin_src emacs-lisp
|
|
(defun imalison:journal-filepath-for-date (&optional date)
|
|
(interactive (list (org-read-date)))
|
|
(let ((date-str (or date (format-time-string "%Y-%m-%d"))))
|
|
(imalison:join-paths
|
|
org-directory "journal" (concat date-str ".org"))))
|
|
|
|
(defun imalison:open-todays-org-journal ()
|
|
(interactive)
|
|
(imalison:open-org-journal (format-time-string "%Y-%m-%d")))
|
|
|
|
(defun imalison:get-journal-template ()
|
|
(with-temp-buffer
|
|
(insert-file-contents (imalison:join-paths org-directory "templates" "daily-journal-template.org"))
|
|
(buffer-string)))
|
|
|
|
(defun imalison:open-org-journal (&optional date)
|
|
(interactive (list (org-read-date nil nil nil "Select a date:")))
|
|
(let* ((filepath (imalison:journal-filepath-for-date date))
|
|
(file-existed (file-exists-p filepath))
|
|
(date-str (or date (format-time-string "%Y-%m-%d")))
|
|
(time-vals (append '(0 0 0) (nthcdr 3 (parse-time-string date-str))))
|
|
(original-format-time-string (symbol-function 'format-time-string)))
|
|
(find-file filepath)
|
|
(when (not file-existed)
|
|
(cl-letf (((symbol-function 'format-time-string)
|
|
(lambda (format-string &optional _time _universal)
|
|
(funcall original-format-time-string format-string (apply #'encode-time time-vals)))))
|
|
(insert (org-capture-fill-template (imalison:get-journal-template)))))))
|
|
|
|
(bind-key "C-c j" 'imalison:open-todays-org-journal)
|
|
#+end_src
|
|
|
|
** Insert a link to a task selected from agenda
|
|
#+begin_src emacs-lisp
|
|
(defun imalison:insert-link-to-agenda ()
|
|
(interactive)
|
|
(let ((all-tasks '()))
|
|
;; Step 1: Get the list of all org-agenda-files
|
|
(dolist (file (org-agenda-files))
|
|
;; Step 2: For each file, search for all TODO headings
|
|
(with-current-buffer (find-file-noselect file)
|
|
(org-map-entries
|
|
(lambda ()
|
|
(let ((heading (org-get-heading t t t t))
|
|
(marker (point-marker)))
|
|
(add-to-list 'all-tasks (cons heading marker)))))))
|
|
;; Step 3: Prompt the user to select a task from the list of all TODO headings
|
|
(let* ((selected-task (completing-read "Select a task: " all-tasks nil t))
|
|
(selected-marker (cdr (assoc selected-task all-tasks)))
|
|
(file (marker-buffer selected-marker))
|
|
(pos (marker-position selected-marker)))
|
|
;; Step 4: Insert a link to the selected task
|
|
(insert (format "[[file:%s::%d][%s]]" (buffer-file-name file) pos selected-task)))))
|
|
#+end_src
|
|
|
|
** org-babel
|
|
*** javascript
|
|
#+begin_src emacs-lisp
|
|
(use-package ob-js
|
|
:straight nil
|
|
:after org
|
|
:config
|
|
(progn
|
|
(add-to-list 'org-babel-load-languages '(js . t))
|
|
(org-babel-do-load-languages 'org-babel-load-languages org-babel-load-languages)
|
|
(add-to-list 'org-babel-tangle-lang-exts '("js" . "js"))))
|
|
#+end_src
|
|
* kat forgets to save her files
|
|
#+begin_src emacs-lisp
|
|
(auto-save-visited-mode +1)
|
|
#+end_src
|
|
* Display line numbers in programming modes
|
|
#+begin_src emacs-lisp
|
|
(defun imalison:enable-display-line-numbers-mode ()
|
|
(display-line-numbers-mode +1))
|
|
(add-hook 'prog-mode-hook 'imalison:enable-display-line-numbers-mode)
|
|
#+end_src
|