[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/denote b951a62245 025/355: Put capture code in denote-o
From: |
ELPA Syncer |
Subject: |
[elpa] externals/denote b951a62245 025/355: Put capture code in denote-org-capture.el |
Date: |
Sun, 26 Jun 2022 23:57:56 -0400 (EDT) |
branch: externals/denote
commit b951a62245806741c43db243ee0f7d47c5107100
Author: Protesilaos Stavrou <info@protesilaos.com>
Commit: Protesilaos Stavrou <info@protesilaos.com>
Put capture code in denote-org-capture.el
---
denote-org-capture.el | 101 ++++++++++++++++++++++++++++++++++++++++++++++++++
denote.el | 58 -----------------------------
2 files changed, 101 insertions(+), 58 deletions(-)
diff --git a/denote-org-capture.el b/denote-org-capture.el
new file mode 100644
index 0000000000..0e25fed973
--- /dev/null
+++ b/denote-org-capture.el
@@ -0,0 +1,101 @@
+;;; denote-org-capture.el --- Denote integration with org-capture -*-
lexical-binding: t -*-
+
+;; Copyright (C) 2022 Protesilaos Stavrou
+
+;; Author: Protesilaos Stavrou <info@protesilaos.com>
+;; URL: https://git.sr.ht/~protesilaos/denote
+;; Version: 0.1.0
+;; Package-Requires: ((emacs "27.1"))
+
+;; This file is NOT part of GNU Emacs.
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+;;
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+;;
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see <https://www.gnu.org/licenses/>.
+
+;;; Commentary:
+;;
+;; Denote integration with org-capture.
+
+;;; Code:
+
+(require 'denote)
+
+(defgroup denote-org-capture ()
+ "Simple tool for plain text notes."
+ :group 'files)
+
+;;; User options
+
+(defcustom denote-org-capture-specifiers "%l\n%i\n%?"
+ "String with format specifieirs for `org-capture-templates'.
+Check that variable's documentation for the details.
+
+This string is append to new notes in the `denote-org-capture'
+function. Every new note has the standard front matter we
+define."
+ :type 'string
+ :group 'denote)
+
+
+;;;###autoload
+(defun denote-org-capture ()
+ "Create new note through `org-capture-templates'.
+Use this as a function that returns the path to the new file.
+The file is populated with Denote's front matter. It can then be
+expanded with the usual specifiers or strings that
+`org-capture-templates' supports.
+
+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--prepare-note denote-last-title denote-last-keywords
denote-last-path)
+ (denote--keywords-add-to-history denote-last-keywords)
+ ;; TODO 2022-06-05: Is there a better way to set up this hook?
+ ;; Alternatively, can we prevent the creation of a file when the
+ ;; capture is aborted?
+ (add-hook 'org-capture-after-finalize-hook
#'denote-org-capture-delete-empty-file)
+ (concat denote-last-front-matter denote-org-capture-specifiers)))
+
+(defun denote-org-capture-delete-empty-file ()
+ "Delete file if capture with `denote-org-capture' is aborted."
+ (when-let* ((file denote-last-path)
+ ((zerop (or (file-attribute-size (file-attributes file)) 0))))
+ (delete-file denote-last-path)))
+
+;; Samples of an `org-capture-templates' entry:
+;;
+;; (setq org-capture-templates
+;; '(("n" "New note (with denote.el)" plain
+;; (file denote-last-path)
+;; #'denote-org-capture
+;; :no-save t
+;; :immediate-finish nil
+;; :kill-buffer t
+;; :jump-to-captured t)))
+;;
+;; (with-eval-after-load 'org-capture
+;; (add-to-list 'org-capture-templates
+;; '("n" "New note (with denote.el)" plain
+;; (file denote-last-path)
+;; #'denote-org-capture
+;; :no-save t
+;; :immediate-finish nil
+;; :kill-buffer t
+;; :jump-to-captured t)))
+
+;; TODO 2022-06-04: `denote-rename-file'
+
+(provide 'denote-org-capture)
+;;; denote-org-capture.el ends here
diff --git a/denote.el b/denote.el
index 0795c14efa..b36ac13d9b 100644
--- a/denote.el
+++ b/denote.el
@@ -82,16 +82,6 @@ If nil, show the keywords in their given order."
:group 'denote
:type 'boolean)
-(defcustom denote-org-capture-specifiers "%l\n%i\n%?"
- "String with format specifieirs for `org-capture-templates'.
-Check that variable's documentation for the details.
-
-This string is append to new notes in the `denote-org-capture'
-function. Every new note has the standard front matter we
-define."
- :type 'string
- :group 'denote)
-
;;; Main variables
;; TODO 2022-06-04: Can we make the entire file name format a defcustom?
@@ -314,54 +304,6 @@ alphabetically."
(denote--prepare-note title keywords)
(denote--keywords-add-to-history keywords))
-;;;###autoload
-(defun denote-org-capture ()
- "Create new note through `org-capture-templates'.
-Use this as a function that returns the path to the new file.
-The file is populated with Denote's front matter. It can then be
-expanded with the usual specifiers or strings that
-`org-capture-templates' supports.
-
-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--prepare-note denote-last-title denote-last-keywords
denote-last-path)
- (denote--keywords-add-to-history denote-last-keywords)
- ;; TODO 2022-06-05: Is there a better way to set up this hook?
- ;; Alternatively, can we prevent the creation of a file when the
- ;; capture is aborted?
- (add-hook 'org-capture-after-finalize-hook
#'denote-org-capture-delete-empty-file)
- (concat denote-last-front-matter denote-org-capture-specifiers)))
-
-(defun denote-org-capture-delete-empty-file ()
- "Delete file if capture with `denote-org-capture' is aborted."
- (when-let* ((file denote-last-path)
- ((zerop (or (file-attribute-size (file-attributes file)) 0))))
- (delete-file denote-last-path)))
-
-;; Samples of an `org-capture-templates' entry:
-;;
-;; (setq org-capture-templates
-;; '(("n" "New note (with denote.el)" plain
-;; (file denote-last-path)
-;; #'denote-org-capture
-;; :no-save t
-;; :immediate-finish nil
-;; :kill-buffer t
-;; :jump-to-captured t)))
-;;
-;; (with-eval-after-load 'org-capture
-;; (add-to-list 'org-capture-templates
-;; '("n" "New note (with denote.el)" plain
-;; (file denote-last-path)
-;; #'denote-org-capture
-;; :no-save t
-;; :immediate-finish nil
-;; :kill-buffer t
-;; :jump-to-captured t)))
-
;; TODO 2022-06-04: `denote-rename-file'
(provide 'denote)
- [elpa] externals/denote dd488756f7 019/355: Refine denote--directory-files, (continued)
- [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, 2022/06/26
- [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 <=
- [elpa] externals/denote 9f4a99243c 035/355: Change how org-capture hook is added, ELPA Syncer, 2022/06/26
- [elpa] externals/denote fa6a3315dc 047/355: Add correct group for org capture specifiers, ELPA Syncer, 2022/06/26
- [elpa] externals/denote f33f8a7040 053/355: Rewrite README as a manual, ELPA Syncer, 2022/06/26
- [elpa] externals/denote 251b35d8f5 003/355: Add GPL, ELPA Syncer, 2022/06/26
- [elpa] externals/denote 2aed386b84 006/355: Add denote-org-capture (WORK-IN-PROGRESS), ELPA Syncer, 2022/06/26
- [elpa] externals/denote 0e2cc10fe6 009/355: Improve integration with org-capture-templates, ELPA Syncer, 2022/06/26
- [elpa] externals/denote 1079beb858 017/355: Add todo about file deletion post org-capture, ELPA Syncer, 2022/06/26
- [elpa] externals/denote 27642bee14 026/355: Clarify 'denote' doc string, ELPA Syncer, 2022/06/26
- [elpa] externals/denote ec3847607b 028/355: Remove to-do about file name format, ELPA Syncer, 2022/06/26
- [elpa] externals/denote 7fe66f43d4 030/355: Remove needless outline and empty line, ELPA Syncer, 2022/06/26