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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/denote 5889d60efb: Make denote-extract-id-from-string p


From: ELPA Syncer
Subject: [elpa] externals/denote 5889d60efb: Make denote-extract-id-from-string public
Date: Mon, 26 Sep 2022 04:57:27 -0400 (EDT)

branch: externals/denote
commit 5889d60efbbbdd17c174ff09f3f5380dabf389ad
Author: Protesilaos Stavrou <info@protesilaos.com>
Commit: Protesilaos Stavrou <info@protesilaos.com>

    Make denote-extract-id-from-string public
    
    Thanks to Elias Storms for discussing the utility of such a function:
    
<https://lists.sr.ht/~protesilaos/denote/%3CDD9ABAAD-6E45-49AD-A77A-694D87B59754@gmail.com%3E>.
---
 README.org | 14 +++++++++-----
 denote.el  | 22 +++++++++++++---------
 2 files changed, 22 insertions(+), 14 deletions(-)

diff --git a/README.org b/README.org
index 451450633d..d0d617beaa 100644
--- a/README.org
+++ b/README.org
@@ -2286,6 +2286,10 @@ might change them without further notice.
   file name where keywords are prefixed with an underscore.  If =PATH=
   has no such keywords, return nil 
([[#h:4e9c7512-84dc-4dfb-9fa9-e15d51178e5d][The file-naming scheme]]).
 
+#+findex: denote-extract-id-from-string
++ ~denote-extract-id-from-string~ :: Return existing Denote identifier
+  in =STRING=, else nil.
+
 #+findex: denote-retrieve-filename-identifier
 + ~denote-retrieve-filename-identifier~ :: Extract identifier from
   =FILE= name.  To only return an existing identifier or create a new
@@ -2946,11 +2950,11 @@ Denote is meant to be a collective effort.  Every bit 
of help matters.
   Kaludercic, Quiliro Ordóñez, Stefan Monnier.
 
 + Ideas and/or user feedback :: Abin Simon, Alan Schmitt, Alfredo
-  Borrás, Benjamin Kästner, Colin McLear, Damien Cassou, Frank Ehmsen,
-  Hanspeter Gisler, Jack Baty, Juanjo Presa, Kaushal Modi, M. Hadi
-  Timachi, Paul van Gelder, Peter Prevos, Shreyas Ragavan, Summer Emacs,
-  Sven Seebeck, Taoufik, Ypot, atanasj, hpgisler, pRot0ta1p, sienic,
-  sundar bp.
+  Borrás, Benjamin Kästner, Colin McLear, Damien Cassou, Elias Storms,
+  Frank Ehmsen, Hanspeter Gisler, Jack Baty, Juanjo Presa, Kaushal
+  Modi, M. Hadi Timachi, Paul van Gelder, Peter Prevos, Shreyas
+  Ragavan, Summer Emacs, Sven Seebeck, Taoufik, Ypot, atanasj,
+  hpgisler, pRot0ta1p, sienic, sundar bp.
 
 Special thanks to Peter Povinec who helped refine the file-naming
 scheme, which is the cornerstone of this project.
diff --git a/denote.el b/denote.el
index 37a077caa1..c3241b0f60 100644
--- a/denote.el
+++ b/denote.el
@@ -539,6 +539,16 @@ FILE must be an absolute path."
   'denote-get-file-name-relative-to-denote-directory
   "1.0.0")
 
+(defun denote-extract-id-from-string (string)
+  "Return existing Denote identifier in STRING, else nil."
+  (when (string-match denote--id-regexp string)
+    (match-string 0 string)))
+
+(define-obsolete-function-alias
+  'denote-link--id-from-string
+  'denote-extract-id-from-string
+  "1.0.0")
+
 ;; TODO 2022-09-26: Maybe we can consolidate this with
 ;; `denote--dir-in-denote-directory-p'?  Another check for the
 ;; directory prefix is done in `denote-file-is-note-p'.
@@ -2220,9 +2230,9 @@ format is always [[denote:IDENTIFIER]]."
   (interactive)
   (if-let* ((regexp (denote-link--file-type-regexp (buffer-file-name)))
             (files (denote-link--expand-identifiers regexp)))
-      (find-file ; TODO 2022-09-05: Revise for possible refinement
+      (find-file
        (denote-get-path-by-id
-        (denote-link--id-from-string
+        (denote-extract-id-from-string
          (denote-link--find-file-prompt files))))
     (user-error "No links found in the current buffer")))
 
@@ -2302,12 +2312,6 @@ file's title.  This has the same meaning as in 
`denote-link'."
             (thing-at-point-looking-at "\\[\\(denote:.*\\)]"))
     (match-string-no-properties 0)))
 
-(defun denote-link--id-from-string (string)
-  "Extract identifier from STRING."
-  (replace-regexp-in-string
-   (concat ".*denote:" "\\(" denote--id-regexp "\\)" ".*")
-   "\\1" string))
-
 ;; NOTE 2022-06-15: I add this as a variable for advanced users who may
 ;; prefer something else.  If there is demand for it, we can make it a
 ;; defcustom, but I think it would be premature at this stage.
@@ -2316,7 +2320,7 @@ file's title.  This has the same meaning as in 
`denote-link'."
 
 (defun denote-link--find-file-at-button (button)
   "Visit file referenced by BUTTON."
-  (let* ((id (denote-link--id-from-string
+  (let* ((id (denote-extract-id-from-string
               (buffer-substring-no-properties
                (button-start button)
                (button-end button))))



reply via email to

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