blob: 31aa5c8d14104cac8706e90ec208826181669559 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
;;; -*- 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
:hook
((dired-mode . denote-dired-mode-in-directories))
:bind (("H-d f" . 'denote-open-or-create)
("H-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 "\" \""))
:custom
(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
|