From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/87478 Path: news.gmane.org!.POSTED!not-for-mail From: Eric Abrahamsen Newsgroups: gmane.emacs.devel,gmane.emacs.gnus.general Subject: Re: [RFC] Gnus generalized search, part II Date: Mon, 24 Apr 2017 13:30:28 -0700 Message-ID: <87shkx5z17.fsf@ericabrahamsen.net> References: <87zif930mt.fsf@ericabrahamsen.net> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1493065917 1383 195.159.176.226 (24 Apr 2017 20:31:57 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 24 Apr 2017 20:31:57 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux) Cc: ding@gnus.org To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Apr 24 22:31:48 2017 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d2keB-00006Z-Jf for ged-emacs-devel@m.gmane.org; Mon, 24 Apr 2017 22:31:47 +0200 Original-Received: from localhost ([::1]:45790 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d2keH-0004Oe-HH for ged-emacs-devel@m.gmane.org; Mon, 24 Apr 2017 16:31:53 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:51306) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d2kdb-0004OM-OZ for emacs-devel@gnu.org; Mon, 24 Apr 2017 16:31:15 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d2kdX-00020w-8b for emacs-devel@gnu.org; Mon, 24 Apr 2017 16:31:11 -0400 Original-Received: from [195.159.176.226] (port=51653 helo=blaine.gmane.org) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1d2kdX-000204-28 for emacs-devel@gnu.org; Mon, 24 Apr 2017 16:31:07 -0400 Original-Received: from list by blaine.gmane.org with local (Exim 4.84_2) (envelope-from ) id 1d2kdN-0007SB-Mm for emacs-devel@gnu.org; Mon, 24 Apr 2017 22:30:57 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Followup-To: gmane.emacs.gnus.general Original-Lines: 54 Original-X-Complaints-To: usenet@blaine.gmane.org Cancel-Lock: sha1:F3yBMdYW7brc4ac1voq6rRQ/Yzg= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 195.159.176.226 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:214268 gmane.emacs.gnus.general:87478 Archived-At: Lars Ingebrigtsen writes: > Eric Abrahamsen writes: > >> The query entered by the user is parsed into a sexp structure, and then >> each engine is responsible for interpreting that. > > I think this sounds like a good approach. I haven't tried the code > myself, but I skimmed it briefly and it looks good to me. :-) Okay, I've pushed these changes as the scratch/nnir-search branch. This branch is mostly the same as the nnir.el file I posted last time, but with more switches for turning query parsing on and off. In the storied Gnus tradition of over-customization, there are now a grand total of four ways of controlling whether queries are parsed or raw: 1. The big switch is `nnir-use-parsed-queries'. It is t by default, but if set to nil, Gnus will behave more or less the way it does now. 2. If a prefix argument is given to the nnir search command (ie, "C-u G G" in the *Group* buffer), that search query will not be parsed, and will be passed raw to all the marked servers/groups. 3. Individual search engines can be told never to parse search queries, by specifying the `raw-queries-p' parameter to engine creation. If multiple groups are marked for searching, the query will be parsed for groups with engines that allow it, and not for engines that don't. 4. Entire classes of engines can be marked never to parse queries, by setting variables like nnir-notmuch-raw-queries-p, with "notmuch" replaced by the various engine names. Again, queries to multiple engines will still be parsed by engines that allow it. I do hope people will test this. Actually testing that search groups behave correctly is of course important, but if you just want to fool with the search language and see how it is parsed, and transformed, you can use stuff like this: #+BEGIN_SRC elisp (let* ((query-string "subject:gnus or since:1w") (parsed-query (nnir-search-parse-query query-string)) (test-imap (make-instance 'gnus-search-imap)) (test-notmuch (make-instance 'gnus-search-notmuch))) (message "notmuch query: %s\nimap query: %s" (nnir-search-transform-top-level test-imap parsed-query) (nnir-search-transform-top-level test-notmuch parsed-query))) #+END_SRC `nnir-search-parse-query' turns strings into sexps, and `nnir-search-transform-top-level' turns the sexps back into engine-specific strings -- it requires an engine instance as the first argument. All the engines are named gnus-search-*. There are more on the way.