Mercurial > emacs
annotate lisp/net/xesam.el @ 110482:99986de658d5
src/w32.c (get_emacs_configuration_options): Fix buffer overrun.
author | Juanma Barranquero <lekktu@gmail.com> |
---|---|
date | Wed, 22 Sep 2010 19:31:21 +0200 |
parents | 3c0cd76e49ff |
children | 417b1e4d63cd |
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 |
106815 | 3 ;; Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc. |
96989
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 | 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 | 12 ;; the Free Software Foundation, either version 3 of the License, or |
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 | 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 |
97618
1f7e10e015fd
* net/xesam.el (xesam-minor-mode): New minor mode.
Michael Albinus <michael.albinus@gmx.de>
parents:
97572
diff
changeset
|
104 ;; Search results are presented in a new buffer. This buffer has the |
1f7e10e015fd
* net/xesam.el (xesam-minor-mode): New minor mode.
Michael Albinus <michael.albinus@gmx.de>
parents:
97572
diff
changeset
|
105 ;; major mode `xesam-mode', with the following keybindings: |
1f7e10e015fd
* net/xesam.el (xesam-minor-mode): New minor mode.
Michael Albinus <michael.albinus@gmx.de>
parents:
97572
diff
changeset
|
106 |
1f7e10e015fd
* net/xesam.el (xesam-minor-mode): New minor mode.
Michael Albinus <michael.albinus@gmx.de>
parents:
97572
diff
changeset
|
107 ;; SPC `scroll-up' |
1f7e10e015fd
* net/xesam.el (xesam-minor-mode): New minor mode.
Michael Albinus <michael.albinus@gmx.de>
parents:
97572
diff
changeset
|
108 ;; DEL `scroll-down' |
1f7e10e015fd
* net/xesam.el (xesam-minor-mode): New minor mode.
Michael Albinus <michael.albinus@gmx.de>
parents:
97572
diff
changeset
|
109 ;; < `beginning-of-buffer' |
1f7e10e015fd
* net/xesam.el (xesam-minor-mode): New minor mode.
Michael Albinus <michael.albinus@gmx.de>
parents:
97572
diff
changeset
|
110 ;; > `end-of-buffer' |
1f7e10e015fd
* net/xesam.el (xesam-minor-mode): New minor mode.
Michael Albinus <michael.albinus@gmx.de>
parents:
97572
diff
changeset
|
111 ;; q `quit-window' |
1f7e10e015fd
* net/xesam.el (xesam-minor-mode): New minor mode.
Michael Albinus <michael.albinus@gmx.de>
parents:
97572
diff
changeset
|
112 ;; z `kill-this-buffer' |
1f7e10e015fd
* net/xesam.el (xesam-minor-mode): New minor mode.
Michael Albinus <michael.albinus@gmx.de>
parents:
97572
diff
changeset
|
113 ;; g `revert-buffer' |
1f7e10e015fd
* net/xesam.el (xesam-minor-mode): New minor mode.
Michael Albinus <michael.albinus@gmx.de>
parents:
97572
diff
changeset
|
114 |
1f7e10e015fd
* net/xesam.el (xesam-minor-mode): New minor mode.
Michael Albinus <michael.albinus@gmx.de>
parents:
97572
diff
changeset
|
115 ;; The search results are represented by widgets. Navigation commands |
1f7e10e015fd
* net/xesam.el (xesam-minor-mode): New minor mode.
Michael Albinus <michael.albinus@gmx.de>
parents:
97572
diff
changeset
|
116 ;; are the usual widget navigation commands: |
1f7e10e015fd
* net/xesam.el (xesam-minor-mode): New minor mode.
Michael Albinus <michael.albinus@gmx.de>
parents:
97572
diff
changeset
|
117 |
1f7e10e015fd
* net/xesam.el (xesam-minor-mode): New minor mode.
Michael Albinus <michael.albinus@gmx.de>
parents:
97572
diff
changeset
|
118 ;; TAB `widget-forward' |
1f7e10e015fd
* net/xesam.el (xesam-minor-mode): New minor mode.
Michael Albinus <michael.albinus@gmx.de>
parents:
97572
diff
changeset
|
119 ;; <backtab> `widget-backward' |
1f7e10e015fd
* net/xesam.el (xesam-minor-mode): New minor mode.
Michael Albinus <michael.albinus@gmx.de>
parents:
97572
diff
changeset
|
120 |
1f7e10e015fd
* net/xesam.el (xesam-minor-mode): New minor mode.
Michael Albinus <michael.albinus@gmx.de>
parents:
97572
diff
changeset
|
121 ;; Applying RET, <down-mouse-1>, or <down-mouse-2> on a URL belonging |
1f7e10e015fd
* net/xesam.el (xesam-minor-mode): New minor mode.
Michael Albinus <michael.albinus@gmx.de>
parents:
97572
diff
changeset
|
122 ;; to the widget, brings up more details of the search hit. The way, |
1f7e10e015fd
* net/xesam.el (xesam-minor-mode): New minor mode.
Michael Albinus <michael.albinus@gmx.de>
parents:
97572
diff
changeset
|
123 ;; how this hit is presented, depends on the type of the hit. HTML |
1f7e10e015fd
* net/xesam.el (xesam-minor-mode): New minor mode.
Michael Albinus <michael.albinus@gmx.de>
parents:
97572
diff
changeset
|
124 ;; files are opened via `browse-url'. Local files are opened in a new |
1f7e10e015fd
* net/xesam.el (xesam-minor-mode): New minor mode.
Michael Albinus <michael.albinus@gmx.de>
parents:
97572
diff
changeset
|
125 ;; buffer, with highlighted search hits (highlighting can be toggled |
1f7e10e015fd
* net/xesam.el (xesam-minor-mode): New minor mode.
Michael Albinus <michael.albinus@gmx.de>
parents:
97572
diff
changeset
|
126 ;; by `xesam-minor-mode' in that buffer). |
1f7e10e015fd
* net/xesam.el (xesam-minor-mode): New minor mode.
Michael Albinus <michael.albinus@gmx.de>
parents:
97572
diff
changeset
|
127 |
96989
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
128 ;;; Code: |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
129 |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
130 ;; 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
|
131 ;; option "--without-dbus". Declare used subroutines and variables. |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
132 (declare-function dbus-call-method "dbusbind.c") |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
133 (declare-function dbus-register-signal "dbusbind.c") |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
134 |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
135 (require 'dbus) |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
136 |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
137 ;; Pacify byte compiler. |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
138 (eval-when-compile |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
139 (require 'cl)) |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
140 |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
141 ;; Widgets are used to highlight the search results. |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
142 (require 'widget) |
97289
6cec2902d7b8
* net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents:
97214
diff
changeset
|
143 (require 'wid-edit) |
96989
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
144 |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
145 ;; `run-at-time' is used in the signal handler. |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
146 (require 'timer) |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
147 |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
148 ;; 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
|
149 (require 'url) |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
150 |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
151 (defgroup xesam nil |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
152 "Xesam compatible interface to search engines." |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
153 :group 'extensions |
107379
3c0cd76e49ff
Fix last change to use existing comm Custom group instead of `net'.
Chong Yidong <cyd@stupidchicken.com>
parents:
107378
diff
changeset
|
154 :group 'comm |
96989
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
155 :version "23.1") |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
156 |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
157 (defcustom xesam-query-type 'user-query |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
158 "Xesam query language type." |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
159 :group 'xesam |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
160 :type '(choice |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
161 (const :tag "Xesam user query" user-query) |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
162 (const :tag "Xesam fulltext query" fulltext-query))) |
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 (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
|
165 "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
|
166 :group 'xesam |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
167 :type 'integer) |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
168 |
97289
6cec2902d7b8
* net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents:
97214
diff
changeset
|
169 (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
|
170 "Face to highlight mode line." |
6cec2902d7b8
* net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents:
97214
diff
changeset
|
171 :group 'xesam) |
6cec2902d7b8
* net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents:
97214
diff
changeset
|
172 |
6cec2902d7b8
* net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents:
97214
diff
changeset
|
173 (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
|
174 "Face to highlight query entries. |
6cec2902d7b8
* net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents:
97214
diff
changeset
|
175 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
|
176 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
|
177 :group 'xesam) |
6cec2902d7b8
* net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents:
97214
diff
changeset
|
178 |
96989
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
179 (defvar xesam-debug nil |
97038
b201d17750ad
* net/xesam.el (xesam-from): Remove defvar.
Michael Albinus <michael.albinus@gmx.de>
parents:
96996
diff
changeset
|
180 "Insert debug information in the help echo.") |
96989
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
181 |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
182 (defconst xesam-service-search "org.freedesktop.xesam.searcher" |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
183 "The D-Bus name used to talk to Xesam.") |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
184 |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
185 (defconst xesam-path-search "/org/freedesktop/xesam/searcher/main" |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
186 "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
|
187 |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
188 ;; Methods: "NewSession", "SetProperty", "GetProperty", |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
189 ;; "CloseSession", "NewSearch", "StartSearch", "GetHitCount", |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
190 ;; "GetHits", "GetHitData", "CloseSearch" and "GetState". |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
191 ;; Signals: "HitsAdded", "HitsRemoved", "HitsModified", "SearchDone" |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
192 ;; and "StateChanged". |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
193 (defconst xesam-interface-search "org.freedesktop.xesam.Search" |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
194 "The D-Bus Xesam search interface.") |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
195 |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
196 (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
|
197 '("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
|
198 "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
|
199 "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
|
200 "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
|
201 "xesam:author" "xesam:bcc" "xesam:birthDate" "xesam:blogContactURL" |
96989
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
202 "xesam:cameraManufacturer" "xesam:cameraModel" "xesam:cc" "xesam:ccdWidth" |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
203 "xesam:cellPhoneNumber" "xesam:characterCount" "xesam:charset" |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
204 "xesam:colorCount" "xesam:colorSpace" "xesam:columnCount" "xesam:comment" |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
205 "xesam:commentCharacterCount" "xesam:conflicts" "xesam:contactMedium" |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
206 "xesam:contactName" "xesam:contactNick" "xesam:contactPhoto" |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
207 "xesam:contactURL" "xesam:contains" "xesam:contenKeyword" |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
208 "xesam:contentComment" "xesam:contentCreated" "xesam:contentModified" |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
209 "xesam:contentType" "xesam:contributor" "xesam:copyright" "xesam:creator" |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
210 "xesam:definesClass" "xesam:definesFunction" "xesam:definesGlobalVariable" |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
211 "xesam:deletionTime" "xesam:depends" "xesam:description" "xesam:device" |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
212 "xesam:disclaimer" "xesam:documentCategory" "xesam:duration" |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
213 "xesam:emailAddress" "xesam:eventEnd" "xesam:eventLocation" |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
214 "xesam:eventStart" "xesam:exposureBias" "xesam:exposureProgram" |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
215 "xesam:exposureTime" "xesam:faxPhoneNumber" "xesam:fileExtension" |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
216 "xesam:fileSystemType" "xesam:flashUsed" "xesam:focalLength" |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
217 "xesam:focusDistance" "xesam:formatSubtype" "xesam:frameCount" |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
218 "xesam:frameRate" "xesam:freeSpace" "xesam:gender" "xesam:generator" |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
219 "xesam:generatorOptions" "xesam:group" "xesam:hash" "xesam:hash" |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
220 "xesam:height" "xesam:homeEmailAddress" "xesam:homePhoneNumber" |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
221 "xesam:homePostalAddress" "xesam:homepageContactURL" |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
222 "xesam:horizontalResolution" "xesam:icqContactMedium" "xesam:id" |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
223 "xesam:imContactMedium" "xesam:interests" "xesam:interlaceMode" |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
224 "xesam:isEncrypted" "xesam:isImportant" "xesam:isInProgress" |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
225 "xesam:isPasswordProtected" "xesam:isRead" "xesam:isoEquivalent" |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
226 "xesam:jabberContactMedium" "xesam:keyword" "xesam:language" "xesam:legal" |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
227 "xesam:license" "xesam:licenseType" "xesam:lineCount" "xesam:links" |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
228 "xesam:mailingPostalAddress" "xesam:maintainer" "xesam:md5Hash" |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
229 "xesam:mediaCodec" "xesam:mediaCodecBitrate" "xesam:mediaCodecType" |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
230 "xesam:meteringMode" "xesam:mimeType" "xesam:mountPoint" |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
231 "xesam:msnContactMedium" "xesam:name" "xesam:occupiedSpace" |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
232 "xesam:orientation" "xesam:originalLocation" "xesam:owner" |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
233 "xesam:pageCount" "xesam:permissions" "xesam:phoneNumber" |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
234 "xesam:physicalAddress" "xesam:pixelFormat" "xesam:primaryRecipient" |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
235 "xesam:programmingLanguage" "xesam:rating" "xesam:receptionTime" |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
236 "xesam:recipient" "xesam:related" "xesam:remoteUser" "xesam:rowCount" |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
237 "xesam:sampleBitDepth" "xesam:sampleFormat" "xesam:secondaryRecipient" |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
238 "xesam:sha1Hash" "xesam:size" "xesam:skypeContactMedium" |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
239 "xesam:sourceCreated" "xesam:sourceModified" "xesam:storageSize" |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
240 "xesam:subject" "xesam:supercedes" "xesam:title" "xesam:to" |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
241 "xesam:totalSpace" "xesam:totalUncompressedSize" "xesam:url" |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
242 "xesam:usageIntensity" "xesam:userComment" "xesam:userKeyword" |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
243 "xesam:uuid" "xesam:version" "xesam:verticalResolution" "xesam:videoBirate" |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
244 "xesam:videoCodec" "xesam:videoCodecType" "xesam:whiteBalance" |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
245 "xesam:width" "xesam:wordCount" "xesam:workEmailAddress" |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
246 "xesam:workPhoneNumber" "xesam:workPostalAddress" |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
247 "xesam:yahooContactMedium") |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
248 "All fields from the Xesam Core Ontology. |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
249 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
|
250 fields are supported.") |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
251 |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
252 (defconst xesam-user-query |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
253 "<?xml version=\"1.0\" encoding=\"UTF-8\"?> |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
254 <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
|
255 <userQuery> |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
256 %s |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
257 </userQuery> |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
258 </request>" |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
259 "The Xesam user query XML.") |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
260 |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
261 (defconst xesam-fulltext-query |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
262 "<?xml version=\"1.0\" encoding=\"UTF-8\"?> |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
263 <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
|
264 <query content=\"xesam:Document\" source=\"xesam:File\"> |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
265 <fullText> |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
266 <string>%s</string> |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
267 </fullText> |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
268 </query> |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
269 </request>" |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
270 "The Xesam fulltext query XML.") |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
271 |
99207
c52fc3b138ed
(dbus-get-unique-name, dbus-debug): Declare.
Glenn Morris <rgm@gnu.org>
parents:
97802
diff
changeset
|
272 (declare-function dbus-get-unique-name "dbusbind.c" (bus)) |
c52fc3b138ed
(dbus-get-unique-name, dbus-debug): Declare.
Glenn Morris <rgm@gnu.org>
parents:
97802
diff
changeset
|
273 |
97214
004f6dc1c1a0
* net/xesam.el (xesam-all-fields): Remove source and content
Michael Albinus <michael.albinus@gmx.de>
parents:
97170
diff
changeset
|
274 (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
|
275 (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
|
276 (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
|
277 "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
|
278 |
004f6dc1c1a0
* net/xesam.el (xesam-all-fields): Remove source and content
Michael Albinus <michael.albinus@gmx.de>
parents:
97170
diff
changeset
|
279 (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
|
280 "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
|
281 `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
|
282 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
|
283 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
|
284 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
|
285 functions." |
004f6dc1c1a0
* net/xesam.el (xesam-all-fields): Remove source and content
Michael Albinus <michael.albinus@gmx.de>
parents:
97170
diff
changeset
|
286 (apply |
004f6dc1c1a0
* net/xesam.el (xesam-all-fields): Remove source and content
Michael Albinus <michael.albinus@gmx.de>
parents:
97170
diff
changeset
|
287 ;; 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
|
288 (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
|
289 (cadr args)) |
004f6dc1c1a0
* net/xesam.el (xesam-all-fields): Remove source and content
Michael Albinus <michael.albinus@gmx.de>
parents:
97170
diff
changeset
|
290 '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
|
291 args)) |
004f6dc1c1a0
* net/xesam.el (xesam-all-fields): Remove source and content
Michael Albinus <michael.albinus@gmx.de>
parents:
97170
diff
changeset
|
292 |
96989
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
293 (defun xesam-get-property (engine property) |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
294 "Return the PROPERTY value of ENGINE." |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
295 ;; "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
|
296 (car (xesam-dbus-call-method |
96989
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
297 :session (car engine) xesam-path-search |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
298 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
|
299 (xesam-get-cached-property engine "session") property))) |
96989
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
300 |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
301 (defun xesam-set-property (engine property value) |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
302 "Set the PROPERTY of ENGINE to VALUE. |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
303 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
|
304 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
|
305 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
|
306 from VALUE, depending on what the search engine accepts." |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
307 ;; "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
|
308 (car (xesam-dbus-call-method |
96989
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
309 :session (car engine) xesam-path-search |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
310 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
|
311 (xesam-get-cached-property engine "session") property |
96989
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
312 ;; 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
|
313 ;; 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
|
314 ;; 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
|
315 ;; engine. |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
316 (list :variant value)))) |
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-minibuffer-vendor-history nil |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
319 "Interactive vendor history.") |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
320 |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
321 (defvar xesam-minibuffer-query-history nil |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
322 "Interactive query history.") |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
323 |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
324 ;; 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
|
325 (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
|
326 (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
|
327 (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
|
328 |
96989
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
329 (defvar xesam-engine nil) |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
330 (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
|
331 (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
|
332 (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
|
333 (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
|
334 (defvar xesam-objects nil) |
96989
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
335 (defvar xesam-current nil) |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
336 (defvar xesam-count nil) |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
337 (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
|
338 (defvar xesam-notify-function nil) |
96989
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
339 (defvar xesam-refreshing nil) |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
340 |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
341 |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
342 ;;; Search engines. |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
343 |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
344 (defvar xesam-search-engines nil |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
345 "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
|
346 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
|
347 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
|
348 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
|
349 identifier, and the display name. Example: |
96989
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
350 |
97214
004f6dc1c1a0
* net/xesam.el (xesam-all-fields): Remove source and content
Michael Albinus <michael.albinus@gmx.de>
parents:
97170
diff
changeset
|
351 \(\(\":1.59\" |
004f6dc1c1a0
* net/xesam.el (xesam-all-fields): Remove source and content
Michael Albinus <michael.albinus@gmx.de>
parents:
97170
diff
changeset
|
352 \(\"session\" . \"0t1214948020ut358230u0p2698r3912347765k3213849828\") |
004f6dc1c1a0
* net/xesam.el (xesam-all-fields): Remove source and content
Michael Albinus <michael.albinus@gmx.de>
parents:
97170
diff
changeset
|
353 \(\"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
|
354 \(\":1.27\" |
004f6dc1c1a0
* net/xesam.el (xesam-all-fields): Remove source and content
Michael Albinus <michael.albinus@gmx.de>
parents:
97170
diff
changeset
|
355 \(\"session\" . \"strigisession1369133069\") |
004f6dc1c1a0
* net/xesam.el (xesam-all-fields): Remove source and content
Michael Albinus <michael.albinus@gmx.de>
parents:
97170
diff
changeset
|
356 \(\"vendor.display\" . \"Strigi Desktop Search\"))) |
96989
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
357 |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
358 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
|
359 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
|
360 |
004f6dc1c1a0
* net/xesam.el (xesam-all-fields): Remove source and content
Michael Albinus <michael.albinus@gmx.de>
parents:
97170
diff
changeset
|
361 (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
|
362 "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
|
363 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
|
364 ;; 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
|
365 ;; 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
|
366 (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
|
367 (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
|
368 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
|
369 (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
|
370 |
004f6dc1c1a0
* net/xesam.el (xesam-all-fields): Remove source and content
Michael Albinus <michael.albinus@gmx.de>
parents:
97170
diff
changeset
|
371 (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
|
372 "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
|
373 (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
|
374 |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
375 (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
|
376 "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
|
377 (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
|
378 (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
|
379 |
99207
c52fc3b138ed
(dbus-get-unique-name, dbus-debug): Declare.
Glenn Morris <rgm@gnu.org>
parents:
97802
diff
changeset
|
380 (defvar dbus-debug) |
c52fc3b138ed
(dbus-get-unique-name, dbus-debug): Declare.
Glenn Morris <rgm@gnu.org>
parents:
97802
diff
changeset
|
381 |
96989
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
382 (defun xesam-search-engines () |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
383 "Return Xesam search engines, stored in `xesam-search-engines'. |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
384 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
|
385 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
|
386 (let ((services (dbus-ignore-errors |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
387 (dbus-list-queued-owners |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
388 :session xesam-service-search))) |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
389 engine vendor-id hit-fields) |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
390 (dolist (service services) |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
391 (unless (assoc-string service xesam-search-engines) |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
392 |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
393 ;; 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
|
394 (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
|
395 (setq engine (assoc service xesam-search-engines)) |
96989
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
396 |
97214
004f6dc1c1a0
* net/xesam.el (xesam-all-fields): Remove source and content
Michael Albinus <michael.albinus@gmx.de>
parents:
97170
diff
changeset
|
397 ;; 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
|
398 (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
|
399 engine "session" |
004f6dc1c1a0
* net/xesam.el (xesam-all-fields): Remove source and content
Michael Albinus <michael.albinus@gmx.de>
parents:
97170
diff
changeset
|
400 (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
|
401 :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
|
402 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
|
403 |
004f6dc1c1a0
* net/xesam.el (xesam-all-fields): Remove source and content
Michael Albinus <michael.albinus@gmx.de>
parents:
97170
diff
changeset
|
404 ;; 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
|
405 ;; 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
|
406 (xesam-set-property engine "search.live" nil) |
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 ;; Check the vendor properties. |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
409 (setq vendor-id (xesam-get-property engine "vendor.id") |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
410 hit-fields (xesam-get-property engine "hit.fields")) |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
411 |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
412 ;; Ususally, `hit.fields' shall describe supported fields. |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
413 ;; 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
|
414 ;; Hopefully, this will change later. |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
415 (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
|
416 (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
|
417 ('Beagle |
7806c35019cb
* net/xesam.el (xesam-search-engines): Add Debbugs hit fields.
Michael Albinus <michael.albinus@gmx.de>
parents:
97381
diff
changeset
|
418 '("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
|
419 ('Strigi |
7806c35019cb
* net/xesam.el (xesam-search-engines): Add Debbugs hit fields.
Michael Albinus <michael.albinus@gmx.de>
parents:
97381
diff
changeset
|
420 '("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
|
421 "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
|
422 "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
|
423 "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
|
424 "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
|
425 "xesam:url")) |
7806c35019cb
* net/xesam.el (xesam-search-engines): Add Debbugs hit fields.
Michael Albinus <michael.albinus@gmx.de>
parents:
97381
diff
changeset
|
426 ('TrackerXesamSession |
7806c35019cb
* net/xesam.el (xesam-search-engines): Add Debbugs hit fields.
Michael Albinus <michael.albinus@gmx.de>
parents:
97381
diff
changeset
|
427 '("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
|
428 ('Debbugs |
7806c35019cb
* net/xesam.el (xesam-search-engines): Add Debbugs hit fields.
Michael Albinus <michael.albinus@gmx.de>
parents:
97381
diff
changeset
|
429 '("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
|
430 "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
|
431 "debbugs:key")) |
7806c35019cb
* net/xesam.el (xesam-search-engines): Add Debbugs hit fields.
Michael Albinus <michael.albinus@gmx.de>
parents:
97381
diff
changeset
|
432 ;; 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
|
433 (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
|
434 "xesam:title" "xesam:url" "yahoo:displayUrl")))) |
96989
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
435 |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
436 (xesam-set-property engine "hit.fields" hit-fields) |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
437 (xesam-set-property engine "hit.fields.extended" '("xesam:snippet")) |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
438 |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
439 ;; Let us notify, when the search engine disappears. |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
440 (dbus-register-signal |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
441 :session dbus-service-dbus dbus-path-dbus |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
442 dbus-interface-dbus "NameOwnerChanged" |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
443 'xesam-delete-search-engine service)))) |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
444 xesam-search-engines) |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
445 |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
446 |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
447 ;;; Search buffers. |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
448 |
97170
dfc12ea9589f
* net/xesam.el (xesam-type, xesam-query, xesam-xml-string): New
Michael Albinus <michael.albinus@gmx.de>
parents:
97038
diff
changeset
|
449 (define-derived-mode xesam-mode nil "Xesam" |
96989
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
450 "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
|
451 In this mode, widgets represent the search results. |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
452 |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
453 \\{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
|
454 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
|
455 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
|
456 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
|
457 (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
|
458 |
97170
dfc12ea9589f
* net/xesam.el (xesam-type, xesam-query, xesam-xml-string): New
Michael Albinus <michael.albinus@gmx.de>
parents:
97038
diff
changeset
|
459 ;; Keymap. |
dfc12ea9589f
* net/xesam.el (xesam-type, xesam-query, xesam-xml-string): New
Michael Albinus <michael.albinus@gmx.de>
parents:
97038
diff
changeset
|
460 (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
|
461 (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
|
462 (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
|
463 |
dfc12ea9589f
* net/xesam.el (xesam-type, xesam-query, xesam-xml-string): New
Michael Albinus <michael.albinus@gmx.de>
parents:
97038
diff
changeset
|
464 ;; 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
|
465 (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
|
466 ;; `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
|
467 ;; `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
|
468 (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
|
469 (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
|
470 (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
|
471 (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
|
472 (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
|
473 (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
|
474 ;; `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
|
475 (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
|
476 ;; `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
|
477 (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
|
478 ;; `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
|
479 (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
|
480 ;; `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
|
481 ;; 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
|
482 (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
|
483 ;; `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
|
484 ;; 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
|
485 ;; 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
|
486 (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
|
487 ;; 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
|
488 (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
|
489 (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
|
490 '(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
|
491 ;; 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
|
492 (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
|
493 (list '(20 |
dfc12ea9589f
* net/xesam.el (xesam-type, xesam-query, xesam-xml-string): New
Michael Albinus <michael.albinus@gmx.de>
parents:
97038
diff
changeset
|
494 (:eval |
dfc12ea9589f
* net/xesam.el (xesam-type, xesam-query, xesam-xml-string): New
Michael Albinus <michael.albinus@gmx.de>
parents:
97038
diff
changeset
|
495 (list "Type: " |
97289
6cec2902d7b8
* net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents:
97214
diff
changeset
|
496 (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
|
497 '(10 |
dfc12ea9589f
* net/xesam.el (xesam-type, xesam-query, xesam-xml-string): New
Michael Albinus <michael.albinus@gmx.de>
parents:
97038
diff
changeset
|
498 (:eval |
dfc12ea9589f
* net/xesam.el (xesam-type, xesam-query, xesam-xml-string): New
Michael Albinus <michael.albinus@gmx.de>
parents:
97038
diff
changeset
|
499 (list " Query: " |
dfc12ea9589f
* net/xesam.el (xesam-type, xesam-query, xesam-xml-string): New
Michael Albinus <michael.albinus@gmx.de>
parents:
97038
diff
changeset
|
500 (propertize |
dfc12ea9589f
* net/xesam.el (xesam-type, xesam-query, xesam-xml-string): New
Michael Albinus <michael.albinus@gmx.de>
parents:
97038
diff
changeset
|
501 xesam-query |
97289
6cec2902d7b8
* net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents:
97214
diff
changeset
|
502 '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
|
503 '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
|
504 |
105372
bd2966850aac
Use `called-interactively-p' instead of `interactive-p'.
Juanma Barranquero <lekktu@gmail.com>
parents:
100908
diff
changeset
|
505 (when (not (called-interactively-p 'interactive)) |
97038
b201d17750ad
* net/xesam.el (xesam-from): Remove defvar.
Michael Albinus <michael.albinus@gmx.de>
parents:
96996
diff
changeset
|
506 ;; Initialize buffer. |
b201d17750ad
* net/xesam.el (xesam-from): Remove defvar.
Michael Albinus <michael.albinus@gmx.de>
parents:
96996
diff
changeset
|
507 (setq buffer-read-only t) |
b201d17750ad
* net/xesam.el (xesam-from): Remove defvar.
Michael Albinus <michael.albinus@gmx.de>
parents:
96996
diff
changeset
|
508 (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
|
509 (erase-buffer)))) |
96989
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
510 |
97170
dfc12ea9589f
* net/xesam.el (xesam-type, xesam-query, xesam-xml-string): New
Michael Albinus <michael.albinus@gmx.de>
parents:
97038
diff
changeset
|
511 ;; 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
|
512 (put 'xesam-mode 'disabled t) |
96989
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
513 |
97289
6cec2902d7b8
* net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents:
97214
diff
changeset
|
514 ;; 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
|
515 ;; 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
|
516 (with-temp-buffer (xesam-mode)) |
6cec2902d7b8
* net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents:
97214
diff
changeset
|
517 |
97618
1f7e10e015fd
* net/xesam.el (xesam-minor-mode): New minor mode.
Michael Albinus <michael.albinus@gmx.de>
parents:
97572
diff
changeset
|
518 (define-minor-mode xesam-minor-mode |
1f7e10e015fd
* net/xesam.el (xesam-minor-mode): New minor mode.
Michael Albinus <michael.albinus@gmx.de>
parents:
97572
diff
changeset
|
519 "Toggle Xesam minor mode. |
1f7e10e015fd
* net/xesam.el (xesam-minor-mode): New minor mode.
Michael Albinus <michael.albinus@gmx.de>
parents:
97572
diff
changeset
|
520 With no argument, this command toggles the mode. |
1f7e10e015fd
* net/xesam.el (xesam-minor-mode): New minor mode.
Michael Albinus <michael.albinus@gmx.de>
parents:
97572
diff
changeset
|
521 Non-null prefix argument turns on the mode. |
1f7e10e015fd
* net/xesam.el (xesam-minor-mode): New minor mode.
Michael Albinus <michael.albinus@gmx.de>
parents:
97572
diff
changeset
|
522 Null prefix argument turns off the mode. |
1f7e10e015fd
* net/xesam.el (xesam-minor-mode): New minor mode.
Michael Albinus <michael.albinus@gmx.de>
parents:
97572
diff
changeset
|
523 |
1f7e10e015fd
* net/xesam.el (xesam-minor-mode): New minor mode.
Michael Albinus <michael.albinus@gmx.de>
parents:
97572
diff
changeset
|
524 When Xesam minor mode is enabled, all text which matches a |
1f7e10e015fd
* net/xesam.el (xesam-minor-mode): New minor mode.
Michael Albinus <michael.albinus@gmx.de>
parents:
97572
diff
changeset
|
525 previous Xesam query in this buffer is highlighted." |
1f7e10e015fd
* net/xesam.el (xesam-minor-mode): New minor mode.
Michael Albinus <michael.albinus@gmx.de>
parents:
97572
diff
changeset
|
526 :group 'xesam |
1f7e10e015fd
* net/xesam.el (xesam-minor-mode): New minor mode.
Michael Albinus <michael.albinus@gmx.de>
parents:
97572
diff
changeset
|
527 :init-value nil |
1f7e10e015fd
* net/xesam.el (xesam-minor-mode): New minor mode.
Michael Albinus <michael.albinus@gmx.de>
parents:
97572
diff
changeset
|
528 :lighter " Xesam" |
1f7e10e015fd
* net/xesam.el (xesam-minor-mode): New minor mode.
Michael Albinus <michael.albinus@gmx.de>
parents:
97572
diff
changeset
|
529 (when (local-variable-p 'xesam-query) |
1f7e10e015fd
* net/xesam.el (xesam-minor-mode): New minor mode.
Michael Albinus <michael.albinus@gmx.de>
parents:
97572
diff
changeset
|
530 ;; Run only if the buffer is related to a Xesam search. |
1f7e10e015fd
* net/xesam.el (xesam-minor-mode): New minor mode.
Michael Albinus <michael.albinus@gmx.de>
parents:
97572
diff
changeset
|
531 (save-excursion |
1f7e10e015fd
* net/xesam.el (xesam-minor-mode): New minor mode.
Michael Albinus <michael.albinus@gmx.de>
parents:
97572
diff
changeset
|
532 (if xesam-minor-mode |
1f7e10e015fd
* net/xesam.el (xesam-minor-mode): New minor mode.
Michael Albinus <michael.albinus@gmx.de>
parents:
97572
diff
changeset
|
533 ;; Highlight hits. |
1f7e10e015fd
* net/xesam.el (xesam-minor-mode): New minor mode.
Michael Albinus <michael.albinus@gmx.de>
parents:
97572
diff
changeset
|
534 (let ((query-regexp (regexp-opt (split-string xesam-query nil t) t)) |
1f7e10e015fd
* net/xesam.el (xesam-minor-mode): New minor mode.
Michael Albinus <michael.albinus@gmx.de>
parents:
97572
diff
changeset
|
535 (case-fold-search t)) |
1f7e10e015fd
* net/xesam.el (xesam-minor-mode): New minor mode.
Michael Albinus <michael.albinus@gmx.de>
parents:
97572
diff
changeset
|
536 ;; I have no idea whether people will like setting |
1f7e10e015fd
* net/xesam.el (xesam-minor-mode): New minor mode.
Michael Albinus <michael.albinus@gmx.de>
parents:
97572
diff
changeset
|
537 ;; `isearch-case-fold-search' and `query-regexp'. Maybe |
1f7e10e015fd
* net/xesam.el (xesam-minor-mode): New minor mode.
Michael Albinus <michael.albinus@gmx.de>
parents:
97572
diff
changeset
|
538 ;; this shall be controlled by a custom option. |
1f7e10e015fd
* net/xesam.el (xesam-minor-mode): New minor mode.
Michael Albinus <michael.albinus@gmx.de>
parents:
97572
diff
changeset
|
539 (unless isearch-case-fold-search (isearch-toggle-case-fold)) |
1f7e10e015fd
* net/xesam.el (xesam-minor-mode): New minor mode.
Michael Albinus <michael.albinus@gmx.de>
parents:
97572
diff
changeset
|
540 (isearch-update-ring query-regexp t) |
1f7e10e015fd
* net/xesam.el (xesam-minor-mode): New minor mode.
Michael Albinus <michael.albinus@gmx.de>
parents:
97572
diff
changeset
|
541 ;; Create overlays. |
1f7e10e015fd
* net/xesam.el (xesam-minor-mode): New minor mode.
Michael Albinus <michael.albinus@gmx.de>
parents:
97572
diff
changeset
|
542 (goto-char (point-min)) |
1f7e10e015fd
* net/xesam.el (xesam-minor-mode): New minor mode.
Michael Albinus <michael.albinus@gmx.de>
parents:
97572
diff
changeset
|
543 (while (re-search-forward query-regexp nil t) |
1f7e10e015fd
* net/xesam.el (xesam-minor-mode): New minor mode.
Michael Albinus <michael.albinus@gmx.de>
parents:
97572
diff
changeset
|
544 (overlay-put |
1f7e10e015fd
* net/xesam.el (xesam-minor-mode): New minor mode.
Michael Albinus <michael.albinus@gmx.de>
parents:
97572
diff
changeset
|
545 (make-overlay |
1f7e10e015fd
* net/xesam.el (xesam-minor-mode): New minor mode.
Michael Albinus <michael.albinus@gmx.de>
parents:
97572
diff
changeset
|
546 (match-beginning 0) (match-end 0)) 'face 'xesam-highlight))) |
1f7e10e015fd
* net/xesam.el (xesam-minor-mode): New minor mode.
Michael Albinus <michael.albinus@gmx.de>
parents:
97572
diff
changeset
|
547 ;; Remove overlays. |
1f7e10e015fd
* net/xesam.el (xesam-minor-mode): New minor mode.
Michael Albinus <michael.albinus@gmx.de>
parents:
97572
diff
changeset
|
548 (dolist (ov (overlays-in (point-min) (point-max))) |
1f7e10e015fd
* net/xesam.el (xesam-minor-mode): New minor mode.
Michael Albinus <michael.albinus@gmx.de>
parents:
97572
diff
changeset
|
549 (delete-overlay ov)))))) |
1f7e10e015fd
* net/xesam.el (xesam-minor-mode): New minor mode.
Michael Albinus <michael.albinus@gmx.de>
parents:
97572
diff
changeset
|
550 |
96989
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
551 (defun xesam-buffer-name (service search) |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
552 "Return the buffer name where to present search results. |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
553 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
|
554 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
|
555 (format "*%s/%s*" service search)) |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
556 |
97289
6cec2902d7b8
* net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents:
97214
diff
changeset
|
557 (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
|
558 "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
|
559 Return propertized STRING." |
97289
6cec2902d7b8
* net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents:
97214
diff
changeset
|
560 (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
|
561 (setq string |
6cec2902d7b8
* net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents:
97214
diff
changeset
|
562 (format |
6cec2902d7b8
* net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents:
97214
diff
changeset
|
563 "%s%s%s" |
6cec2902d7b8
* net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents:
97214
diff
changeset
|
564 (match-string 1 string) |
6cec2902d7b8
* net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents:
97214
diff
changeset
|
565 (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
|
566 (match-string 5 string)))) |
6cec2902d7b8
* net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents:
97214
diff
changeset
|
567 string) |
6cec2902d7b8
* net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents:
97214
diff
changeset
|
568 |
6cec2902d7b8
* net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents:
97214
diff
changeset
|
569 (defun xesam-refresh-entry (engine entry) |
96989
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
570 "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
|
571 (let* ((result (nth (1- xesam-current) xesam-objects)) |
96989
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
572 widget) |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
573 |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
574 ;; Create widget. |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
575 (setq widget (widget-convert 'link)) |
97038
b201d17750ad
* net/xesam.el (xesam-from): Remove defvar.
Michael Albinus <michael.albinus@gmx.de>
parents:
96996
diff
changeset
|
576 (when xesam-debug |
b201d17750ad
* net/xesam.el (xesam-from): Remove defvar.
Michael Albinus <michael.albinus@gmx.de>
parents:
96996
diff
changeset
|
577 (widget-put widget :help-echo "")) |
96989
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
578 |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
579 ;; 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
|
580 (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
|
581 (when (cond |
6cec2902d7b8
* net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents:
97214
diff
changeset
|
582 ((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
|
583 ((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
|
584 ((caar result) t)) |
96989
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
585 (when xesam-debug |
97038
b201d17750ad
* net/xesam.el (xesam-from): Remove defvar.
Michael Albinus <michael.albinus@gmx.de>
parents:
96996
diff
changeset
|
586 (widget-put |
b201d17750ad
* net/xesam.el (xesam-from): Remove defvar.
Michael Albinus <michael.albinus@gmx.de>
parents:
96996
diff
changeset
|
587 widget :help-echo |
b201d17750ad
* net/xesam.el (xesam-from): Remove defvar.
Michael Albinus <michael.albinus@gmx.de>
parents:
96996
diff
changeset
|
588 (format "%s%s: %s\n" |
b201d17750ad
* net/xesam.el (xesam-from): Remove defvar.
Michael Albinus <michael.albinus@gmx.de>
parents:
96996
diff
changeset
|
589 (widget-get widget :help-echo) field (caar result)))) |
96989
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
590 (widget-put widget (intern (concat ":" field)) (caar result))) |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
591 (setq result (cdr result))) |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
592 |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
593 ;; 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
|
594 (when |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
595 (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
|
596 (widget-put |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
597 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
|
598 |
97289
6cec2902d7b8
* net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents:
97214
diff
changeset
|
599 ;; 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
|
600 (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
|
601 (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
|
602 (widget-put |
6cec2902d7b8
* net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents:
97214
diff
changeset
|
603 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
|
604 |
96989
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
605 ;; First line: :tag. |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
606 (cond |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
607 ((widget-member widget :xesam:title) |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
608 (widget-put widget :tag (widget-get widget :xesam:title))) |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
609 ((widget-member widget :xesam:subject) |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
610 (widget-put widget :tag (widget-get widget :xesam:subject))) |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
611 ((widget-member widget :xesam:mimeType) |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
612 (widget-put widget :tag (widget-get widget :xesam:mimeType))) |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
613 ((widget-member widget :xesam:name) |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
614 (widget-put widget :tag (widget-get widget :xesam:name)))) |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
615 |
97289
6cec2902d7b8
* net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents:
97214
diff
changeset
|
616 ;; Highlight the search items. |
6cec2902d7b8
* net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents:
97214
diff
changeset
|
617 (when (widget-member widget :tag) |
6cec2902d7b8
* net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents:
97214
diff
changeset
|
618 (widget-put |
6cec2902d7b8
* net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents:
97214
diff
changeset
|
619 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
|
620 |
96989
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
621 ;; Last Modified. |
97572
9fb28094a3cf
* net/xesam.el (xesam-highlight-string): Precise doc string.
Michael Albinus <michael.albinus@gmx.de>
parents:
97517
diff
changeset
|
622 (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
|
623 (not |
9fb28094a3cf
* net/xesam.el (xesam-highlight-string): Precise doc string.
Michael Albinus <michael.albinus@gmx.de>
parents:
97517
diff
changeset
|
624 (zerop |
9fb28094a3cf
* net/xesam.el (xesam-highlight-string): Precise doc string.
Michael Albinus <michael.albinus@gmx.de>
parents:
97517
diff
changeset
|
625 (string-to-number (widget-get widget :xesam:sourceModified))))) |
96989
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
626 (widget-put |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
627 widget :tag |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
628 (format |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
629 "%s\nLast Modified: %s" |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
630 (or (widget-get widget :tag) "") |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
631 (format-time-string |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
632 "%d %B %Y, %T" |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
633 (seconds-to-time |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
634 (string-to-number (widget-get widget :xesam:sourceModified))))))) |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
635 |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
636 ;; Second line: :value. |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
637 (widget-put widget :value (widget-get widget :xesam:url)) |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
638 |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
639 (cond |
97517
352b14f1dab0
* net/xesam.el (xesam-vendor, xesam-notify-function): New local
Michael Albinus <michael.albinus@gmx.de>
parents:
97455
diff
changeset
|
640 ;; 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
|
641 ;; `xesam-mode-hooks'. |
352b14f1dab0
* net/xesam.el (xesam-vendor, xesam-notify-function): New local
Michael Albinus <michael.albinus@gmx.de>
parents:
97455
diff
changeset
|
642 (xesam-notify-function |
352b14f1dab0
* net/xesam.el (xesam-vendor, xesam-notify-function): New local
Michael Albinus <michael.albinus@gmx.de>
parents:
97455
diff
changeset
|
643 (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
|
644 |
96989
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
645 ;; In case of HTML, we use a URL link. |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
646 ((and (widget-member widget :xesam:mimeType) |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
647 (string-equal "text/html" (widget-get widget :xesam:mimeType))) |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
648 (setcar widget 'url-link)) |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
649 |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
650 ;; 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
|
651 ((string-match "file" |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
652 (url-type (url-generic-parse-url |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
653 (widget-get widget :xesam:url)))) |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
654 (widget-put |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
655 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
|
656 (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
|
657 (let ((query xesam-query)) |
9fb28094a3cf
* net/xesam.el (xesam-highlight-string): Precise doc string.
Michael Albinus <michael.albinus@gmx.de>
parents:
97517
diff
changeset
|
658 (find-file |
9fb28094a3cf
* net/xesam.el (xesam-highlight-string): Precise doc string.
Michael Albinus <michael.albinus@gmx.de>
parents:
97517
diff
changeset
|
659 (url-filename (url-generic-parse-url (widget-value widget)))) |
97618
1f7e10e015fd
* net/xesam.el (xesam-minor-mode): New minor mode.
Michael Albinus <michael.albinus@gmx.de>
parents:
97572
diff
changeset
|
660 (set (make-local-variable 'xesam-query) query) |
1f7e10e015fd
* net/xesam.el (xesam-minor-mode): New minor mode.
Michael Albinus <michael.albinus@gmx.de>
parents:
97572
diff
changeset
|
661 (xesam-minor-mode 1)))) |
96989
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
662 (widget-put |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
663 widget :value |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
664 (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
|
665 |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
666 ;; Third line: :doc. |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
667 (cond |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
668 ((widget-member widget :xesam:summary) |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
669 (widget-put widget :doc (widget-get widget :xesam:summary))) |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
670 ((widget-member widget :xesam:snippet) |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
671 (widget-put widget :doc (widget-get widget :xesam:snippet)))) |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
672 |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
673 (when (widget-member widget :doc) |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
674 (with-temp-buffer |
97289
6cec2902d7b8
* net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents:
97214
diff
changeset
|
675 (insert |
6cec2902d7b8
* net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents:
97214
diff
changeset
|
676 (xesam-highlight-string (widget-get widget :doc))) |
96989
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
677 (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
|
678 (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
|
679 (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
|
680 |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
681 ;; Format the widget. |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
682 (widget-put |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
683 widget :format |
97038
b201d17750ad
* net/xesam.el (xesam-from): Remove defvar.
Michael Albinus <michael.albinus@gmx.de>
parents:
96996
diff
changeset
|
684 (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
|
685 (if (widget-member widget :tag) "%{%t%}\n" "") |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
686 (if (widget-member widget :doc) "%h" ""))) |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
687 |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
688 ;; Write widget. |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
689 (goto-char (point-max)) |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
690 (widget-default-create widget) |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
691 (set-buffer-modified-p nil) |
97038
b201d17750ad
* net/xesam.el (xesam-from): Remove defvar.
Michael Albinus <michael.albinus@gmx.de>
parents:
96996
diff
changeset
|
692 (force-mode-line-update) |
96989
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
693 (redisplay))) |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
694 |
97289
6cec2902d7b8
* net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents:
97214
diff
changeset
|
695 (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
|
696 "Retrieve hits from ENGINE." |
6cec2902d7b8
* net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents:
97214
diff
changeset
|
697 (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
|
698 (setq xesam-objects |
6cec2902d7b8
* net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents:
97214
diff
changeset
|
699 (append xesam-objects |
6cec2902d7b8
* net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents:
97214
diff
changeset
|
700 (xesam-dbus-call-method |
6cec2902d7b8
* net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents:
97214
diff
changeset
|
701 :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
|
702 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
|
703 |
96989
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
704 (defun xesam-refresh-search-buffer (engine search) |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
705 "Refreshes the buffer, presenting results of SEARCH." |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
706 (with-current-buffer (xesam-buffer-name (car engine) search) |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
707 ;; 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
|
708 (unless (or xesam-refreshing (>= xesam-current xesam-to)) |
96989
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
709 (setq xesam-refreshing t) |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
710 (unwind-protect |
97289
6cec2902d7b8
* net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents:
97214
diff
changeset
|
711 (let (widget) |
6cec2902d7b8
* net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents:
97214
diff
changeset
|
712 |
6cec2902d7b8
* net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents:
97214
diff
changeset
|
713 ;; Retrieve needed hits for visualization. |
6cec2902d7b8
* net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents:
97214
diff
changeset
|
714 (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
|
715 (xesam-get-hits |
6cec2902d7b8
* net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents:
97214
diff
changeset
|
716 engine search |
6cec2902d7b8
* net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents:
97214
diff
changeset
|
717 (min xesam-hits-per-page |
6cec2902d7b8
* net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents:
97214
diff
changeset
|
718 (- (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
|
719 |
6cec2902d7b8
* net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents:
97214
diff
changeset
|
720 ;; Add all result widgets. |
97038
b201d17750ad
* net/xesam.el (xesam-from): Remove defvar.
Michael Albinus <michael.albinus@gmx.de>
parents:
96996
diff
changeset
|
721 (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
|
722 (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
|
723 (xesam-refresh-entry engine search)) |
96989
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
724 |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
725 ;; Add "NEXT" widget. |
97289
6cec2902d7b8
* net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents:
97214
diff
changeset
|
726 (when (> xesam-count xesam-to) |
96989
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
727 (goto-char (point-max)) |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
728 (widget-create |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
729 'link |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
730 :notify |
97455
a5d0ee62856d
* net/xesam.el (xesam-refresh-entry): Use `save-excursion' in the
Michael Albinus <michael.albinus@gmx.de>
parents:
97399
diff
changeset
|
731 (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
|
732 (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
|
733 (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
|
734 (xesam-refresh-search-buffer xesam-engine xesam-search)) |
96989
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
735 "NEXT") |
97289
6cec2902d7b8
* net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents:
97214
diff
changeset
|
736 (widget-beginning-of-line)) |
6cec2902d7b8
* net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents:
97214
diff
changeset
|
737 |
6cec2902d7b8
* net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents:
97214
diff
changeset
|
738 ;; Prefetch next hits. |
6cec2902d7b8
* net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents:
97214
diff
changeset
|
739 (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
|
740 (length xesam-objects)) |
6cec2902d7b8
* net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents:
97214
diff
changeset
|
741 (xesam-get-hits |
6cec2902d7b8
* net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents:
97214
diff
changeset
|
742 engine search |
6cec2902d7b8
* net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents:
97214
diff
changeset
|
743 (min xesam-hits-per-page |
6cec2902d7b8
* net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents:
97214
diff
changeset
|
744 (- (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
|
745 (length xesam-objects))))) |
96989
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
746 |
97399
7806c35019cb
* net/xesam.el (xesam-search-engines): Add Debbugs hit fields.
Michael Albinus <michael.albinus@gmx.de>
parents:
97381
diff
changeset
|
747 ;; Add "DONE" widget. |
7806c35019cb
* net/xesam.el (xesam-search-engines): Add Debbugs hit fields.
Michael Albinus <michael.albinus@gmx.de>
parents:
97381
diff
changeset
|
748 (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
|
749 (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
|
750 (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
|
751 (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
|
752 |
96989
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
753 ;; Return with save settings. |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
754 (setq xesam-refreshing nil))))) |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
755 |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
756 |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
757 ;;; Search functions. |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
758 |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
759 (defun xesam-signal-handler (&rest args) |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
760 "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
|
761 (let* ((service (dbus-event-service-name last-input-event)) |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
762 (member (dbus-event-member-name last-input-event)) |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
763 (search (nth 0 args)) |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
764 (buffer (xesam-buffer-name service search))) |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
765 |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
766 (when (get-buffer buffer) |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
767 (with-current-buffer buffer |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
768 (cond |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
769 |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
770 ((string-equal member "HitsAdded") |
97038
b201d17750ad
* net/xesam.el (xesam-from): Remove defvar.
Michael Albinus <michael.albinus@gmx.de>
parents:
96996
diff
changeset
|
771 (setq xesam-count (+ xesam-count (nth 1 args))) |
96989
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
772 ;; 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
|
773 (run-at-time |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
774 0 nil |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
775 'xesam-refresh-search-buffer |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
776 (assoc service xesam-search-engines) search)) |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
777 |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
778 ((string-equal member "SearchDone") |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
779 (setq mode-line-process |
97289
6cec2902d7b8
* net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents:
97214
diff
changeset
|
780 (propertize " Done" 'face 'xesam-mode-line)) |
96989
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
781 (force-mode-line-update))))))) |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
782 |
97289
6cec2902d7b8
* net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents:
97214
diff
changeset
|
783 (defun xesam-kill-buffer-function () |
6cec2902d7b8
* net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents:
97214
diff
changeset
|
784 "Send the CloseSearch indication." |
6cec2902d7b8
* net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents:
97214
diff
changeset
|
785 (when (and (eq major-mode 'xesam-mode) (stringp xesam-search)) |
97802
48c669cb45f9
* net/xesam.el (xesam-kill-buffer-function): Wrap code by
Michael Albinus <michael.albinus@gmx.de>
parents:
97618
diff
changeset
|
786 (ignore-errors ;; The D-Bus service could have disappeared. |
48c669cb45f9
* net/xesam.el (xesam-kill-buffer-function): Wrap code by
Michael Albinus <michael.albinus@gmx.de>
parents:
97618
diff
changeset
|
787 (xesam-dbus-call-method |
48c669cb45f9
* net/xesam.el (xesam-kill-buffer-function): Wrap code by
Michael Albinus <michael.albinus@gmx.de>
parents:
97618
diff
changeset
|
788 :session (car xesam-engine) xesam-path-search |
48c669cb45f9
* net/xesam.el (xesam-kill-buffer-function): Wrap code by
Michael Albinus <michael.albinus@gmx.de>
parents:
97618
diff
changeset
|
789 xesam-interface-search "CloseSearch" xesam-search)))) |
97289
6cec2902d7b8
* net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents:
97214
diff
changeset
|
790 |
97170
dfc12ea9589f
* net/xesam.el (xesam-type, xesam-query, xesam-xml-string): New
Michael Albinus <michael.albinus@gmx.de>
parents:
97038
diff
changeset
|
791 (defun xesam-new-search (engine type query) |
96989
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
792 "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
|
793 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
|
794 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
|
795 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
|
796 search, is returned." |
96989
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
797 (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
|
798 (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
|
799 (xml-string |
dfc12ea9589f
* net/xesam.el (xesam-type, xesam-query, xesam-xml-string): New
Michael Albinus <michael.albinus@gmx.de>
parents:
97038
diff
changeset
|
800 (format |
dfc12ea9589f
* net/xesam.el (xesam-type, xesam-query, xesam-xml-string): New
Michael Albinus <michael.albinus@gmx.de>
parents:
97038
diff
changeset
|
801 (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
|
802 (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
|
803 (search (xesam-dbus-call-method |
96989
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
804 :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
|
805 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
|
806 |
96989
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
807 ;; Let us notify for relevant signals. We ignore "HitsRemoved", |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
808 ;; "HitsModified" and "StateChanged"; there is nothing to do for |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
809 ;; us. |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
810 (dbus-register-signal |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
811 :session service xesam-path-search |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
812 xesam-interface-search "HitsAdded" |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
813 'xesam-signal-handler search) |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
814 (dbus-register-signal |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
815 :session service xesam-path-search |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
816 xesam-interface-search "SearchDone" |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
817 'xesam-signal-handler search) |
97038
b201d17750ad
* net/xesam.el (xesam-from): Remove defvar.
Michael Albinus <michael.albinus@gmx.de>
parents:
96996
diff
changeset
|
818 |
96989
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
819 ;; Create the search buffer. |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
820 (with-current-buffer |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
821 (generate-new-buffer (xesam-buffer-name service search)) |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
822 (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
|
823 ;; 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
|
824 ;; 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
|
825 ;; 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
|
826 (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
|
827 (xesam-mode) |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
828 (setq xesam-engine engine |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
829 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
|
830 ;; `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
|
831 ;; 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
|
832 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
|
833 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
|
834 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
|
835 xesam-objects nil |
97038
b201d17750ad
* net/xesam.el (xesam-from): Remove defvar.
Michael Albinus <michael.albinus@gmx.de>
parents:
96996
diff
changeset
|
836 ;; 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
|
837 ;; 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
|
838 ;; information, when applicable. |
96989
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
839 mode-line-buffer-identification |
97038
b201d17750ad
* net/xesam.el (xesam-from): Remove defvar.
Michael Albinus <michael.albinus@gmx.de>
parents:
96996
diff
changeset
|
840 (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
|
841 (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
|
842 (propertize |
97517
352b14f1dab0
* net/xesam.el (xesam-vendor, xesam-notify-function): New local
Michael Albinus <michael.albinus@gmx.de>
parents:
97455
diff
changeset
|
843 xesam-vendor |
97214
004f6dc1c1a0
* net/xesam.el (xesam-all-fields): Remove source and content
Michael Albinus <michael.albinus@gmx.de>
parents:
97170
diff
changeset
|
844 'help-echo |
97038
b201d17750ad
* net/xesam.el (xesam-from): Remove defvar.
Michael Albinus <michael.albinus@gmx.de>
parents:
96996
diff
changeset
|
845 (mapconcat |
97455
a5d0ee62856d
* net/xesam.el (xesam-refresh-entry): Use `save-excursion' in the
Michael Albinus <michael.albinus@gmx.de>
parents:
97399
diff
changeset
|
846 (lambda (x) |
a5d0ee62856d
* net/xesam.el (xesam-refresh-entry): Use `save-excursion' in the
Michael Albinus <michael.albinus@gmx.de>
parents:
97399
diff
changeset
|
847 (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
|
848 '("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
|
849 "vendor.ontology.fields" "vendor.ontology.contents" |
b201d17750ad
* net/xesam.el (xesam-from): Remove defvar.
Michael Albinus <michael.albinus@gmx.de>
parents:
96996
diff
changeset
|
850 "vendor.ontology.sources" "vendor.extensions" |
b201d17750ad
* net/xesam.el (xesam-from): Remove defvar.
Michael Albinus <michael.albinus@gmx.de>
parents:
96996
diff
changeset
|
851 "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
|
852 "\n")))) |
97289
6cec2902d7b8
* net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents:
97214
diff
changeset
|
853 (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
|
854 (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
|
855 |
dfc12ea9589f
* net/xesam.el (xesam-type, xesam-query, xesam-xml-string): New
Michael Albinus <michael.albinus@gmx.de>
parents:
97038
diff
changeset
|
856 ;; 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
|
857 (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
|
858 :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
|
859 xesam-interface-search "StartSearch" search) |
96989
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
860 |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
861 ;; Return search id. |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
862 search)) |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
863 |
97399
7806c35019cb
* net/xesam.el (xesam-search-engines): Add Debbugs hit fields.
Michael Albinus <michael.albinus@gmx.de>
parents:
97381
diff
changeset
|
864 ;;;###autoload |
96989
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
865 (defun xesam-search (engine query) |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
866 "Perform an interactive search. |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
867 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
|
868 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
|
869 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
|
870 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
|
871 |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
872 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
|
873 Example: |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
874 |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
875 (xesam-search (car (xesam-search-engines)) \"emacs\")" |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
876 (interactive |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
877 (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
|
878 (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
|
879 (xesam-search-engines))) |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
880 (vendor |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
881 (if (> (length vendors) 1) |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
882 (completing-read |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
883 "Enter search engine: " vendors nil t |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
884 (try-completion "" vendors) 'xesam-minibuffer-vendor-history) |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
885 (car vendors)))) |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
886 (list |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
887 ;; ENGINE. |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
888 (when vendor |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
889 (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
|
890 (when (string-equal |
004f6dc1c1a0
* net/xesam.el (xesam-all-fields): Remove source and content
Michael Albinus <michael.albinus@gmx.de>
parents:
97170
diff
changeset
|
891 (xesam-get-cached-property elt "vendor.display") vendor) |
96989
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
892 (setq engine elt)))) |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
893 ;; QUERY. |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
894 (when vendor |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
895 (read-from-minibuffer |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
896 "Enter search string: " nil nil nil |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
897 'xesam-minibuffer-query-history))))) |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
898 |
97170
dfc12ea9589f
* net/xesam.el (xesam-type, xesam-query, xesam-xml-string): New
Michael Albinus <michael.albinus@gmx.de>
parents:
97038
diff
changeset
|
899 (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
|
900 (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
|
901 (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
|
902 (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
|
903 (xesam-new-search engine xesam-query-type query)))) |
96989
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
904 |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
905 (provide 'xesam) |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
906 |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
907 ;;; TODO: |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
908 |
97572
9fb28094a3cf
* net/xesam.el (xesam-highlight-string): Precise doc string.
Michael Albinus <michael.albinus@gmx.de>
parents:
97517
diff
changeset
|
909 ;; * 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
|
910 ;; * 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
|
911 ;; * With prefix, let's choose search engine. |
96989
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
912 ;; * Minibuffer completion for user queries. |
97038
b201d17750ad
* net/xesam.el (xesam-from): Remove defvar.
Michael Albinus <michael.albinus@gmx.de>
parents:
96996
diff
changeset
|
913 ;; * `revert-buffer-function' implementation. |
b201d17750ad
* net/xesam.el (xesam-from): Remove defvar.
Michael Albinus <michael.albinus@gmx.de>
parents:
96996
diff
changeset
|
914 ;; |
96989
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
915 ;; * Mid term |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
916 ;; - If available, use ontologies for field selection. |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
917 ;; - Search engines for Emacs bugs database, wikipedia, google, |
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
918 ;; yahoo, ebay, ... |
97289
6cec2902d7b8
* net/xesam.el (top): Require `wid-edit' always.
Michael Albinus <michael.albinus@gmx.de>
parents:
97214
diff
changeset
|
919 ;; - 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
|
920 |
96996 | 921 ;; arch-tag: 7fb9fc6c-c2ff-4bc7-bb42-bacb80cce2b2 |
96989
691e8bf892cb
* net/xesam.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
922 ;;; xesam.el ends here |