annotate lisp/net/xesam.el @ 97572:9fb28094a3cf

* net/xesam.el (xesam-highlight-string): Precise doc string. (xesam-highlight-buffer): New defun. (xesam-refresh-entry): Use it. Better check for sourceModified.
author Michael Albinus <michael.albinus@gmx.de>
date Wed, 20 Aug 2008 20:08:16 +0000
parents 352b14f1dab0
children 1f7e10e015fd
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
97399
7806c35019cb * net/xesam.el (xesam-search-engines): Add Debbugs hit fields.
Michael Albinus <michael.albinus@gmx.de>
parents: 97381
diff changeset
25 ;; This package provides an interface to Xesam, a D-Bus based "eXtEnsible
96989
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
97399
7806c35019cb * net/xesam.el (xesam-search-engines): Add Debbugs hit fields.
Michael Albinus <michael.albinus@gmx.de>
parents: 97381
diff changeset
35 ;; running, which supports the Xesam interface. Beagle and strigi have
96989
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.
97517
352b14f1dab0 * net/xesam.el (xesam-vendor, xesam-notify-function): New local
Michael Albinus <michael.albinus@gmx.de>
parents: 97455
diff changeset
299 (defvar xesam-vendor nil)
352b14f1dab0 * net/xesam.el (xesam-vendor, xesam-notify-function): New local
Michael Albinus <michael.albinus@gmx.de>
parents: 97455
diff changeset
300 (make-variable-buffer-local 'xesam-vendor)
352b14f1dab0 * net/xesam.el (xesam-vendor, xesam-notify-function): New local
Michael Albinus <michael.albinus@gmx.de>
parents: 97455
diff changeset
301 (put 'xesam-vendor 'permanent-local t)
352b14f1dab0 * net/xesam.el (xesam-vendor, xesam-notify-function): New local
Michael Albinus <michael.albinus@gmx.de>
parents: 97455
diff changeset
302
96989
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
303 (defvar xesam-engine nil)
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
304 (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
305 (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
306 (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
307 (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
308 (defvar xesam-objects nil)
96989
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
309 (defvar xesam-current nil)
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
310 (defvar xesam-count nil)
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
311 (defvar xesam-to nil)
97517
352b14f1dab0 * net/xesam.el (xesam-vendor, xesam-notify-function): New local
Michael Albinus <michael.albinus@gmx.de>
parents: 97455
diff changeset
312 (defvar xesam-notify-function nil)
96989
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
313 (defvar xesam-refreshing nil)
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
314
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
315
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
316 ;;; Search engines.
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
317
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
318 (defvar xesam-search-engines nil
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
319 "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
320 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
321 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
322 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
323 identifier, and the display name. Example:
96989
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
324
97214
004f6dc1c1a0 * net/xesam.el (xesam-all-fields): Remove source and content
Michael Albinus <michael.albinus@gmx.de>
parents: 97170
diff changeset
325 \(\(\":1.59\"
004f6dc1c1a0 * net/xesam.el (xesam-all-fields): Remove source and content
Michael Albinus <michael.albinus@gmx.de>
parents: 97170
diff changeset
326 \(\"session\" . \"0t1214948020ut358230u0p2698r3912347765k3213849828\")
004f6dc1c1a0 * net/xesam.el (xesam-all-fields): Remove source and content
Michael Albinus <michael.albinus@gmx.de>
parents: 97170
diff changeset
327 \(\"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
328 \(\":1.27\"
004f6dc1c1a0 * net/xesam.el (xesam-all-fields): Remove source and content
Michael Albinus <michael.albinus@gmx.de>
parents: 97170
diff changeset
329 \(\"session\" . \"strigisession1369133069\")
004f6dc1c1a0 * net/xesam.el (xesam-all-fields): Remove source and content
Michael Albinus <michael.albinus@gmx.de>
parents: 97170
diff changeset
330 \(\"vendor.display\" . \"Strigi Desktop Search\")))
96989
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
331
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
332 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
333 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
334
004f6dc1c1a0 * net/xesam.el (xesam-all-fields): Remove source and content
Michael Albinus <michael.albinus@gmx.de>
parents: 97170
diff changeset
335 (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
336 "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
337 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
338 ;; 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
339 ;; 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
340 (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
341 (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
342 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
343 (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
344
004f6dc1c1a0 * net/xesam.el (xesam-all-fields): Remove source and content
Michael Albinus <michael.albinus@gmx.de>
parents: 97170
diff changeset
345 (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
346 "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
347 (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
348
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
349 (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
350 "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
351 (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
352 (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
353
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
354 (defun xesam-search-engines ()
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
355 "Return Xesam search engines, stored in `xesam-search-engines'.
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
356 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
357 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
358 (let ((services (dbus-ignore-errors
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
359 (dbus-list-queued-owners
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
360 :session xesam-service-search)))
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
361 engine vendor-id hit-fields)
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
362 (dolist (service services)
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
363 (unless (assoc-string service xesam-search-engines)
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
364
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
365 ;; 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
366 (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
367 (setq engine (assoc service xesam-search-engines))
96989
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
368
97214
004f6dc1c1a0 * net/xesam.el (xesam-all-fields): Remove source and content
Michael Albinus <michael.albinus@gmx.de>
parents: 97170
diff changeset
369 ;; 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
370 (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
371 engine "session"
004f6dc1c1a0 * net/xesam.el (xesam-all-fields): Remove source and content
Michael Albinus <michael.albinus@gmx.de>
parents: 97170
diff changeset
372 (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
373 :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
374 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
375
004f6dc1c1a0 * net/xesam.el (xesam-all-fields): Remove source and content
Michael Albinus <michael.albinus@gmx.de>
parents: 97170
diff changeset
376 ;; 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
377 ;; 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
378 (xesam-set-property engine "search.live" nil)
96989
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
379
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
380 ;; Check the vendor properties.
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
381 (setq vendor-id (xesam-get-property engine "vendor.id")
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
382 hit-fields (xesam-get-property engine "hit.fields"))
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
383
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
384 ;; Ususally, `hit.fields' shall describe supported fields.
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
385 ;; 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
386 ;; Hopefully, this will change later.
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
387 (setq hit-fields
97399
7806c35019cb * net/xesam.el (xesam-search-engines): Add Debbugs hit fields.
Michael Albinus <michael.albinus@gmx.de>
parents: 97381
diff changeset
388 (case (intern vendor-id)
7806c35019cb * net/xesam.el (xesam-search-engines): Add Debbugs hit fields.
Michael Albinus <michael.albinus@gmx.de>
parents: 97381
diff changeset
389 ('Beagle
7806c35019cb * net/xesam.el (xesam-search-engines): Add Debbugs hit fields.
Michael Albinus <michael.albinus@gmx.de>
parents: 97381
diff changeset
390 '("xesam:mimeType" "xesam:url"))
7806c35019cb * net/xesam.el (xesam-search-engines): Add Debbugs hit fields.
Michael Albinus <michael.albinus@gmx.de>
parents: 97381
diff changeset
391 ('Strigi
7806c35019cb * net/xesam.el (xesam-search-engines): Add Debbugs hit fields.
Michael Albinus <michael.albinus@gmx.de>
parents: 97381
diff changeset
392 '("xesam:author" "xesam:cc" "xesam:charset"
7806c35019cb * net/xesam.el (xesam-search-engines): Add Debbugs hit fields.
Michael Albinus <michael.albinus@gmx.de>
parents: 97381
diff changeset
393 "xesam:contentType" "xesam:fileExtension"
7806c35019cb * net/xesam.el (xesam-search-engines): Add Debbugs hit fields.
Michael Albinus <michael.albinus@gmx.de>
parents: 97381
diff changeset
394 "xesam:id" "xesam:lineCount" "xesam:links"
7806c35019cb * net/xesam.el (xesam-search-engines): Add Debbugs hit fields.
Michael Albinus <michael.albinus@gmx.de>
parents: 97381
diff changeset
395 "xesam:mimeType" "xesam:name" "xesam:size"
7806c35019cb * net/xesam.el (xesam-search-engines): Add Debbugs hit fields.
Michael Albinus <michael.albinus@gmx.de>
parents: 97381
diff changeset
396 "xesam:sourceModified" "xesam:subject" "xesam:to"
7806c35019cb * net/xesam.el (xesam-search-engines): Add Debbugs hit fields.
Michael Albinus <michael.albinus@gmx.de>
parents: 97381
diff changeset
397 "xesam:url"))
7806c35019cb * net/xesam.el (xesam-search-engines): Add Debbugs hit fields.
Michael Albinus <michael.albinus@gmx.de>
parents: 97381
diff changeset
398 ('TrackerXesamSession
7806c35019cb * net/xesam.el (xesam-search-engines): Add Debbugs hit fields.
Michael Albinus <michael.albinus@gmx.de>
parents: 97381
diff changeset
399 '("xesam:relevancyRating" "xesam:url"))
7806c35019cb * net/xesam.el (xesam-search-engines): Add Debbugs hit fields.
Michael Albinus <michael.albinus@gmx.de>
parents: 97381
diff changeset
400 ('Debbugs
7806c35019cb * net/xesam.el (xesam-search-engines): Add Debbugs hit fields.
Michael Albinus <michael.albinus@gmx.de>
parents: 97381
diff changeset
401 '("xesam:keyword" "xesam:owner" "xesam:title"
7806c35019cb * net/xesam.el (xesam-search-engines): Add Debbugs hit fields.
Michael Albinus <michael.albinus@gmx.de>
parents: 97381
diff changeset
402 "xesam:url" "xesam:sourceModified" "xesam:mimeType"
7806c35019cb * net/xesam.el (xesam-search-engines): Add Debbugs hit fields.
Michael Albinus <michael.albinus@gmx.de>
parents: 97381
diff changeset
403 "debbugs:key"))
7806c35019cb * net/xesam.el (xesam-search-engines): Add Debbugs hit fields.
Michael Albinus <michael.albinus@gmx.de>
parents: 97381
diff changeset
404 ;; xesam-tools yahoo service.
7806c35019cb * net/xesam.el (xesam-search-engines): Add Debbugs hit fields.
Michael Albinus <michael.albinus@gmx.de>
parents: 97381
diff changeset
405 (t '("xesam:contentModified" "xesam:mimeType" "xesam:summary"
7806c35019cb * net/xesam.el (xesam-search-engines): Add Debbugs hit fields.
Michael Albinus <michael.albinus@gmx.de>
parents: 97381
diff changeset
406 "xesam:title" "xesam:url" "yahoo:displayUrl"))))
96989
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 (xesam-set-property engine "hit.fields" hit-fields)
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
409 (xesam-set-property engine "hit.fields.extended" '("xesam:snippet"))
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
410
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
411 ;; Let us notify, when the search engine disappears.
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
412 (dbus-register-signal
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
413 :session dbus-service-dbus dbus-path-dbus
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
414 dbus-interface-dbus "NameOwnerChanged"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
415 'xesam-delete-search-engine service))))
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
416 xesam-search-engines)
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
417
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
418
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
419 ;;; Search buffers.
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
420
97170
dfc12ea9589f * net/xesam.el (xesam-type, xesam-query, xesam-xml-string): New
Michael Albinus <michael.albinus@gmx.de>
parents: 97038
diff changeset
421 (define-derived-mode xesam-mode nil "Xesam"
96989
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
422 "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
423 In this mode, widgets represent the search results.
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
424
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
425 \\{xesam-mode-map}
97517
352b14f1dab0 * net/xesam.el (xesam-vendor, xesam-notify-function): New local
Michael Albinus <michael.albinus@gmx.de>
parents: 97455
diff changeset
426 Turning on Xesam mode runs the normal hook `xesam-mode-hook'. It
352b14f1dab0 * net/xesam.el (xesam-vendor, xesam-notify-function): New local
Michael Albinus <michael.albinus@gmx.de>
parents: 97455
diff changeset
427 can be used to set `xesam-notify-function', which must a search
352b14f1dab0 * net/xesam.el (xesam-vendor, xesam-notify-function): New local
Michael Albinus <michael.albinus@gmx.de>
parents: 97455
diff changeset
428 engine specific, widget :notify function to visualize xesam:url."
352b14f1dab0 * net/xesam.el (xesam-vendor, xesam-notify-function): New local
Michael Albinus <michael.albinus@gmx.de>
parents: 97455
diff changeset
429 (set (make-local-variable 'xesam-notify-function) nil)
352b14f1dab0 * net/xesam.el (xesam-vendor, xesam-notify-function): New local
Michael Albinus <michael.albinus@gmx.de>
parents: 97455
diff changeset
430
97170
dfc12ea9589f * net/xesam.el (xesam-type, xesam-query, xesam-xml-string): New
Michael Albinus <michael.albinus@gmx.de>
parents: 97038
diff changeset
431 ;; Keymap.
dfc12ea9589f * net/xesam.el (xesam-type, xesam-query, xesam-xml-string): New
Michael Albinus <michael.albinus@gmx.de>
parents: 97038
diff changeset
432 (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
433 (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
434 (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
435
dfc12ea9589f * net/xesam.el (xesam-type, xesam-query, xesam-xml-string): New
Michael Albinus <michael.albinus@gmx.de>
parents: 97038
diff changeset
436 ;; 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
437 (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
438 ;; `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
439 ;; `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
440 (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
441 (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
442 (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
443 (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
444 (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
445 (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
446 ;; `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
447 (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
448 ;; `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
449 (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
450 ;; `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
451 (set (make-local-variable 'xesam-to) xesam-hits-per-page)
97517
352b14f1dab0 * net/xesam.el (xesam-vendor, xesam-notify-function): New local
Michael Albinus <michael.albinus@gmx.de>
parents: 97455
diff changeset
452 ;; `xesam-notify-function' can be a search engine specific function
352b14f1dab0 * net/xesam.el (xesam-vendor, xesam-notify-function): New local
Michael Albinus <michael.albinus@gmx.de>
parents: 97455
diff changeset
453 ;; to visualize xesam:url. It can be overwritten in `xesam-mode'.
352b14f1dab0 * net/xesam.el (xesam-vendor, xesam-notify-function): New local
Michael Albinus <michael.albinus@gmx.de>
parents: 97455
diff changeset
454 (set (make-local-variable 'xesam-notify-function) nil)
97170
dfc12ea9589f * net/xesam.el (xesam-type, xesam-query, xesam-xml-string): New
Michael Albinus <michael.albinus@gmx.de>
parents: 97038
diff changeset
455 ;; `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
456 ;; 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
457 ;; 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
458 (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
459 ;; 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
460 (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
461 (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
462 '(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
463 ;; 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
464 (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
465 (list '(20
dfc12ea9589f * net/xesam.el (xesam-type, xesam-query, xesam-xml-string): New
Michael Albinus <michael.albinus@gmx.de>
parents: 97038
diff changeset
466 (:eval
dfc12ea9589f * net/xesam.el (xesam-type, xesam-query, xesam-xml-string): New
Michael Albinus <michael.albinus@gmx.de>
parents: 97038
diff changeset
467 (list "Type: "
97289
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
468 (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
469 '(10
dfc12ea9589f * net/xesam.el (xesam-type, xesam-query, xesam-xml-string): New
Michael Albinus <michael.albinus@gmx.de>
parents: 97038
diff changeset
470 (:eval
dfc12ea9589f * net/xesam.el (xesam-type, xesam-query, xesam-xml-string): New
Michael Albinus <michael.albinus@gmx.de>
parents: 97038
diff changeset
471 (list " Query: "
dfc12ea9589f * net/xesam.el (xesam-type, xesam-query, xesam-xml-string): New
Michael Albinus <michael.albinus@gmx.de>
parents: 97038
diff changeset
472 (propertize
dfc12ea9589f * net/xesam.el (xesam-type, xesam-query, xesam-xml-string): New
Michael Albinus <michael.albinus@gmx.de>
parents: 97038
diff changeset
473 xesam-query
97289
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
474 '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
475 '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
476
97038
b201d17750ad * net/xesam.el (xesam-from): Remove defvar.
Michael Albinus <michael.albinus@gmx.de>
parents: 96996
diff changeset
477 (when (not (interactive-p))
b201d17750ad * net/xesam.el (xesam-from): Remove defvar.
Michael Albinus <michael.albinus@gmx.de>
parents: 96996
diff changeset
478 ;; Initialize buffer.
b201d17750ad * net/xesam.el (xesam-from): Remove defvar.
Michael Albinus <michael.albinus@gmx.de>
parents: 96996
diff changeset
479 (setq buffer-read-only t)
b201d17750ad * net/xesam.el (xesam-from): Remove defvar.
Michael Albinus <michael.albinus@gmx.de>
parents: 96996
diff changeset
480 (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
481 (erase-buffer))))
96989
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
482
97170
dfc12ea9589f * net/xesam.el (xesam-type, xesam-query, xesam-xml-string): New
Michael Albinus <michael.albinus@gmx.de>
parents: 97038
diff changeset
483 ;; 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
484 (put 'xesam-mode 'disabled t)
96989
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
485
97289
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
486 ;; 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
487 ;; 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
488 (with-temp-buffer (xesam-mode))
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
489
96989
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
490 (defun xesam-buffer-name (service search)
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
491 "Return the buffer name where to present search results.
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
492 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
493 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
494 (format "*%s/%s*" service search))
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
495
97289
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
496 (defun xesam-highlight-string (string)
97572
9fb28094a3cf * net/xesam.el (xesam-highlight-string): Precise doc string.
Michael Albinus <michael.albinus@gmx.de>
parents: 97517
diff changeset
497 "Highlight text enclosed by <b> and </b>.
9fb28094a3cf * net/xesam.el (xesam-highlight-string): Precise doc string.
Michael Albinus <michael.albinus@gmx.de>
parents: 97517
diff changeset
498 Return propertized STRING."
97289
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
499 (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
500 (setq string
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
501 (format
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
502 "%s%s%s"
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
503 (match-string 1 string)
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
504 (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
505 (match-string 5 string))))
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
506 string)
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
507
97572
9fb28094a3cf * net/xesam.el (xesam-highlight-string): Precise doc string.
Michael Albinus <michael.albinus@gmx.de>
parents: 97517
diff changeset
508 (defun xesam-highlight-buffer (regexp &optional buffer)
9fb28094a3cf * net/xesam.el (xesam-highlight-string): Precise doc string.
Michael Albinus <michael.albinus@gmx.de>
parents: 97517
diff changeset
509 "Highlight text matching REGEXP in BUFFER.
9fb28094a3cf * net/xesam.el (xesam-highlight-string): Precise doc string.
Michael Albinus <michael.albinus@gmx.de>
parents: 97517
diff changeset
510 If BUFFER is nil, use the current buffer"
9fb28094a3cf * net/xesam.el (xesam-highlight-string): Precise doc string.
Michael Albinus <michael.albinus@gmx.de>
parents: 97517
diff changeset
511 (with-current-buffer (or buffer (current-buffer))
9fb28094a3cf * net/xesam.el (xesam-highlight-string): Precise doc string.
Michael Albinus <michael.albinus@gmx.de>
parents: 97517
diff changeset
512 (save-excursion
9fb28094a3cf * net/xesam.el (xesam-highlight-string): Precise doc string.
Michael Albinus <michael.albinus@gmx.de>
parents: 97517
diff changeset
513 (let ((case-fold-search t))
9fb28094a3cf * net/xesam.el (xesam-highlight-string): Precise doc string.
Michael Albinus <michael.albinus@gmx.de>
parents: 97517
diff changeset
514 (goto-char (point-min))
9fb28094a3cf * net/xesam.el (xesam-highlight-string): Precise doc string.
Michael Albinus <michael.albinus@gmx.de>
parents: 97517
diff changeset
515 (while (re-search-forward regexp nil t)
9fb28094a3cf * net/xesam.el (xesam-highlight-string): Precise doc string.
Michael Albinus <michael.albinus@gmx.de>
parents: 97517
diff changeset
516 (overlay-put
9fb28094a3cf * net/xesam.el (xesam-highlight-string): Precise doc string.
Michael Albinus <michael.albinus@gmx.de>
parents: 97517
diff changeset
517 (make-overlay
9fb28094a3cf * net/xesam.el (xesam-highlight-string): Precise doc string.
Michael Albinus <michael.albinus@gmx.de>
parents: 97517
diff changeset
518 (match-beginning 0) (match-end 0)) 'face 'xesam-highlight))))))
9fb28094a3cf * net/xesam.el (xesam-highlight-string): Precise doc string.
Michael Albinus <michael.albinus@gmx.de>
parents: 97517
diff changeset
519
97289
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
520 (defun xesam-refresh-entry (engine entry)
96989
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
521 "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
522 (let* ((result (nth (1- xesam-current) xesam-objects))
96989
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
523 widget)
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
524
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
525 ;; Create widget.
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
526 (setq widget (widget-convert 'link))
97038
b201d17750ad * net/xesam.el (xesam-from): Remove defvar.
Michael Albinus <michael.albinus@gmx.de>
parents: 96996
diff changeset
527 (when xesam-debug
b201d17750ad * net/xesam.el (xesam-from): Remove defvar.
Michael Albinus <michael.albinus@gmx.de>
parents: 96996
diff changeset
528 (widget-put widget :help-echo ""))
96989
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
529
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
530 ;; 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
531 (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
532 (when (cond
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
533 ((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
534 ((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
535 ((caar result) t))
96989
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
536 (when xesam-debug
97038
b201d17750ad * net/xesam.el (xesam-from): Remove defvar.
Michael Albinus <michael.albinus@gmx.de>
parents: 96996
diff changeset
537 (widget-put
b201d17750ad * net/xesam.el (xesam-from): Remove defvar.
Michael Albinus <michael.albinus@gmx.de>
parents: 96996
diff changeset
538 widget :help-echo
b201d17750ad * net/xesam.el (xesam-from): Remove defvar.
Michael Albinus <michael.albinus@gmx.de>
parents: 96996
diff changeset
539 (format "%s%s: %s\n"
b201d17750ad * net/xesam.el (xesam-from): Remove defvar.
Michael Albinus <michael.albinus@gmx.de>
parents: 96996
diff changeset
540 (widget-get widget :help-echo) field (caar result))))
96989
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
541 (widget-put widget (intern (concat ":" field)) (caar result)))
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
542 (setq result (cdr result)))
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
543
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
544 ;; 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
545 (when
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
546 (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
547 (widget-put
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
548 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
549
97289
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
550 ;; 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
551 (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
552 (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
553 (widget-put
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
554 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
555
96989
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
556 ;; First line: :tag.
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 ((widget-member widget :xesam:title)
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
559 (widget-put widget :tag (widget-get widget :xesam:title)))
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
560 ((widget-member widget :xesam:subject)
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
561 (widget-put widget :tag (widget-get widget :xesam:subject)))
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
562 ((widget-member widget :xesam:mimeType)
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
563 (widget-put widget :tag (widget-get widget :xesam:mimeType)))
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
564 ((widget-member widget :xesam:name)
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
565 (widget-put widget :tag (widget-get widget :xesam:name))))
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
566
97289
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
567 ;; Highlight the search items.
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
568 (when (widget-member widget :tag)
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
569 (widget-put
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
570 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
571
96989
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
572 ;; Last Modified.
97572
9fb28094a3cf * net/xesam.el (xesam-highlight-string): Precise doc string.
Michael Albinus <michael.albinus@gmx.de>
parents: 97517
diff changeset
573 (when (and (widget-member widget :xesam:sourceModified)
9fb28094a3cf * net/xesam.el (xesam-highlight-string): Precise doc string.
Michael Albinus <michael.albinus@gmx.de>
parents: 97517
diff changeset
574 (not
9fb28094a3cf * net/xesam.el (xesam-highlight-string): Precise doc string.
Michael Albinus <michael.albinus@gmx.de>
parents: 97517
diff changeset
575 (zerop
9fb28094a3cf * net/xesam.el (xesam-highlight-string): Precise doc string.
Michael Albinus <michael.albinus@gmx.de>
parents: 97517
diff changeset
576 (string-to-number (widget-get widget :xesam:sourceModified)))))
96989
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
577 (widget-put
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
578 widget :tag
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
579 (format
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
580 "%s\nLast Modified: %s"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
581 (or (widget-get widget :tag) "")
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
582 (format-time-string
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
583 "%d %B %Y, %T"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
584 (seconds-to-time
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
585 (string-to-number (widget-get widget :xesam:sourceModified)))))))
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
586
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
587 ;; Second line: :value.
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
588 (widget-put widget :value (widget-get widget :xesam:url))
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
589
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
590 (cond
97517
352b14f1dab0 * net/xesam.el (xesam-vendor, xesam-notify-function): New local
Michael Albinus <michael.albinus@gmx.de>
parents: 97455
diff changeset
591 ;; A search engine can set `xesam-notify-function' via
352b14f1dab0 * net/xesam.el (xesam-vendor, xesam-notify-function): New local
Michael Albinus <michael.albinus@gmx.de>
parents: 97455
diff changeset
592 ;; `xesam-mode-hooks'.
352b14f1dab0 * net/xesam.el (xesam-vendor, xesam-notify-function): New local
Michael Albinus <michael.albinus@gmx.de>
parents: 97455
diff changeset
593 (xesam-notify-function
352b14f1dab0 * net/xesam.el (xesam-vendor, xesam-notify-function): New local
Michael Albinus <michael.albinus@gmx.de>
parents: 97455
diff changeset
594 (widget-put widget :notify xesam-notify-function))
352b14f1dab0 * net/xesam.el (xesam-vendor, xesam-notify-function): New local
Michael Albinus <michael.albinus@gmx.de>
parents: 97455
diff changeset
595
96989
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
596 ;; In case of HTML, we use a URL link.
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
597 ((and (widget-member widget :xesam:mimeType)
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
598 (string-equal "text/html" (widget-get widget :xesam:mimeType)))
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
599 (setcar widget 'url-link))
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
600
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
601 ;; 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
602 ((string-match "file"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
603 (url-type (url-generic-parse-url
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
604 (widget-get widget :xesam:url))))
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
605 (widget-put
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
606 widget :notify
97455
a5d0ee62856d * net/xesam.el (xesam-refresh-entry): Use `save-excursion' in the
Michael Albinus <michael.albinus@gmx.de>
parents: 97399
diff changeset
607 (lambda (widget &rest ignore)
97572
9fb28094a3cf * net/xesam.el (xesam-highlight-string): Precise doc string.
Michael Albinus <michael.albinus@gmx.de>
parents: 97517
diff changeset
608 (let ((query xesam-query))
9fb28094a3cf * net/xesam.el (xesam-highlight-string): Precise doc string.
Michael Albinus <michael.albinus@gmx.de>
parents: 97517
diff changeset
609 (find-file
9fb28094a3cf * net/xesam.el (xesam-highlight-string): Precise doc string.
Michael Albinus <michael.albinus@gmx.de>
parents: 97517
diff changeset
610 (url-filename (url-generic-parse-url (widget-value widget))))
9fb28094a3cf * net/xesam.el (xesam-highlight-string): Precise doc string.
Michael Albinus <michael.albinus@gmx.de>
parents: 97517
diff changeset
611 (xesam-highlight-buffer (regexp-opt (split-string query nil t))))))
96989
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
612 (widget-put
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
613 widget :value
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
614 (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
615
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
616 ;; Third line: :doc.
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
617 (cond
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
618 ((widget-member widget :xesam:summary)
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
619 (widget-put widget :doc (widget-get widget :xesam:summary)))
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
620 ((widget-member widget :xesam:snippet)
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
621 (widget-put widget :doc (widget-get widget :xesam:snippet))))
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
622
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
623 (when (widget-member widget :doc)
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
624 (with-temp-buffer
97289
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
625 (insert
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
626 (xesam-highlight-string (widget-get widget :doc)))
96989
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
627 (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
628 (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
629 (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
630
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
631 ;; Format the widget.
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
632 (widget-put
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
633 widget :format
97038
b201d17750ad * net/xesam.el (xesam-from): Remove defvar.
Michael Albinus <michael.albinus@gmx.de>
parents: 96996
diff changeset
634 (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
635 (if (widget-member widget :tag) "%{%t%}\n" "")
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
636 (if (widget-member widget :doc) "%h" "")))
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
637
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
638 ;; Write widget.
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
639 (goto-char (point-max))
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
640 (widget-default-create widget)
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
641 (set-buffer-modified-p nil)
97038
b201d17750ad * net/xesam.el (xesam-from): Remove defvar.
Michael Albinus <michael.albinus@gmx.de>
parents: 96996
diff changeset
642 (force-mode-line-update)
96989
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
643 (redisplay)))
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
644
97289
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
645 (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
646 "Retrieve hits from ENGINE."
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
647 (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
648 (setq xesam-objects
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
649 (append xesam-objects
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
650 (xesam-dbus-call-method
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
651 :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
652 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
653
96989
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
654 (defun xesam-refresh-search-buffer (engine search)
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
655 "Refreshes the buffer, presenting results of SEARCH."
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
656 (with-current-buffer (xesam-buffer-name (car engine) search)
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
657 ;; 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
658 (unless (or xesam-refreshing (>= xesam-current xesam-to))
96989
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
659 (setq xesam-refreshing t)
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
660 (unwind-protect
97289
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
661 (let (widget)
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
662
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
663 ;; Retrieve needed hits for visualization.
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
664 (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
665 (xesam-get-hits
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
666 engine search
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
667 (min xesam-hits-per-page
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
668 (- (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
669
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
670 ;; Add all result widgets.
97038
b201d17750ad * net/xesam.el (xesam-from): Remove defvar.
Michael Albinus <michael.albinus@gmx.de>
parents: 96996
diff changeset
671 (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
672 (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
673 (xesam-refresh-entry engine search))
96989
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
674
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
675 ;; Add "NEXT" widget.
97289
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
676 (when (> xesam-count xesam-to)
96989
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
677 (goto-char (point-max))
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
678 (widget-create
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
679 'link
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
680 :notify
97455
a5d0ee62856d * net/xesam.el (xesam-refresh-entry): Use `save-excursion' in the
Michael Albinus <michael.albinus@gmx.de>
parents: 97399
diff changeset
681 (lambda (widget &rest ignore)
a5d0ee62856d * net/xesam.el (xesam-refresh-entry): Use `save-excursion' in the
Michael Albinus <michael.albinus@gmx.de>
parents: 97399
diff changeset
682 (setq xesam-to (+ xesam-to xesam-hits-per-page))
a5d0ee62856d * net/xesam.el (xesam-refresh-entry): Use `save-excursion' in the
Michael Albinus <michael.albinus@gmx.de>
parents: 97399
diff changeset
683 (widget-delete widget)
a5d0ee62856d * net/xesam.el (xesam-refresh-entry): Use `save-excursion' in the
Michael Albinus <michael.albinus@gmx.de>
parents: 97399
diff changeset
684 (xesam-refresh-search-buffer xesam-engine xesam-search))
96989
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
685 "NEXT")
97289
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
686 (widget-beginning-of-line))
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
687
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
688 ;; Prefetch next hits.
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
689 (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
690 (length xesam-objects))
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
691 (xesam-get-hits
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
692 engine search
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
693 (min xesam-hits-per-page
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
694 (- (min (+ xesam-hits-per-page xesam-to) xesam-count)
97455
a5d0ee62856d * net/xesam.el (xesam-refresh-entry): Use `save-excursion' in the
Michael Albinus <michael.albinus@gmx.de>
parents: 97399
diff changeset
695 (length xesam-objects)))))
96989
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
696
97399
7806c35019cb * net/xesam.el (xesam-search-engines): Add Debbugs hit fields.
Michael Albinus <michael.albinus@gmx.de>
parents: 97381
diff changeset
697 ;; Add "DONE" widget.
7806c35019cb * net/xesam.el (xesam-search-engines): Add Debbugs hit fields.
Michael Albinus <michael.albinus@gmx.de>
parents: 97381
diff changeset
698 (when (= xesam-current xesam-count)
7806c35019cb * net/xesam.el (xesam-search-engines): Add Debbugs hit fields.
Michael Albinus <michael.albinus@gmx.de>
parents: 97381
diff changeset
699 (goto-char (point-max))
7806c35019cb * net/xesam.el (xesam-search-engines): Add Debbugs hit fields.
Michael Albinus <michael.albinus@gmx.de>
parents: 97381
diff changeset
700 (widget-create 'link :notify 'ignore "DONE")
97455
a5d0ee62856d * net/xesam.el (xesam-refresh-entry): Use `save-excursion' in the
Michael Albinus <michael.albinus@gmx.de>
parents: 97399
diff changeset
701 (widget-beginning-of-line)))
97399
7806c35019cb * net/xesam.el (xesam-search-engines): Add Debbugs hit fields.
Michael Albinus <michael.albinus@gmx.de>
parents: 97381
diff changeset
702
96989
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
703 ;; Return with save settings.
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
704 (setq xesam-refreshing nil)))))
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
705
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
706
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
707 ;;; Search functions.
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
708
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
709 (defun xesam-signal-handler (&rest args)
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
710 "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
711 (let* ((service (dbus-event-service-name last-input-event))
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
712 (member (dbus-event-member-name last-input-event))
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
713 (search (nth 0 args))
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
714 (buffer (xesam-buffer-name service search)))
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
715
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
716 (when (get-buffer buffer)
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
717 (with-current-buffer buffer
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
718 (cond
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
719
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
720 ((string-equal member "HitsAdded")
97038
b201d17750ad * net/xesam.el (xesam-from): Remove defvar.
Michael Albinus <michael.albinus@gmx.de>
parents: 96996
diff changeset
721 (setq xesam-count (+ xesam-count (nth 1 args)))
96989
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
722 ;; 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
723 (run-at-time
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
724 0 nil
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
725 'xesam-refresh-search-buffer
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
726 (assoc service xesam-search-engines) search))
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
727
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
728 ((string-equal member "SearchDone")
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
729 (setq mode-line-process
97289
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
730 (propertize " Done" 'face 'xesam-mode-line))
96989
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
731 (force-mode-line-update)))))))
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
732
97289
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
733 (defun xesam-kill-buffer-function ()
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
734 "Send the CloseSearch indication."
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
735 (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
736 (xesam-dbus-call-method
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
737 :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
738 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
739
97170
dfc12ea9589f * net/xesam.el (xesam-type, xesam-query, xesam-xml-string): New
Michael Albinus <michael.albinus@gmx.de>
parents: 97038
diff changeset
740 (defun xesam-new-search (engine type query)
96989
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
741 "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
742 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
743 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
744 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
745 search, is returned."
96989
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
746 (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
747 (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
748 (xml-string
dfc12ea9589f * net/xesam.el (xesam-type, xesam-query, xesam-xml-string): New
Michael Albinus <michael.albinus@gmx.de>
parents: 97038
diff changeset
749 (format
dfc12ea9589f * net/xesam.el (xesam-type, xesam-query, xesam-xml-string): New
Michael Albinus <michael.albinus@gmx.de>
parents: 97038
diff changeset
750 (if (eq type 'user-query) xesam-user-query xesam-fulltext-query)
97455
a5d0ee62856d * net/xesam.el (xesam-refresh-entry): Use `save-excursion' in the
Michael Albinus <michael.albinus@gmx.de>
parents: 97399
diff changeset
751 (url-insert-entities-in-string query)))
97214
004f6dc1c1a0 * net/xesam.el (xesam-all-fields): Remove source and content
Michael Albinus <michael.albinus@gmx.de>
parents: 97170
diff changeset
752 (search (xesam-dbus-call-method
96989
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
753 :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
754 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
755
96989
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
756 ;; Let us notify for relevant signals. We ignore "HitsRemoved",
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
757 ;; "HitsModified" and "StateChanged"; there is nothing to do for
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
758 ;; us.
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
759 (dbus-register-signal
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
760 :session service xesam-path-search
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
761 xesam-interface-search "HitsAdded"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
762 'xesam-signal-handler search)
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
763 (dbus-register-signal
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
764 :session service xesam-path-search
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
765 xesam-interface-search "SearchDone"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
766 'xesam-signal-handler search)
97038
b201d17750ad * net/xesam.el (xesam-from): Remove defvar.
Michael Albinus <michael.albinus@gmx.de>
parents: 96996
diff changeset
767
96989
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
768 ;; Create the search buffer.
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
769 (with-current-buffer
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
770 (generate-new-buffer (xesam-buffer-name service search))
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
771 (switch-to-buffer-other-window (current-buffer))
97517
352b14f1dab0 * net/xesam.el (xesam-vendor, xesam-notify-function): New local
Michael Albinus <michael.albinus@gmx.de>
parents: 97455
diff changeset
772 ;; Inialize buffer with `xesam-mode'. `xesam-vendor' must be
352b14f1dab0 * net/xesam.el (xesam-vendor, xesam-notify-function): New local
Michael Albinus <michael.albinus@gmx.de>
parents: 97455
diff changeset
773 ;; set before calling `xesam-mode', because we want to give the
352b14f1dab0 * net/xesam.el (xesam-vendor, xesam-notify-function): New local
Michael Albinus <michael.albinus@gmx.de>
parents: 97455
diff changeset
774 ;; hook functions a chance to identify their search engine.
352b14f1dab0 * net/xesam.el (xesam-vendor, xesam-notify-function): New local
Michael Albinus <michael.albinus@gmx.de>
parents: 97455
diff changeset
775 (setq xesam-vendor (xesam-get-cached-property engine "vendor.id"))
96989
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
776 (xesam-mode)
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
777 (setq xesam-engine engine
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
778 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
779 ;; `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
780 ;; 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
781 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
782 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
783 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
784 xesam-objects nil
97038
b201d17750ad * net/xesam.el (xesam-from): Remove defvar.
Michael Albinus <michael.albinus@gmx.de>
parents: 96996
diff changeset
785 ;; 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
786 ;; 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
787 ;; information, when applicable.
96989
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
788 mode-line-buffer-identification
97038
b201d17750ad * net/xesam.el (xesam-from): Remove defvar.
Michael Albinus <michael.albinus@gmx.de>
parents: 96996
diff changeset
789 (if (not xesam-debug)
97517
352b14f1dab0 * net/xesam.el (xesam-vendor, xesam-notify-function): New local
Michael Albinus <michael.albinus@gmx.de>
parents: 97455
diff changeset
790 (list 12 (propertized-buffer-identification xesam-vendor))
97038
b201d17750ad * net/xesam.el (xesam-from): Remove defvar.
Michael Albinus <michael.albinus@gmx.de>
parents: 96996
diff changeset
791 (propertize
97517
352b14f1dab0 * net/xesam.el (xesam-vendor, xesam-notify-function): New local
Michael Albinus <michael.albinus@gmx.de>
parents: 97455
diff changeset
792 xesam-vendor
97214
004f6dc1c1a0 * net/xesam.el (xesam-all-fields): Remove source and content
Michael Albinus <michael.albinus@gmx.de>
parents: 97170
diff changeset
793 'help-echo
97038
b201d17750ad * net/xesam.el (xesam-from): Remove defvar.
Michael Albinus <michael.albinus@gmx.de>
parents: 96996
diff changeset
794 (mapconcat
97455
a5d0ee62856d * net/xesam.el (xesam-refresh-entry): Use `save-excursion' in the
Michael Albinus <michael.albinus@gmx.de>
parents: 97399
diff changeset
795 (lambda (x)
a5d0ee62856d * net/xesam.el (xesam-refresh-entry): Use `save-excursion' in the
Michael Albinus <michael.albinus@gmx.de>
parents: 97399
diff changeset
796 (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
797 '("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
798 "vendor.ontology.fields" "vendor.ontology.contents"
b201d17750ad * net/xesam.el (xesam-from): Remove defvar.
Michael Albinus <michael.albinus@gmx.de>
parents: 96996
diff changeset
799 "vendor.ontology.sources" "vendor.extensions"
b201d17750ad * net/xesam.el (xesam-from): Remove defvar.
Michael Albinus <michael.albinus@gmx.de>
parents: 96996
diff changeset
800 "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
801 "\n"))))
97289
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
802 (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
803 (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
804
dfc12ea9589f * net/xesam.el (xesam-type, xesam-query, xesam-xml-string): New
Michael Albinus <michael.albinus@gmx.de>
parents: 97038
diff changeset
805 ;; 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
806 (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
807 :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
808 xesam-interface-search "StartSearch" search)
96989
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
809
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
810 ;; Return search id.
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
811 search))
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
812
97399
7806c35019cb * net/xesam.el (xesam-search-engines): Add Debbugs hit fields.
Michael Albinus <michael.albinus@gmx.de>
parents: 97381
diff changeset
813 ;;;###autoload
96989
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
814 (defun xesam-search (engine query)
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
815 "Perform an interactive search.
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
816 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
817 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
818 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
819 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
820
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
821 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
822 Example:
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
823
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
824 (xesam-search (car (xesam-search-engines)) \"emacs\")"
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
825 (interactive
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
826 (let* ((vendors (mapcar
97455
a5d0ee62856d * net/xesam.el (xesam-refresh-entry): Use `save-excursion' in the
Michael Albinus <michael.albinus@gmx.de>
parents: 97399
diff changeset
827 (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
828 (xesam-search-engines)))
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
829 (vendor
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
830 (if (> (length vendors) 1)
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
831 (completing-read
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
832 "Enter search engine: " vendors nil t
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
833 (try-completion "" vendors) 'xesam-minibuffer-vendor-history)
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
834 (car vendors))))
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
835 (list
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
836 ;; ENGINE.
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
837 (when vendor
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
838 (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
839 (when (string-equal
004f6dc1c1a0 * net/xesam.el (xesam-all-fields): Remove source and content
Michael Albinus <michael.albinus@gmx.de>
parents: 97170
diff changeset
840 (xesam-get-cached-property elt "vendor.display") vendor)
96989
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
841 (setq engine elt))))
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
842 ;; QUERY.
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
843 (when vendor
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
844 (read-from-minibuffer
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
845 "Enter search string: " nil nil nil
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
846 'xesam-minibuffer-query-history)))))
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
847
97170
dfc12ea9589f * net/xesam.el (xesam-type, xesam-query, xesam-xml-string): New
Michael Albinus <michael.albinus@gmx.de>
parents: 97038
diff changeset
848 (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
849 (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
850 (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
851 (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
852 (xesam-new-search engine xesam-query-type query))))
96989
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
853
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
854 (provide 'xesam)
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
855
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
856 ;;; TODO:
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
857
97572
9fb28094a3cf * net/xesam.el (xesam-highlight-string): Precise doc string.
Michael Albinus <michael.albinus@gmx.de>
parents: 97517
diff changeset
858 ;; * Buffer highlighting needs better analysis of query string.
97289
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
859 ;; * 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
860 ;; * With prefix, let's choose search engine.
96989
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
861 ;; * Minibuffer completion for user queries.
97038
b201d17750ad * net/xesam.el (xesam-from): Remove defvar.
Michael Albinus <michael.albinus@gmx.de>
parents: 96996
diff changeset
862 ;; * `revert-buffer-function' implementation.
b201d17750ad * net/xesam.el (xesam-from): Remove defvar.
Michael Albinus <michael.albinus@gmx.de>
parents: 96996
diff changeset
863 ;;
96989
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
864 ;; * Mid term
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
865 ;; - If available, use ontologies for field selection.
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
866 ;; - Search engines for Emacs bugs database, wikipedia, google,
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
867 ;; yahoo, ebay, ...
97289
6cec2902d7b8 * net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents: 97214
diff changeset
868 ;; - 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
869
96996
3035988dd0b3 Add arch tagline
Miles Bader <miles@gnu.org>
parents: 96989
diff changeset
870 ;; arch-tag: 7fb9fc6c-c2ff-4bc7-bb42-bacb80cce2b2
96989
691e8bf892cb * net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
871 ;;; xesam.el ends here