emacs-elpa-diffs
[Top][All Lists]
Advanced

[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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]