;;; -*- 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" #'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) ("C-c d j" . 'denote-journal-extras-new-or-existing-entry) :map org-mode-map ("C-c l" . 'denote-link)) :config (require 'denote-journal-extras) (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) denote-dired-directories (list denote-directory) denote-journal-extras-directory (expand-file-name "~/dc/log") denote-journal-extras-title-format 'day-date-month-year)) (provide 'bd--notes) ;;; bd--notes.el ends here