[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/denote f193199c88 228/355: Insert generic format links
From: |
ELPA Syncer |
Subject: |
[elpa] externals/denote f193199c88 228/355: Insert generic format links with prefix argument |
Date: |
Sun, 26 Jun 2022 23:58:27 -0400 (EDT) |
branch: externals/denote
commit f193199c8850eab1bdde4dcb988232a99ad0ea37
Author: Protesilaos Stavrou <info@protesilaos.com>
Commit: Protesilaos Stavrou <info@protesilaos.com>
Insert generic format links with prefix argument
---
README.org | 21 ++++++++++++++++++---
denote-link.el | 39 ++++++++++++++++++++++++++++++---------
2 files changed, 48 insertions(+), 12 deletions(-)
diff --git a/README.org b/README.org
index 9282f532e4..a9bb47cfb5 100644
--- a/README.org
+++ b/README.org
@@ -581,12 +581,17 @@ participate in the development of Denote.
*The linking facility is the only major area that needs to be reviewed
before releasing the first stable version of Denote.*
+#+findex: denote-link
The ~denote-link~ command inserts a link at point to an entry specified
at the minibuffer prompt. Links are formatted depending on the file
type of current note. In Org and plain text buffers, links are
formatted thus: =[[denote:IDENTIFIER][TITLE]]=. While in Markdown they
are expressed as =[TITLE](denote:IDENTIFIER)=.
+When ~denote-link~ is called with a prefix argument (=C-u= by default)
+it formats links like =[[denote:IDENTIFIER]]=. The user might prefer
+its simplicity.
+
How those links behave will depend on the user's preference. Denote
provides a simple-minded implementation for such link, which either
works competently with point-and-click kind of interaction or, at the
@@ -689,9 +694,19 @@ typographic list, such as:
- link3
#+end_example
-Each link is formatted according to the file type of the current note.
-The current note is excluded from the matching entries (adding a link to
-itself is pointless).
+Each link is formatted according to the file type of the current note,
+as explained further above about the ~denote-link~ command. The current
+note is excluded from the matching entries (adding a link to itself is
+pointless).
+
+When called with a prefix argument (=C-u=) ~denote-link-add-links~ will
+format all links as =[[denote:IDENTIFIER]]=, hence a typographic list:
+
+#+begin_example
+- [[denote:IDENTIFIER-1]]
+- [[denote:IDENTIFIER-2]]
+- [[denote:IDENTIFIER-3]]
+#+end_example
Same examples of a regular expression that can be used with this
command:
diff --git a/denote-link.el b/denote-link.el
index ada84d252c..3bbf807136 100644
--- a/denote-link.el
+++ b/denote-link.el
@@ -97,6 +97,9 @@ and/or the documentation string of `display-buffer'."
(defconst denote-link--format-markdown "[%2$s](denote:%1$s)"
"Format of Markdown link to note.")
+(defconst denote-link--format-id-only "[[denote:%s]]"
+ "Format of identifier-only link to note.")
+
(defconst denote-link--regexp-org
(concat "\\[\\[" "denote:" "\\(?1:" denote--id-regexp "\\)" "]" "\\[.*?]]"))
@@ -118,17 +121,30 @@ and/or the documentation string of `display-buffer'."
(defun denote-link--format-link (file pattern)
"Prepare link to FILE using PATTERN."
(let* ((file-id (denote-retrieve--filename-identifier file))
- (file-title (denote-retrieve--value-title file)))
+ (file-title (unless (string= pattern denote-link--format-id-only)
+ (denote-retrieve--value-title file))))
(format pattern file-id file-title)))
+(defun denote-link--extension-format-or-id (id-only)
+ "Determine format for link.
+If ID-ONLY is non-nil, use `denote-link--format-id-only', else
+delegate to `denote-link--file-type-format'."
+ (if id-only
+ denote-link--format-id-only
+ (denote-link--file-type-format (buffer-file-name))))
+
;;;###autoload
-(defun denote-link (target)
- "Create link to TARGET note in variable `denote-directory'."
- (interactive (list (denote-retrieve--read-file-prompt)))
+(defun denote-link (target &optional id-only)
+ "Create link to TARGET note in variable `denote-directory'.
+With optional ID-ONLY, such as a universal prefix
+argument (\\[universal-argument]), insert links with just the
+identifier and no further description. In this case, the link
+format is always [[denote:IDENTIFIER]]."
+ (interactive (list (denote-retrieve--read-file-prompt) current-prefix-arg))
(insert
(denote-link--format-link
target
- (denote-link--file-type-format (buffer-file-name)))))
+ (denote-link--extension-format-or-id id-only))))
(defalias 'denote-link-insert-link (symbol-function 'denote-link))
@@ -269,15 +285,20 @@ default, it will show up below the current window."
"Minibuffer history for `denote-link-add-links'.")
;;;###autoload
-(defun denote-link-add-links (regexp)
+(defun denote-link-add-links (regexp &optional id-only)
"Insert links to all notes matching REGEXP.
Use this command to reference multiple files at once.
Particularly useful for the creation of metanotes (read the
-manual for more on the matter)."
+manual for more on the matter).
+
+Optional ID-ONLY has the same meaning as in `denote-link': it
+inserts links with just the identifier."
(interactive
- (list (read-regexp "Insert links matching REGEX: " nil
'denote-link--add-links-history)))
+ (list
+ (read-regexp "Insert links matching REGEX: " nil
'denote-link--add-links-history)
+ current-prefix-arg))
(let* ((default-directory (denote-directory))
- (ext (denote-link--file-type-format (buffer-file-name))))
+ (ext (denote-link--extension-format-or-id id-only)))
(if-let ((files (denote--directory-files-matching-regexp regexp)))
(insert (denote-link--prepare-links files ext))
(user-error "No links matching `%s'" regexp))))
- [elpa] externals/denote d66312e517 172/355: Fix regression in file extension caused by f57e9c5, (continued)
- [elpa] externals/denote d66312e517 172/355: Fix regression in file extension caused by f57e9c5, ELPA Syncer, 2022/06/27
- [elpa] externals/denote 553c10a9cc 178/355: Tweak doc string, ELPA Syncer, 2022/06/27
- [elpa] externals/denote 8e6e2736dc 174/355: Add generic denote-link-find-file, ELPA Syncer, 2022/06/27
- [elpa] externals/denote b54dd3404d 186/355: Tweak doc string, ELPA Syncer, 2022/06/27
- [elpa] externals/denote 5195f13f55 197/355: Add optional absolute for denote--directory-files, ELPA Syncer, 2022/06/27
- [elpa] externals/denote a160d9f147 196/355: Fix typo in the manual, ELPA Syncer, 2022/06/27
- [elpa] externals/denote 3654f902e6 210/355: Accept optional group in denote-retrieve--search, ELPA Syncer, 2022/06/27
- [elpa] externals/denote aab21a74dd 194/355: Register 'denote:' custom Org hyperlink type, ELPA Syncer, 2022/06/27
- [elpa] externals/denote 4dc46d1b68 185/355: Set denote-link-fontify-backlinks to t by default, ELPA Syncer, 2022/06/27
- [elpa] externals/denote d5b62c4e58 220/355: Add denote-date command (notes for past date), ELPA Syncer, 2022/06/27
- [elpa] externals/denote f193199c88 228/355: Insert generic format links with prefix argument,
ELPA Syncer <=
- [elpa] externals/denote e1c45e25f4 219/355: Optionally no current in files in dir regexp match, ELPA Syncer, 2022/06/27
- [elpa] externals/denote a1d315ff84 237/355: Reword statement about metanotes, ELPA Syncer, 2022/06/27
- [elpa] externals/denote 1ba3ccc7d0 291/355: Add missing conditionality from commit 7074b25, ELPA Syncer, 2022/06/27
- [elpa] externals/denote cea51a8a11 242/355: Add section with Frequently Asked Questions, ELPA Syncer, 2022/06/27
- [elpa] externals/denote a785de6760 244/355: Make sure minibuffer can be resized while renaming, ELPA Syncer, 2022/06/27
- [elpa] externals/denote 6a0cb450c6 303/355: Add section referencing alternative blog posts, ELPA Syncer, 2022/06/27
- [elpa] externals/denote f03d75a72b 268/355: Document tasks/ideas to do/explore, ELPA Syncer, 2022/06/27
- [elpa] externals/denote 995ef56415 247/355: Improve check in denote-dired--edit-front-matter-p, ELPA Syncer, 2022/06/27
- [elpa] externals/denote 34d11cea33 243/355: Include 'denote-retrieve' in sample configuration, ELPA Syncer, 2022/06/27
- [elpa] externals/denote ecaaa6bb63 259/355: Only consider items with id in directory files, ELPA Syncer, 2022/06/27