From bbee0d8e36149d703eee0cfeb9583affa3f0b677 Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Mon, 30 Oct 2023 15:57:35 +1100 Subject: Add some checks to avoid accidental unsubscribing from a list. --- traclicker.el | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/traclicker.el b/traclicker.el index 40884a0..2cb5f58 100644 --- a/traclicker.el +++ b/traclicker.el @@ -59,6 +59,14 @@ Will scan from both cur and new subdirs." (defvar tracli-data nil "Data read from and written to `tracli-db-file'.") +(defcustom tracli-exclude-url-pattern + "\\<\\([uU]nsubscribe\\|opt.?out\\)\\>" + "URL pattern to exclude from collection. + +For example to avoid accidental unsubscription." + :type 'regexp + :group 'traclicker) + (defun tracli-read-data () "Read data from `tracli-db-file'." (when (file-exists-p tracli-db-file) @@ -136,10 +144,12 @@ Sends a HEAD request." (save-excursion (let ((results)) (while (re-search-forward org-link-plain-re nil t) - (let ((scheme (match-string 1)) - (url (match-string 0))) + (let ((scheme (match-string-no-properties 1)) + (url (match-string-no-properties 0))) (when (and (member scheme '("http" "https")) - (not (member url results))) + (not (member url results)) + (not (string-match-p tracli-exclude-url-pattern url)) + (not (gethash url (alist-get 'urls tracli-data)))) (push url results)))) (reverse results)))) -- cgit v1.2.3