[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master cae0056769 08/10: Allow filtering what items are added to Ecomple
From: |
Philip Kaludercic |
Subject: |
master cae0056769 08/10: Allow filtering what items are added to Ecomplete |
Date: |
Fri, 14 Oct 2022 12:30:37 -0400 (EDT) |
branch: master
commit cae00567690033308ff06b5d09629e55813c52dd
Author: Philip Kaludercic <philipk@posteo.net>
Commit: Philip Kaludercic <philipk@posteo.net>
Allow filtering what items are added to Ecomplete
* etc/NEWS: Mention new option.
* lisp/ecomplete.el (ecomplete-filter-regexp): Add new option.
(ecomplete-add-item): Respect new option. (bug#58487)
---
etc/NEWS | 5 +++++
lisp/ecomplete.el | 35 +++++++++++++++++++++--------------
2 files changed, 26 insertions(+), 14 deletions(-)
diff --git a/etc/NEWS b/etc/NEWS
index 464cb2719f..dcbf3a6aa3 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -1376,6 +1376,11 @@ the ecomplete database.
*** New user option 'ecomplete-auto-select'.
If non-nil and there's only one matching option, auto-select that.
+---
+*** New user option 'ecomplete-filter-regexp'.
+If non-nil this user option describes what email addresses to ignore
+and not add to the database.
+
** Dired
+++
diff --git a/lisp/ecomplete.el b/lisp/ecomplete.el
index 6ff67d46d2..21f5f456ea 100644
--- a/lisp/ecomplete.el
+++ b/lisp/ecomplete.el
@@ -86,6 +86,11 @@ string that was matched."
:type 'boolean
:version "29.1")
+(defcustom ecomplete-filter-regexp nil
+ "Regular expression of addresses to not store."
+ :type 'regexp
+ :version "29.1")
+
;;; Internal variables.
(defvar ecomplete-database nil)
@@ -104,20 +109,22 @@ string that was matched."
By default, the longest version of TEXT will be preserved, but if
FORCE is non-nil, use TEXT exactly as is."
(unless ecomplete-database (ecomplete-setup))
- (let ((elems (assq type ecomplete-database))
- (now (time-convert nil 'integer))
- entry)
- (unless elems
- (push (setq elems (list type)) ecomplete-database))
- (if (setq entry (assoc key (cdr elems)))
- (pcase-let ((`(,_key ,count ,_time ,oldtext) entry))
- (setcdr entry (list (1+ count) now
- ;; Preserve the "more complete" text.
- (if (or force
- (>= (length text) (length oldtext)))
- text
- oldtext))))
- (nconc elems (list (list key 1 now text))))))
+ (unless (and ecomplete-filter-regexp
+ (string-match-p ecomplete-filter-regexp key))
+ (let ((elems (assq type ecomplete-database))
+ (now (time-convert nil 'integer))
+ entry)
+ (unless elems
+ (push (setq elems (list type)) ecomplete-database))
+ (if (setq entry (assoc key (cdr elems)))
+ (pcase-let ((`(,_key ,count ,_time ,oldtext) entry))
+ (setcdr entry (list (1+ count) now
+ ;; Preserve the "more complete" text.
+ (if (or force
+ (>= (length text) (length oldtext)))
+ text
+ oldtext))))
+ (nconc elems (list (list key 1 now text)))))))
(defun ecomplete--remove-item (type key)
"Remove the element of TYPE and KEY from the ecomplete database."
- master updated (b175a9fb7e -> 51fc195d39), Philip Kaludercic, 2022/10/14
- master db69681759 06/10: * lisp/net/rcirc.el (rcirc-generate-log-filename): Append ".log", Philip Kaludercic, 2022/10/14
- master cae0056769 08/10: Allow filtering what items are added to Ecomplete,
Philip Kaludercic <=
- master ff0fe62002 02/10: Mention that vc-prepare-patch can interact with a log-view, Philip Kaludercic, 2022/10/14
- master 8fc5148429 09/10: * lisp/net/rcirc.el (rcirc-bridged-nick): Inherit from highlight, Philip Kaludercic, 2022/10/14
- master be1afa047f 01/10: * lisp/play/zone.el (zone): Allow selecting a program, Philip Kaludercic, 2022/10/14
- master 000cd5f9f6 05/10: ; * lisp/vc/vc.el (vc-default-prepare-patch): Add missing argument, Philip Kaludercic, 2022/10/14
- master 60f46b45d9 04/10: Prepare all inline patches at once, Philip Kaludercic, 2022/10/14
- master 6539eb0588 07/10: Prevent .dir-locals.el from being byte-compiled, Philip Kaludercic, 2022/10/14
- master 51fc195d39 10/10: Add a quick-help menu, Philip Kaludercic, 2022/10/14
- master 5426b4d7bf 03/10: Allow reordering commits in 'vc-prepare-patch' prompt, Philip Kaludercic, 2022/10/14