annotate lisp/net/xesam.el @ 97187:faad486370aa

Remove orphaned comment.
author Bill Wohler <wohler@newt.com>
date Fri, 01 Aug 2008 04:23:13 +0000
parents dfc12ea9589f
children 004f6dc1c1a0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
96989
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1 ;;; xesam.el --- Xesam interface to search engines.
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
2
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
3 ;; Copyright (C) 2008 Free Software Foundation, Inc.
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
4
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
5 ;; Author: Michael Albinus <michael.albinus@gmx.de>
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
6 ;; Keywords: tools, hypermedia
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
7
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
8 ;; This file is part of GNU Emacs.
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
9
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
11 ;; it under the terms of the GNU General Public License as published by
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
12 ;; the Free Software Foundation; either version 3, or (at your option)
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
13 ;; any later version.
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
14
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
15 ;; GNU Emacs is distributed in the hope that it will be useful,
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
18 ;; GNU General Public License for more details.
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
19
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
20 ;; You should have received a copy of the GNU General Public License
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
21 ;; along with GNU Emacs; see the file COPYING. If not, see
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
22 ;; <http://www.gnu.org/licenses/>.
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
23
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
24 ;;; Commentary:
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
25
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
26 ;; This package provides an interface to the Xesam, a D-Bus based "eXtEnsible
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
27 ;; Search And Metadata specification". It has been tested with
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
28 ;;
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
29 ;; xesam-glib 0.3.4, xesam-tools 0.6.1
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
30 ;; beagle 0.3.7, beagle-xesam 0.2
97170
dfc12ea9589f * net/xesam.el (xesam-type, xesam-query, xesam-xml-string): New
Michael Albinus <michael.albinus@gmx.de>
parents: 97038
diff changeset
31 ;; strigi 0.5.11
96989
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
32
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
33 ;; The precondition for this package is a D-Bus aware Emacs. This is
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
34 ;; configured per default, when Emacs is built on a machine running
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
35 ;; D-Bus. Furthermore, there must be at least one search engine
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
36 ;; running, which support the Xesam interface. Beagle and strigi have
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
37 ;; been tested; tracker, pinot and recoll are also said to support
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
38 ;; Xesam. You can check the existence of such a search engine by
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
39 ;;
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
40 ;; (dbus-list-queued-owners :session "org.freedesktop.xesam.searcher")
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
41
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
42 ;; In order to start a search, you must load xesam.el:
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
43 ;;
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
44 ;; (require 'xesam)
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
45
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
46 ;; xesam.el supports two types of queries, which are explained *very* short:
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
47 ;;
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
48 ;; * Full text queries. Just search keys shall be given, like
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
49 ;;
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
50 ;; hello world
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
51 ;;
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
52 ;; A full text query in xesam.el is restricted to files.
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
53 ;;
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
54 ;; * Xesam End User Search Language queries. The Xesam query language
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
55 ;; is described at <http://xesam.org/main/XesamUserSearchLanguage>,
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
56 ;; which must be consulted for the whole features.
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
57 ;;
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
58 ;; A query string consists of search keys, collectors, selectors,
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
59 ;; and phrases. Search keys are words like in a full text query:
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
60 ;;
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
61 ;; hello word
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
62 ;;
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
63 ;; A selector is a tuple <keyword><relation>. <keyword> can be any
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
64 ;; predefined Xesam keyword, the most common keywords are "ext"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
65 ;; (file name extension), "format " (mime type), "tag" (user
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
66 ;; keywords) and "type" (types of items, like "audio", "file",
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
67 ;; "picture", "attachment"). <relation> is a comparison to a value,
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
68 ;; which must be a string (relation ":" or "=") or number (relation
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
69 ;; "<=", ">=", "<", ">"):
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
70 ;;
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
71 ;; type:attachment ext=el
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
72 ;;
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
73 ;; A collector is one of the items "AND", "and", "&&", "OR", "or",
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
74 ;; "||", or "-". The default collector on multiple terms is "AND";
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
75 ;; "-" means "AND NOT".
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
76 ;;
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
77 ;; albinus -type:file
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
78 ;;
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
79 ;; A phrase is a string enclosed in quotes, with appended modifiers
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
80 ;; (single letters). Examples of modifiers are "c" (case
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
81 ;; sensitive), "C" (case insensitive), "e" (exact match), "r"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
82 ;; (regular expression):
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
83 ;;
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
84 ;; "Hello world"c
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
85
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
86 ;; You can customize, whether you want to apply a Xesam user query, or
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
87 ;; a full text query. Note, that not every search engine supports
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
88 ;; both query types.
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
89 ;;
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
90 ;; (setq xesam-query-type 'fulltext-query)
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
91 ;;
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
92 ;; Another option to be customised is the number of hits to be
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
93 ;; presented at once.
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
94 ;;
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
95 ;; (setq xesam-hits-per-page 50)
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
96
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
97 ;; A search can be started by the command
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
98 ;;
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
99 ;; M-x xesam-search
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
100 ;;
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
101 ;; When several search engines are registered, the engine to be used
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
102 ;; can be selected via minibuffer completion. Afterwards, the query
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
103 ;; shall be entered in the minibuffer.
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
104
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
105 ;;; Code:
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
106
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
107 ;; D-Bus support in the Emacs core can be disabled with configuration
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
108 ;; option "--without-dbus". Declare used subroutines and variables.
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
109 (declare-function dbus-call-method "dbusbind.c")
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
110 (declare-function dbus-register-signal "dbusbind.c")
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
111
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
112 (require 'dbus)
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
113
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
114 ;; Pacify byte compiler.
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
115 (eval-when-compile
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
116 (require 'cl))
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
117
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
118 ;; Widgets are used to highlight the search results.
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
119 (require 'widget)
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
120
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
121 (eval-when-compile
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
122 (require 'wid-edit))
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
123
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
124 ;; `run-at-time' is used in the signal handler.
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
125 (require 'timer)
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
126
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
127 ;; The default search field is "xesam:url". It must be inspected.
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
128 (require 'url)
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
129
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
130 (defgroup xesam nil
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
131 "Xesam compatible interface to search engines."
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
132 :group 'extensions
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
133 :group 'hypermedia
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
134 :version "23.1")
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
135
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
136 (defcustom xesam-query-type 'user-query
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
137 "Xesam query language type."
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
138 :group 'xesam
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
139 :type '(choice
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
140 (const :tag "Xesam user query" user-query)
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
141 (const :tag "Xesam fulltext query" fulltext-query)))
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
142
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
143 (defcustom xesam-hits-per-page 20
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
144 "Number of search hits to be displayed in the result buffer"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
145 :group 'xesam
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
146 :type 'integer)
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
147
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
148 (defvar xesam-debug nil
97038
b201d17750ad * net/xesam.el (xesam-from): Remove defvar.
Michael Albinus <michael.albinus@gmx.de>
parents: 96996
diff changeset
149 "Insert debug information in the help echo.")
96989
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
150
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
151 (defconst xesam-service-search "org.freedesktop.xesam.searcher"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
152 "The D-Bus name used to talk to Xesam.")
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
153
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
154 (defconst xesam-path-search "/org/freedesktop/xesam/searcher/main"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
155 "The D-Bus object path used to talk to Xesam.")
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
156
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
157 ;; Methods: "NewSession", "SetProperty", "GetProperty",
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
158 ;; "CloseSession", "NewSearch", "StartSearch", "GetHitCount",
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
159 ;; "GetHits", "GetHitData", "CloseSearch" and "GetState".
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
160 ;; Signals: "HitsAdded", "HitsRemoved", "HitsModified", "SearchDone"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
161 ;; and "StateChanged".
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
162 (defconst xesam-interface-search "org.freedesktop.xesam.Search"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
163 "The D-Bus Xesam search interface.")
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
164
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
165 (defconst xesam-all-fields
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
166 '("xesam:35mmEquivalent" "xesam:Alarm" "xesam:Archive" "xesam:Audio"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
167 "xesam:AudioList" "xesam:Content" "xesam:DataObject" "xesam:DeletedFile"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
168 "xesam:Document" "xesam:Email" "xesam:EmailAttachment" "xesam:Event"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
169 "xesam:File" "xesam:FileSystem" "xesam:FreeBusy" "xesam:IMMessage"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
170 "xesam:Image" "xesam:Journal" "xesam:Mailbox" "xesam:Media"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
171 "xesam:MediaList" "xesam:Message" "xesam:PIM" "xesam:Partition"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
172 "xesam:Photo" "xesam:Presentation" "xesam:Project" "xesam:RemoteResource"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
173 "xesam:Software" "xesam:SourceCode" "xesam:Spreadsheet" "xesam:Storage"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
174 "xesam:Task" "xesam:TextDocument" "xesam:Video" "xesam:Visual"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
175 "xesam:aimContactMedium" "xesam:aperture" "xesam:aspectRatio"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
176 "xesam:attachmentEncoding" "xesam:attendee" "xesam:audioBirate"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
177 "xesam:audioChannels" "xesam:audioCodec" "xesam:audioCodecType"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
178 "xesam:audioSampleFormat" "xesam:audioSampleRate" "xesam:author"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
179 "xesam:bcc" "xesam:birthDate" "xesam:blogContactURL"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
180 "xesam:cameraManufacturer" "xesam:cameraModel" "xesam:cc" "xesam:ccdWidth"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
181 "xesam:cellPhoneNumber" "xesam:characterCount" "xesam:charset"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
182 "xesam:colorCount" "xesam:colorSpace" "xesam:columnCount" "xesam:comment"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
183 "xesam:commentCharacterCount" "xesam:conflicts" "xesam:contactMedium"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
184 "xesam:contactName" "xesam:contactNick" "xesam:contactPhoto"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
185 "xesam:contactURL" "xesam:contains" "xesam:contenKeyword"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
186 "xesam:contentComment" "xesam:contentCreated" "xesam:contentModified"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
187 "xesam:contentType" "xesam:contributor" "xesam:copyright" "xesam:creator"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
188 "xesam:definesClass" "xesam:definesFunction" "xesam:definesGlobalVariable"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
189 "xesam:deletionTime" "xesam:depends" "xesam:description" "xesam:device"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
190 "xesam:disclaimer" "xesam:documentCategory" "xesam:duration"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
191 "xesam:emailAddress" "xesam:eventEnd" "xesam:eventLocation"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
192 "xesam:eventStart" "xesam:exposureBias" "xesam:exposureProgram"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
193 "xesam:exposureTime" "xesam:faxPhoneNumber" "xesam:fileExtension"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
194 "xesam:fileSystemType" "xesam:flashUsed" "xesam:focalLength"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
195 "xesam:focusDistance" "xesam:formatSubtype" "xesam:frameCount"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
196 "xesam:frameRate" "xesam:freeSpace" "xesam:gender" "xesam:generator"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
197 "xesam:generatorOptions" "xesam:group" "xesam:hash" "xesam:hash"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
198 "xesam:height" "xesam:homeEmailAddress" "xesam:homePhoneNumber"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
199 "xesam:homePostalAddress" "xesam:homepageContactURL"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
200 "xesam:horizontalResolution" "xesam:icqContactMedium" "xesam:id"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
201 "xesam:imContactMedium" "xesam:interests" "xesam:interlaceMode"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
202 "xesam:isEncrypted" "xesam:isImportant" "xesam:isInProgress"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
203 "xesam:isPasswordProtected" "xesam:isRead" "xesam:isoEquivalent"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
204 "xesam:jabberContactMedium" "xesam:keyword" "xesam:language" "xesam:legal"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
205 "xesam:license" "xesam:licenseType" "xesam:lineCount" "xesam:links"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
206 "xesam:mailingPostalAddress" "xesam:maintainer" "xesam:md5Hash"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
207 "xesam:mediaCodec" "xesam:mediaCodecBitrate" "xesam:mediaCodecType"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
208 "xesam:meteringMode" "xesam:mimeType" "xesam:mountPoint"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
209 "xesam:msnContactMedium" "xesam:name" "xesam:occupiedSpace"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
210 "xesam:orientation" "xesam:originalLocation" "xesam:owner"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
211 "xesam:pageCount" "xesam:permissions" "xesam:phoneNumber"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
212 "xesam:physicalAddress" "xesam:pixelFormat" "xesam:primaryRecipient"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
213 "xesam:programmingLanguage" "xesam:rating" "xesam:receptionTime"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
214 "xesam:recipient" "xesam:related" "xesam:remoteUser" "xesam:rowCount"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
215 "xesam:sampleBitDepth" "xesam:sampleFormat" "xesam:secondaryRecipient"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
216 "xesam:sha1Hash" "xesam:size" "xesam:skypeContactMedium"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
217 "xesam:sourceCreated" "xesam:sourceModified" "xesam:storageSize"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
218 "xesam:subject" "xesam:supercedes" "xesam:title" "xesam:to"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
219 "xesam:totalSpace" "xesam:totalUncompressedSize" "xesam:url"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
220 "xesam:usageIntensity" "xesam:userComment" "xesam:userKeyword"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
221 "xesam:uuid" "xesam:version" "xesam:verticalResolution" "xesam:videoBirate"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
222 "xesam:videoCodec" "xesam:videoCodecType" "xesam:whiteBalance"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
223 "xesam:width" "xesam:wordCount" "xesam:workEmailAddress"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
224 "xesam:workPhoneNumber" "xesam:workPostalAddress"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
225 "xesam:yahooContactMedium")
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
226 "All fields from the Xesam Core Ontology.
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
227 This defconst can be used to check for a new search engine, which
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
228 fields are supported.")
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
229
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
230 (defconst xesam-user-query
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
231 "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
232 <request xmlns=\"http://freedesktop.org/standards/xesam/1.0/query\">
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
233 <userQuery>
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
234 %s
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
235 </userQuery>
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
236 </request>"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
237 "The Xesam user query XML.")
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
238
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
239 (defconst xesam-fulltext-query
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
240 "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
241 <request xmlns=\"http://freedesktop.org/standards/xesam/1.0/query\">
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
242 <query content=\"xesam:Document\" source=\"xesam:File\">
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
243 <fullText>
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
244 <string>%s</string>
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
245 </fullText>
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
246 </query>
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
247 </request>"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
248 "The Xesam fulltext query XML.")
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
249
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
250 (defun xesam-get-property (engine property)
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
251 "Return the PROPERTY value of ENGINE."
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
252 ;; "GetProperty" returns a variant, so we must use the car.
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
253 (car (dbus-call-method
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
254 :session (car engine) xesam-path-search
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
255 xesam-interface-search "GetProperty"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
256 (cdr engine) property)))
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
257
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
258 (defun xesam-set-property (engine property value)
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
259 "Set the PROPERTY of ENGINE to VALUE.
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
260 VALUE can be a string, a non-negative integer, a boolean
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
261 value (nil or t), or a list of them. It returns the new value of
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
262 PROPERTY in the search engine. This new value can be different
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
263 from VALUE, depending on what the search engine accepts."
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
264 ;; "SetProperty" returns a variant, so we must use the car.
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
265 (car (dbus-call-method
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
266 :session (car engine) xesam-path-search
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
267 xesam-interface-search "SetProperty"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
268 (cdr engine) property
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
269 ;; The value must be a variant. It can be only a string, an
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
270 ;; unsigned int, a boolean, or an array of them. So we need
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
271 ;; no type keyword; we let the type check to the search
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
272 ;; engine.
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
273 (list :variant value))))
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
274
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
275 (defvar xesam-minibuffer-vendor-history nil
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
276 "Interactive vendor history.")
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
277
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
278 (defvar xesam-minibuffer-query-history nil
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
279 "Interactive query history.")
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
280
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
281 ;; Pacify byte compiler.
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
282 (defvar xesam-engine nil)
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
283 (defvar xesam-search nil)
97170
dfc12ea9589f * net/xesam.el (xesam-type, xesam-query, xesam-xml-string): New
Michael Albinus <michael.albinus@gmx.de>
parents: 97038
diff changeset
284 (defvar xesam-type nil)
dfc12ea9589f * net/xesam.el (xesam-type, xesam-query, xesam-xml-string): New
Michael Albinus <michael.albinus@gmx.de>
parents: 97038
diff changeset
285 (defvar xesam-query nil)
dfc12ea9589f * net/xesam.el (xesam-type, xesam-query, xesam-xml-string): New
Michael Albinus <michael.albinus@gmx.de>
parents: 97038
diff changeset
286 (defvar xesam-xml-string nil)
96989
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
287 (defvar xesam-current nil)
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
288 (defvar xesam-count nil)
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
289 (defvar xesam-to nil)
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
290 (defvar xesam-refreshing nil)
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
291
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
292
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
293 ;;; Search engines.
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
294
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
295 (defvar xesam-search-engines nil
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
296 "List of available Xesam search engines.
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
297 Every entry is a triple of the unique D-Bus service name of the
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
298 engine, the session identifier, and the display name. Example:
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
299
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
300 \(\(\":1.59\" \"0t1214948020ut358230u0p2698r3912347765k3213849828\" \"Tracker Xesam Service\")
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
301 \(\":1.27\" \"strigisession1369133069\" \"Strigi Desktop Search\"))
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
302
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
303 A Xesam-compatible search engine is identified as a queued D-Bus
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
304 service of `xesam-service-search'.")
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
305
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
306 (defun xesam-delete-search-engine (&rest args)
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
307 "Removes service from `xesam-search-engines'."
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
308 (when (and (= (length args) 3) (stringp (car args)))
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
309 (setq xesam-search-engines
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
310 (delete (assoc (car args) xesam-search-engines)
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
311 xesam-search-engines))))
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
312
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
313 (defun xesam-search-engines ()
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
314 "Return Xesam search engines, stored in `xesam-search-engines'.
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
315 The first search engine is the name owner of `xesam-service-search'.
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
316 If there is no registered search engine at all, the function returns `nil'."
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
317 (let ((services (dbus-ignore-errors
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
318 (dbus-list-queued-owners
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
319 :session xesam-service-search)))
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
320 engine vendor-id hit-fields)
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
321 (dolist (service services)
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
322 (unless (assoc-string service xesam-search-engines)
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
323
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
324 ;; Open a new session, and add it to the search engines list.
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
325 (add-to-list
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
326 'xesam-search-engines
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
327 (setq engine
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
328 (cons service
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
329 (dbus-call-method
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
330 :session service xesam-path-search
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
331 xesam-interface-search "NewSession")))
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
332 'append)
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
333
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
334 ;; Set the "search.live" property; otherwise the search engine
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
335 ;; might refuse to answer.
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
336 ; (xesam-set-property engine "search.live" t)
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
337
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
338 ;; Check the vendor properties.
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
339 (setq vendor-id (xesam-get-property engine "vendor.id")
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
340 hit-fields (xesam-get-property engine "hit.fields"))
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
341
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
342 ;; Ususally, `hit.fields' shall describe supported fields.
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
343 ;; That is not the case now, so we set it ourselves.
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
344 ;; Hopefully, this will change later.
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
345 (setq hit-fields
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
346 (cond
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
347 ((string-equal vendor-id "Beagle")
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
348 '("xesam:mimeType" "xesam:url"))
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
349 ((string-equal vendor-id "Strigi")
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
350 '("xesam:author" "xesam:cc" "xesam:cc" "xesam:charset"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
351 "xesam:contentType" "xesam:fileExtension" "xesam:id"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
352 "xesam:lineCount" "xesam:links" "xesam:mimeType" "xesam:name"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
353 "xesam:size" "xesam:sourceModified" "xesam:subject"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
354 "xesam:to" "xesam:url"))
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
355 ((string-equal vendor-id "TrackerXesamSession")
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
356 '("xesam:relevancyRating" "xesam:url"))
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
357 ;; xesam-tools yahoo service.
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
358 (t '("xesam:contentModified" "xesam:mimeType" "xesam:summary"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
359 "xesam:title" "xesam:url" "yahoo:displayUrl"))))
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
360
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
361 (xesam-set-property engine "hit.fields" hit-fields)
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
362 (xesam-set-property engine "hit.fields.extended" '("xesam:snippet"))
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
363
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
364 ;; Let us notify, when the search engine disappears.
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
365 (dbus-register-signal
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
366 :session dbus-service-dbus dbus-path-dbus
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
367 dbus-interface-dbus "NameOwnerChanged"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
368 'xesam-delete-search-engine service))))
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
369 xesam-search-engines)
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
370
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
371
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
372 ;;; Search buffers.
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
373
97170
dfc12ea9589f * net/xesam.el (xesam-type, xesam-query, xesam-xml-string): New
Michael Albinus <michael.albinus@gmx.de>
parents: 97038
diff changeset
374 (define-derived-mode xesam-mode nil "Xesam"
96989
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
375 "Major mode for presenting search results of a Xesam search.
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
376 In this mode, widgets represent the search results.
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
377
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
378 \\{xesam-mode-map}
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
379 Turning on Xesam mode runs the normal hook `xesam-mode-hook'."
97170
dfc12ea9589f * net/xesam.el (xesam-type, xesam-query, xesam-xml-string): New
Michael Albinus <michael.albinus@gmx.de>
parents: 97038
diff changeset
380 ;; Keymap.
dfc12ea9589f * net/xesam.el (xesam-type, xesam-query, xesam-xml-string): New
Michael Albinus <michael.albinus@gmx.de>
parents: 97038
diff changeset
381 (setq xesam-mode-map (copy-keymap special-mode-map))
dfc12ea9589f * net/xesam.el (xesam-type, xesam-query, xesam-xml-string): New
Michael Albinus <michael.albinus@gmx.de>
parents: 97038
diff changeset
382 (set-keymap-parent xesam-mode-map widget-keymap)
dfc12ea9589f * net/xesam.el (xesam-type, xesam-query, xesam-xml-string): New
Michael Albinus <michael.albinus@gmx.de>
parents: 97038
diff changeset
383 (define-key xesam-mode-map "z" 'kill-this-buffer)
dfc12ea9589f * net/xesam.el (xesam-type, xesam-query, xesam-xml-string): New
Michael Albinus <michael.albinus@gmx.de>
parents: 97038
diff changeset
384
dfc12ea9589f * net/xesam.el (xesam-type, xesam-query, xesam-xml-string): New
Michael Albinus <michael.albinus@gmx.de>
parents: 97038
diff changeset
385 ;; Maybe we implement something useful, later on.
dfc12ea9589f * net/xesam.el (xesam-type, xesam-query, xesam-xml-string): New
Michael Albinus <michael.albinus@gmx.de>
parents: 97038
diff changeset
386 (set (make-local-variable 'revert-buffer-function) 'ignore)
dfc12ea9589f * net/xesam.el (xesam-type, xesam-query, xesam-xml-string): New
Michael Albinus <michael.albinus@gmx.de>
parents: 97038
diff changeset
387 ;; `xesam-engine', `xesam-search', `xesam-type', `xesam-query', and
dfc12ea9589f * net/xesam.el (xesam-type, xesam-query, xesam-xml-string): New
Michael Albinus <michael.albinus@gmx.de>
parents: 97038
diff changeset
388 ;; `xesam-xml-string' will be set in `xesam-new-search'.
dfc12ea9589f * net/xesam.el (xesam-type, xesam-query, xesam-xml-string): New
Michael Albinus <michael.albinus@gmx.de>
parents: 97038
diff changeset
389 (set (make-local-variable 'xesam-engine) nil)
dfc12ea9589f * net/xesam.el (xesam-type, xesam-query, xesam-xml-string): New
Michael Albinus <michael.albinus@gmx.de>
parents: 97038
diff changeset
390 (set (make-local-variable 'xesam-search) nil)
dfc12ea9589f * net/xesam.el (xesam-type, xesam-query, xesam-xml-string): New
Michael Albinus <michael.albinus@gmx.de>
parents: 97038
diff changeset
391 (set (make-local-variable 'xesam-type) "")
dfc12ea9589f * net/xesam.el (xesam-type, xesam-query, xesam-xml-string): New
Michael Albinus <michael.albinus@gmx.de>
parents: 97038
diff changeset
392 (set (make-local-variable 'xesam-query) "")
dfc12ea9589f * net/xesam.el (xesam-type, xesam-query, xesam-xml-string): New
Michael Albinus <michael.albinus@gmx.de>
parents: 97038
diff changeset
393 (set (make-local-variable 'xesam-xml-string) "")
dfc12ea9589f * net/xesam.el (xesam-type, xesam-query, xesam-xml-string): New
Michael Albinus <michael.albinus@gmx.de>
parents: 97038
diff changeset
394 ;; `xesam-current' is the last hit put into the search buffer,
dfc12ea9589f * net/xesam.el (xesam-type, xesam-query, xesam-xml-string): New
Michael Albinus <michael.albinus@gmx.de>
parents: 97038
diff changeset
395 (set (make-local-variable 'xesam-current) 0)
dfc12ea9589f * net/xesam.el (xesam-type, xesam-query, xesam-xml-string): New
Michael Albinus <michael.albinus@gmx.de>
parents: 97038
diff changeset
396 ;; `xesam-count' is the number of hits reported by the search engine.
dfc12ea9589f * net/xesam.el (xesam-type, xesam-query, xesam-xml-string): New
Michael Albinus <michael.albinus@gmx.de>
parents: 97038
diff changeset
397 (set (make-local-variable 'xesam-count) 0)
dfc12ea9589f * net/xesam.el (xesam-type, xesam-query, xesam-xml-string): New
Michael Albinus <michael.albinus@gmx.de>
parents: 97038
diff changeset
398 ;; `xesam-to' is the upper hit number to be presented.
dfc12ea9589f * net/xesam.el (xesam-type, xesam-query, xesam-xml-string): New
Michael Albinus <michael.albinus@gmx.de>
parents: 97038
diff changeset
399 (set (make-local-variable 'xesam-to) xesam-hits-per-page)
dfc12ea9589f * net/xesam.el (xesam-type, xesam-query, xesam-xml-string): New
Michael Albinus <michael.albinus@gmx.de>
parents: 97038
diff changeset
400 ;; `xesam-refreshing' is an indicator, whether the buffer is just
dfc12ea9589f * net/xesam.el (xesam-type, xesam-query, xesam-xml-string): New
Michael Albinus <michael.albinus@gmx.de>
parents: 97038
diff changeset
401 ;; being updated. Needed, because `xesam-refresh-search-buffer'
dfc12ea9589f * net/xesam.el (xesam-type, xesam-query, xesam-xml-string): New
Michael Albinus <michael.albinus@gmx.de>
parents: 97038
diff changeset
402 ;; can be triggered by an event.
dfc12ea9589f * net/xesam.el (xesam-type, xesam-query, xesam-xml-string): New
Michael Albinus <michael.albinus@gmx.de>
parents: 97038
diff changeset
403 (set (make-local-variable 'xesam-refreshing) nil)
dfc12ea9589f * net/xesam.el (xesam-type, xesam-query, xesam-xml-string): New
Michael Albinus <michael.albinus@gmx.de>
parents: 97038
diff changeset
404 ;; Mode line position returns hit counters.
dfc12ea9589f * net/xesam.el (xesam-type, xesam-query, xesam-xml-string): New
Michael Albinus <michael.albinus@gmx.de>
parents: 97038
diff changeset
405 (set (make-local-variable 'mode-line-position)
dfc12ea9589f * net/xesam.el (xesam-type, xesam-query, xesam-xml-string): New
Michael Albinus <michael.albinus@gmx.de>
parents: 97038
diff changeset
406 (list '(-3 "%p%")
dfc12ea9589f * net/xesam.el (xesam-type, xesam-query, xesam-xml-string): New
Michael Albinus <michael.albinus@gmx.de>
parents: 97038
diff changeset
407 '(10 (:eval (format " (%d/%d)" xesam-current xesam-count)))))
dfc12ea9589f * net/xesam.el (xesam-type, xesam-query, xesam-xml-string): New
Michael Albinus <michael.albinus@gmx.de>
parents: 97038
diff changeset
408 ;; Header line contains the query string.
dfc12ea9589f * net/xesam.el (xesam-type, xesam-query, xesam-xml-string): New
Michael Albinus <michael.albinus@gmx.de>
parents: 97038
diff changeset
409 (set (make-local-variable 'header-line-format)
dfc12ea9589f * net/xesam.el (xesam-type, xesam-query, xesam-xml-string): New
Michael Albinus <michael.albinus@gmx.de>
parents: 97038
diff changeset
410 (list '(20
dfc12ea9589f * net/xesam.el (xesam-type, xesam-query, xesam-xml-string): New
Michael Albinus <michael.albinus@gmx.de>
parents: 97038
diff changeset
411 (:eval
dfc12ea9589f * net/xesam.el (xesam-type, xesam-query, xesam-xml-string): New
Michael Albinus <michael.albinus@gmx.de>
parents: 97038
diff changeset
412 (list "Type: "
dfc12ea9589f * net/xesam.el (xesam-type, xesam-query, xesam-xml-string): New
Michael Albinus <michael.albinus@gmx.de>
parents: 97038
diff changeset
413 (propertize xesam-type 'face 'font-lock-type-face))))
dfc12ea9589f * net/xesam.el (xesam-type, xesam-query, xesam-xml-string): New
Michael Albinus <michael.albinus@gmx.de>
parents: 97038
diff changeset
414 '(10
dfc12ea9589f * net/xesam.el (xesam-type, xesam-query, xesam-xml-string): New
Michael Albinus <michael.albinus@gmx.de>
parents: 97038
diff changeset
415 (:eval
dfc12ea9589f * net/xesam.el (xesam-type, xesam-query, xesam-xml-string): New
Michael Albinus <michael.albinus@gmx.de>
parents: 97038
diff changeset
416 (list " Query: "
dfc12ea9589f * net/xesam.el (xesam-type, xesam-query, xesam-xml-string): New
Michael Albinus <michael.albinus@gmx.de>
parents: 97038
diff changeset
417 (propertize
dfc12ea9589f * net/xesam.el (xesam-type, xesam-query, xesam-xml-string): New
Michael Albinus <michael.albinus@gmx.de>
parents: 97038
diff changeset
418 xesam-query
dfc12ea9589f * net/xesam.el (xesam-type, xesam-query, xesam-xml-string): New
Michael Albinus <michael.albinus@gmx.de>
parents: 97038
diff changeset
419 'face 'font-lock-type-face
dfc12ea9589f * net/xesam.el (xesam-type, xesam-query, xesam-xml-string): New
Michael Albinus <michael.albinus@gmx.de>
parents: 97038
diff changeset
420 'help-echo xesam-xml-string))))))
dfc12ea9589f * net/xesam.el (xesam-type, xesam-query, xesam-xml-string): New
Michael Albinus <michael.albinus@gmx.de>
parents: 97038
diff changeset
421
97038
b201d17750ad * net/xesam.el (xesam-from): Remove defvar.
Michael Albinus <michael.albinus@gmx.de>
parents: 96996
diff changeset
422 (when (not (interactive-p))
b201d17750ad * net/xesam.el (xesam-from): Remove defvar.
Michael Albinus <michael.albinus@gmx.de>
parents: 96996
diff changeset
423 ;; Initialize buffer.
b201d17750ad * net/xesam.el (xesam-from): Remove defvar.
Michael Albinus <michael.albinus@gmx.de>
parents: 96996
diff changeset
424 (setq buffer-read-only t)
b201d17750ad * net/xesam.el (xesam-from): Remove defvar.
Michael Albinus <michael.albinus@gmx.de>
parents: 96996
diff changeset
425 (let ((inhibit-read-only t))
97170
dfc12ea9589f * net/xesam.el (xesam-type, xesam-query, xesam-xml-string): New
Michael Albinus <michael.albinus@gmx.de>
parents: 97038
diff changeset
426 (erase-buffer))))
96989
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
427
97170
dfc12ea9589f * net/xesam.el (xesam-type, xesam-query, xesam-xml-string): New
Michael Albinus <michael.albinus@gmx.de>
parents: 97038
diff changeset
428 ;; It doesn't make sense to call it interactively.
dfc12ea9589f * net/xesam.el (xesam-type, xesam-query, xesam-xml-string): New
Michael Albinus <michael.albinus@gmx.de>
parents: 97038
diff changeset
429 (put 'xesam-mode 'disabled t)
96989
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
430
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
431 (defun xesam-buffer-name (service search)
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
432 "Return the buffer name where to present search results.
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
433 SERVICE is the D-Bus unique service name of the Xesam search engine.
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
434 SEARCH is the search identification in that engine. Both must be strings."
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
435 (format "*%s/%s*" service search))
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
436
97038
b201d17750ad * net/xesam.el (xesam-from): Remove defvar.
Michael Albinus <michael.albinus@gmx.de>
parents: 96996
diff changeset
437 (defun xesam-refresh-entry (engine search)
96989
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
438 "Refreshes one entry in the search buffer."
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
439 (let* ((result
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
440 (car
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
441 (dbus-call-method
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
442 :session (car engine) xesam-path-search
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
443 xesam-interface-search "GetHits" search 1)))
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
444 (snippet)
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
445 ;; We must disable this for the time being; the search
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
446 ;; engines don't return usable values so far.
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
447 ; (caaar
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
448 ; (dbus-ignore-errors
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
449 ; (dbus-call-method
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
450 ; :session (car engine) xesam-path-search
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
451 ; xesam-interface-search "GetHitData"
97038
b201d17750ad * net/xesam.el (xesam-from): Remove defvar.
Michael Albinus <michael.albinus@gmx.de>
parents: 96996
diff changeset
452 ; search (list xesam-current) '("snippet")))))
96989
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
453 widget)
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
454
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
455 ;; Create widget.
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
456 (setq widget (widget-convert 'link))
97038
b201d17750ad * net/xesam.el (xesam-from): Remove defvar.
Michael Albinus <michael.albinus@gmx.de>
parents: 96996
diff changeset
457 (when xesam-debug
b201d17750ad * net/xesam.el (xesam-from): Remove defvar.
Michael Albinus <michael.albinus@gmx.de>
parents: 96996
diff changeset
458 (widget-put widget :help-echo ""))
96989
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
459
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
460 ;; Take all results.
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
461 (dolist (field (xesam-get-property engine "hit.fields"))
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
462 (when (not (zerop (length (caar result))))
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
463 (when xesam-debug
97038
b201d17750ad * net/xesam.el (xesam-from): Remove defvar.
Michael Albinus <michael.albinus@gmx.de>
parents: 96996
diff changeset
464 (widget-put
b201d17750ad * net/xesam.el (xesam-from): Remove defvar.
Michael Albinus <michael.albinus@gmx.de>
parents: 96996
diff changeset
465 widget :help-echo
b201d17750ad * net/xesam.el (xesam-from): Remove defvar.
Michael Albinus <michael.albinus@gmx.de>
parents: 96996
diff changeset
466 (format "%s%s: %s\n"
b201d17750ad * net/xesam.el (xesam-from): Remove defvar.
Michael Albinus <michael.albinus@gmx.de>
parents: 96996
diff changeset
467 (widget-get widget :help-echo) field (caar result))))
96989
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
468 (widget-put widget (intern (concat ":" field)) (caar result)))
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
469 (setq result (cdr result)))
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
470
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
471 ;; Strigi doesn't return URLs in xesam:url. We must fix this.
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
472 (when
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
473 (not (url-type (url-generic-parse-url (widget-get widget :xesam:url))))
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
474 (widget-put
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
475 widget :xesam:url (concat "file://" (widget-get widget :xesam:url))))
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
476
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
477 ;; First line: :tag.
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
478 (cond
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
479 ((widget-member widget :xesam:title)
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
480 (widget-put widget :tag (widget-get widget :xesam:title)))
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
481 ((widget-member widget :xesam:subject)
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
482 (widget-put widget :tag (widget-get widget :xesam:subject)))
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
483 ((widget-member widget :xesam:mimeType)
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
484 (widget-put widget :tag (widget-get widget :xesam:mimeType)))
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
485 ((widget-member widget :xesam:name)
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
486 (widget-put widget :tag (widget-get widget :xesam:name))))
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
487
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
488 ;; Last Modified.
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
489 (when (widget-member widget :xesam:sourceModified)
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
490 (widget-put
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
491 widget :tag
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
492 (format
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
493 "%s\nLast Modified: %s"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
494 (or (widget-get widget :tag) "")
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
495 (format-time-string
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
496 "%d %B %Y, %T"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
497 (seconds-to-time
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
498 (string-to-number (widget-get widget :xesam:sourceModified)))))))
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
499
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
500 ;; Second line: :value.
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
501 (widget-put widget :value (widget-get widget :xesam:url))
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
502
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
503 (cond
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
504 ;; In case of HTML, we use a URL link.
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
505 ((and (widget-member widget :xesam:mimeType)
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
506 (string-equal "text/html" (widget-get widget :xesam:mimeType)))
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
507 (setcar widget 'url-link))
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
508
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
509 ;; For local files, we will open the file as default action.
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
510 ((string-match "file"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
511 (url-type (url-generic-parse-url
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
512 (widget-get widget :xesam:url))))
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
513 (widget-put
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
514 widget :notify
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
515 '(lambda (widget &rest ignore)
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
516 (find-file
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
517 (url-filename (url-generic-parse-url (widget-value widget))))))
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
518 (widget-put
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
519 widget :value
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
520 (url-filename (url-generic-parse-url (widget-get widget :xesam:url))))))
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
521
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
522 ;; Third line: :doc.
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
523 (cond
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
524 ((widget-member widget :xesam:summary)
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
525 (widget-put widget :doc (widget-get widget :xesam:summary)))
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
526 ((widget-member widget :xesam:snippet)
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
527 (widget-put widget :doc (widget-get widget :xesam:snippet))))
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
528
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
529 (when (widget-member widget :doc)
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
530 (widget-put widget :help-echo (widget-get widget :doc))
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
531 (with-temp-buffer
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
532 (insert (widget-get widget :doc))
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
533 (fill-region-as-paragraph (point-min) (point-max))
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
534 (widget-put widget :doc (buffer-string))))
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
535
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
536 ;; Format the widget.
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
537 (widget-put
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
538 widget :format
97038
b201d17750ad * net/xesam.el (xesam-from): Remove defvar.
Michael Albinus <michael.albinus@gmx.de>
parents: 96996
diff changeset
539 (format "%d. %s%%[%%v%%]\n%s\n" xesam-current
96989
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
540 (if (widget-member widget :tag) "%{%t%}\n" "")
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
541 (if (widget-member widget :doc) "%h" "")))
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
542
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
543 ;; Write widget.
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
544 (goto-char (point-max))
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
545 (widget-default-create widget)
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
546 (set-buffer-modified-p nil)
97038
b201d17750ad * net/xesam.el (xesam-from): Remove defvar.
Michael Albinus <michael.albinus@gmx.de>
parents: 96996
diff changeset
547 (force-mode-line-update)
96989
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
548 (redisplay)))
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
549
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
550 (defun xesam-refresh-search-buffer (engine search)
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
551 "Refreshes the buffer, presenting results of SEARCH."
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
552 (with-current-buffer (xesam-buffer-name (car engine) search)
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
553 ;; Work only if nobody else is here.
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
554 (unless xesam-refreshing
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
555 (setq xesam-refreshing t)
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
556 (unwind-protect
97038
b201d17750ad * net/xesam.el (xesam-from): Remove defvar.
Michael Albinus <michael.albinus@gmx.de>
parents: 96996
diff changeset
557 (let (widget updated)
96989
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
558 ;; Add all result widgets. The upper boundary is always
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
559 ;; computed, because new hits might have arrived while
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
560 ;; running.
97038
b201d17750ad * net/xesam.el (xesam-from): Remove defvar.
Michael Albinus <michael.albinus@gmx.de>
parents: 96996
diff changeset
561 (while (< xesam-current (min xesam-to xesam-count))
b201d17750ad * net/xesam.el (xesam-from): Remove defvar.
Michael Albinus <michael.albinus@gmx.de>
parents: 96996
diff changeset
562 (setq updated t
b201d17750ad * net/xesam.el (xesam-from): Remove defvar.
Michael Albinus <michael.albinus@gmx.de>
parents: 96996
diff changeset
563 xesam-current (1+ xesam-current))
b201d17750ad * net/xesam.el (xesam-from): Remove defvar.
Michael Albinus <michael.albinus@gmx.de>
parents: 96996
diff changeset
564 (xesam-refresh-entry engine search))
96989
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
565
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
566 ;; Add "NEXT" widget.
97038
b201d17750ad * net/xesam.el (xesam-from): Remove defvar.
Michael Albinus <michael.albinus@gmx.de>
parents: 96996
diff changeset
567 (when (and updated (> xesam-count xesam-to))
96989
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
568 (goto-char (point-max))
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
569 (widget-create
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
570 'link
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
571 :notify
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
572 '(lambda (widget &rest ignore)
97038
b201d17750ad * net/xesam.el (xesam-from): Remove defvar.
Michael Albinus <michael.albinus@gmx.de>
parents: 96996
diff changeset
573 (setq xesam-to (+ xesam-to xesam-hits-per-page))
96989
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
574 (widget-delete widget)
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
575 (xesam-refresh-search-buffer xesam-engine xesam-search))
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
576 "NEXT")
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
577 (widget-beginning-of-line)))
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
578
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
579 ;; Return with save settings.
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
580 (setq xesam-refreshing nil)))))
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
581
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
582
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
583 ;;; Search functions.
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
584
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
585 (defun xesam-signal-handler (&rest args)
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
586 "Handles the different D-Bus signals of a Xesam search."
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
587 (let* ((service (dbus-event-service-name last-input-event))
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
588 (member (dbus-event-member-name last-input-event))
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
589 (search (nth 0 args))
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
590 (buffer (xesam-buffer-name service search)))
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
591
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
592 (when (get-buffer buffer)
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
593 (with-current-buffer buffer
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
594 (cond
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
595
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
596 ((string-equal member "HitsAdded")
97038
b201d17750ad * net/xesam.el (xesam-from): Remove defvar.
Michael Albinus <michael.albinus@gmx.de>
parents: 96996
diff changeset
597 (setq xesam-count (+ xesam-count (nth 1 args)))
96989
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
598 ;; We use `run-at-time' in order to not block the event queue.
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
599 (run-at-time
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
600 0 nil
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
601 'xesam-refresh-search-buffer
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
602 (assoc service xesam-search-engines) search))
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
603
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
604 ((string-equal member "SearchDone")
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
605 (setq mode-line-process
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
606 (propertize " Done" 'face 'font-lock-type-face))
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
607 (force-mode-line-update)))))))
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
608
97170
dfc12ea9589f * net/xesam.el (xesam-type, xesam-query, xesam-xml-string): New
Michael Albinus <michael.albinus@gmx.de>
parents: 97038
diff changeset
609 (defun xesam-new-search (engine type query)
96989
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
610 "Create a new search session.
97170
dfc12ea9589f * net/xesam.el (xesam-type, xesam-query, xesam-xml-string): New
Michael Albinus <michael.albinus@gmx.de>
parents: 97038
diff changeset
611 ENGINE identifies the search engine. TYPE is the query type, it
dfc12ea9589f * net/xesam.el (xesam-type, xesam-query, xesam-xml-string): New
Michael Albinus <michael.albinus@gmx.de>
parents: 97038
diff changeset
612 can be either `fulltext-query', or `user-query'. QUERY is a
dfc12ea9589f * net/xesam.el (xesam-type, xesam-query, xesam-xml-string): New
Michael Albinus <michael.albinus@gmx.de>
parents: 97038
diff changeset
613 string in the Xesam query language. A string, identifying the
dfc12ea9589f * net/xesam.el (xesam-type, xesam-query, xesam-xml-string): New
Michael Albinus <michael.albinus@gmx.de>
parents: 97038
diff changeset
614 search, is returned."
96989
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
615 (let* ((service (car engine))
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
616 (session (cdr engine))
97170
dfc12ea9589f * net/xesam.el (xesam-type, xesam-query, xesam-xml-string): New
Michael Albinus <michael.albinus@gmx.de>
parents: 97038
diff changeset
617 (xml-string
dfc12ea9589f * net/xesam.el (xesam-type, xesam-query, xesam-xml-string): New
Michael Albinus <michael.albinus@gmx.de>
parents: 97038
diff changeset
618 (format
dfc12ea9589f * net/xesam.el (xesam-type, xesam-query, xesam-xml-string): New
Michael Albinus <michael.albinus@gmx.de>
parents: 97038
diff changeset
619 (if (eq type 'user-query) xesam-user-query xesam-fulltext-query)
dfc12ea9589f * net/xesam.el (xesam-type, xesam-query, xesam-xml-string): New
Michael Albinus <michael.albinus@gmx.de>
parents: 97038
diff changeset
620 query))
96989
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
621 (search (dbus-call-method
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
622 :session service xesam-path-search
97170
dfc12ea9589f * net/xesam.el (xesam-type, xesam-query, xesam-xml-string): New
Michael Albinus <michael.albinus@gmx.de>
parents: 97038
diff changeset
623 xesam-interface-search "NewSearch" session xml-string)))
97038
b201d17750ad * net/xesam.el (xesam-from): Remove defvar.
Michael Albinus <michael.albinus@gmx.de>
parents: 96996
diff changeset
624
96989
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
625 ;; Let us notify for relevant signals. We ignore "HitsRemoved",
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
626 ;; "HitsModified" and "StateChanged"; there is nothing to do for
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
627 ;; us.
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
628 (dbus-register-signal
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
629 :session service xesam-path-search
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
630 xesam-interface-search "HitsAdded"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
631 'xesam-signal-handler search)
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
632 (dbus-register-signal
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
633 :session service xesam-path-search
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
634 xesam-interface-search "SearchDone"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
635 'xesam-signal-handler search)
97038
b201d17750ad * net/xesam.el (xesam-from): Remove defvar.
Michael Albinus <michael.albinus@gmx.de>
parents: 96996
diff changeset
636
96989
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
637 ;; Create the search buffer.
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
638 (with-current-buffer
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
639 (generate-new-buffer (xesam-buffer-name service search))
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
640 (switch-to-buffer-other-window (current-buffer))
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
641 (xesam-mode)
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
642 (setq xesam-engine engine
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
643 xesam-search search
97170
dfc12ea9589f * net/xesam.el (xesam-type, xesam-query, xesam-xml-string): New
Michael Albinus <michael.albinus@gmx.de>
parents: 97038
diff changeset
644 ;; `xesam-type', `xesam-query' and `xesam-xml-string'
dfc12ea9589f * net/xesam.el (xesam-type, xesam-query, xesam-xml-string): New
Michael Albinus <michael.albinus@gmx.de>
parents: 97038
diff changeset
645 ;; are displayed in the header line.
dfc12ea9589f * net/xesam.el (xesam-type, xesam-query, xesam-xml-string): New
Michael Albinus <michael.albinus@gmx.de>
parents: 97038
diff changeset
646 xesam-type (symbol-name type)
dfc12ea9589f * net/xesam.el (xesam-type, xesam-query, xesam-xml-string): New
Michael Albinus <michael.albinus@gmx.de>
parents: 97038
diff changeset
647 xesam-query query
dfc12ea9589f * net/xesam.el (xesam-type, xesam-query, xesam-xml-string): New
Michael Albinus <michael.albinus@gmx.de>
parents: 97038
diff changeset
648 xesam-xml-string xml-string
97038
b201d17750ad * net/xesam.el (xesam-from): Remove defvar.
Michael Albinus <michael.albinus@gmx.de>
parents: 96996
diff changeset
649 ;; The buffer identification shall indicate the search
b201d17750ad * net/xesam.el (xesam-from): Remove defvar.
Michael Albinus <michael.albinus@gmx.de>
parents: 96996
diff changeset
650 ;; engine. The `help-echo' property is used for debug
b201d17750ad * net/xesam.el (xesam-from): Remove defvar.
Michael Albinus <michael.albinus@gmx.de>
parents: 96996
diff changeset
651 ;; information, when applicable.
96989
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
652 mode-line-buffer-identification
97038
b201d17750ad * net/xesam.el (xesam-from): Remove defvar.
Michael Albinus <michael.albinus@gmx.de>
parents: 96996
diff changeset
653 (if (not xesam-debug)
b201d17750ad * net/xesam.el (xesam-from): Remove defvar.
Michael Albinus <michael.albinus@gmx.de>
parents: 96996
diff changeset
654 (list
b201d17750ad * net/xesam.el (xesam-from): Remove defvar.
Michael Albinus <michael.albinus@gmx.de>
parents: 96996
diff changeset
655 12 (propertized-buffer-identification
b201d17750ad * net/xesam.el (xesam-from): Remove defvar.
Michael Albinus <michael.albinus@gmx.de>
parents: 96996
diff changeset
656 (xesam-get-property engine "vendor.id")))
b201d17750ad * net/xesam.el (xesam-from): Remove defvar.
Michael Albinus <michael.albinus@gmx.de>
parents: 96996
diff changeset
657 (propertize
b201d17750ad * net/xesam.el (xesam-from): Remove defvar.
Michael Albinus <michael.albinus@gmx.de>
parents: 96996
diff changeset
658 (xesam-get-property engine "vendor.id") 'help-echo
b201d17750ad * net/xesam.el (xesam-from): Remove defvar.
Michael Albinus <michael.albinus@gmx.de>
parents: 96996
diff changeset
659 (mapconcat
b201d17750ad * net/xesam.el (xesam-from): Remove defvar.
Michael Albinus <michael.albinus@gmx.de>
parents: 96996
diff changeset
660 '(lambda (x) (format "%s: %s" x (xesam-get-property engine x)))
b201d17750ad * net/xesam.el (xesam-from): Remove defvar.
Michael Albinus <michael.albinus@gmx.de>
parents: 96996
diff changeset
661 '("vendor.id" "vendor.version" "vendor.display" "vendor.xesam"
b201d17750ad * net/xesam.el (xesam-from): Remove defvar.
Michael Albinus <michael.albinus@gmx.de>
parents: 96996
diff changeset
662 "vendor.ontology.fields" "vendor.ontology.contents"
b201d17750ad * net/xesam.el (xesam-from): Remove defvar.
Michael Albinus <michael.albinus@gmx.de>
parents: 96996
diff changeset
663 "vendor.ontology.sources" "vendor.extensions"
b201d17750ad * net/xesam.el (xesam-from): Remove defvar.
Michael Albinus <michael.albinus@gmx.de>
parents: 96996
diff changeset
664 "vendor.ontologies" "vendor.maxhits")
97170
dfc12ea9589f * net/xesam.el (xesam-type, xesam-query, xesam-xml-string): New
Michael Albinus <michael.albinus@gmx.de>
parents: 97038
diff changeset
665 "\n"))))
dfc12ea9589f * net/xesam.el (xesam-type, xesam-query, xesam-xml-string): New
Michael Albinus <michael.albinus@gmx.de>
parents: 97038
diff changeset
666 (force-mode-line-update))
dfc12ea9589f * net/xesam.el (xesam-type, xesam-query, xesam-xml-string): New
Michael Albinus <michael.albinus@gmx.de>
parents: 97038
diff changeset
667
dfc12ea9589f * net/xesam.el (xesam-type, xesam-query, xesam-xml-string): New
Michael Albinus <michael.albinus@gmx.de>
parents: 97038
diff changeset
668 ;; Start the search.
dfc12ea9589f * net/xesam.el (xesam-type, xesam-query, xesam-xml-string): New
Michael Albinus <michael.albinus@gmx.de>
parents: 97038
diff changeset
669 (dbus-call-method
dfc12ea9589f * net/xesam.el (xesam-type, xesam-query, xesam-xml-string): New
Michael Albinus <michael.albinus@gmx.de>
parents: 97038
diff changeset
670 :session (car engine) xesam-path-search
dfc12ea9589f * net/xesam.el (xesam-type, xesam-query, xesam-xml-string): New
Michael Albinus <michael.albinus@gmx.de>
parents: 97038
diff changeset
671 xesam-interface-search "StartSearch" search)
96989
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
672
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
673 ;; Return search id.
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
674 search))
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
675
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
676 (defun xesam-search (engine query)
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
677 "Perform an interactive search.
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
678 ENGINE is the Xesam search engine to be applied, it must be one of the
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
679 entries of `xesam-search-engines'. QUERY is the search string in the
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
680 Xesam user query language. If the search engine does not support
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
681 the Xesam user query language, a Xesam fulltext search is applied.
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
682
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
683 The default search engine is the first entry in `xesam-search-engines'.
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
684 Example:
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
685
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
686 (xesam-search (car (xesam-search-engines)) \"emacs\")"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
687 (interactive
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
688 (let* ((vendors (mapcar
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
689 '(lambda (x) (xesam-get-property x "vendor.display"))
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
690 (xesam-search-engines)))
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
691 (vendor
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
692 (if (> (length vendors) 1)
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
693 (completing-read
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
694 "Enter search engine: " vendors nil t
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
695 (try-completion "" vendors) 'xesam-minibuffer-vendor-history)
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
696 (car vendors))))
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
697 (list
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
698 ;; ENGINE.
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
699 (when vendor
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
700 (dolist (elt (xesam-search-engines) engine)
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
701 (when (string-equal (xesam-get-property elt "vendor.display") vendor)
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
702 (setq engine elt))))
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
703 ;; QUERY.
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
704 (when vendor
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
705 (read-from-minibuffer
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
706 "Enter search string: " nil nil nil
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
707 'xesam-minibuffer-query-history)))))
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
708
97170
dfc12ea9589f * net/xesam.el (xesam-type, xesam-query, xesam-xml-string): New
Michael Albinus <michael.albinus@gmx.de>
parents: 97038
diff changeset
709 (if (null engine)
dfc12ea9589f * net/xesam.el (xesam-type, xesam-query, xesam-xml-string): New
Michael Albinus <michael.albinus@gmx.de>
parents: 97038
diff changeset
710 (message "No search engine running")
dfc12ea9589f * net/xesam.el (xesam-type, xesam-query, xesam-xml-string): New
Michael Albinus <michael.albinus@gmx.de>
parents: 97038
diff changeset
711 (if (zerop (length query))
dfc12ea9589f * net/xesam.el (xesam-type, xesam-query, xesam-xml-string): New
Michael Albinus <michael.albinus@gmx.de>
parents: 97038
diff changeset
712 (message "No query applied")
dfc12ea9589f * net/xesam.el (xesam-type, xesam-query, xesam-xml-string): New
Michael Albinus <michael.albinus@gmx.de>
parents: 97038
diff changeset
713 (xesam-new-search engine xesam-query-type query))))
96989
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
714
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
715 (provide 'xesam)
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
716
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
717 ;;; TODO:
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
718
97170
dfc12ea9589f * net/xesam.el (xesam-type, xesam-query, xesam-xml-string): New
Michael Albinus <michael.albinus@gmx.de>
parents: 97038
diff changeset
719 ;; * Solve error, that xesam-mode does not work the very first time.
96989
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
720 ;; * Retrieve several results at once.
97170
dfc12ea9589f * net/xesam.el (xesam-type, xesam-query, xesam-xml-string): New
Michael Albinus <michael.albinus@gmx.de>
parents: 97038
diff changeset
721 ;; * Retrieve hits for the next page in advance.
dfc12ea9589f * net/xesam.el (xesam-type, xesam-query, xesam-xml-string): New
Michael Albinus <michael.albinus@gmx.de>
parents: 97038
diff changeset
722 ;; * With prefix, let's chosse search engine.
96989
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
723 ;; * Improve mode-line handling. Show search string etc.
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
724 ;; * Minibuffer completion for user queries.
97038
b201d17750ad * net/xesam.el (xesam-from): Remove defvar.
Michael Albinus <michael.albinus@gmx.de>
parents: 96996
diff changeset
725 ;; * `revert-buffer-function' implementation.
b201d17750ad * net/xesam.el (xesam-from): Remove defvar.
Michael Albinus <michael.albinus@gmx.de>
parents: 96996
diff changeset
726 ;; * Close search when search buffer is killed.
b201d17750ad * net/xesam.el (xesam-from): Remove defvar.
Michael Albinus <michael.albinus@gmx.de>
parents: 96996
diff changeset
727 ;;
96989
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
728 ;; * Mid term
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
729 ;; - If available, use ontologies for field selection.
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
730 ;; - Search engines for Emacs bugs database, wikipedia, google,
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
731 ;; yahoo, ebay, ...
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
732
96996
3035988dd0b3 Add arch tagline
Miles Bader <miles@gnu.org>
parents: 96989
diff changeset
733 ;; arch-tag: 7fb9fc6c-c2ff-4bc7-bb42-bacb80cce2b2
96989
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
734 ;;; xesam.el ends here