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

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

[elpa] externals/denote 5cfc1d1be5 1/3: Add denote-faces-broken-link (on


From: ELPA Syncer
Subject: [elpa] externals/denote 5cfc1d1be5 1/3: Add denote-faces-broken-link (only works with Org)
Date: Thu, 4 Aug 2022 22:57:27 -0400 (EDT)

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

    Add denote-faces-broken-link (only works with Org)
---
 README.org | 17 +++++++++++++----
 denote.el  | 16 +++++++++++++++-
 2 files changed, 28 insertions(+), 5 deletions(-)

diff --git a/README.org b/README.org
index 69b4b13515..dbfa1f128d 100644
--- a/README.org
+++ b/README.org
@@ -796,11 +796,20 @@ case the user needs it.
 Links are created only for files which qualify as a "note" for our
 purposes ([[#h:fc913d54-26c8-4c41-be86-999839e8ad31][Linking notes]]).
 
+[ The following two faces are part of {{{development-version}}} ]
+
 #+vindex: denote-faces-link
-Links are styled with the ~denote-faces-link~ face [part of
-{{{development-version}}}], which looks exactly like an ordinary link by
-default.  This is just a convenience for the user/theme in case they
-want =denote:= links to remain distinct from other links.
+Links are styled with the ~denote-faces-link~ face, which looks exactly
+like an ordinary link by default.  This is just a convenience for the
+user/theme in case they want =denote:= links to remain distinct from
+other links.
+
+#+vindex: denote-faces-broken-link
+In Org files, broken links get the ~denote-faces-broken-link~ if the
+linked identifier does not resolve to a file path with a note.  The
+ability to use distinct faces for such a scenario is a feature of Org,
+which is not available in other supported file types that use Emacs'
+generic button mechanism.
 
 ** Insert links matching a regexp
 :PROPERTIES:
diff --git a/denote.el b/denote.el
index c37f722591..47414a2cc0 100644
--- a/denote.el
+++ b/denote.el
@@ -1387,6 +1387,12 @@ The operation does the following:
   "Face used to style Denote links in the buffer."
   :group 'denote-faces)
 
+(defface denote-faces-broken-link '((t :inherit (error link)))
+  "Face used to style Denote broken links in the buffer.
+This only works in Org files, as Emacs' generic buttons do not
+provide a facility that uses a face based on certain conditions."
+  :group 'denote-faces)
+
 (defface denote-faces-subdirectory
   '((t :inherit bold))
   "Face for subdirectory of file name.
@@ -1937,6 +1943,14 @@ file."
    (denote-link--ol-resolve-link-to-target link)
    nil))
 
+(defun denote-link-ol-face (link)
+  "Return appropriate face for LINK.
+If the LINK resolves to a note, use `denote-faces-link', else
+return `denote-faces-broken-link'."
+  (if (denote-link--ol-resolve-link-to-target link)
+      'denote-faces-link
+    'denote-faces-broken-link))
+
 (defun denote-link-ol-complete ()
   "Like `denote-link' but for Org integration.
 This lets the user complete a link through the `org-insert-link'
@@ -1976,7 +1990,7 @@ backend."
           (org-link-set-parameters
            "denote"
            :follow #'denote-link-ol-follow
-           :face 'denote-faces-link
+           :face #'denote-link-ol-face
            :complete #'denote-link-ol-complete
            :export #'denote-link-ol-export)))))
 



reply via email to

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