[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/denote b42f68c8e8 156/355: Add denote-type command
From: |
ELPA Syncer |
Subject: |
[elpa] externals/denote b42f68c8e8 156/355: Add denote-type command |
Date: |
Sun, 26 Jun 2022 23:58:18 -0400 (EDT) |
branch: externals/denote
commit b42f68c8e87cc5da379929d22907c2e6c8b2be2c
Author: Protesilaos Stavrou <info@protesilaos.com>
Commit: Protesilaos Stavrou <info@protesilaos.com>
Add denote-type command
---
README.org | 14 ++++++++++----
denote.el | 32 ++++++++++++++++++++++++++++++++
2 files changed, 42 insertions(+), 4 deletions(-)
diff --git a/README.org b/README.org
index a114496e4e..206a5e4294 100644
--- a/README.org
+++ b/README.org
@@ -217,12 +217,13 @@ holds the relevant value. In simple terms:
:END:
#+findex: denote
+#+findex: denote-type
#+findex: denote-org-capture
-There are two ways to write a note with Denote: invoke the ~denote~
-command or leverage the ~org-capture-templates~ by setting up a template
-which calls the function ~denote-org-capture~.
+There are three ways to write a note with Denote: invoke the ~denote~,
+or ~denote-type~ commands, or leverage the ~org-capture-templates~ by
+setting up a template which calls the function ~denote-org-capture~.
-In the first case, all that is needed is to run ~denote~. It will first
+In the first case, all that is needed is to run ~denote~. It will
prompt for a title. Once it is supplied, the command will ask for
keywords. The resulting note will have a file name as already explained
([[#h:4e9c7512-84dc-4dfb-9fa9-e15d51178e5d][The file naming scheme]]).
@@ -245,6 +246,11 @@ The ~denote~ command can also be called from Lisp, in
which case it
expects the =TITLE= and =KEYWORDS= arguments. The former is a string,
the latter a list of strings.
+The ~denote-type~ command is like ~denote~ except it also prompts for a
+file type to use as a local value for ~denote-file-type~. In practical
+terms, this lets you produce, say, a note in Markdown even though you
+normally write in Org ([[#h:f34b172b-3440-446c-aec1-bf818d0aabfe][Notes in
multiple file types]]).
+
For integration with ~org-capture~, the user must first add the relevant
template. Such as:
diff --git a/denote.el b/denote.el
index 4ee4bc3c28..6bbd58c103 100644
--- a/denote.el
+++ b/denote.el
@@ -562,5 +562,37 @@ alphabetically in both the file name and file contents."
(denote--prepare-note title keywords)
(denote--keywords-add-to-history keywords))
+(defvar denote--file-type-history nil
+ "Minibuffer history of `denote--file-type-prompt'.")
+
+(defun denote--file-type-prompt ()
+ "Prompt for `denote-file-type'.
+Note that a non-nil value other than `text', `markdown-yaml', and
+`markdown-toml' falls back to an Org file type. We use `org'
+here for clarity."
+ (completing-read
+ "Select file type: " '(org markdown-yaml markdown-toml text) nil t
+ nil 'denote--file-type-history))
+
+(defun denote--file-type-symbol (filetype)
+ "Return FILETYPE as a symbol."
+ (cond
+ ((stringp filetype)
+ (intern filetype))
+ ((symbolp filetype)
+ filetype)
+ (t (user-error "`%s' is not a symbol or string" filetype))))
+
+;;;###autoload
+(defun denote-type (filetype)
+ "Like `denote' but with FILETYPE for `denote-file-type'.
+In practice, this command lets you create, say, a Markdown file
+even when your default is Org.
+
+When called from Lisp the FILETYPE must be a symbol."
+ (interactive (list (denote--file-type-prompt)))
+ (let ((denote-file-type (denote--file-type-symbol filetype)))
+ (call-interactively #'denote)))
+
(provide 'denote)
;;; denote.el ends here
- [elpa] externals/denote d8b2903fa9 077/355: Acknowledge Jack Baty for commit dfc3a8f, (continued)
- [elpa] externals/denote d8b2903fa9 077/355: Acknowledge Jack Baty for commit dfc3a8f, ELPA Syncer, 2022/06/27
- [elpa] externals/denote 142b628c2e 127/355: Apply distinct face to keyword delimiter, ELPA Syncer, 2022/06/27
- [elpa] externals/denote 86e437da43 150/355: Document .dir-locals.el for multi-type notes, ELPA Syncer, 2022/06/27
- [elpa] externals/denote e92137a548 148/355: Use file attribute for mod time while renaming, ELPA Syncer, 2022/06/27
- [elpa] externals/denote c9926a528e 133/355: perf: Stop searching for the title or identifier after the 1st match, ELPA Syncer, 2022/06/27
- [elpa] externals/denote f55dee06b1 143/355: Add documentation about our minibuffer histories, ELPA Syncer, 2022/06/27
- [elpa] externals/denote 97e8c30bcf 153/355: Rewrite the package Overview, ELPA Syncer, 2022/06/27
- [elpa] externals/denote 171b873cb5 142/355: Require denote-retrieve (0e83bee) in denote-link, ELPA Syncer, 2022/06/27
- [elpa] externals/denote 6a286c97f8 154/355: Rephrase statement for clarity, ELPA Syncer, 2022/06/27
- [elpa] externals/denote 0e83bee5b7 141/355: Add denote-retrieve for internal purposes, ELPA Syncer, 2022/06/27
- [elpa] externals/denote b42f68c8e8 156/355: Add denote-type command,
ELPA Syncer <=
- [elpa] externals/denote e841a51ca7 155/355: Fix typo, ELPA Syncer, 2022/06/27
- [elpa] externals/denote bc93a8ecda 137/355: Update the manual on the matter of backlinks, ELPA Syncer, 2022/06/27
- [elpa] externals/denote 45bea4166a 158/355: Update Acknowledgements, ELPA Syncer, 2022/06/27
- [elpa] externals/denote d4cbb974a5 157/355: Rewrite node on multi file types (due to b42f68c), ELPA Syncer, 2022/06/27
- [elpa] externals/denote 479899d973 162/355: Clarify wording about journal/diary extras, ELPA Syncer, 2022/06/27
- [elpa] externals/denote e9bc790675 167/355: Clarify that auto-backlinks may be removed, ELPA Syncer, 2022/06/27
- [elpa] externals/denote 4bc7aa4dfd 166/355: Remove outdated doc string from private function, ELPA Syncer, 2022/06/27
- [elpa] externals/denote d9f439e47f 173/355: Add helper function to prepare completion table, ELPA Syncer, 2022/06/27
- [elpa] externals/denote 91090d42c6 180/355: Fix regexp match for backlinks, ELPA Syncer, 2022/06/27
- [elpa] externals/denote 768372281f 177/355: Fix formatting typo, ELPA Syncer, 2022/06/27