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

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

[elpa] externals/denote ee22a7f380 038/355: Add helper function for line


From: ELPA Syncer
Subject: [elpa] externals/denote ee22a7f380 038/355: Add helper function for line predicates
Date: Sun, 26 Jun 2022 23:57:57 -0400 (EDT)

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

    Add helper function for line predicates
---
 denote.el | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/denote.el b/denote.el
index 71ddc9486d..99059e7626 100644
--- a/denote.el
+++ b/denote.el
@@ -143,6 +143,29 @@ trailing hyphen."
   "Return non-nil if FILE is empty."
   (zerop (or (file-attribute-size (file-attributes file)) 0)))
 
+(defvar denote--line-regexp-alist
+  '((empty . "[\s\t]*$")
+    (indent . "^[\s\t]+")
+    (non-empty . "^.+$")
+    (list . "^\\([\s\t#*+]+\\|[0-9]+[^\s]?[).]+\\)")
+    (heading . "^\\*+ +"))              ; assumes Org markup
+  "Alist of regexp types used by `denote-line-regexp-p'.")
+
+(defun denote--line-regexp-p (type &optional n)
+  "Test for TYPE on line.
+TYPE is the car of a cons cell in
+`denote--line-regexp-alist'.  It matches a regular
+expression.
+
+With optional N, search in the Nth line from point."
+  (save-excursion
+    (goto-char (point-at-bol))
+    (and (not (bobp))
+         (or (beginning-of-line n) t)
+         (save-match-data
+           (looking-at
+            (alist-get type denote--line-regexp-alist))))))
+
 ;;;; Keywords
 
 (defun denote--directory-files ()



reply via email to

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