Set up org-capture

master
trémeur 12 months ago
parent 7cfb540149
commit 759c011e98

1
.gitignore vendored

@ -12,6 +12,7 @@ nohup.out
network-security.data network-security.data
nov-places nov-places
org-persist/* org-persist/*
persist/*
places places
*recentf *recentf
request/* request/*

@ -0,0 +1,92 @@
(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"
(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"
(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"
(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"
(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 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)
("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)))

@ -1,5 +1,5 @@
(defun filejournal () (defun filejournal ()
"Refile heading to specific file based on heading" "Refile heading to specific file based on heading (journal edition)"
(interactive) (interactive)
(setq orgheading (org-get-heading)) (setq orgheading (org-get-heading))
(setq orgyear (substring orgheading 0 4)) (setq orgyear (substring orgheading 0 4))
@ -9,6 +9,17 @@
(let ((org-refile-targets '((orgfilepath :maxlevel . 1)))) (let ((org-refile-targets '((orgfilepath :maxlevel . 1))))
(org-refile))) (org-refile)))
(defun filediscord ()
"Refile heading to specific file based on heading (discord edition)"
(interactive)
(setq orgheading (org-get-heading))
(setq orgyear (substring orgheading 0 4))
(setq orgmonth (substring orgheading 5 7))
(setq orgfilepath (concat "~/Documents/drive/org/journal/" orgyear "/" orgmonth "/" orgheading ".org"))
(org-edit-headline "discord")
(let ((org-refile-targets '((orgfilepath :maxlevel . 1))))
(org-refile)))
(defun filedate () (defun filedate ()
"Insert timestamp if required based on file name" "Insert timestamp if required based on file name"
(interactive) (interactive)

Loading…
Cancel
Save