Generalise dired fontification

There is no need to limit it to the denote-directory.  We ultimately
want to fontify all Denote-style file names, not just the notes created
by Denote.

For example, I have been recording all my longer-term storage using such
a naming scheme: this mode gives me the extra faces for .pdf, .mp3, and
other files.

Users of Denote may want this for attachments.

The upside of having this as a buffer-local mode is that the user can
write a wrapper function that applies the mode only in a given
directory (like we were doing before).

Thanks to Ypot for suggesting a kernel of this idea in issue 1 over at
the GitHub mirror: <https://github.com/protesilaos/denote/issues/1>.
This commit is contained in:
Protesilaos Stavrou 2022-06-08 10:38:51 +03:00
parent 3209bc23ef
commit 431124fea1
No known key found for this signature in database
GPG key ID: 99BD6459CD5CA3EA
3 changed files with 6 additions and 10 deletions

View file

@ -370,7 +370,7 @@ Denote is meant to be a collective effort. Every bit of help matters.
+ Author/maintainer :: Protesilaos Stavrou.
+ Ideas and/or user feedback :: Kaushal Modi.
+ Ideas and/or user feedback :: Kaushal Modi, Ypot.
* GNU Free Documentation License
:PROPERTIES:

View file

@ -88,18 +88,14 @@
(defun denote-dired--setup (&optional reverse)
"Setup `denote-dired--fontify' local hook.
If optional REVERSE is non-nil, remove the hook."
(cond
(reverse
(setq dired-font-lock-keywords denote-dired-original-keywords))
((or (string-match-p (denote--directory) default-directory)
(string-match-p (abbreviate-file-name denote-directory) default-directory)
(string-match-p denote-directory default-directory))
(denote-dired--fontify)))
(if reverse
(setq dired-font-lock-keywords denote-dired-original-keywords)
(denote-dired--fontify))
(font-lock-refresh-defaults))
;;;###autoload
(define-minor-mode denote-dired-mode
"Integrate denote with Dired."
"Fontify all Denote-style file names in Dired."
:global nil
:group 'denote-dired
(if denote-dired-mode

View file

@ -112,7 +112,7 @@ specifiers."
"Regular expression to match `denote-keywords'.")
(defconst denote--file-regexp
(concat denote--id-regexp denote--keyword-regexp "\\(.*\\)\\.org")
(concat denote--id-regexp denote--keyword-regexp "\\(.*\\)\\..*")
"Regular expression to match file names from `denote-new-note'.")
(defconst denote--punctuation-regexp "[][{}!@#$%^&*()_=+'\"?,.\|;:~`‘’“”]*"