You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

110 lines
3.7 KiB
EmacsLisp

(unless (string-equal system-type "android")
(unless (string-equal user-login-name "3055822")
(require 'org-capture)
(defun findread ()
"Find or create heading for read books"
(filedate)
(goto-char (point-min))
(if (not (search-forward "** read" nil t))
(if (not (search-forward "* books" nil t))
(progn
(goto-char (point-max))
(insert "* books\n** read"))
(insert "\n** read"))))
(defun findacquired ()
"Find or create heading for acquired books"
(filedate)
(goto-char (point-min))
(if (not (search-forward "** acquired" nil t))
(if (not (search-forward "* books" nil t))
(progn
(goto-char (point-max))
(insert "* books\n** acquired"))
(insert "\n** acquired"))))
(defun findwatched ()
"Find or create heading for watched films"
(filedate)
(goto-char (point-min))
(if (not (search-forward "** watched" nil t))
(if (not (search-forward "* films" nil t))
(progn
(goto-char (point-max))
(insert "* films\n** watched"))
(insert "\n** watched"))))
(defun findvisited ()
"Find or create heading for visited places"
(filedate)
(goto-char (point-min))
(if (not (search-forward "** visited" nil t))
(if (not (search-forward "* places" nil t))
(progn
(goto-char (point-max))
(insert "* places\n** visited"))
(insert "\n** visited"))))
(defun finddw ()
"Find or create heading for DW posts"
(filedate)
(goto-char (point-min))
(if (not (search-forward "* dw" nil t))
(progn
(goto-char (point-max))
(insert "* dw"))))
(defun therating ()
"Rate some media"
(setq therating nil)
(setq ratingreturn "")
(setq therating (completing-read "Rating: " '("1" "2" "3" "4" "5")))
(when (equal therating "1")
(setq ratingreturn " and rated ★"))
(when (equal therating "2")
(setq ratingreturn " and rated ★★"))
(when (equal therating "3")
(setq ratingreturn " and rated ★★★"))
(when (equal therating "4")
(setq ratingreturn " and rated ★★★★"))
(when (equal therating "5")
(setq ratingreturn " and rated ★★★★★"))
ratingreturn)
(defun thevisitdate ()
"Add dates for a visit"
(setq visitreturn "")
(setq visitstart (read-string "Start date (YYYY-MM-DD): " ))
(unless (equal visitstart "")
(setq visitend (read-string "End date (YYYY-MM-DD): " ))
(setq visitreturn (concat " <" visitstart ">--<" visitend ">")))
visitreturn)
(setq org-default-notes-file (concat "~/Documents/drive/org/journal/" (format-time-string "%Y/%m/%Y-%m-%d") ".org"))
(setq org-capture-templates
'(("a" "Acquired book" entry
(file+function "" findacquired)
"* %^{Author} /%^{Title}/"
:jump-to-captured t)
("b" "Read book" entry
(file+function "" findread)
"* %^{Author} /%^{Title}/%(therating)"
:jump-to-captured t)
("d" "DW post" entry
(file+function "" finddw)
"* %^{Title}\n%?"
:jump-to-captured t)
("f" "Watched film" entry
(file+function "" findwatched)
"* %^{Title} (%^{Year})%(therating)"
:jump-to-captured t)
("p" "Visited place" entry
(file+function "" findvisited)
"* %^{Place}%(thevisitdate)"
:jump-to-captured t)))
(global-set-key (kbd "C-c c") #'org-capture)))