[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master c7d86a3 4/5: New gnorb-helm file
From: |
Eric Abrahamsen |
Subject: |
[elpa] master c7d86a3 4/5: New gnorb-helm file |
Date: |
Thu, 3 May 2018 15:38:00 -0400 (EDT) |
branch: master
commit c7d86a3f0080cc0c5ba07206cd9de95829338ff0
Author: Eric Abrahamsen <address@hidden>
Commit: Eric Abrahamsen <address@hidden>
New gnorb-helm file
* packages/gnorb/gnorb-helm.el: New library, so far only one command.
(gnorb-helm-search-registry): Command for searching the Gnus
registry.
(gnorb-helm-gnus-registry-candidates): Extract values from the
registry.
* packages/gnorb/gnorb.org: Document.
---
packages/gnorb/gnorb-helm.el | 91 ++++++++++++++++++++++++++++++++++++++++++++
packages/gnorb/gnorb.info | 13 +++++--
packages/gnorb/gnorb.org | 8 +++-
packages/gnorb/gnorb.texi | 9 ++++-
4 files changed, 113 insertions(+), 8 deletions(-)
diff --git a/packages/gnorb/gnorb-helm.el b/packages/gnorb/gnorb-helm.el
new file mode 100644
index 0000000..bdf490d
--- /dev/null
+++ b/packages/gnorb/gnorb-helm.el
@@ -0,0 +1,91 @@
+;;; gnorb-helm.el --- Interface between Helm and Gnorb -*- lexical-binding:
t; -*-
+
+;; Copyright (C) 2018 Free Software Foundation, Inc.
+
+;; Author: Eric Abrahamsen <address@hidden>
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see <https://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;; Convenience functions relying on the helm package.
+
+;;; Code:
+
+(require 'gnorb-gnus)
+(require 'nngnorb)
+(require 'gnorb-utils)
+
+(declare-function 'helm-make-source "ext:helm-source")
+(declare-function 'helm "ext:helm")
+(declare-function 'helm-marked-candidates "ext:helm")
+
+(defun gnorb-helm-gnus-registry-candidates ()
+ "Return a list of candidates from the Gnus registry."
+ (let (ret from recipient subject group)
+ (maphash
+ (lambda (msg-id data)
+ (when (setq group (car-safe (cdr (assoc 'group data)))
+ from (car-safe (cdr (assoc 'sender data)))
+ subject (car-safe (cdr (assoc 'subject data)))
+ recipient (car-safe (cdr (assoc 'recipient data))))
+ (push (cons (format "%s: %s"
+ (if (string-match-p from
gnus-ignored-from-addresses)
+ recipient
+ from)
+ subject) ; display
+ (cons msg-id group)) ; real
+ ret)))
+ (slot-value gnus-registry-db 'data))
+ ret))
+
+;;;###autoload
+(defun gnorb-helm-search-registry ()
+ "Use helm and the Gnus registry to search messages."
+ (interactive)
+ (require 'helm)
+ (unless (gnus-alive-p)
+ (error "Gnus is not running"))
+ (unless gnus-registry-enabled
+ (error "The Gnus registry is not enabled"))
+ (let* ((msgs (helm :sources
+ (helm-make-source "Gnus Registry" 'helm-source-sync
+ :candidates #'gnorb-helm-gnus-registry-candidates
+ :action (lambda (&rest _ignored)
(helm-marked-candidates)))
+ :buffer "*helm Gnus Registry*"))
+ (server (gnorb-gnus-find-gnorb-server))
+ (artlist
+ (mapcar
+ (lambda (msg)
+ (pcase-let ((`(,group . ,artno) (gnorb-msg-id-request-head
+ (car msg) (cdr msg))))
+ (when (and artno (integerp artno) (> artno 0))
+ (vector group artno 100))))
+ msgs))
+ (name (make-temp-name "registry messages"))
+ (spec (list
+ (cons 'nnir-specs (list (cons 'nnir-query-spec
+ `((query . "dummy")
+ (articles . ,artlist)))
+ (cons 'nnir-group-spec
+ `((,server ,(list name))))))
+ (cons 'nnir-artlist nil))))
+ (when msgs
+ (switch-to-buffer gnus-group-buffer)
+ (gnus-group-read-ephemeral-group
+ name `(nnir ,server) nil `(switch-to-buffer ,gnus-group-buffer)
+ nil nil spec))))
+
+(provide 'gnorb-helm)
+;;; gnorb-helm.el ends here
diff --git a/packages/gnorb/gnorb.info b/packages/gnorb/gnorb.info
index 0bb27fa..ee9a0df 100644
--- a/packages/gnorb/gnorb.info
+++ b/packages/gnorb/gnorb.info
@@ -695,11 +695,16 @@ set of groups beforehand.
tracked in the registry. Search strings are given as a series of
“key:value” terms, with double quotes around multi-word values.
See docstring for available keys.
+‘gnorb-helm-search-registry’
+ Helm users can use this function to conduct a more visual search of
+ the registry. Only sender/recipient and subject lines are matched
+ against.
- This function is not bound by default; you might consider:
+ These functions are not bound by default; you might consider:
(with-eval-after-load "gnus-group"
- (define-key gnus-group-group-map (kbd "/")
#'gnorb-gnus-search-registry))
+ (define-key gnus-group-group-map (kbd "/") #'gnorb-gnus-search-registry)
+ (define-key gnus-group-group-map (kbd "?")
#'gnorb-helm-search-registry))
File: gnorb.info, Node: User Options 2, Prev: Searching With the Registry,
Up: Misc Gnus
@@ -836,8 +841,8 @@ Node: Inserting BBDB links25199
Node: User Options 125455
Node: Misc Gnus28353
Node: Searching With the Registry28547
-Node: User Options 229574
-Node: Default Keybindings32752
+Node: User Options 229849
+Node: Default Keybindings33027
End Tag Table
diff --git a/packages/gnorb/gnorb.org b/packages/gnorb/gnorb.org
index dfc2d92..951c014 100644
--- a/packages/gnorb/gnorb.org
+++ b/packages/gnorb/gnorb.org
@@ -495,12 +495,16 @@ a particular set of groups beforehand.
strings are given as a series of "key:value" terms, with double
quotes around multi-word values. See docstring for available
keys.
+- `gnorb-helm-search-registry' :: Helm users can use this function to
+ conduct a more visual search of the registry. Only
+ sender/recipient and subject lines are matched against.
-This function is not bound by default; you might consider:
+These functions are not bound by default; you might consider:
#+BEGIN_SRC elisp
(with-eval-after-load "gnus-group"
- (define-key gnus-group-group-map (kbd "/") #'gnorb-gnus-search-registry))
+ (define-key gnus-group-group-map (kbd "/") #'gnorb-gnus-search-registry)
+ (define-key gnus-group-group-map (kbd "?") #'gnorb-helm-search-registry))
#+END_SRC
** User Options
- `gnorb-gnus-mail-search-backend' :: Specifies the search backend
diff --git a/packages/gnorb/gnorb.texi b/packages/gnorb/gnorb.texi
index 6c3a2fc..5eed70d 100644
--- a/packages/gnorb/gnorb.texi
+++ b/packages/gnorb/gnorb.texi
@@ -685,13 +685,18 @@ and match it against messages tracked in the registry.
Search
strings are given as a series of ``key:value'' terms, with double
quotes around multi-word values. See docstring for available
keys.
address@hidden `gnorb-helm-search-registry'
+Helm users can use this function to
+conduct a more visual search of the registry. Only
+sender/recipient and subject lines are matched against.
@end table
-This function is not bound by default; you might consider:
+These functions are not bound by default; you might consider:
@lisp
(with-eval-after-load "gnus-group"
- (define-key gnus-group-group-map (kbd "/") #'gnorb-gnus-search-registry))
+ (define-key gnus-group-group-map (kbd "/") #'gnorb-gnus-search-registry)
+ (define-key gnus-group-group-map (kbd "?") #'gnorb-helm-search-registry))
@end lisp
@node User Options 2
- [elpa] master updated (e538c67 -> 7c12813), Eric Abrahamsen, 2018/05/03
- [elpa] master 620d210 2/5: Missing a require for seq package, Eric Abrahamsen, 2018/05/03
- [elpa] master 7d3f43c 1/5: Factor out function for finding nngnorb server, Eric Abrahamsen, 2018/05/03
- [elpa] master 7c12813 5/5: Update copyright notices, bump to version 1.5, Eric Abrahamsen, 2018/05/03
- [elpa] master c7d86a3 4/5: New gnorb-helm file,
Eric Abrahamsen <=
- [elpa] master 6f43089 3/5: New function gnorb-gnus-search-registry, Eric Abrahamsen, 2018/05/03