[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/org-contacts f3fa9fc0b8 125/154: use less magic symbol
From: |
ELPA Syncer |
Subject: |
[elpa] externals/org-contacts f3fa9fc0b8 125/154: use less magic symbol extract code |
Date: |
Fri, 9 Sep 2022 15:58:54 -0400 (EDT) |
branch: externals/org-contacts
commit f3fa9fc0b83b0ad3cd42cd73751e95950c49fe38
Author: stardiviner <numbchild@gmail.com>
Commit: stardiviner <numbchild@gmail.com>
use less magic symbol extract code
> #+begin_src emacs-lisp
> (defun org-contacts-org-complete-function ()
> "Function used in `completion-at-point-functions' in `org-mode' to
complete @name."
> (when-let* ((bounds (bounds-of-thing-at-point 'symbol))
> (begin (1- (car bounds)))
> (end (cdr bounds))
> (symbol (buffer-substring-no-properties begin end))
> (org-contacts-prefix-p (string-prefix-p "@" symbol))
> ;; (prefix (substring-no-properties symbol 1 nil))
> )
> (when org-contacts-prefix-p
> (list begin
> end
> (completion-table-dynamic
> (lambda (_)
> (mapcar
> (lambda (contact) (plist-get contact :name))
> (org-contacts--all-contacts))))))))
> #+end_src
This gives a `begin..end` region which presumably includes `@`.
Does (plist-get contact :name) return names that start with `@`?
If not, the completion will never match.
> And test with execute following ~add-hook~ in org-mode buffer or
> emacs-lisp-mode buffer:
In emacs-lisp-mode, `@` has symbol syntax, so
(bounds-of-thing-at-point 'symbol)
will include `@` in the returned region, whereas in Org mode
`@` seems to have punctuation syntax so the `@` will not be included in
the returned region.
Maybe instead of `bounds-of-thing-at-point` you want to use something
less "magic", like (skip-chars-backward "[:alnum:]@").
---
org-contacts.el | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/org-contacts.el b/org-contacts.el
index ec26017323..55054bdad6 100644
--- a/org-contacts.el
+++ b/org-contacts.el
@@ -677,9 +677,8 @@ description."
(defun org-contacts-org-complete-function ()
"Function used in `completion-at-point-functions' in `org-mode' to complete
@name."
- (when-let* ((bounds (bounds-of-thing-at-point 'symbol))
- (begin (1- (car bounds)))
- (end (cdr bounds))
+ (when-let* ((end (point))
+ (begin (save-excursion (skip-chars-backward "[:alnum:]@")
(point)))
(symbol (buffer-substring-no-properties begin end))
(org-contacts-prefix-p (string-prefix-p "@" symbol))
;; (prefix (substring-no-properties symbol 1 nil))
- [elpa] externals/org-contacts 81d9ed977d 138/154: Ensure font-lock after org-mode in company-mode doc-buffer, (continued)
- [elpa] externals/org-contacts 81d9ed977d 138/154: Ensure font-lock after org-mode in company-mode doc-buffer, ELPA Syncer, 2022/09/09
- [elpa] externals/org-contacts 8f008e1b70 131/154: Fix company-mode doc-buffer support with reverse query contact element in all contacts list., ELPA Syncer, 2022/09/09
- [elpa] externals/org-contacts c8408cf44e 118/154: replace gnus-rescale-image with create-image property :height, ELPA Syncer, 2022/09/09
- [elpa] externals/org-contacts 5d0ecac118 143/154: Update package description., ELPA Syncer, 2022/09/09
- [elpa] externals/org-contacts 8078958995 082/154: contrib: Fix error messages., ELPA Syncer, 2022/09/09
- [elpa] externals/org-contacts 60339bd55f 087/154: Make `org-make-tags-matcher' lexical binding friendly, ELPA Syncer, 2022/09/09
- [elpa] externals/org-contacts 74019274c0 110/154: Update copyright years, ELPA Syncer, 2022/09/09
- [elpa] externals/org-contacts 0af8ca84b4 107/154: org-contacts.el: Display contacts buffer result., ELPA Syncer, 2022/09/09
- [elpa] externals/org-contacts 74edb70b13 078/154: contrib/lisp/org-contacts.el: Factorize the construction of the database, ELPA Syncer, 2022/09/09
- [elpa] externals/org-contacts 46726d2637 112/154: Don't use deprecated functions, ELPA Syncer, 2022/09/09
- [elpa] externals/org-contacts f3fa9fc0b8 125/154: use less magic symbol extract code,
ELPA Syncer <=
- [elpa] externals/org-contacts 8a074f2a41 133/154: company-mode doc-buffer return customized buffer which support customization, ELPA Syncer, 2022/09/09
- [elpa] externals/org-contacts aaf9ce8bd0 128/154: Add capf completion properties, ELPA Syncer, 2022/09/09
- [elpa] externals/org-contacts 02ac3ed9d0 150/154: Fix Warning: ‘org-show-context’ is an obsolete function (as of 9.6); use ‘org-fold-show-context’ instead., ELPA Syncer, 2022/09/09
- [elpa] externals/org-contacts 3ea7298670 130/154: Enable company-mode support, ELPA Syncer, 2022/09/09