[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/denote 0aab5bc835 012/355: Tweak code for the sake of o
From: |
ELPA Syncer |
Subject: |
[elpa] externals/denote 0aab5bc835 012/355: Tweak code for the sake of org-capture |
Date: |
Sun, 26 Jun 2022 23:57:55 -0400 (EDT) |
branch: externals/denote
commit 0aab5bc835198e72169207484e7702eccc600632
Author: Protesilaos Stavrou <info@protesilaos.com>
Commit: Protesilaos Stavrou <info@protesilaos.com>
Tweak code for the sake of org-capture
---
denote.el | 48 ++++++++++++++++++++++++++----------------------
1 file changed, 26 insertions(+), 22 deletions(-)
diff --git a/denote.el b/denote.el
index 4ef07e4c12..d9471f1086 100644
--- a/denote.el
+++ b/denote.el
@@ -98,6 +98,8 @@ If nil, show the keywords in their given order."
(defvar denote--last-path nil "Store last path.")
(defvar denote--last-title nil "Store last title.")
(defvar denote--last-keywords nil "Store last keywords.")
+(defvar denote--last-buffer nil "Store last buffer.")
+(defvar denote--last-front-matter nil "Store last front-matter.")
;;;; File name helpers
@@ -254,12 +256,15 @@ Format current time, else use optional ID."
(defun denote--prepare-note (title keywords &optional path)
"Use TITLE and KEYWORDS to prepare new note file.
Use optional PATH, else create it with `denote--path'."
- (let* ((filename (or path (denote--path title keywords))))
- (with-current-buffer (find-file filename)
- (insert
- (denote--file-meta-header
- title (format-time-string "%F") keywords filename
- (format-time-string denote-id))))))
+ (let* ((filename (or path (denote--path title keywords)))
+ (default-directory denote-directory)
+ (buffer (find-file filename))
+ (header (denote--file-meta-header
+ title (format-time-string "%F") keywords filename
+ (format-time-string denote-id))))
+ (with-current-buffer buffer (insert header))
+ (setq denote--last-front-matter header)
+ (setq denote--last-buffer buffer)))
(defvar denote--title-history nil
"Minibuffer history of `denote--title-prompt'.")
@@ -304,27 +309,26 @@ Search the source code of this function for a comment
with a
sample template. We will eventually have a manual."
(let ((title (denote--title-prompt))
(keywords (denote--keywords-prompt)))
- (denote--path title keywords)
- (denote--keywords-add-to-history denote--last-keywords)
- (denote--prepare-note denote--last-title denote--last-keywords
denote--last-path)
- denote--last-path))
+ (prog1
+ (denote--path title keywords)
+ (denote--prepare-note denote--last-title denote--last-keywords
denote--last-path)
+ (denote--keywords-add-to-history denote--last-keywords))))
;; Sample of an `org-capture-templates' entry:
;;
-;; ("n" "Note (with denote.el)" plain
-;; (function denote-org-capture-path)
-;; ,(concat "%i"
-;; "\n"
-;; "%a")
-;; :unnarrowed t
-;; :no-save t
-;; :immediate-finish nil
-;; :kill-buffer t
-;; :jump-to-captured t
-;; :empty-lines-before 1)
+;; (setq org-capture-templates
+;; `(("n" "New note (with denote.el)" plain
+;; #'denote-org-capture
+;; ,(concat "%i"
+;; "\n\n"
+;; "%a")
+;; :no-save t
+;; :immediate-finish t
+;; :kill-buffer t
+;; :jump-to-captured t)))
;;
;; FIXME 2022-06-04: The :kill-buffer does not actually kill the buffer
-;; of the file if we use C-c C-k in the capture buffer...
+;; of the file if we use C-c C-k in the capture buffer.
;; TODO 2022-06-04: `denote-rename-file'
- [elpa] branch externals/denote created (now 4f85d0ece8), ELPA Syncer, 2022/06/26
- [elpa] externals/denote 2350d254a0 002/355: Add README: denote is for private use, ELPA Syncer, 2022/06/26
- [elpa] externals/denote 8957eb6720 001/355: Add initial version of denote.el, ELPA Syncer, 2022/06/26
- [elpa] externals/denote e76a6642ad 004/355: Add TODO for file rename, ELPA Syncer, 2022/06/26
- [elpa] externals/denote bdb849caef 008/355: Remove needless interactive spec, ELPA Syncer, 2022/06/26
- [elpa] externals/denote 3c06d7d119 005/355: Tweak front matter, ELPA Syncer, 2022/06/26
- [elpa] externals/denote e9f5c69846 010/355: Placate the compiler, ELPA Syncer, 2022/06/26
- [elpa] externals/denote 39d9870635 018/355: Change punct regexp location; make it defconst, ELPA Syncer, 2022/06/26
- [elpa] externals/denote dd488756f7 019/355: Refine denote--directory-files, ELPA Syncer, 2022/06/26
- [elpa] externals/denote 0aab5bc835 012/355: Tweak code for the sake of org-capture,
ELPA Syncer <=
- [elpa] externals/denote d90ea28d00 013/355: Update one-line description, ELPA Syncer, 2022/06/26
- [elpa] externals/denote 0dd4700e32 014/355: Fix typo, ELPA Syncer, 2022/06/26
- [elpa] externals/denote c3674ff813 023/355: Fix typo, ELPA Syncer, 2022/06/26
- [elpa] externals/denote 3790125482 027/355: Remove to-do, ELPA Syncer, 2022/06/26
- [elpa] externals/denote 5744240289 036/355: Remove needless to-do, ELPA Syncer, 2022/06/26
- [elpa] externals/denote aaa691aa15 020/355: Refine front-matter, ELPA Syncer, 2022/06/26
- [elpa] externals/denote 153827f6c8 021/355: Add denote-link, ELPA Syncer, 2022/06/26
- [elpa] externals/denote 21104787f7 024/355: Put link functionality in denote-link.el, ELPA Syncer, 2022/06/26
- [elpa] externals/denote b951a62245 025/355: Put capture code in denote-org-capture.el, ELPA Syncer, 2022/06/26
- [elpa] externals/denote 9f4a99243c 035/355: Change how org-capture hook is added, ELPA Syncer, 2022/06/26