[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/denote 49a2932d42 189/355: Implement denote-link-add-li
From: |
ELPA Syncer |
Subject: |
[elpa] externals/denote 49a2932d42 189/355: Implement denote-link-add-links |
Date: |
Sun, 26 Jun 2022 23:58:22 -0400 (EDT) |
branch: externals/denote
commit 49a2932d42a53812b6a5a69dd0daa87753a44dd2
Author: Protesilaos Stavrou <info@protesilaos.com>
Commit: Protesilaos Stavrou <info@protesilaos.com>
Implement denote-link-add-links
---
README.org | 38 ++++++++++++++++++++++++++++++++++++++
denote-link.el | 29 +++++++++++++++++++++++++++++
2 files changed, 67 insertions(+)
diff --git a/README.org b/README.org
index cf879c0e3a..054f5fb3aa 100644
--- a/README.org
+++ b/README.org
@@ -597,6 +597,44 @@ By default, the backlinks' buffer is displayed below the
current window.
The doc string of our user option includes a configuration that places
the buffer in a left side window instead.
+#+findex: denote-link-add-links
+The command ~denote-link-add-links~ adds links matching a regular
+expression or plain string. The links are added at point as a
+typographic list, such as:
+
+#+begin_example
+- link1
+- link2
+#+end_example
+
+The current note is excluded from the matching entries (adding a link to
+itself is pointless).
+
+Same examples of a regular expression that can be used with this
+command:
+
+- =journal= match all files which include =journal= anywhere in their
+ name.
+
+- =_journal= match all files which include =journal= as a keyword.
+
+- =^2022.*_journal= match all file names starting with =2022= and
+ including the keyword =journal=.
+
+If files are created with ~denote-sort-keywords~ as non-nil (the
+default), then it is easy to write a regexp that includes multiple
+keywords in alphabetic order:
+
+- =_denote.*_package= match all files that include both the =denote= and
+ =package= keywords, in this order.
+
+- =\(.*denote.*package.*\)\|\(.*package.*denote.*\)= is the same as
+ above, but out-of-order.
+
+Remember that in Emacs regexp input only needs to be quoted once when
+done interactively but twice when called from Lisp. What we show above
+is for interactive usage.
+
** TODO Finalise first version of denote-link.el [2/4]
*** DONE Add generic linking mechanism
*** DONE Flesh out the ~denote-link-backlinks~ prototype
diff --git a/denote-link.el b/denote-link.el
index 1c8e998b3d..c23c6c1fbc 100644
--- a/denote-link.el
+++ b/denote-link.el
@@ -256,5 +256,34 @@ default, it will show up below the current window."
(denote-link--prepare-backlinks id files title)
(user-error "No links to the current note"))))
+(defvar denote-link--links-to-files nil
+ "String of `denote-link-add-links-matching-keyword'.")
+
+(defun denote-link--prepare-links (files ext)
+ "Prepare links to FILES using format of EXT."
+ (setq denote-link--links-to-files
+ (with-temp-buffer
+ (mapc (lambda (f)
+ (insert (concat "- " (denote-link--format-link f ext)))
+ (newline))
+ files)
+ (let ((min (point-min))
+ (max (point-max)))
+ (buffer-substring-no-properties min max)))))
+
+;;;###autoload
+(defun denote-link-add-links (regexp)
+ "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)."
+ (interactive
+ (list (read-regexp "Insert links matching REGEX: ")))
+ (let* ((default-directory (denote-directory))
+ (ext (denote-link--file-type-format (buffer-file-name))))
+ (if-let ((files (denote--directory-files-matching-regexp regexp)))
+ (insert (denote-link--prepare-links files ext))
+ (user-error "No links matching `%s'" regexp))))
+
(provide 'denote-link)
;;; denote-link.el ends here
- [elpa] externals/denote 7cba33e08e 119/355: LAST BREAKING CHANGE to file-naming scheme, (continued)
- [elpa] externals/denote 7cba33e08e 119/355: LAST BREAKING CHANGE to file-naming scheme, ELPA Syncer, 2022/06/26
- [elpa] externals/denote c5a5748594 116/355: Abstract plain text front matter delimiter, ELPA Syncer, 2022/06/26
- [elpa] externals/denote e394057985 134/355: Document how to store multiple types of notes, ELPA Syncer, 2022/06/26
- [elpa] externals/denote d90695213c 151/355: Add minor clarifications in the manual, ELPA Syncer, 2022/06/26
- [elpa] externals/denote ce41b421ef 147/355: Update denote-retrieve symbols in denote-link, ELPA Syncer, 2022/06/26
- [elpa] externals/denote 0e75e46b32 138/355: Improve denote-dired-rename-file, ELPA Syncer, 2022/06/26
- [elpa] externals/denote cdb7f554f2 160/355: Remove extra parenthesis from sample configuration, ELPA Syncer, 2022/06/26
- [elpa] externals/denote 88e64be2cb 176/355: Fix plain text link format, ELPA Syncer, 2022/06/26
- [elpa] externals/denote 7fab21926d 183/355: Process 'find' output in denote-retrieve, ELPA Syncer, 2022/06/26
- [elpa] externals/denote ecc7922a77 169/355: BREAKING remove support for hardcoded backlinks, ELPA Syncer, 2022/06/26
- [elpa] externals/denote 49a2932d42 189/355: Implement denote-link-add-links,
ELPA Syncer <=
- [elpa] externals/denote a7a0bf0255 207/355: Tweak doc string, ELPA Syncer, 2022/06/26
- [elpa] externals/denote 2338ee4698 181/355: Refine how identifier is retrieved from file names, ELPA Syncer, 2022/06/26
- [elpa] externals/denote 1a124c2be6 204/355: Make 'denote:' link follow links like 'file:', ELPA Syncer, 2022/06/26
- [elpa] externals/denote a76b7fb0b8 193/355: Make plain text links the same as Org's, ELPA Syncer, 2022/06/26
- [elpa] externals/denote 683180bcfc 206/355: Remove superfluous function and var, ELPA Syncer, 2022/06/26
- [elpa] externals/denote 2e56f06381 201/355: Install aliases for certain commands, ELPA Syncer, 2022/06/26
- [elpa] externals/denote f8b2d44508 203/355: Depend on Emacs 27.2, not 27.1, ELPA Syncer, 2022/06/26
- [elpa] externals/denote a0525a0154 216/355: Do not try front matter rewrite on non-notes, ELPA Syncer, 2022/06/26
- [elpa] externals/denote 74962d17f2 217/355: Improve denote-retrieve error handling, ELPA Syncer, 2022/06/26
- [elpa] externals/denote 5228b1bb17 231/355: Sort 'denote-link-add-links' contents, ELPA Syncer, 2022/06/26