Put org files in Syncthing instead of dropbox
This commit is contained in:
parent
06be62d091
commit
99916d990b
179
emacs/init.org
179
emacs/init.org
@ -1502,13 +1502,24 @@ The JSON multitool.
|
||||
* Org Mode
|
||||
Notes, agenda, calendar, blogging, journaling, etc.
|
||||
|
||||
A function to get my org directory:
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
(defvar syncthing-path (expand-file-name "~/Sync")
|
||||
"The absolute path to the Syncthing directory")
|
||||
|
||||
(defun org-directory (&optional path)
|
||||
"Returns the directory for my org notes, appends PATH if given"
|
||||
(f-join syncthing-path "org" (s-chop-prefix (f-path-separator) (or path ""))))
|
||||
#+END_SRC
|
||||
|
||||
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
(jdormit/define-prefix "o" "org")
|
||||
(leader-def-key "oa" 'org-agenda)
|
||||
(leader-def-key "oc" 'org-capture)
|
||||
(setq org-src-fontify-natively t
|
||||
org-ellipsis " ▼"
|
||||
org-directory (concat (get-dropbox-directory) "/org")
|
||||
org-directory (org-directory)
|
||||
org-link-elisp-confirm-function 'y-or-n-p
|
||||
org-startup-with-inline-images t)
|
||||
(add-hook 'org-mode-hook #'auto-fill-mode)
|
||||
@ -1553,7 +1564,7 @@ A function to add ids to every heading in an Org file:
|
||||
** Agenda files
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
(defun agenda-files (&optional file)
|
||||
(let ((agenda-dir (concat (file-name-as-directory (get-dropbox-directory)) "org")))
|
||||
(let ((agenda-dir (org-directory)))
|
||||
(if file
|
||||
(concat (file-name-as-directory agenda-dir) file)
|
||||
agenda-dir)))
|
||||
@ -1912,33 +1923,32 @@ It's very useful to open a new org buffer for a quick org-babel exploration.
|
||||
Integrate Google calendar with org-mode:
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
(defun get-calendar-file (name)
|
||||
(concat (file-name-as-directory (get-dropbox-directory))
|
||||
"org/" name))
|
||||
(org-directory name))
|
||||
|
||||
(use-package org-gcal
|
||||
:after (org)
|
||||
:commands (org-gcal-sync
|
||||
org-gcal-fetch
|
||||
org-gcal-post-at-point
|
||||
org-gcal-delete-at-point
|
||||
org-gcal-refresh-token)
|
||||
org-gcal-fetch
|
||||
org-gcal-post-at-point
|
||||
org-gcal-delete-at-point
|
||||
org-gcal-refresh-token)
|
||||
:config
|
||||
(setq org-gcal-client-id (password-store-get "lola-org-gcal-client-id")
|
||||
org-gcal-client-secret (password-store-get "lola-org-gcal-client-secret")
|
||||
org-gcal-file-alist `(("jeremydormitzer@lola.com" . ,(get-calendar-file "lola-gcal.org"))
|
||||
("jeremy.dormitzer@gmail.com" . ,(get-calendar-file "personal-gcal.org"))
|
||||
("lut2o2moohg6qkdsto1qfq7th4@group.calendar.google.com" . ,(get-calendar-file "j-n-gcal.org")))
|
||||
org-gcal-notify-p nil))
|
||||
org-gcal-client-secret (password-store-get "lola-org-gcal-client-secret")
|
||||
org-gcal-file-alist `(("jeremydormitzer@lola.com" . ,(get-calendar-file "lola-gcal.org"))
|
||||
("jeremy.dormitzer@gmail.com" . ,(get-calendar-file "personal-gcal.org"))
|
||||
("lut2o2moohg6qkdsto1qfq7th4@group.calendar.google.com" . ,(get-calendar-file "j-n-gcal.org")))
|
||||
org-gcal-notify-p nil))
|
||||
|
||||
(defun org-gcal-fetch-and-save ()
|
||||
(interactive)
|
||||
(deferred:$
|
||||
(org-gcal-fetch)
|
||||
(deferred:nextc it
|
||||
(lambda ()
|
||||
(dolist (entry org-gcal-file-alist)
|
||||
(with-current-buffer (cdr entry)
|
||||
(save-buffer)))))))
|
||||
(lambda ()
|
||||
(dolist (entry org-gcal-file-alist)
|
||||
(with-current-buffer (cdr entry)
|
||||
(save-buffer)))))))
|
||||
|
||||
(add-hook 'emacs-startup-hook #'org-gcal-fetch-and-save)
|
||||
|
||||
@ -2045,90 +2055,89 @@ Intelligently inserts an org-mode link from the clipboard.
|
||||
|
||||
(defun org-capture-bookmark-get-url ()
|
||||
(let* ((clip (org-cliplink-clipboard-content))
|
||||
(parsed (url-generic-parse-url clip)))
|
||||
(if (url-type parsed)
|
||||
clip
|
||||
(read-string "Bookmark URL: "))))
|
||||
(parsed (url-generic-parse-url clip)))
|
||||
(if (url-type parsed)
|
||||
clip
|
||||
(read-string "Bookmark URL: "))))
|
||||
|
||||
(defun org-capture-bookmark-get-title (url)
|
||||
(or (org-cliplink-retrieve-title-synchronously url)
|
||||
(read-string "Bookmark title: ")))
|
||||
(read-string "Bookmark title: ")))
|
||||
|
||||
(defun bookmark-file (title)
|
||||
(concat (get-dropbox-directory)
|
||||
(format "/org/%s.org" (org-roam--get-new-id title))))
|
||||
(org-directory (format "%s.org" (org-roam--get-new-id title))))
|
||||
|
||||
(defun org-capture-bookmark-file ()
|
||||
(let* ((url (org-capture-bookmark-get-url))
|
||||
(title (org-capture-bookmark-get-title url)))
|
||||
(setq org-capture-bookmark-last-url url)
|
||||
(setq org-capture-bookmark-last-title title)
|
||||
(bookmark-file title)))
|
||||
(title (org-capture-bookmark-get-title url)))
|
||||
(setq org-capture-bookmark-last-url url)
|
||||
(setq org-capture-bookmark-last-title title)
|
||||
(bookmark-file title)))
|
||||
|
||||
(defun org-capture-bookmark-link ()
|
||||
(format "[[%s][%s]]"
|
||||
org-capture-bookmark-last-url
|
||||
org-capture-bookmark-last-title))
|
||||
org-capture-bookmark-last-url
|
||||
org-capture-bookmark-last-title))
|
||||
|
||||
(defun org-capture-bookmark-title ()
|
||||
org-capture-bookmark-last-title)
|
||||
|
||||
(defun save-bookmark (url)
|
||||
(save-excursion
|
||||
(goto-char (point-min))
|
||||
(when (search-forward "* Bookmark" nil t)
|
||||
(org-board-new url)
|
||||
(wallabag-add-entry url
|
||||
(cl-function
|
||||
(lambda (&key data &allow-other-keys)
|
||||
(let ((entry-url (format "%s/view/%s"
|
||||
wallabag-base-url
|
||||
(alist-get 'id data))))
|
||||
(message "Added bookmark to Wallabag: %s" entry-url))))))))
|
||||
(goto-char (point-min))
|
||||
(when (search-forward "* Bookmark" nil t)
|
||||
(org-board-new url)
|
||||
(wallabag-add-entry url
|
||||
(cl-function
|
||||
(lambda (&key data &allow-other-keys)
|
||||
(let ((entry-url (format "%s/view/%s"
|
||||
wallabag-base-url
|
||||
(alist-get 'id data))))
|
||||
(message "Added bookmark to Wallabag: %s" entry-url))))))))
|
||||
|
||||
(defun org-capture-bookmark-after-finalize ()
|
||||
"Runs `org-board-new' on the captured entry.
|
||||
Also saves to Wallabag."
|
||||
(let ((success (not org-note-abort))
|
||||
(key (plist-get org-capture-plist :key))
|
||||
(desc (plist-get org-capture-plist :description)))
|
||||
(when (and success
|
||||
(equal key "b")
|
||||
(equal desc "Bookmark")
|
||||
org-capture-bookmark-last-url)
|
||||
(save-bookmark org-capture-bookmark-last-url)
|
||||
(setq org-capture-bookmark-last-url nil)
|
||||
(setq org-capture-bookmark-last-title nil))))
|
||||
(key (plist-get org-capture-plist :key))
|
||||
(desc (plist-get org-capture-plist :description)))
|
||||
(when (and success
|
||||
(equal key "b")
|
||||
(equal desc "Bookmark")
|
||||
org-capture-bookmark-last-url)
|
||||
(save-bookmark org-capture-bookmark-last-url)
|
||||
(setq org-capture-bookmark-last-url nil)
|
||||
(setq org-capture-bookmark-last-title nil))))
|
||||
|
||||
(add-hook 'org-capture-prepare-finalize-hook
|
||||
#'org-capture-bookmark-after-finalize)
|
||||
#'org-capture-bookmark-after-finalize)
|
||||
|
||||
(add-to-list 'org-capture-templates
|
||||
'("b" "Bookmark" plain
|
||||
(file org-capture-bookmark-file)
|
||||
"#+TITLE: %(org-capture-bookmark-title)\n\n- tags :: [[file:deft/bookmarks.org][Bookmarks]]\n- source :: %(org-capture-bookmark-link)\n%?\n* Bookmark"))
|
||||
'("b" "Bookmark" plain
|
||||
(file org-capture-bookmark-file)
|
||||
"#+TITLE: %(org-capture-bookmark-title)\n\n- tags :: [[file:deft/bookmarks.org][Bookmarks]]\n- source :: %(org-capture-bookmark-link)\n%?\n* Bookmark"))
|
||||
|
||||
;; Org-protocol setup
|
||||
(defun make-org-protocol-bookmark (url title)
|
||||
(with-temp-buffer
|
||||
(let ((filename (bookmark-file title)))
|
||||
(save-excursion
|
||||
(insert (concat (format "#+TITLE: %s\n\n" title)
|
||||
"- tags :: [[file:deft/bookmarks.org][Bookmarks]]\n"
|
||||
(format "- source :: [[%s][%s]]\n\n" url title)
|
||||
"* Bookmark"))
|
||||
(write-file filename)
|
||||
(save-bookmark url)
|
||||
(save-buffer)))))
|
||||
(let ((filename (bookmark-file title)))
|
||||
(save-excursion
|
||||
(insert (concat (format "#+TITLE: %s\n\n" title)
|
||||
"- tags :: [[file:deft/bookmarks.org][Bookmarks]]\n"
|
||||
(format "- source :: [[%s][%s]]\n\n" url title)
|
||||
"* Bookmark"))
|
||||
(write-file filename)
|
||||
(save-bookmark url)
|
||||
(save-buffer)))))
|
||||
|
||||
(defun bookmark-via-org-protocol (url)
|
||||
(org-cliplink-retrieve-title (url-unhex-string url) #'make-org-protocol-bookmark))
|
||||
|
||||
(add-to-list 'org-protocol-protocol-alist
|
||||
'("Bookmark"
|
||||
:protocol "bookmark"
|
||||
:function bookmark-via-org-protocol
|
||||
:kill-client t))
|
||||
'("Bookmark"
|
||||
:protocol "bookmark"
|
||||
:function bookmark-via-org-protocol
|
||||
:kill-client t))
|
||||
|
||||
:config
|
||||
(add-to-list 'org-board-wget-switches "--recursive")
|
||||
@ -2136,18 +2145,18 @@ Intelligently inserts an org-mode link from the clipboard.
|
||||
(add-to-list 'org-board-wget-switches "--span-hosts")
|
||||
;; Use w3m instead of eww to open org-board archived links
|
||||
(advice-add 'org-board-open-with :around
|
||||
(lambda (oldfn filename-string arg &rest args)
|
||||
(cond
|
||||
((not (file-exists-p filename-string)) 1)
|
||||
((and filename-string
|
||||
(or (and arg (eq org-board-default-browser 'system))
|
||||
(and (not arg) (eq org-board-default-browser 'eww))))
|
||||
(let ((filename (concat "file://"
|
||||
(s-chop-prefix "file://"
|
||||
filename-string))))
|
||||
(w3m filename t)
|
||||
0))
|
||||
(:else (apply oldfn filename-string arg args)))))
|
||||
(lambda (oldfn filename-string arg &rest args)
|
||||
(cond
|
||||
((not (file-exists-p filename-string)) 1)
|
||||
((and filename-string
|
||||
(or (and arg (eq org-board-default-browser 'system))
|
||||
(and (not arg) (eq org-board-default-browser 'eww))))
|
||||
(let ((filename (concat "file://"
|
||||
(s-chop-prefix "file://"
|
||||
filename-string))))
|
||||
(w3m filename t)
|
||||
0))
|
||||
(:else (apply oldfn filename-string arg args)))))
|
||||
:general
|
||||
(org-mode-map "C-c b" org-board-keymap))
|
||||
#+END_SRC
|
||||
@ -2209,7 +2218,7 @@ Quickly find stuff in Org files:
|
||||
:hook
|
||||
(after-init . org-roam-mode)
|
||||
:custom
|
||||
(org-roam-directory (concat (get-dropbox-directory) "/org"))
|
||||
(org-roam-directory (org-directory))
|
||||
:init
|
||||
(leader-def-key "fo" #'org-roam-find-file)
|
||||
(leader-def-key "of" #'org-roam-find-file)
|
||||
@ -2261,7 +2270,7 @@ nice with Org-roam:
|
||||
(leader-def-key "ojt" #'org-journal-today)
|
||||
:custom
|
||||
(org-journal-file-type 'daily)
|
||||
(org-journal-dir (concat (get-dropbox-directory) "/org"))
|
||||
(org-journal-dir (org-directory))
|
||||
(org-journal-file-format "%Y-%m-%d.org")
|
||||
(org-journal-file-header 'org-journal-file-header-func)
|
||||
(org-journal-carryover-items "")
|
||||
@ -5956,13 +5965,9 @@ A fuzzy-finder for notes.
|
||||
:init
|
||||
(setq deft-extensions '("org" "txt" "md" "markdown" "text")
|
||||
deft-recursive t
|
||||
deft-directory (concat
|
||||
(file-name-as-directory (get-dropbox-directory))
|
||||
"org"))
|
||||
deft-directory (org-directory))
|
||||
;; Still lots of notes in the old Deft directory
|
||||
(add-to-list 'org-agenda-files
|
||||
(concat (file-name-as-directory (get-dropbox-directory))
|
||||
"/org/deft"))
|
||||
(add-to-list 'org-agenda-files (org-directory "deft"))
|
||||
(leader-def-key "D" #'deft)
|
||||
(leader-def-key "od" #'deft)
|
||||
:config
|
||||
@ -6571,7 +6576,7 @@ Jira in Emacs:
|
||||
(use-package org-jira
|
||||
:init
|
||||
(setq jiralib-url "https://lola.atlassian.net"
|
||||
org-jira-working-dir (concat (get-dropbox-directory) "/org/jira")
|
||||
org-jira-working-dir (org-directory "jira")
|
||||
org-jira-jira-status-to-org-keyword-alist '(("To Do" . "TODO")
|
||||
("Blocked" . "BLOCKED")
|
||||
("In Progress" . "IN PROGRESS")
|
||||
|
Loading…
Reference in New Issue
Block a user