[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] scratch/org-contacts-rebased 03dc64d 110/118: Change how completi
From: |
Stefan Monnier |
Subject: |
[elpa] scratch/org-contacts-rebased 03dc64d 110/118: Change how completion is done |
Date: |
Fri, 12 Nov 2021 15:37:14 -0500 (EST) |
branch: scratch/org-contacts-rebased
commit 03dc64db77636df585cf0ffd65861a8be562308b
Author: Morgan Smith <Morgan.J.Smith@outlook.com>
Commit: Stefan Monnier <monnier@iro.umontreal.ca>
Change how completion is done
---
org-contacts.el | 51 +++++++++++++++++++++++----------------------------
1 file changed, 23 insertions(+), 28 deletions(-)
diff --git a/org-contacts.el b/org-contacts.el
index 4c34cdd..cb7a0ae 100644
--- a/org-contacts.el
+++ b/org-contacts.el
@@ -500,7 +500,7 @@ prefixes rather than just the beginning of the string."
((cycle-sort-function . org-contacts-display-sort-function)
(display-sort-function . org-contacts-display-sort-function))))
-(defun org-contacts-complete-group (start end string)
+(defun org-contacts-complete-group (string)
"Complete text at START from a group.
A group FOO is composed of contacts with the tag FOO."
@@ -518,12 +518,11 @@ A group FOO is composed of contacts with the tag FOO."
(cl-loop for contact in (org-contacts-filter)
nconc (org-split-string
(or (cdr (assoc-string "ALLTAGS" (caddr
contact))) "") ":")))))))
- (list start end
+
(if (= (length completion-list) 1)
;; We've found the correct group, returns the address
(let ((tag (get-text-property 0 'org-contacts-group
(car completion-list))))
- (lambda (string pred &optional to-ignore)
(mapconcat 'identity
(cl-loop for contact in (org-contacts-filter
nil
@@ -540,12 +539,12 @@ A group FOO is composed of contacts with the tag FOO."
""))) ""))
;; If the user has an email address,
append USER <EMAIL>.
if email collect
(org-contacts-format-email contact-name email))
- ", ")))
+ ", "))
;; We haven't found the correct group
(completion-table-case-fold completion-list
- (not
org-contacts-completion-ignore-case))))))))
+ (not
org-contacts-completion-ignore-case)))))))
-(defun org-contacts-complete-tags-props (start end string)
+(defun org-contacts-complete-tags-props (string)
"Insert emails that match the tags expression.
For example: FOO-BAR will match entries tagged with FOO but not
@@ -578,11 +577,8 @@ description."
(eval (cdr (org-make-tags-matcher (cl-subseq
string 1))))))
collect (org-contacts-format-email contact-name email))
",")))
- (when (not (string= "" result))
- ;; return (start end function)
- (let* ((to-return result))
- (list start end
- (lambda (string pred &optional to-ignore) to-return))))))))
+ (when (not (string= "" result))
+ result)))))
(defun org-contacts-remove-ignored-property-values (ignore-list list)
"Remove all ignore-list's elements from list and you can use
@@ -593,7 +589,7 @@ description."
ignore-list))
list))
-(defun org-contacts-complete-name (start end string)
+(defun org-contacts-complete-name (string)
"Complete text at START with a user name and email."
(let* ((completion-ignore-case org-contacts-completion-ignore-case)
(completion-list
@@ -622,27 +618,26 @@ description."
string
(org-uniquify completion-list))))
(when completion-list
- (list start end
- (org-contacts-make-collection-prefix completion-list)))))
+ (org-contacts-make-collection-prefix completion-list))))
-(defun org-contacts-message-complete-function (&optional start)
+(defun org-contacts-message-complete-function ()
"Function used in `completion-at-point-functions' in `message-mode'."
- ;; Avoid to complete in `post-command-hook'.
- (when completion-in-region-mode
- (remove-hook 'post-command-hook #'completion-in-region--postch))
(let ((mail-abbrev-mode-regexp
"^\\(Resent-To\\|To\\|B?Cc\\|Reply-To\\|From\\|Mail-Followup-To\\|Mail-Copies-To\\|Disposition-Notification-To\\|Return-Receipt-To\\):"))
(when (mail-abbrev-in-expansion-header-p)
- (let*
- ((end (point))
- (start (or start
- (save-excursion
- (re-search-backward "\\(\\`\\|[\n:,]\\)[ \t]*")
- (goto-char (match-end 0))
- (point))))
- (string (buffer-substring start end)))
- (run-hook-with-args-until-success
- 'org-contacts-complete-functions start end string)))))
+ (let
+ ((beg
+ (save-excursion
+ (re-search-backward "\\(\\`\\|[\n:,]\\)[ \t]*")
+ (goto-char (match-end 0))
+ (point)))
+ (end (point)))
+ (list beg
+ end
+ (completion-table-dynamic
+ (lambda (string)
+ (run-hook-with-args-until-success
+ 'org-contacts-complete-functions string))))))))
(defun org-contacts-gnus-get-name-email ()
"Get name and email address from Gnus message."
- [elpa] scratch/org-contacts-rebased 3b371ff 080/118: org-contacts.el: Catch `nextfile' in `org-contacts-db', (continued)
- [elpa] scratch/org-contacts-rebased 3b371ff 080/118: org-contacts.el: Catch `nextfile' in `org-contacts-db', Stefan Monnier, 2021/11/12
- [elpa] scratch/org-contacts-rebased cfa1db0 081/118: Remove some home-grown copies of cl-lib functions., Stefan Monnier, 2021/11/12
- [elpa] scratch/org-contacts-rebased ee973b2 087/118: Deprecate `org-find-if' in favor of `cl-find-if', Stefan Monnier, 2021/11/12
- [elpa] scratch/org-contacts-rebased 204548b 092/118: Fix function declarations, Stefan Monnier, 2021/11/12
- [elpa] scratch/org-contacts-rebased 79d7a88 096/118: org-contacts.el: Add support for org-id generated link., Stefan Monnier, 2021/11/12
- [elpa] scratch/org-contacts-rebased a603ab3 099/118: org-contacts.el: replace obsolete alias `loop' with `cl-loop', Stefan Monnier, 2021/11/12
- [elpa] scratch/org-contacts-rebased 38f7b80 100/118: org-contacts.el: Only use org-id-store-link if org-id is loaded, Stefan Monnier, 2021/11/12
- [elpa] scratch/org-contacts-rebased 3d068b7 104/118: org-contacts.el: Display contacts buffer result., Stefan Monnier, 2021/11/12
- [elpa] scratch/org-contacts-rebased fd660ce 111/118: Tidy up whitespace, Stefan Monnier, 2021/11/12
- [elpa] scratch/org-contacts-rebased 7b87e73 106/118: Prefer HTTPS to HTTP in most links, Stefan Monnier, 2021/11/12
- [elpa] scratch/org-contacts-rebased 03dc64d 110/118: Change how completion is done,
Stefan Monnier <=
- [elpa] scratch/org-contacts-rebased 18ba907 114/118: Try to support different type of AVATAR property., Stefan Monnier, 2021/11/12
- [elpa] scratch/org-contacts-rebased 45bc95a 083/118: org-contacts: Fix org-contacts-matcher for BIRTHDAYs, Stefan Monnier, 2021/11/12
- [elpa] scratch/org-contacts-rebased 49dd482 089/118: Use `string-match-p' instead of `org-string-match-p', Stefan Monnier, 2021/11/12
- [elpa] scratch/org-contacts-rebased 124cc7a 098/118: org-contacts.el: Add usage comments, Stefan Monnier, 2021/11/12
- [elpa] scratch/org-contacts-rebased b2837af 109/118: simplify logic, remove unused variables, switch to lexical binding, Stefan Monnier, 2021/11/12
- [elpa] scratch/org-contacts-rebased 5174678 116/118: Fix AVATAR property value not exist problem, Stefan Monnier, 2021/11/12
- [elpa] scratch/org-contacts-rebased 1be8aa9 069/118: Merge branch 'maint', Stefan Monnier, 2021/11/12
- [elpa] scratch/org-contacts-rebased 9c233be 070/118: Revert "Update copyright years.", Stefan Monnier, 2021/11/12
- [elpa] scratch/org-contacts-rebased fc25530 074/118: contrib/lisp/org-contacts.el: Add a hook to allow users to plug completion functions, Stefan Monnier, 2021/11/12
- [elpa] scratch/org-contacts-rebased d3509e4 076/118: contrib/lisp/org-contacts.el: Complete contacts using tags and properties, Stefan Monnier, 2021/11/12