diff options
author | Yuchen Pei <id@ypei.org> | 2023-10-30 15:57:35 +1100 |
---|---|---|
committer | Yuchen Pei <id@ypei.org> | 2023-10-30 15:57:35 +1100 |
commit | bbee0d8e36149d703eee0cfeb9583affa3f0b677 (patch) | |
tree | 6bea99f2fe434398d5d55521be4ae120a5bcefc9 | |
parent | 3bb56c9c9087fe29236ec03ac09489f7d01d203b (diff) |
Add some checks to avoid accidental unsubscribing from a list.
-rw-r--r-- | traclicker.el | 16 |
1 files 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)))) |