Refactor org-mode config
This commit is contained in:
parent
8537361e50
commit
b7d03fff52
3 changed files with 104 additions and 98 deletions
|
@ -1,6 +1,6 @@
|
|||
;;; defuns-org-custom.el -- custom functions, links, etc. for Org-mode
|
||||
|
||||
(progn ;; Custom links
|
||||
;;; Custom links
|
||||
(defun narf--org-id-to-file (id dir &optional pattern)
|
||||
(let* ((glob (f-glob (format (concat "%s" (or pattern "%s-*.org")) dir id)))
|
||||
(glob-len (length glob)))
|
||||
|
@ -18,7 +18,8 @@
|
|||
(defun narf/org-link-invoice (id)
|
||||
(org-open-file (narf--org-id-to-file id org-directory-invoices "%s.org") t))
|
||||
|
||||
(defun narf-org-complete (type)
|
||||
;;;###autoload
|
||||
(defun narf/org-complete (type)
|
||||
(let ((default-directory (symbol-value (intern (format "org-directory-%ss" type)))))
|
||||
(let* ((file (org-iread-file-name ">>> "))
|
||||
(match (s-match "^\\([0-9]+\\)[-.]" (f-filename file))))
|
||||
|
@ -26,14 +27,17 @@
|
|||
(user-error "Invalid file ID"))
|
||||
(format "%s:%s" type (cadr match)))))
|
||||
|
||||
;;;###autoload
|
||||
(defun org-contact-complete-link ()
|
||||
(narf-org-complete "contact"))
|
||||
(narf/org-complete "contact"))
|
||||
;;;###autoload
|
||||
(defun org-project-complete-link ()
|
||||
(narf-org-complete "project"))
|
||||
(narf/org-complete "project"))
|
||||
;;;###autoload
|
||||
(defun org-invoice-complete-link ()
|
||||
(narf-org-complete "invoice")))
|
||||
(narf/org-complete "invoice"))
|
||||
|
||||
(progn ;; Deft
|
||||
;;; Deft
|
||||
;;;###autoload
|
||||
(defun narf/deft-projects ()
|
||||
(interactive)
|
||||
|
@ -51,7 +55,7 @@
|
|||
;;;###autoload
|
||||
(defun narf/deft-invoices ())
|
||||
;;;###autoload
|
||||
(defun narf/deft-writing ()))
|
||||
(defun narf/deft-writing ())
|
||||
|
||||
(provide 'defuns-org-custom)
|
||||
;;; defuns-org-custom.el ends here
|
||||
|
|
|
@ -27,24 +27,14 @@
|
|||
('above
|
||||
(narf/org-table-prepend-row-or-shift-up))))
|
||||
(t
|
||||
(org-back-to-heading)
|
||||
(let ((first-p (org-first-sibling-p))
|
||||
(orig-char (point)))
|
||||
(cl-case direction
|
||||
('below
|
||||
(org-insert-heading-after-current)
|
||||
(unless first-p
|
||||
(save-excursion
|
||||
(goto-char orig-char)
|
||||
(evil-insert-newline-above)))
|
||||
(save-excursion
|
||||
(evil-insert-newline-below)))
|
||||
(org-insert-heading-after-current))
|
||||
('above
|
||||
(save-excursion
|
||||
(evil-insert-newline-below))
|
||||
(unless first-p
|
||||
(save-excursion
|
||||
(evil-insert-newline-above))))))))
|
||||
(org-back-to-heading)
|
||||
(org-insert-heading)))
|
||||
(when (org-element-property :todo-type context)
|
||||
(org-todo 'todo))))
|
||||
(evil-append-line 1)))
|
||||
|
||||
;;;###autoload
|
||||
|
@ -250,10 +240,11 @@ COUNT-FOOTNOTES? is non-nil."
|
|||
(let ((path (if (string-match-p "^[/~]" dest)
|
||||
dest
|
||||
(expand-file-name dest default-directory))))
|
||||
(shell-command
|
||||
(if (shell-command
|
||||
(format "/usr/local/bin/pandoc '%s' -o '%s'"
|
||||
(buffer-file-name) path))
|
||||
(message "Done! Exported to: %s" path)))
|
||||
(message "Done! Exported to: %s" path)
|
||||
(user-error "Export failed"))))
|
||||
|
||||
;;;###autoload
|
||||
(defun narf/org-remove-link ()
|
||||
|
|
|
@ -7,10 +7,10 @@
|
|||
:keymap (make-sparse-keymap) ; defines evil-org-mode-map
|
||||
:group 'evil-org)
|
||||
|
||||
(defvar org-directory (concat narf-dropbox-dir "org/"))
|
||||
(defvar org-directory-contacts (expand-file-name "work/contacts/" org-directory))
|
||||
(defvar org-directory-projects (expand-file-name "work/projects/" org-directory))
|
||||
(defvar org-directory-invoices (expand-file-name "work/invoices/" org-directory))
|
||||
(defvar org-directory (expand-file-name "org/" narf-dropbox-dir))
|
||||
(defvar org-directory-contacts (expand-file-name "my/contacts/" org-directory))
|
||||
(defvar org-directory-projects (expand-file-name "my/projects/" org-directory))
|
||||
(defvar org-directory-invoices (expand-file-name "my/invoices/" org-directory))
|
||||
|
||||
(add-hook! org-load 'narf|org-init)
|
||||
|
||||
|
@ -53,7 +53,7 @@
|
|||
|
||||
org-capture-templates
|
||||
'(("t" "TODO" entry
|
||||
(file+headline (concat org-directory "gtd.org") "Inbox")
|
||||
(file+headline (concat org-directory "todo.org") "Inbox")
|
||||
"** TODO %? %u")
|
||||
|
||||
;; TODO Select file from org files
|
||||
|
@ -66,13 +66,13 @@
|
|||
;; "** %<%H:%M>: %? :unsorted:\n%i" :prepend t)
|
||||
|
||||
("j" "Journal" entry
|
||||
(file+datetree (concat org-directory "personal/journal.org"))
|
||||
(file+datetree (concat org-directory "journal.org"))
|
||||
"** %<%H:%M>: %?\n%i" :prepend t)
|
||||
|
||||
;; TODO Select file from notes folder
|
||||
;; ("n" "Notes" entry
|
||||
;; (file "~/Dropbox/notes/trivia.org")
|
||||
;; "* %u %?\n%i" :prepend t)
|
||||
("n" "Notes" entry
|
||||
(file+headline (concat org-directory "notes.org") "Inbox")
|
||||
"* %u %?\n%i" :prepend t)
|
||||
|
||||
("s" "Writing Scraps" entry
|
||||
(file+headline (concat org-directory "writing/scraps.org") "Unsorted")
|
||||
|
@ -202,6 +202,7 @@ will function properly."
|
|||
;; (defface org-item-checkbox '((t ())) "Face for checkbox list lines")
|
||||
;; (defface org-item-checkbox-checked '((t ())) "Face for checked checkbox list lines")
|
||||
(defface org-whitespace '((t ())) "Face for spaces")
|
||||
(defface org-list-bullet '((t ())) "Face for list bullets")
|
||||
(font-lock-add-keywords
|
||||
'org-mode `(("^ *\\(#\\+begin_src\\>\\)"
|
||||
(1 (narf/show-as ?#)))
|
||||
|
@ -213,10 +214,10 @@ will function properly."
|
|||
(1 (narf/show-as ?\")))
|
||||
|
||||
;; Hide TODO tags
|
||||
("\\(\\* DONE\\) \\([^$:\n\r]+\\)"
|
||||
("^\\**\\(\\* DONE\\) \\([^$:\n\r]+\\)"
|
||||
(1 (narf/show-as ?☑))
|
||||
(2 'org-headline-done))
|
||||
("\\(\\* TODO\\) [^$:\n\r]+"
|
||||
("^\\**\\(\\* TODO\\) "
|
||||
(1 (narf/show-as ?☐)))
|
||||
|
||||
("[-+*] \\(\\[ \\]\\) "
|
||||
|
@ -225,18 +226,11 @@ will function properly."
|
|||
(1 (narf/show-as ?☑))
|
||||
(2 'org-headline-done))
|
||||
|
||||
;; ("\\([-+] \\(\\[ \\]\\) \\([^$:\n\r]+\\)\\)"
|
||||
;; (2 'org-item-checkbox))
|
||||
;; ("\\([-+] \\(\\[X\\]\\) \\([^$:\n\r]+\\)\\)"
|
||||
;; (2 'org-item-checkbox-checked))
|
||||
|
||||
;; Color code TODOs with !'s to denote priority
|
||||
("\\* TODO\\( !\\)! [^$:\n\r]+"
|
||||
(0 'org-todo-vhigh)
|
||||
(1 (narf/show-as ?!)))
|
||||
("\\* TODO\\( !\\) [^$:\n\r]+"
|
||||
(0 'org-todo-high)
|
||||
(1 (narf/show-as ?!)))
|
||||
("\\* TODO .* !!$"
|
||||
(0 'org-todo-vhigh))
|
||||
("\\* TODO .* !$"
|
||||
(0 'org-todo-high))
|
||||
|
||||
;; Show checkbox for other todo states (but don't hide the label)
|
||||
(,(concat
|
||||
|
@ -245,14 +239,12 @@ will function properly."
|
|||
" ")
|
||||
(1 (narf/show-as ?☐)))
|
||||
|
||||
("^ *\\([-+]\\)\\( \\)+[^$\n\r]+"
|
||||
(1 'org-code)
|
||||
;; (2 'org-whitespace)
|
||||
)
|
||||
("^ *\\([-+]\\|[0-9]+[).]\\)\\( \\)+[^$\n\r]+"
|
||||
(1 'org-list-bullet))
|
||||
("^ +\\(\\*\\) "
|
||||
(1 (narf/show-as ?◦)))
|
||||
;; ("^ +"
|
||||
;; (0 'org-whitespace))
|
||||
("^ +"
|
||||
(0 'org-whitespace))
|
||||
)))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
@ -261,17 +253,14 @@ will function properly."
|
|||
(evil-org-mode +1)
|
||||
(org-bullets-mode +1)
|
||||
(org-indent-mode +1)
|
||||
;; (text-scale-set 0.5)
|
||||
(text-scale-set 1)
|
||||
|
||||
(diminish 'org-indent-mode)
|
||||
|
||||
(narf|enable-tab-width-2)
|
||||
(setq truncate-lines nil)
|
||||
(setq line-spacing '0.2)
|
||||
;; (variable-pitch-mode 1)
|
||||
|
||||
;; Allow cursor beyond eol so we can reach around hidden emphasis markers
|
||||
(set (make-local-variable 'evil-move-beyond-eol) t)
|
||||
(variable-pitch-mode 1)
|
||||
|
||||
(defun narf|org-update-statistics-cookies () (org-update-statistics-cookies t))
|
||||
(add-hook 'before-save-hook 'narf|org-update-statistics-cookies nil t)
|
||||
|
@ -313,6 +302,28 @@ will function properly."
|
|||
(org-add-link-type "project" 'narf/org-link-project)
|
||||
(org-add-link-type "invoice" 'narf/org-link-invoice)
|
||||
|
||||
(add-to-list 'recentf-exclude (expand-file-name "%s.+\\.org$" org-directory))
|
||||
(after! helm
|
||||
(mapc (lambda (r) (add-to-list 'helm-boring-file-regexp-list r))
|
||||
(list "\\.attach$" "\\.Rhistory$")))
|
||||
|
||||
(after! winner
|
||||
(dolist (bufname '("*Org todo*"
|
||||
"*Org Links*"
|
||||
"*Agenda Commands*"))
|
||||
(push bufname winner-boring-buffers)))
|
||||
|
||||
;; fix some org-mode + yasnippet conflicts:
|
||||
(defun yas/org-very-safe-expand ()
|
||||
(let ((yas/fallback-behavior 'return-nil)) (yas/expand)))
|
||||
|
||||
(add-hook 'org-mode-hook
|
||||
(lambda ()
|
||||
(make-variable-buffer-local 'yas/trigger-key)
|
||||
(setq yas/trigger-key [tab])
|
||||
(add-to-list 'org-tab-first-hook 'yas/org-very-safe-expand)
|
||||
(define-key yas/keymap [tab] 'yas-next-field)))
|
||||
|
||||
;;; Evil integration
|
||||
(progn
|
||||
(advice-add 'evil-force-normal-state :before 'org-remove-occur-highlights)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue