Skip to content

Commit

Permalink
Handle and match new "group" entry in addressbook.
Browse files Browse the repository at this point in the history
* helm-bookmark.el (helm-bookmark--addressbook-search-mail): Renamed
from helm-bookmark--addressbook-search-fn.
(helm-bookmark--addressbook-search-group): New.
(helm-bookmark-addressbook-class): Add group prop at initialization and
add one more fn to search fns.
  • Loading branch information
thierryvolpiatto committed Nov 30, 2016
1 parent e7d045d commit 12b1dc5
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions helm-bookmark.el
Expand Up @@ -519,7 +519,7 @@ than `w3m-browse-url' use it."
;;; Addressbook.
;;
;;
(defun helm-bookmark-addressbook-search-fn (pattern)
(defun helm-bookmark--addressbook-search-mail (pattern)
(helm-awhile (next-single-property-change (point) 'email)
(goto-char it)
(end-of-line)
Expand All @@ -530,17 +530,29 @@ than `w3m-browse-url' use it."
(cl-return
(+ (point) (match-end 0))))))

(defun helm-bookmark--addressbook-search-group (pattern)
(helm-awhile (next-single-property-change (point) 'group)
(goto-char it)
(end-of-line)
(when (string-match pattern
(get-text-property
0 'group (buffer-substring
(point-at-bol) (point-at-eol))))
(cl-return
(+ (point) (match-end 0))))))

(defclass helm-bookmark-addressbook-class (helm-source-in-buffer)
((init :initform (lambda ()
(require 'addressbook-bookmark nil t)
(bookmark-maybe-load-default-file)
(helm-init-candidates-in-buffer
'global
(cl-loop for b in (helm-bookmark-addressbook-setup-alist)
collect (propertize
b 'email (bookmark-prop-get
b 'email))))))
(search :initform 'helm-bookmark-addressbook-search-fn)
collect (propertize b
'email (bookmark-prop-get b 'email)
'group (bookmark-prop-get b 'group))))))
(search :initform '(helm-bookmark--addressbook-search-group
helm-bookmark--addressbook-search-mail))
(persistent-action :initform
(lambda (candidate)
(let ((bmk (helm-bookmark-get-bookmark-from-name
Expand Down

0 comments on commit 12b1dc5

Please sign in to comment.