annotate lisp/net/xesam.el @ 97390:11deca4a880b

(org-renumber-ordered-list): Fix bob/bobp typo. (org-extract-attributes): Let-bind `key', `value'. (org-make-tags-matcher): Let-bind `time-p'.
author Glenn Morris <rgm@gnu.org>
date Sun, 10 Aug 2008 01:27:40 +0000
parents 22514244a76d
children 7806c35019cb
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
97381
22514244a76d Standardize license layout.
Glenn Morris <rgm@gnu.org>
parents: 97289
diff changeset
10 ;; GNU Emacs is free software: you can redistribute it and/or modify
96989
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
97381
22514244a76d Standardize license layout.
Glenn Morris <rgm@gnu.org>
parents: 97289
diff changeset
12 ;; the Free Software Foundation, either version 3 of the License, or
22514244a76d Standardize license layout.
Glenn Morris <rgm@gnu.org>
parents: 97289
diff changeset
13 ;; (at your option) any later version.
96989
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
97381
22514244a76d Standardize license layout.
Glenn Morris <rgm@gnu.org>
parents: 97289
diff changeset
21 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
96989
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
22
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
23 ;;; Commentary:
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
24
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
25 ;; 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
26 ;; Search And Metadata specification". It has been tested with
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
27 ;;
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
28 ;; 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
29 ;; 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
30 ;; strigi 0.5.11
96989
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
31
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
32 ;; 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
33 ;; 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
34 ;; 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
35 ;; 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
36 ;; 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
37 ;; 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
38 ;;
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
39 ;; (dbus-list-queued-owners :session "org.freedesktop.xesam.searcher")
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
40
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
41 ;; 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
42 ;;
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
43 ;; (require 'xesam)
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
44
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
45 ;; 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
46 ;;
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
47 ;; * 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
48 ;;
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
49 ;; hello world
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
50 ;;
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
51 ;; 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
52 ;;
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
53 ;; * 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
54 ;; is described at <http://xesam.org/main/XesamUserSearchLanguage>,
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
55 ;; which must be consulted for the whole features.
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
56 ;;
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
57 ;; A query string consists of search keys, collectors, selectors,
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
58 ;; 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
59 ;;
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
60 ;; hello word
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
61 ;;
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
62 ;; 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
63 ;; predefined Xesam keyword, the most common keywords are "ext"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
64 ;; (file name extension), "format " (mime type), "tag" (user
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
65 ;; keywords) and "type" (types of items, like "audio", "file",
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
66 ;; "picture", "attachment"). <relation> is a comparison to a value,
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
67 ;; 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
68 ;; "<=", ">=", "<", ">"):
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 ;; type:attachment ext=el
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
71 ;;
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
72 ;; 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
73 ;; "||", or "-". The default collector on multiple terms is "AND";
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
74 ;; "-" means "AND NOT".
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
75 ;;
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
76 ;; albinus -type:file
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
77 ;;
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
78 ;; 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
79 ;; (single letters). Examples of modifiers are "c" (case
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
80 ;; sensitive), "C" (case insensitive), "e" (exact match), "r"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
81 ;; (regular expression):
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
82 ;;
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
83 ;; "Hello world"c
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
84
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
85 ;; 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
86 ;; 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
87 ;; both query types.
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
88 ;;
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
89 ;; (setq xesam-query-type 'fulltext-query)
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
90 ;;
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
91 ;; 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
92 ;; presented at once.
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
93 ;;
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
94 ;; (setq xesam-hits-per-page 50)
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
95
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
96 ;; A search can be started by the command
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
97 ;;
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
98 ;; M-x xesam-search
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
99 ;;
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
100 ;; 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
101 ;; can be selected via minibuffer completion. Afterwards, the query
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
102 ;; shall be entered in the minibuffer.
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
103
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
104 ;;; Code:
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
105
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
106 ;; 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
107 ;; option "--without-dbus". Declare used subroutines and variables.
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
108 (declare-function dbus-call-method "dbusbind.c")
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
109 (declare-function dbus-register-signal "dbusbind.c")
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
110
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
111 (require 'dbus)
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
112
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
113 ;; Pacify byte compiler.
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
114 (eval-when-compile
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
115 (require 'cl))
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
116
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
117 ;; Widgets are used to highlight the search results.
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
118 (require 'widget)
97289
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
119 (require 'wid-edit)
96989
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 ;; `run-at-time' is used in the signal handler.
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
122 (require 'timer)
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 ;; 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
125 (require 'url)
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 (defgroup xesam nil
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
128 "Xesam compatible interface to search engines."
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
129 :group 'extensions
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
130 :group 'hypermedia
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
131 :version "23.1")
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
132
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
133 (defcustom xesam-query-type 'user-query
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
134 "Xesam query language type."
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
135 :group 'xesam
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
136 :type '(choice
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
137 (const :tag "Xesam user query" user-query)
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
138 (const :tag "Xesam fulltext query" fulltext-query)))
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
139
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
140 (defcustom xesam-hits-per-page 20
97289
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
141 "Number of search hits to be displayed in the result buffer."
96989
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
142 :group 'xesam
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
143 :type 'integer)
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
144
97289
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
145 (defface xesam-mode-line '((t :inherit mode-line-emphasis))
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
146 "Face to highlight mode line."
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
147 :group 'xesam)
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
148
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
149 (defface xesam-highlight '((t :inherit match))
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
150 "Face to highlight query entries.
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
151 It will be overlayed by `widget-documentation-face', so it shall
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
152 be different at least in one face property not set in that face."
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
153 :group 'xesam)
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
154
96989
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
155 (defvar xesam-debug nil
97038
b201d17750ad * net/xesam.el (xesam-from): Remove defvar.
Michael Albinus <michael.albinus@gmx.de>
parents: 96996
diff changeset
156 "Insert debug information in the help echo.")
96989
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
157
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
158 (defconst xesam-service-search "org.freedesktop.xesam.searcher"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
159 "The D-Bus name used to talk to Xesam.")
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
160
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
161 (defconst xesam-path-search "/org/freedesktop/xesam/searcher/main"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
162 "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
163
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
164 ;; Methods: "NewSession", "SetProperty", "GetProperty",
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
165 ;; "CloseSession", "NewSearch", "StartSearch", "GetHitCount",
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
166 ;; "GetHits", "GetHitData", "CloseSearch" and "GetState".
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
167 ;; Signals: "HitsAdded", "HitsRemoved", "HitsModified", "SearchDone"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
168 ;; and "StateChanged".
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
169 (defconst xesam-interface-search "org.freedesktop.xesam.Search"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
170 "The D-Bus Xesam search interface.")
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
171
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
172 (defconst xesam-all-fields
97214
004f6dc1c1a0 * net/xesam.el (xesam-all-fields): Remove source and content
Michael Albinus <michael.albinus@gmx.de>
parents: 97170
diff changeset
173 '("xesam:35mmEquivalent" "xesam:aimContactMedium" "xesam:aperture"
004f6dc1c1a0 * net/xesam.el (xesam-all-fields): Remove source and content
Michael Albinus <michael.albinus@gmx.de>
parents: 97170
diff changeset
174 "xesam:aspectRatio" "xesam:attachmentEncoding" "xesam:attendee"
004f6dc1c1a0 * net/xesam.el (xesam-all-fields): Remove source and content
Michael Albinus <michael.albinus@gmx.de>
parents: 97170
diff changeset
175 "xesam:audioBirate" "xesam:audioChannels" "xesam:audioCodec"
004f6dc1c1a0 * net/xesam.el (xesam-all-fields): Remove source and content
Michael Albinus <michael.albinus@gmx.de>
parents: 97170
diff changeset
176 "xesam:audioCodecType" "xesam:audioSampleFormat" "xesam:audioSampleRate"
004f6dc1c1a0 * net/xesam.el (xesam-all-fields): Remove source and content
Michael Albinus <michael.albinus@gmx.de>
parents: 97170
diff changeset
177 "xesam:author" "xesam:bcc" "xesam:birthDate" "xesam:blogContactURL"
96989
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
178 "xesam:cameraManufacturer" "xesam:cameraModel" "xesam:cc" "xesam:ccdWidth"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
179 "xesam:cellPhoneNumber" "xesam:characterCount" "xesam:charset"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
180 "xesam:colorCount" "xesam:colorSpace" "xesam:columnCount" "xesam:comment"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
181 "xesam:commentCharacterCount" "xesam:conflicts" "xesam:contactMedium"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
182 "xesam:contactName" "xesam:contactNick" "xesam:contactPhoto"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
183 "xesam:contactURL" "xesam:contains" "xesam:contenKeyword"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
184 "xesam:contentComment" "xesam:contentCreated" "xesam:contentModified"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
185 "xesam:contentType" "xesam:contributor" "xesam:copyright" "xesam:creator"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
186 "xesam:definesClass" "xesam:definesFunction" "xesam:definesGlobalVariable"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
187 "xesam:deletionTime" "xesam:depends" "xesam:description" "xesam:device"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
188 "xesam:disclaimer" "xesam:documentCategory" "xesam:duration"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
189 "xesam:emailAddress" "xesam:eventEnd" "xesam:eventLocation"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
190 "xesam:eventStart" "xesam:exposureBias" "xesam:exposureProgram"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
191 "xesam:exposureTime" "xesam:faxPhoneNumber" "xesam:fileExtension"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
192 "xesam:fileSystemType" "xesam:flashUsed" "xesam:focalLength"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
193 "xesam:focusDistance" "xesam:formatSubtype" "xesam:frameCount"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
194 "xesam:frameRate" "xesam:freeSpace" "xesam:gender" "xesam:generator"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
195 "xesam:generatorOptions" "xesam:group" "xesam:hash" "xesam:hash"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
196 "xesam:height" "xesam:homeEmailAddress" "xesam:homePhoneNumber"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
197 "xesam:homePostalAddress" "xesam:homepageContactURL"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
198 "xesam:horizontalResolution" "xesam:icqContactMedium" "xesam:id"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
199 "xesam:imContactMedium" "xesam:interests" "xesam:interlaceMode"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
200 "xesam:isEncrypted" "xesam:isImportant" "xesam:isInProgress"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
201 "xesam:isPasswordProtected" "xesam:isRead" "xesam:isoEquivalent"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
202 "xesam:jabberContactMedium" "xesam:keyword" "xesam:language" "xesam:legal"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
203 "xesam:license" "xesam:licenseType" "xesam:lineCount" "xesam:links"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
204 "xesam:mailingPostalAddress" "xesam:maintainer" "xesam:md5Hash"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
205 "xesam:mediaCodec" "xesam:mediaCodecBitrate" "xesam:mediaCodecType"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
206 "xesam:meteringMode" "xesam:mimeType" "xesam:mountPoint"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
207 "xesam:msnContactMedium" "xesam:name" "xesam:occupiedSpace"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
208 "xesam:orientation" "xesam:originalLocation" "xesam:owner"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
209 "xesam:pageCount" "xesam:permissions" "xesam:phoneNumber"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
210 "xesam:physicalAddress" "xesam:pixelFormat" "xesam:primaryRecipient"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
211 "xesam:programmingLanguage" "xesam:rating" "xesam:receptionTime"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
212 "xesam:recipient" "xesam:related" "xesam:remoteUser" "xesam:rowCount"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
213 "xesam:sampleBitDepth" "xesam:sampleFormat" "xesam:secondaryRecipient"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
214 "xesam:sha1Hash" "xesam:size" "xesam:skypeContactMedium"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
215 "xesam:sourceCreated" "xesam:sourceModified" "xesam:storageSize"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
216 "xesam:subject" "xesam:supercedes" "xesam:title" "xesam:to"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
217 "xesam:totalSpace" "xesam:totalUncompressedSize" "xesam:url"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
218 "xesam:usageIntensity" "xesam:userComment" "xesam:userKeyword"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
219 "xesam:uuid" "xesam:version" "xesam:verticalResolution" "xesam:videoBirate"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
220 "xesam:videoCodec" "xesam:videoCodecType" "xesam:whiteBalance"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
221 "xesam:width" "xesam:wordCount" "xesam:workEmailAddress"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
222 "xesam:workPhoneNumber" "xesam:workPostalAddress"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
223 "xesam:yahooContactMedium")
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
224 "All fields from the Xesam Core Ontology.
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
225 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
226 fields are supported.")
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
227
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
228 (defconst xesam-user-query
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
229 "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
230 <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
231 <userQuery>
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
232 %s
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 </request>"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
235 "The Xesam user query XML.")
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
236
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
237 (defconst xesam-fulltext-query
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
238 "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
239 <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
240 <query content=\"xesam:Document\" source=\"xesam:File\">
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
241 <fullText>
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
242 <string>%s</string>
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 </query>
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
245 </request>"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
246 "The Xesam fulltext query XML.")
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
247
97214
004f6dc1c1a0 * net/xesam.el (xesam-all-fields): Remove source and content
Michael Albinus <michael.albinus@gmx.de>
parents: 97170
diff changeset
248 (defvar xesam-dbus-unique-names
004f6dc1c1a0 * net/xesam.el (xesam-all-fields): Remove source and content
Michael Albinus <michael.albinus@gmx.de>
parents: 97170
diff changeset
249 (list (cons :system (dbus-get-unique-name :system))
004f6dc1c1a0 * net/xesam.el (xesam-all-fields): Remove source and content
Michael Albinus <michael.albinus@gmx.de>
parents: 97170
diff changeset
250 (cons :session (dbus-get-unique-name :session)))
004f6dc1c1a0 * net/xesam.el (xesam-all-fields): Remove source and content
Michael Albinus <michael.albinus@gmx.de>
parents: 97170
diff changeset
251 "The unique names, under which Emacs is registered at D-Bus.")
004f6dc1c1a0 * net/xesam.el (xesam-all-fields): Remove source and content
Michael Albinus <michael.albinus@gmx.de>
parents: 97170
diff changeset
252
004f6dc1c1a0 * net/xesam.el (xesam-all-fields): Remove source and content
Michael Albinus <michael.albinus@gmx.de>
parents: 97170
diff changeset
253 (defun xesam-dbus-call-method (&rest args)
004f6dc1c1a0 * net/xesam.el (xesam-all-fields): Remove source and content
Michael Albinus <michael.albinus@gmx.de>
parents: 97170
diff changeset
254 "Apply a D-Bus method call.
004f6dc1c1a0 * net/xesam.el (xesam-all-fields): Remove source and content
Michael Albinus <michael.albinus@gmx.de>
parents: 97170
diff changeset
255 `dbus-call-method' is to be preferred, because it is more
004f6dc1c1a0 * net/xesam.el (xesam-all-fields): Remove source and content
Michael Albinus <michael.albinus@gmx.de>
parents: 97170
diff changeset
256 performant. If the target D-Bus service is owned by Emacs, this
004f6dc1c1a0 * net/xesam.el (xesam-all-fields): Remove source and content
Michael Albinus <michael.albinus@gmx.de>
parents: 97170
diff changeset
257 is not applicable, and `dbus-call-method-non-blocking' must be
004f6dc1c1a0 * net/xesam.el (xesam-all-fields): Remove source and content
Michael Albinus <michael.albinus@gmx.de>
parents: 97170
diff changeset
258 used instead. ARGS are identical to the argument list of both
004f6dc1c1a0 * net/xesam.el (xesam-all-fields): Remove source and content
Michael Albinus <michael.albinus@gmx.de>
parents: 97170
diff changeset
259 functions."
004f6dc1c1a0 * net/xesam.el (xesam-all-fields): Remove source and content
Michael Albinus <michael.albinus@gmx.de>
parents: 97170
diff changeset
260 (apply
004f6dc1c1a0 * net/xesam.el (xesam-all-fields): Remove source and content
Michael Albinus <michael.albinus@gmx.de>
parents: 97170
diff changeset
261 ;; The first argument is the bus, the second argument the targt service.
004f6dc1c1a0 * net/xesam.el (xesam-all-fields): Remove source and content
Michael Albinus <michael.albinus@gmx.de>
parents: 97170
diff changeset
262 (if (string-equal (cdr (assoc (car args) xesam-dbus-unique-names))
004f6dc1c1a0 * net/xesam.el (xesam-all-fields): Remove source and content
Michael Albinus <michael.albinus@gmx.de>
parents: 97170
diff changeset
263 (cadr args))
004f6dc1c1a0 * net/xesam.el (xesam-all-fields): Remove source and content
Michael Albinus <michael.albinus@gmx.de>
parents: 97170
diff changeset
264 'dbus-call-method-non-blocking 'dbus-call-method)
004f6dc1c1a0 * net/xesam.el (xesam-all-fields): Remove source and content
Michael Albinus <michael.albinus@gmx.de>
parents: 97170
diff changeset
265 args))
004f6dc1c1a0 * net/xesam.el (xesam-all-fields): Remove source and content
Michael Albinus <michael.albinus@gmx.de>
parents: 97170
diff changeset
266
96989
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
267 (defun xesam-get-property (engine property)
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
268 "Return the PROPERTY value of ENGINE."
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
269 ;; "GetProperty" returns a variant, so we must use the car.
97214
004f6dc1c1a0 * net/xesam.el (xesam-all-fields): Remove source and content
Michael Albinus <michael.albinus@gmx.de>
parents: 97170
diff changeset
270 (car (xesam-dbus-call-method
96989
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
271 :session (car engine) xesam-path-search
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
272 xesam-interface-search "GetProperty"
97214
004f6dc1c1a0 * net/xesam.el (xesam-all-fields): Remove source and content
Michael Albinus <michael.albinus@gmx.de>
parents: 97170
diff changeset
273 (xesam-get-cached-property engine "session") property)))
96989
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 (defun xesam-set-property (engine property value)
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
276 "Set the PROPERTY of ENGINE to VALUE.
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
277 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
278 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
279 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
280 from VALUE, depending on what the search engine accepts."
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
281 ;; "SetProperty" returns a variant, so we must use the car.
97214
004f6dc1c1a0 * net/xesam.el (xesam-all-fields): Remove source and content
Michael Albinus <michael.albinus@gmx.de>
parents: 97170
diff changeset
282 (car (xesam-dbus-call-method
96989
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
283 :session (car engine) xesam-path-search
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
284 xesam-interface-search "SetProperty"
97214
004f6dc1c1a0 * net/xesam.el (xesam-all-fields): Remove source and content
Michael Albinus <michael.albinus@gmx.de>
parents: 97170
diff changeset
285 (xesam-get-cached-property engine "session") property
96989
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
286 ;; 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
287 ;; 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
288 ;; 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
289 ;; engine.
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
290 (list :variant value))))
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 (defvar xesam-minibuffer-vendor-history nil
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
293 "Interactive vendor history.")
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-minibuffer-query-history nil
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
296 "Interactive query history.")
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
297
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
298 ;; Pacify byte compiler.
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
299 (defvar xesam-engine nil)
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
300 (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
301 (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
302 (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
303 (defvar xesam-xml-string nil)
97289
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
304 (defvar xesam-objects nil)
96989
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
305 (defvar xesam-current nil)
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
306 (defvar xesam-count nil)
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
307 (defvar xesam-to nil)
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
308 (defvar xesam-refreshing nil)
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
309
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
310
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
311 ;;; 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 (defvar xesam-search-engines nil
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
314 "List of available Xesam search engines.
97214
004f6dc1c1a0 * net/xesam.el (xesam-all-fields): Remove source and content
Michael Albinus <michael.albinus@gmx.de>
parents: 97170
diff changeset
315 Every entry is an association list, with a car denoting the
004f6dc1c1a0 * net/xesam.el (xesam-all-fields): Remove source and content
Michael Albinus <michael.albinus@gmx.de>
parents: 97170
diff changeset
316 unique D-Bus service name of the engine. The rest of the entry
004f6dc1c1a0 * net/xesam.el (xesam-all-fields): Remove source and content
Michael Albinus <michael.albinus@gmx.de>
parents: 97170
diff changeset
317 are cached associations of engine attributes, like the session
004f6dc1c1a0 * net/xesam.el (xesam-all-fields): Remove source and content
Michael Albinus <michael.albinus@gmx.de>
parents: 97170
diff changeset
318 identifier, and the display name. Example:
96989
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
319
97214
004f6dc1c1a0 * net/xesam.el (xesam-all-fields): Remove source and content
Michael Albinus <michael.albinus@gmx.de>
parents: 97170
diff changeset
320 \(\(\":1.59\"
004f6dc1c1a0 * net/xesam.el (xesam-all-fields): Remove source and content
Michael Albinus <michael.albinus@gmx.de>
parents: 97170
diff changeset
321 \(\"session\" . \"0t1214948020ut358230u0p2698r3912347765k3213849828\")
004f6dc1c1a0 * net/xesam.el (xesam-all-fields): Remove source and content
Michael Albinus <michael.albinus@gmx.de>
parents: 97170
diff changeset
322 \(\"vendor.display\" . \"Tracker Xesam Service\"))
004f6dc1c1a0 * net/xesam.el (xesam-all-fields): Remove source and content
Michael Albinus <michael.albinus@gmx.de>
parents: 97170
diff changeset
323 \(\":1.27\"
004f6dc1c1a0 * net/xesam.el (xesam-all-fields): Remove source and content
Michael Albinus <michael.albinus@gmx.de>
parents: 97170
diff changeset
324 \(\"session\" . \"strigisession1369133069\")
004f6dc1c1a0 * net/xesam.el (xesam-all-fields): Remove source and content
Michael Albinus <michael.albinus@gmx.de>
parents: 97170
diff changeset
325 \(\"vendor.display\" . \"Strigi Desktop Search\")))
96989
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
326
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
327 A Xesam-compatible search engine is identified as a queued D-Bus
97214
004f6dc1c1a0 * net/xesam.el (xesam-all-fields): Remove source and content
Michael Albinus <michael.albinus@gmx.de>
parents: 97170
diff changeset
328 service of the known service `xesam-service-search'.")
004f6dc1c1a0 * net/xesam.el (xesam-all-fields): Remove source and content
Michael Albinus <michael.albinus@gmx.de>
parents: 97170
diff changeset
329
004f6dc1c1a0 * net/xesam.el (xesam-all-fields): Remove source and content
Michael Albinus <michael.albinus@gmx.de>
parents: 97170
diff changeset
330 (defun xesam-get-cached-property (engine property)
004f6dc1c1a0 * net/xesam.el (xesam-all-fields): Remove source and content
Michael Albinus <michael.albinus@gmx.de>
parents: 97170
diff changeset
331 "Return the PROPERTY value of ENGINE from the cache.
004f6dc1c1a0 * net/xesam.el (xesam-all-fields): Remove source and content
Michael Albinus <michael.albinus@gmx.de>
parents: 97170
diff changeset
332 If PROPERTY is not existing, retrieve it from ENGINE first."
004f6dc1c1a0 * net/xesam.el (xesam-all-fields): Remove source and content
Michael Albinus <michael.albinus@gmx.de>
parents: 97170
diff changeset
333 ;; If the property has not been cached yet, we retrieve it from the
004f6dc1c1a0 * net/xesam.el (xesam-all-fields): Remove source and content
Michael Albinus <michael.albinus@gmx.de>
parents: 97170
diff changeset
334 ;; engine, and cache it.
004f6dc1c1a0 * net/xesam.el (xesam-all-fields): Remove source and content
Michael Albinus <michael.albinus@gmx.de>
parents: 97170
diff changeset
335 (unless (assoc property engine)
004f6dc1c1a0 * net/xesam.el (xesam-all-fields): Remove source and content
Michael Albinus <michael.albinus@gmx.de>
parents: 97170
diff changeset
336 (xesam-set-cached-property
004f6dc1c1a0 * net/xesam.el (xesam-all-fields): Remove source and content
Michael Albinus <michael.albinus@gmx.de>
parents: 97170
diff changeset
337 engine property (xesam-get-property engine property)))
004f6dc1c1a0 * net/xesam.el (xesam-all-fields): Remove source and content
Michael Albinus <michael.albinus@gmx.de>
parents: 97170
diff changeset
338 (cdr (assoc property engine)))
004f6dc1c1a0 * net/xesam.el (xesam-all-fields): Remove source and content
Michael Albinus <michael.albinus@gmx.de>
parents: 97170
diff changeset
339
004f6dc1c1a0 * net/xesam.el (xesam-all-fields): Remove source and content
Michael Albinus <michael.albinus@gmx.de>
parents: 97170
diff changeset
340 (defun xesam-set-cached-property (engine property value)
004f6dc1c1a0 * net/xesam.el (xesam-all-fields): Remove source and content
Michael Albinus <michael.albinus@gmx.de>
parents: 97170
diff changeset
341 "Set the PROPERTY of ENGINE to VALUE in the cache."
004f6dc1c1a0 * net/xesam.el (xesam-all-fields): Remove source and content
Michael Albinus <michael.albinus@gmx.de>
parents: 97170
diff changeset
342 (setcdr engine (append (cdr engine) (list (cons property value)))))
96989
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
343
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
344 (defun xesam-delete-search-engine (&rest args)
97214
004f6dc1c1a0 * net/xesam.el (xesam-all-fields): Remove source and content
Michael Albinus <michael.albinus@gmx.de>
parents: 97170
diff changeset
345 "Remove service from `xesam-search-engines'."
004f6dc1c1a0 * net/xesam.el (xesam-all-fields): Remove source and content
Michael Albinus <michael.albinus@gmx.de>
parents: 97170
diff changeset
346 (setq xesam-search-engines
004f6dc1c1a0 * net/xesam.el (xesam-all-fields): Remove source and content
Michael Albinus <michael.albinus@gmx.de>
parents: 97170
diff changeset
347 (delete (assoc (car args) xesam-search-engines) xesam-search-engines)))
96989
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
348
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
349 (defun xesam-search-engines ()
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
350 "Return Xesam search engines, stored in `xesam-search-engines'.
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
351 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
352 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
353 (let ((services (dbus-ignore-errors
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
354 (dbus-list-queued-owners
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
355 :session xesam-service-search)))
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
356 engine vendor-id hit-fields)
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
357 (dolist (service services)
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
358 (unless (assoc-string service xesam-search-engines)
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
359
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
360 ;; Open a new session, and add it to the search engines list.
97214
004f6dc1c1a0 * net/xesam.el (xesam-all-fields): Remove source and content
Michael Albinus <michael.albinus@gmx.de>
parents: 97170
diff changeset
361 (add-to-list 'xesam-search-engines (list service) 'append)
004f6dc1c1a0 * net/xesam.el (xesam-all-fields): Remove source and content
Michael Albinus <michael.albinus@gmx.de>
parents: 97170
diff changeset
362 (setq engine (assoc service xesam-search-engines))
96989
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
363
97214
004f6dc1c1a0 * net/xesam.el (xesam-all-fields): Remove source and content
Michael Albinus <michael.albinus@gmx.de>
parents: 97170
diff changeset
364 ;; Add the session string.
004f6dc1c1a0 * net/xesam.el (xesam-all-fields): Remove source and content
Michael Albinus <michael.albinus@gmx.de>
parents: 97170
diff changeset
365 (xesam-set-cached-property
004f6dc1c1a0 * net/xesam.el (xesam-all-fields): Remove source and content
Michael Albinus <michael.albinus@gmx.de>
parents: 97170
diff changeset
366 engine "session"
004f6dc1c1a0 * net/xesam.el (xesam-all-fields): Remove source and content
Michael Albinus <michael.albinus@gmx.de>
parents: 97170
diff changeset
367 (xesam-dbus-call-method
004f6dc1c1a0 * net/xesam.el (xesam-all-fields): Remove source and content
Michael Albinus <michael.albinus@gmx.de>
parents: 97170
diff changeset
368 :session service xesam-path-search
004f6dc1c1a0 * net/xesam.el (xesam-all-fields): Remove source and content
Michael Albinus <michael.albinus@gmx.de>
parents: 97170
diff changeset
369 xesam-interface-search "NewSession"))
004f6dc1c1a0 * net/xesam.el (xesam-all-fields): Remove source and content
Michael Albinus <michael.albinus@gmx.de>
parents: 97170
diff changeset
370
004f6dc1c1a0 * net/xesam.el (xesam-all-fields): Remove source and content
Michael Albinus <michael.albinus@gmx.de>
parents: 97170
diff changeset
371 ;; Unset the "search.live" property; we don't want to be
004f6dc1c1a0 * net/xesam.el (xesam-all-fields): Remove source and content
Michael Albinus <michael.albinus@gmx.de>
parents: 97170
diff changeset
372 ;; informed by changed results.
004f6dc1c1a0 * net/xesam.el (xesam-all-fields): Remove source and content
Michael Albinus <michael.albinus@gmx.de>
parents: 97170
diff changeset
373 (xesam-set-property engine "search.live" nil)
96989
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
374
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
375 ;; Check the vendor properties.
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
376 (setq vendor-id (xesam-get-property engine "vendor.id")
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
377 hit-fields (xesam-get-property engine "hit.fields"))
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
378
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
379 ;; Ususally, `hit.fields' shall describe supported fields.
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
380 ;; 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
381 ;; Hopefully, this will change later.
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
382 (setq hit-fields
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
383 (cond
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
384 ((string-equal vendor-id "Beagle")
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
385 '("xesam:mimeType" "xesam:url"))
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
386 ((string-equal vendor-id "Strigi")
97289
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
387 '("xesam:author" "xesam:cc" "xesam:charset"
96989
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
388 "xesam:contentType" "xesam:fileExtension" "xesam:id"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
389 "xesam:lineCount" "xesam:links" "xesam:mimeType" "xesam:name"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
390 "xesam:size" "xesam:sourceModified" "xesam:subject"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
391 "xesam:to" "xesam:url"))
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
392 ((string-equal vendor-id "TrackerXesamSession")
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
393 '("xesam:relevancyRating" "xesam:url"))
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
394 ;; xesam-tools yahoo service.
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
395 (t '("xesam:contentModified" "xesam:mimeType" "xesam:summary"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
396 "xesam:title" "xesam:url" "yahoo:displayUrl"))))
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
397
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
398 (xesam-set-property engine "hit.fields" hit-fields)
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
399 (xesam-set-property engine "hit.fields.extended" '("xesam:snippet"))
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
400
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
401 ;; Let us notify, when the search engine disappears.
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
402 (dbus-register-signal
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
403 :session dbus-service-dbus dbus-path-dbus
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
404 dbus-interface-dbus "NameOwnerChanged"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
405 'xesam-delete-search-engine service))))
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
406 xesam-search-engines)
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
407
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
408
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
409 ;;; Search buffers.
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
410
97170
dfc12ea9589f * net/xesam.el (xesam-type, xesam-query, xesam-xml-string): New
Michael Albinus <michael.albinus@gmx.de>
parents: 97038
diff changeset
411 (define-derived-mode xesam-mode nil "Xesam"
96989
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
412 "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
413 In this mode, widgets represent the search results.
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
414
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
415 \\{xesam-mode-map}
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
416 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
417 ;; Keymap.
dfc12ea9589f * net/xesam.el (xesam-type, xesam-query, xesam-xml-string): New
Michael Albinus <michael.albinus@gmx.de>
parents: 97038
diff changeset
418 (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
419 (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
420 (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
421
dfc12ea9589f * net/xesam.el (xesam-type, xesam-query, xesam-xml-string): New
Michael Albinus <michael.albinus@gmx.de>
parents: 97038
diff changeset
422 ;; 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
423 (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
424 ;; `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
425 ;; `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
426 (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
427 (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
428 (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
429 (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
430 (set (make-local-variable 'xesam-xml-string) "")
97289
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
431 (set (make-local-variable 'xesam-objects) nil)
97170
dfc12ea9589f * net/xesam.el (xesam-type, xesam-query, xesam-xml-string): New
Michael Albinus <michael.albinus@gmx.de>
parents: 97038
diff changeset
432 ;; `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
433 (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
434 ;; `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
435 (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
436 ;; `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
437 (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
438 ;; `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
439 ;; 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
440 ;; 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
441 (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
442 ;; 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
443 (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
444 (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
445 '(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
446 ;; 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
447 (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
448 (list '(20
dfc12ea9589f * net/xesam.el (xesam-type, xesam-query, xesam-xml-string): New
Michael Albinus <michael.albinus@gmx.de>
parents: 97038
diff changeset
449 (:eval
dfc12ea9589f * net/xesam.el (xesam-type, xesam-query, xesam-xml-string): New
Michael Albinus <michael.albinus@gmx.de>
parents: 97038
diff changeset
450 (list "Type: "
97289
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
451 (propertize xesam-type 'face 'xesam-mode-line))))
97170
dfc12ea9589f * net/xesam.el (xesam-type, xesam-query, xesam-xml-string): New
Michael Albinus <michael.albinus@gmx.de>
parents: 97038
diff changeset
452 '(10
dfc12ea9589f * net/xesam.el (xesam-type, xesam-query, xesam-xml-string): New
Michael Albinus <michael.albinus@gmx.de>
parents: 97038
diff changeset
453 (:eval
dfc12ea9589f * net/xesam.el (xesam-type, xesam-query, xesam-xml-string): New
Michael Albinus <michael.albinus@gmx.de>
parents: 97038
diff changeset
454 (list " Query: "
dfc12ea9589f * net/xesam.el (xesam-type, xesam-query, xesam-xml-string): New
Michael Albinus <michael.albinus@gmx.de>
parents: 97038
diff changeset
455 (propertize
dfc12ea9589f * net/xesam.el (xesam-type, xesam-query, xesam-xml-string): New
Michael Albinus <michael.albinus@gmx.de>
parents: 97038
diff changeset
456 xesam-query
97289
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
457 'face 'xesam-mode-line
97214
004f6dc1c1a0 * net/xesam.el (xesam-all-fields): Remove source and content
Michael Albinus <michael.albinus@gmx.de>
parents: 97170
diff changeset
458 'help-echo (when xesam-debug xesam-xml-string)))))))
97170
dfc12ea9589f * net/xesam.el (xesam-type, xesam-query, xesam-xml-string): New
Michael Albinus <michael.albinus@gmx.de>
parents: 97038
diff changeset
459
97038
b201d17750ad * net/xesam.el (xesam-from): Remove defvar.
Michael Albinus <michael.albinus@gmx.de>
parents: 96996
diff changeset
460 (when (not (interactive-p))
b201d17750ad * net/xesam.el (xesam-from): Remove defvar.
Michael Albinus <michael.albinus@gmx.de>
parents: 96996
diff changeset
461 ;; Initialize buffer.
b201d17750ad * net/xesam.el (xesam-from): Remove defvar.
Michael Albinus <michael.albinus@gmx.de>
parents: 96996
diff changeset
462 (setq buffer-read-only t)
b201d17750ad * net/xesam.el (xesam-from): Remove defvar.
Michael Albinus <michael.albinus@gmx.de>
parents: 96996
diff changeset
463 (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
464 (erase-buffer))))
96989
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
465
97170
dfc12ea9589f * net/xesam.el (xesam-type, xesam-query, xesam-xml-string): New
Michael Albinus <michael.albinus@gmx.de>
parents: 97038
diff changeset
466 ;; 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
467 (put 'xesam-mode 'disabled t)
96989
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
468
97289
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
469 ;; The very first buffer created with `xesam-mode' does not have the
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
470 ;; keymap etc. So we create a dummy buffer. Stupid.
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
471 (with-temp-buffer (xesam-mode))
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
472
96989
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
473 (defun xesam-buffer-name (service search)
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
474 "Return the buffer name where to present search results.
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
475 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
476 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
477 (format "*%s/%s*" service search))
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
478
97289
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
479 (defun xesam-highlight-string (string)
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
480 "Highlight text enclosed by <b> and </b>."
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
481 (while (string-match "\\(.*\\)\\(<b>\\)\\(.*\\)\\(</b>\\)\\(.*\\)" string)
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
482 (setq string
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
483 (format
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
484 "%s%s%s"
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
485 (match-string 1 string)
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
486 (propertize (match-string 3 string) 'face 'xesam-highlight)
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
487 (match-string 5 string))))
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
488 string)
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
489
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
490 (defun xesam-refresh-entry (engine entry)
96989
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
491 "Refreshes one entry in the search buffer."
97289
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
492 (let* ((result (nth (1- xesam-current) xesam-objects))
96989
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
493 widget)
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
494
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
495 ;; Create widget.
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
496 (setq widget (widget-convert 'link))
97038
b201d17750ad * net/xesam.el (xesam-from): Remove defvar.
Michael Albinus <michael.albinus@gmx.de>
parents: 96996
diff changeset
497 (when xesam-debug
b201d17750ad * net/xesam.el (xesam-from): Remove defvar.
Michael Albinus <michael.albinus@gmx.de>
parents: 96996
diff changeset
498 (widget-put widget :help-echo ""))
96989
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 ;; Take all results.
97214
004f6dc1c1a0 * net/xesam.el (xesam-all-fields): Remove source and content
Michael Albinus <michael.albinus@gmx.de>
parents: 97170
diff changeset
501 (dolist (field (xesam-get-cached-property engine "hit.fields"))
97289
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
502 (when (cond
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
503 ((stringp (caar result)) (not (zerop (length (caar result)))))
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
504 ((numberp (caar result)) (not (zerop (caar result))))
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
505 ((caar result) t))
96989
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
506 (when xesam-debug
97038
b201d17750ad * net/xesam.el (xesam-from): Remove defvar.
Michael Albinus <michael.albinus@gmx.de>
parents: 96996
diff changeset
507 (widget-put
b201d17750ad * net/xesam.el (xesam-from): Remove defvar.
Michael Albinus <michael.albinus@gmx.de>
parents: 96996
diff changeset
508 widget :help-echo
b201d17750ad * net/xesam.el (xesam-from): Remove defvar.
Michael Albinus <michael.albinus@gmx.de>
parents: 96996
diff changeset
509 (format "%s%s: %s\n"
b201d17750ad * net/xesam.el (xesam-from): Remove defvar.
Michael Albinus <michael.albinus@gmx.de>
parents: 96996
diff changeset
510 (widget-get widget :help-echo) field (caar result))))
96989
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
511 (widget-put widget (intern (concat ":" field)) (caar result)))
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
512 (setq result (cdr result)))
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
513
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
514 ;; 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
515 (when
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
516 (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
517 (widget-put
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
518 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
519
97289
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
520 ;; Strigi returns xesam:size as string. We must fix this.
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
521 (when (and (widget-member widget :xesam:size)
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
522 (stringp (widget-get widget :xesam:size)))
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
523 (widget-put
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
524 widget :xesam:size (string-to-number (widget-get widget :xesam:url))))
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
525
96989
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
526 ;; First line: :tag.
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
527 (cond
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
528 ((widget-member widget :xesam:title)
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
529 (widget-put widget :tag (widget-get widget :xesam:title)))
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
530 ((widget-member widget :xesam:subject)
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
531 (widget-put widget :tag (widget-get widget :xesam:subject)))
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
532 ((widget-member widget :xesam:mimeType)
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
533 (widget-put widget :tag (widget-get widget :xesam:mimeType)))
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
534 ((widget-member widget :xesam:name)
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
535 (widget-put widget :tag (widget-get widget :xesam:name))))
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
536
97289
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
537 ;; Highlight the search items.
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
538 (when (widget-member widget :tag)
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
539 (widget-put
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
540 widget :tag (xesam-highlight-string (widget-get widget :tag))))
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
541
96989
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
542 ;; Last Modified.
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
543 (when (widget-member widget :xesam:sourceModified)
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
544 (widget-put
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
545 widget :tag
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
546 (format
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
547 "%s\nLast Modified: %s"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
548 (or (widget-get widget :tag) "")
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
549 (format-time-string
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
550 "%d %B %Y, %T"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
551 (seconds-to-time
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
552 (string-to-number (widget-get widget :xesam:sourceModified)))))))
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
553
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
554 ;; Second line: :value.
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
555 (widget-put widget :value (widget-get widget :xesam:url))
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
556
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
557 (cond
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
558 ;; In case of HTML, we use a URL link.
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
559 ((and (widget-member widget :xesam:mimeType)
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
560 (string-equal "text/html" (widget-get widget :xesam:mimeType)))
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
561 (setcar widget 'url-link))
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
562
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
563 ;; 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
564 ((string-match "file"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
565 (url-type (url-generic-parse-url
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
566 (widget-get widget :xesam:url))))
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
567 (widget-put
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
568 widget :notify
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
569 '(lambda (widget &rest ignore)
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
570 (find-file
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
571 (url-filename (url-generic-parse-url (widget-value widget))))))
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
572 (widget-put
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
573 widget :value
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
574 (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
575
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
576 ;; Third line: :doc.
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
577 (cond
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
578 ((widget-member widget :xesam:summary)
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
579 (widget-put widget :doc (widget-get widget :xesam:summary)))
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
580 ((widget-member widget :xesam:snippet)
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
581 (widget-put widget :doc (widget-get widget :xesam:snippet))))
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 (when (widget-member widget :doc)
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
584 (with-temp-buffer
97289
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
585 (insert
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
586 (xesam-highlight-string (widget-get widget :doc)))
96989
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
587 (fill-region-as-paragraph (point-min) (point-max))
97289
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
588 (widget-put widget :doc (buffer-string)))
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
589 (widget-put widget :help-echo (widget-get widget :doc)))
96989
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
590
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
591 ;; Format the widget.
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
592 (widget-put
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
593 widget :format
97038
b201d17750ad * net/xesam.el (xesam-from): Remove defvar.
Michael Albinus <michael.albinus@gmx.de>
parents: 96996
diff changeset
594 (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
595 (if (widget-member widget :tag) "%{%t%}\n" "")
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
596 (if (widget-member widget :doc) "%h" "")))
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
597
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
598 ;; Write widget.
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
599 (goto-char (point-max))
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
600 (widget-default-create widget)
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
601 (set-buffer-modified-p nil)
97038
b201d17750ad * net/xesam.el (xesam-from): Remove defvar.
Michael Albinus <michael.albinus@gmx.de>
parents: 96996
diff changeset
602 (force-mode-line-update)
96989
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
603 (redisplay)))
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
604
97289
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
605 (defun xesam-get-hits (engine search hits)
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
606 "Retrieve hits from ENGINE."
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
607 (with-current-buffer (xesam-buffer-name (car engine) search)
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
608 (setq xesam-objects
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
609 (append xesam-objects
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
610 (xesam-dbus-call-method
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
611 :session (car engine) xesam-path-search
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
612 xesam-interface-search "GetHits" search hits)))))
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
613
96989
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
614 (defun xesam-refresh-search-buffer (engine search)
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
615 "Refreshes the buffer, presenting results of SEARCH."
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
616 (with-current-buffer (xesam-buffer-name (car engine) search)
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
617 ;; Work only if nobody else is here.
97289
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
618 (unless (or xesam-refreshing (>= xesam-current xesam-to))
96989
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
619 (setq xesam-refreshing t)
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
620 (unwind-protect
97289
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
621 (let (widget)
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
622
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
623 ;; Retrieve needed hits for visualization.
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
624 (while (> (min xesam-to xesam-count) (length xesam-objects))
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
625 (xesam-get-hits
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
626 engine search
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
627 (min xesam-hits-per-page
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
628 (- (min xesam-to xesam-count) (length xesam-objects)))))
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
629
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
630 ;; Add all result widgets.
97038
b201d17750ad * net/xesam.el (xesam-from): Remove defvar.
Michael Albinus <michael.albinus@gmx.de>
parents: 96996
diff changeset
631 (while (< xesam-current (min xesam-to xesam-count))
97289
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
632 (setq xesam-current (1+ xesam-current))
97038
b201d17750ad * net/xesam.el (xesam-from): Remove defvar.
Michael Albinus <michael.albinus@gmx.de>
parents: 96996
diff changeset
633 (xesam-refresh-entry engine search))
96989
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
634
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
635 ;; Add "NEXT" widget.
97289
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
636 (when (> xesam-count xesam-to)
96989
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
637 (goto-char (point-max))
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
638 (widget-create
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
639 'link
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
640 :notify
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
641 '(lambda (widget &rest ignore)
97038
b201d17750ad * net/xesam.el (xesam-from): Remove defvar.
Michael Albinus <michael.albinus@gmx.de>
parents: 96996
diff changeset
642 (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
643 (widget-delete widget)
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
644 (xesam-refresh-search-buffer xesam-engine xesam-search))
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
645 "NEXT")
97289
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
646 (widget-beginning-of-line))
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
647
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
648 ;; Prefetch next hits.
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
649 (when (> (min (+ xesam-hits-per-page xesam-to) xesam-count)
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
650 (length xesam-objects))
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
651 (xesam-get-hits
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
652 engine search
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
653 (min xesam-hits-per-page
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
654 (- (min (+ xesam-hits-per-page xesam-to) xesam-count)
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
655 (length xesam-objects))))))
96989
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
656
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
657 ;; Return with save settings.
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
658 (setq xesam-refreshing nil)))))
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
659
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
660
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
661 ;;; Search functions.
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
662
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
663 (defun xesam-signal-handler (&rest args)
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
664 "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
665 (let* ((service (dbus-event-service-name last-input-event))
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
666 (member (dbus-event-member-name last-input-event))
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
667 (search (nth 0 args))
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
668 (buffer (xesam-buffer-name service search)))
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
669
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
670 (when (get-buffer buffer)
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
671 (with-current-buffer buffer
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
672 (cond
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
673
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
674 ((string-equal member "HitsAdded")
97038
b201d17750ad * net/xesam.el (xesam-from): Remove defvar.
Michael Albinus <michael.albinus@gmx.de>
parents: 96996
diff changeset
675 (setq xesam-count (+ xesam-count (nth 1 args)))
96989
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
676 ;; 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
677 (run-at-time
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
678 0 nil
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
679 'xesam-refresh-search-buffer
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
680 (assoc service xesam-search-engines) search))
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
681
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
682 ((string-equal member "SearchDone")
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
683 (setq mode-line-process
97289
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
684 (propertize " Done" 'face 'xesam-mode-line))
96989
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
685 (force-mode-line-update)))))))
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
686
97289
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
687 (defun xesam-kill-buffer-function ()
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
688 "Send the CloseSearch indication."
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
689 (when (and (eq major-mode 'xesam-mode) (stringp xesam-search))
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
690 (xesam-dbus-call-method
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
691 :session (car xesam-engine) xesam-path-search
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
692 xesam-interface-search "CloseSearch" xesam-search)))
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
693
97170
dfc12ea9589f * net/xesam.el (xesam-type, xesam-query, xesam-xml-string): New
Michael Albinus <michael.albinus@gmx.de>
parents: 97038
diff changeset
694 (defun xesam-new-search (engine type query)
96989
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
695 "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
696 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
697 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
698 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
699 search, is returned."
96989
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
700 (let* ((service (car engine))
97214
004f6dc1c1a0 * net/xesam.el (xesam-all-fields): Remove source and content
Michael Albinus <michael.albinus@gmx.de>
parents: 97170
diff changeset
701 (session (xesam-get-cached-property engine "session"))
97170
dfc12ea9589f * net/xesam.el (xesam-type, xesam-query, xesam-xml-string): New
Michael Albinus <michael.albinus@gmx.de>
parents: 97038
diff changeset
702 (xml-string
dfc12ea9589f * net/xesam.el (xesam-type, xesam-query, xesam-xml-string): New
Michael Albinus <michael.albinus@gmx.de>
parents: 97038
diff changeset
703 (format
dfc12ea9589f * net/xesam.el (xesam-type, xesam-query, xesam-xml-string): New
Michael Albinus <michael.albinus@gmx.de>
parents: 97038
diff changeset
704 (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
705 query))
97214
004f6dc1c1a0 * net/xesam.el (xesam-all-fields): Remove source and content
Michael Albinus <michael.albinus@gmx.de>
parents: 97170
diff changeset
706 (search (xesam-dbus-call-method
96989
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
707 :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
708 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
709
96989
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
710 ;; Let us notify for relevant signals. We ignore "HitsRemoved",
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
711 ;; "HitsModified" and "StateChanged"; there is nothing to do for
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
712 ;; us.
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
713 (dbus-register-signal
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
714 :session service xesam-path-search
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
715 xesam-interface-search "HitsAdded"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
716 'xesam-signal-handler search)
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
717 (dbus-register-signal
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
718 :session service xesam-path-search
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
719 xesam-interface-search "SearchDone"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
720 'xesam-signal-handler search)
97038
b201d17750ad * net/xesam.el (xesam-from): Remove defvar.
Michael Albinus <michael.albinus@gmx.de>
parents: 96996
diff changeset
721
96989
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
722 ;; Create the search buffer.
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
723 (with-current-buffer
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
724 (generate-new-buffer (xesam-buffer-name service search))
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
725 (switch-to-buffer-other-window (current-buffer))
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
726 (xesam-mode)
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
727 (setq xesam-engine engine
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
728 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
729 ;; `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
730 ;; 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
731 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
732 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
733 xesam-xml-string xml-string
97289
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
734 xesam-objects nil
97038
b201d17750ad * net/xesam.el (xesam-from): Remove defvar.
Michael Albinus <michael.albinus@gmx.de>
parents: 96996
diff changeset
735 ;; 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
736 ;; 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
737 ;; information, when applicable.
96989
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
738 mode-line-buffer-identification
97038
b201d17750ad * net/xesam.el (xesam-from): Remove defvar.
Michael Albinus <michael.albinus@gmx.de>
parents: 96996
diff changeset
739 (if (not xesam-debug)
b201d17750ad * net/xesam.el (xesam-from): Remove defvar.
Michael Albinus <michael.albinus@gmx.de>
parents: 96996
diff changeset
740 (list
b201d17750ad * net/xesam.el (xesam-from): Remove defvar.
Michael Albinus <michael.albinus@gmx.de>
parents: 96996
diff changeset
741 12 (propertized-buffer-identification
97214
004f6dc1c1a0 * net/xesam.el (xesam-all-fields): Remove source and content
Michael Albinus <michael.albinus@gmx.de>
parents: 97170
diff changeset
742 (xesam-get-cached-property engine "vendor.id")))
97038
b201d17750ad * net/xesam.el (xesam-from): Remove defvar.
Michael Albinus <michael.albinus@gmx.de>
parents: 96996
diff changeset
743 (propertize
97214
004f6dc1c1a0 * net/xesam.el (xesam-all-fields): Remove source and content
Michael Albinus <michael.albinus@gmx.de>
parents: 97170
diff changeset
744 (xesam-get-cached-property engine "vendor.id")
004f6dc1c1a0 * net/xesam.el (xesam-all-fields): Remove source and content
Michael Albinus <michael.albinus@gmx.de>
parents: 97170
diff changeset
745 'help-echo
97038
b201d17750ad * net/xesam.el (xesam-from): Remove defvar.
Michael Albinus <michael.albinus@gmx.de>
parents: 96996
diff changeset
746 (mapconcat
97214
004f6dc1c1a0 * net/xesam.el (xesam-all-fields): Remove source and content
Michael Albinus <michael.albinus@gmx.de>
parents: 97170
diff changeset
747 '(lambda (x)
004f6dc1c1a0 * net/xesam.el (xesam-all-fields): Remove source and content
Michael Albinus <michael.albinus@gmx.de>
parents: 97170
diff changeset
748 (format "%s: %s" x (xesam-get-cached-property engine x)))
97038
b201d17750ad * net/xesam.el (xesam-from): Remove defvar.
Michael Albinus <michael.albinus@gmx.de>
parents: 96996
diff changeset
749 '("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
750 "vendor.ontology.fields" "vendor.ontology.contents"
b201d17750ad * net/xesam.el (xesam-from): Remove defvar.
Michael Albinus <michael.albinus@gmx.de>
parents: 96996
diff changeset
751 "vendor.ontology.sources" "vendor.extensions"
b201d17750ad * net/xesam.el (xesam-from): Remove defvar.
Michael Albinus <michael.albinus@gmx.de>
parents: 96996
diff changeset
752 "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
753 "\n"))))
97289
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
754 (add-hook 'kill-buffer-hook 'xesam-kill-buffer-function)
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
755 (force-mode-line-update))
97170
dfc12ea9589f * net/xesam.el (xesam-type, xesam-query, xesam-xml-string): New
Michael Albinus <michael.albinus@gmx.de>
parents: 97038
diff changeset
756
dfc12ea9589f * net/xesam.el (xesam-type, xesam-query, xesam-xml-string): New
Michael Albinus <michael.albinus@gmx.de>
parents: 97038
diff changeset
757 ;; Start the search.
97214
004f6dc1c1a0 * net/xesam.el (xesam-all-fields): Remove source and content
Michael Albinus <michael.albinus@gmx.de>
parents: 97170
diff changeset
758 (xesam-dbus-call-method
97170
dfc12ea9589f * net/xesam.el (xesam-type, xesam-query, xesam-xml-string): New
Michael Albinus <michael.albinus@gmx.de>
parents: 97038
diff changeset
759 :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
760 xesam-interface-search "StartSearch" search)
96989
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
761
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
762 ;; Return search id.
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
763 search))
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
764
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
765 (defun xesam-search (engine query)
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
766 "Perform an interactive search.
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
767 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
768 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
769 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
770 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
771
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
772 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
773 Example:
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
774
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
775 (xesam-search (car (xesam-search-engines)) \"emacs\")"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
776 (interactive
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
777 (let* ((vendors (mapcar
97214
004f6dc1c1a0 * net/xesam.el (xesam-all-fields): Remove source and content
Michael Albinus <michael.albinus@gmx.de>
parents: 97170
diff changeset
778 '(lambda (x) (xesam-get-cached-property x "vendor.display"))
96989
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
779 (xesam-search-engines)))
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
780 (vendor
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
781 (if (> (length vendors) 1)
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
782 (completing-read
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
783 "Enter search engine: " vendors nil t
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
784 (try-completion "" vendors) 'xesam-minibuffer-vendor-history)
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
785 (car vendors))))
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
786 (list
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
787 ;; ENGINE.
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
788 (when vendor
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
789 (dolist (elt (xesam-search-engines) engine)
97214
004f6dc1c1a0 * net/xesam.el (xesam-all-fields): Remove source and content
Michael Albinus <michael.albinus@gmx.de>
parents: 97170
diff changeset
790 (when (string-equal
004f6dc1c1a0 * net/xesam.el (xesam-all-fields): Remove source and content
Michael Albinus <michael.albinus@gmx.de>
parents: 97170
diff changeset
791 (xesam-get-cached-property elt "vendor.display") vendor)
96989
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
792 (setq engine elt))))
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
793 ;; QUERY.
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
794 (when vendor
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
795 (read-from-minibuffer
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
796 "Enter search string: " nil nil nil
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
797 'xesam-minibuffer-query-history)))))
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
798
97170
dfc12ea9589f * net/xesam.el (xesam-type, xesam-query, xesam-xml-string): New
Michael Albinus <michael.albinus@gmx.de>
parents: 97038
diff changeset
799 (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
800 (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
801 (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
802 (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
803 (xesam-new-search engine xesam-query-type query))))
96989
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
804
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
805 (provide 'xesam)
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
806
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
807 ;;; TODO:
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
808
97289
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
809 ;; * Accept input while retrieving prefetched hits. `run-at-time'?
97214
004f6dc1c1a0 * net/xesam.el (xesam-all-fields): Remove source and content
Michael Albinus <michael.albinus@gmx.de>
parents: 97170
diff changeset
810 ;; * With prefix, let's choose search engine.
96989
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
811 ;; * Minibuffer completion for user queries.
97038
b201d17750ad * net/xesam.el (xesam-from): Remove defvar.
Michael Albinus <michael.albinus@gmx.de>
parents: 96996
diff changeset
812 ;; * `revert-buffer-function' implementation.
b201d17750ad * net/xesam.el (xesam-from): Remove defvar.
Michael Albinus <michael.albinus@gmx.de>
parents: 96996
diff changeset
813 ;;
96989
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
814 ;; * Mid term
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
815 ;; - If available, use ontologies for field selection.
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
816 ;; - Search engines for Emacs bugs database, wikipedia, google,
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
817 ;; yahoo, ebay, ...
97289
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
818 ;; - Construct complex queries via widgets, like in mairix.el.
96989
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
819
96996
3035988dd0b3 Add arch tagline
Miles Bader <miles@gnu.org>
parents: 96989
diff changeset
820 ;; arch-tag: 7fb9fc6c-c2ff-4bc7-bb42-bacb80cce2b2
96989
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
821 ;;; xesam.el ends here