[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/denote 3ea15caf42 1/4: Define denote-get-identifier-at-
From: |
ELPA Syncer |
Subject: |
[elpa] externals/denote 3ea15caf42 1/4: Define denote-get-identifier-at-point function |
Date: |
Wed, 31 Jul 2024 12:57:57 -0400 (EDT) |
branch: externals/denote
commit 3ea15caf42e8f5d17475e87dc41ab894753acea7
Author: Protesilaos Stavrou <info@protesilaos.com>
Commit: Protesilaos Stavrou <info@protesilaos.com>
Define denote-get-identifier-at-point function
I am implementing this in response to a question by Alan Schmitt in
issue 400: <https://github.com/protesilaos/denote/issues/400>.
---
README.org | 4 ++++
denote.el | 11 +++++++++--
2 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/README.org b/README.org
index 23d9330fb0..0d31076686 100644
--- a/README.org
+++ b/README.org
@@ -4682,6 +4682,10 @@ might change them without further notice.
+ Function ~denote-get-path-by-id~ :: Return absolute path of =ID=
string in ~denote-directory-files~.
+#+findex: denote-get-identifier-at-point
++ Function ~denote-get-identifier-at-point~ :: Return the identifier
+ at point or =POINT=. [ Part of {{{development-version}}}. ]
+
#+findex: denote-barf-duplicate-id
+ Function ~denote-barf-duplicate-id~ :: Throw a ~user-error~ if
=IDENTIFIER= already exists.
diff --git a/denote.el b/denote.el
index 495690dfa3..51212e442f 100644
--- a/denote.el
+++ b/denote.el
@@ -4218,8 +4218,15 @@ Implementation based on the function
`org-activate-links'."
(throw :exit t)))))) ; signal success
nil))
-(defun denote--get-link-file-path-at-point ()
- "Return link to the Denote file path at point.
+(defun denote-get-identifier-at-point (&optional point)
+ "Return the Denote identifier at point or optional POINT."
+ (when-let ((position (or point (point)))
+ (_ (eq (get-text-property position 'face) 'denote-faces-link)))
+ (or (get-text-property position 'denote-link-id)
+ (let ((property (get-text-property position 'help-echo)))
+ (string-match denote-id-regexp property)
+ (match-string-no-properties 0 property)))))
+
(defun denote--get-link-file-path-at-point (&optional point)
"Return link to the Denote file path at point or optional POINT.
To be used as a `thing-at' provider."