2022-09-16 17:45:59 -08:00
|
|
|
;;; mitch-orgstuff.el --- Hacking on top of Org mode.
|
|
|
|
|
|
|
|
;;; Commentary:
|
|
|
|
|
|
|
|
;; Some of the things I want to do with org aren't built-in or intended. This
|
|
|
|
;; file is the cum total of my intent to implement these things.
|
|
|
|
|
|
|
|
;;; Code:
|
|
|
|
|
|
|
|
(defvar org-directory (expand-file-name "org/" "~"))
|
2022-09-24 19:02:57 -08:00
|
|
|
(defvar org-agenda-files '("~/org/"))
|
2022-09-16 17:45:59 -08:00
|
|
|
(defvar org-vw-dir org-directory) ;; whoops
|
2022-09-24 19:02:57 -08:00
|
|
|
(defvar org-wiki-regex "\\`[^.].*\\.org\\'")
|
2022-09-16 17:45:59 -08:00
|
|
|
|
|
|
|
(defun org-vw-get-filename (word)
|
|
|
|
"Given WORD, generate the absolute filename for that org-vw entry."
|
|
|
|
(expand-file-name (format "%s.org" (downcase word)) org-vw-dir))
|
|
|
|
;; (org-vw-get-filename "wordWERD")
|
|
|
|
|
|
|
|
(defun org-vw-make-newlink ()
|
|
|
|
"Make the word at point the link to an org file, like in VimWiki."
|
|
|
|
(interactive)
|
|
|
|
(let* ((oldpoint (point))
|
|
|
|
(current-word (thing-at-point 'word 'no-properties))
|
|
|
|
(cw-file-name (org-vw-get-filename current-word)))
|
|
|
|
(backward-word)
|
|
|
|
(kill-word 1)
|
|
|
|
(org-insert-link nil cw-file-name current-word)
|
|
|
|
(goto-char oldpoint)))
|
|
|
|
;; (org-insert-link nil "~/" "a file or sth")
|
|
|
|
|
|
|
|
(defun org-vw-show-markup () ;;broken, just use org-appear or sth
|
|
|
|
"When on a line containing hidden characters, show them."
|
|
|
|
(interactive)
|
|
|
|
(let ((point (point))
|
|
|
|
(bol (point-at-bol))
|
|
|
|
(eol (point-at-eol)))
|
|
|
|
(remove-text-properties bol eol
|
|
|
|
'(invisible nil))
|
|
|
|
t))
|
|
|
|
(defun org-vw-back ()
|
|
|
|
"Go back to the previous org file and bury this buffer."
|
|
|
|
(interactive)
|
|
|
|
(if (buffer-modified-p)
|
|
|
|
(if (y-or-n-p "Do you want to save this file?")
|
|
|
|
(save-buffer)))
|
|
|
|
(bury-buffer)
|
|
|
|
(other-window 1))
|
|
|
|
|
|
|
|
(define-minor-mode org-vw-mode
|
|
|
|
"Org VimWiki mode."
|
|
|
|
:lighter " VW"
|
|
|
|
:keymap (make-sparse-keymap)
|
|
|
|
;; This is a hack, because hyperbole is scary. Ideal implementation would add
|
|
|
|
;; a proper case rather than this weird fallback.
|
2022-09-24 18:59:50 -08:00
|
|
|
(require 'hyperbole)
|
2022-09-16 17:45:59 -08:00
|
|
|
(make-local-variable action-key-default-function)
|
|
|
|
(setq-local action-key-default-function #'org-vw-make-newlink)
|
|
|
|
;; General:
|
|
|
|
(general-define-key
|
|
|
|
:keymaps 'local
|
|
|
|
:states 'normal
|
|
|
|
"DEL" 'org-vw-back))
|
|
|
|
;; (add-to-list 'auto-mode-alist `(,org-wiki-regex . org-vw-mode))
|
|
|
|
(add-hook 'org-mode-hook #'org-vw-mode)
|
|
|
|
|
|
|
|
;; ------------------ ABANDON ALL SANITY, YE WHO ENTER HERE --------------------
|
|
|
|
|
|
|
|
;; Below, I attempt to generalize tangling a whole directory of org files into
|
|
|
|
;; whichever export format, and then apply that.
|
|
|
|
|
2022-09-24 19:02:57 -08:00
|
|
|
;; (require 'ox-hugo)
|
|
|
|
|
|
|
|
;; --------- LET THY BRAIN NO LONGER TREMBLE, FOR I AM BECOME COMPLETE ---------
|
|
|
|
|
|
|
|
(defun mitch-insert-current-datetime ()
|
|
|
|
"Insert the current date and time in my preffered format, with a newline at
|
|
|
|
the end."
|
|
|
|
(interactive)
|
2022-09-26 13:01:11 -08:00
|
|
|
(let ((calendar-date-display-form calendar-iso-date-display-form))
|
|
|
|
(insert
|
|
|
|
(downcase
|
|
|
|
(format "%s %s\n" (calendar-date-string (calendar-current-date))
|
|
|
|
(format-time-string "%-l:%M %p"))))))
|
2022-09-24 19:34:15 -08:00
|
|
|
(defun mitch-1st-heading-now ()
|
2022-09-24 19:02:57 -08:00
|
|
|
"Insert a brand new 2nd level Org heading containing the current date/time.
|
|
|
|
Start insert mode."
|
|
|
|
(interactive)
|
2022-09-25 12:43:01 -08:00
|
|
|
(goto-char (point-max))
|
2022-09-24 19:34:15 -08:00
|
|
|
(insert "* ")
|
2022-09-24 19:02:57 -08:00
|
|
|
(mitch-insert-current-datetime)
|
|
|
|
(evil-insert 1))
|
2022-09-16 17:45:59 -08:00
|
|
|
|
|
|
|
(provide 'mitch-orgstuff)
|
|
|
|
;;; mitch-orgstuff.el ends here
|