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

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

[elpa] externals/ebdb a02c02d: Add new option ebdb-completion-ignore-cas


From: Eric Abrahamsen
Subject: [elpa] externals/ebdb a02c02d: Add new option ebdb-completion-ignore-case
Date: Sat, 5 Dec 2020 19:10:41 -0500 (EST)

branch: externals/ebdb
commit a02c02d04d7ac2f242bd7c38b9ccb5428bdf35e1
Author: Eric Abrahamsen <eric@ericabrahamsen.net>
Commit: Eric Abrahamsen <eric@ericabrahamsen.net>

    Add new option ebdb-completion-ignore-case
    
    * ebdb.el (ebdb-completion-ignore-case): Used as value of
    `completion-ignore-case' where appropriate.
    (ebdb-read): :around method influencing all field read operations.
    (ebdb-read-string): Use here.
    * ebdb-com.el (ebdb-completing-read-record,
    ebdb-completing-read-mails): Use in these places, too.
---
 ebdb-com.el | 10 ++++++----
 ebdb.el     | 33 +++++++++++++++++++++++----------
 2 files changed, 29 insertions(+), 14 deletions(-)

diff --git a/ebdb-com.el b/ebdb-com.el
index 657c192..636cb5f 100644
--- a/ebdb-com.el
+++ b/ebdb-com.el
@@ -2620,8 +2620,9 @@ Obey `ebdb-completion-list'."
   "Read and return a record from the EBDB.
 PROMPT is used in `completing-read'.  Actual completion is done
 using the function `ebdb-record-completion-table'."
-  (let ((string (completing-read
-                prompt #'ebdb-record-completion-table nil t)))
+  (let* ((completion-ignore-case ebdb-completion-ignore-case)
+        (string (completing-read
+                 prompt #'ebdb-record-completion-table nil t)))
     (unless (string-empty-p string)
       (or (car-safe (ebdb-gethash string '(name alt-names mail)))
          (message "No matching records for \"%s\"" string)))))
@@ -2629,8 +2630,9 @@ using the function `ebdb-record-completion-table'."
 ;;;###autoload
 (defun ebdb-completing-read-mails (prompt &optional init)
   "Like `read-string', but with `ebdb-complete-mail' completion."
-  (read-from-minibuffer prompt init
-                        ebdb-completing-read-mails-map))
+  (let ((completion-ignore-case ebdb-completion-ignore-case))
+    (read-from-minibuffer prompt init
+                          ebdb-completing-read-mails-map)))
 
 (defconst ebdb-quoted-string-syntax-table
   (let ((st (make-syntax-table)))
diff --git a/ebdb.el b/ebdb.el
index ff087ea..d9ad344 100644
--- a/ebdb.el
+++ b/ebdb.el
@@ -613,6 +613,13 @@ For fields lacking an entry here `ebdb-default-separator' 
is used instead."
   :group 'ebdb-record-edit
   :type '(repeat (list symbol regexp string)))
 
+(defcustom ebdb-completion-ignore-case t
+  "EBDB-specific value of `completion-ignore-case'.
+This has an effect when entering field data with completion, for
+instance anniversary months or address countries."
+  :group 'ebdb-record-edit
+  :type 'boolean)
+
 (defcustom ebdb-image-path nil
   "List of directories to search for `ebdb-image'."
   :group 'ebdb-record-edit
@@ -1127,6 +1134,11 @@ old field.  By now we've sucked all the useful 
information out of
 it, and if this process is successful it will get deleted."
   (apply 'make-instance class slots))
 
+(cl-defmethod ebdb-read :around ((cls (subclass ebdb-field))
+                                &optional _slots _obj)
+  (let ((completion-ignore-case ebdb-completion-ignore-case))
+    (cl-call-next-method)))
+
 ;; Pretty much everything in here should implement an `ebdb-string'
 ;; method.
 (cl-defgeneric ebdb-string (obj)
@@ -4774,17 +4786,18 @@ same meaning as in `completing-read'."
        ;; Hack: In `minibuffer-local-completion-map' remove
        ;; the binding of SPC to `minibuffer-complete-word'
        ;; and of ? to `minibuffer-completion-help'.
-       (minibuffer-with-setup-hook
-           (lambda ()
-             (use-local-map
-              (let ((map (make-sparse-keymap)))
-                (set-keymap-parent map (current-local-map))
-                (define-key map " " nil)
-                (define-key map "?" nil)
-                map)))
-         (completing-read prompt collection nil require-match init))
+       (let ((completion-ignore-case ebdb-completion-ignore-case))
+        (minibuffer-with-setup-hook
+             (lambda ()
+               (use-local-map
+               (let ((map (make-sparse-keymap)))
+                  (set-keymap-parent map (current-local-map))
+                  (define-key map " " nil)
+                  (define-key map "?" nil)
+                  map)))
+           (completing-read prompt collection nil require-match init)))
      (let ((string (read-string prompt init)))
-       (if (string-empty-p string)
+       (if (string-blank-p string)
           (signal 'ebdb-empty (list prompt))
         string)))))
 



reply via email to

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