diff options
Diffstat (limited to 'guix/kolwynia/home/bdunahu/files/.config/emacs/modules/bd--notes.el')
| -rw-r--r-- | guix/kolwynia/home/bdunahu/files/.config/emacs/modules/bd--notes.el | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/guix/kolwynia/home/bdunahu/files/.config/emacs/modules/bd--notes.el b/guix/kolwynia/home/bdunahu/files/.config/emacs/modules/bd--notes.el new file mode 100644 index 0000000..13f80f4 --- /dev/null +++ b/guix/kolwynia/home/bdunahu/files/.config/emacs/modules/bd--notes.el @@ -0,0 +1,77 @@ +;;; -*- lexical-binding: t; -*- +;;; Commentary: +;;; Code: + + +(defvar scratch-buffer nil + "Non-nil if the current buffer is a scratch buffer.") +(make-variable-buffer-local 'scratch-buffer) +(defun bd/send-to-scratch () + "Creates/switches to the scratch for `major-mode', +then pastes the active region." + (interactive) + (let* ((mode major-mode) + (name (format "*scratch for %s*" mode)) + (contents (when (region-active-p) + (buffer-substring-no-properties + (region-beginning) (region-end)))) + (buf (get-buffer name))) + (pop-to-buffer + (with-current-buffer (get-buffer-create name) + (funcall mode) + (setq-local scratch-buffer t) + (when contents + (insert (format "\n\n%s" contents))) + (current-buffer))))) +(keymap-global-set "C-c s" #'scratch-buffer) +(keymap-global-set "C-c C-s" #'bd/send-to-scratch) +;; default *scratch* must have var set +(add-hook 'emacs-startup-hook + (lambda () + (with-current-buffer "*scratch*" + (setq-local scratch-buffer t)))) +(advice-add 'scratch-buffer :after (lambda () (setq-local scratch-buffer t))) + +(use-package denote + :defer 1 + :hook + ((dired-mode . denote-dired-mode-in-directories)) + :bind (("C-c d d" . 'denote) + ("C-c d f" . 'denote-open-or-create) + :map org-mode-map + ("C-c l" . 'denote-link)) + :config + + (defconst bd/denote-skribe-front-matter + "(post + :title \"%s\" + :date %s + :tags '(\"%s\") + ;; identifier: %s +\n\n)") + (defun bd/denote-skribe-format-date (date) + "Format DATE as a scheme procedure." + (format-time-string "(make-date* %Y %m %d %H %M)" date)) + (defun bd/denote-format-keywords-for-skribe-front-matter (keywords) + "Format front matter KEYWORDS for skribe file type. +KEYWORDS is a list of strings." + (string-join keywords "\" \"")) + :config + (setopt denote-file-type 'org + denote-known-keywords + '("ss" "writing" "reading" "art" + "csu" "umass" "cs" "guix" + "emacs" "programs" "mem") + denote-directory (expand-file-name "~/dc/") + denote-prompts '(title file-type keywords subdirectory) + denote-dired-directories (list denote-directory))) + +(use-package denote-journal + :bind (("C-c d j" . 'denote-journal-new-or-existing-entry)) + :config + (setopt denote-journal-directory (expand-file-name "~/dc/log") + denote-journal-title-format 'day-date-month-year)) + + +(provide 'bd--notes) +;;; bd--notes.el ends here |
