Mercurial > emacs
comparison lisp/net/xesam.el @ 97399:7806c35019cb
* net/xesam.el (xesam-search-engines): Add Debbugs hit fields.
(xesam-refresh-entry): Add Debbugs handling. Insert a widget
"DONE", when all hits are retrieved.
(xesam-search): autoload it.
author | Michael Albinus <michael.albinus@gmx.de> |
---|---|
date | Sun, 10 Aug 2008 19:35:39 +0000 |
parents | 22514244a76d |
children | a5d0ee62856d |
comparison
equal
deleted
inserted
replaced
97398:fe058c1304c6 | 97399:7806c35019cb |
---|---|
20 ;; You should have received a copy of the GNU General Public License | 20 ;; You should have received a copy of the GNU General Public License |
21 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. | 21 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
22 | 22 |
23 ;;; Commentary: | 23 ;;; Commentary: |
24 | 24 |
25 ;; This package provides an interface to the Xesam, a D-Bus based "eXtEnsible | 25 ;; This package provides an interface to Xesam, a D-Bus based "eXtEnsible |
26 ;; Search And Metadata specification". It has been tested with | 26 ;; Search And Metadata specification". It has been tested with |
27 ;; | 27 ;; |
28 ;; xesam-glib 0.3.4, xesam-tools 0.6.1 | 28 ;; xesam-glib 0.3.4, xesam-tools 0.6.1 |
29 ;; beagle 0.3.7, beagle-xesam 0.2 | 29 ;; beagle 0.3.7, beagle-xesam 0.2 |
30 ;; strigi 0.5.11 | 30 ;; strigi 0.5.11 |
31 | 31 |
32 ;; The precondition for this package is a D-Bus aware Emacs. This is | 32 ;; The precondition for this package is a D-Bus aware Emacs. This is |
33 ;; configured per default, when Emacs is built on a machine running | 33 ;; configured per default, when Emacs is built on a machine running |
34 ;; D-Bus. Furthermore, there must be at least one search engine | 34 ;; D-Bus. Furthermore, there must be at least one search engine |
35 ;; running, which support the Xesam interface. Beagle and strigi have | 35 ;; running, which supports the Xesam interface. Beagle and strigi have |
36 ;; been tested; tracker, pinot and recoll are also said to support | 36 ;; been tested; tracker, pinot and recoll are also said to support |
37 ;; Xesam. You can check the existence of such a search engine by | 37 ;; Xesam. You can check the existence of such a search engine by |
38 ;; | 38 ;; |
39 ;; (dbus-list-queued-owners :session "org.freedesktop.xesam.searcher") | 39 ;; (dbus-list-queued-owners :session "org.freedesktop.xesam.searcher") |
40 | 40 |
378 | 378 |
379 ;; Ususally, `hit.fields' shall describe supported fields. | 379 ;; Ususally, `hit.fields' shall describe supported fields. |
380 ;; That is not the case now, so we set it ourselves. | 380 ;; That is not the case now, so we set it ourselves. |
381 ;; Hopefully, this will change later. | 381 ;; Hopefully, this will change later. |
382 (setq hit-fields | 382 (setq hit-fields |
383 (cond | 383 (case (intern vendor-id) |
384 ((string-equal vendor-id "Beagle") | 384 ('Beagle |
385 '("xesam:mimeType" "xesam:url")) | 385 '("xesam:mimeType" "xesam:url")) |
386 ((string-equal vendor-id "Strigi") | 386 ('Strigi |
387 '("xesam:author" "xesam:cc" "xesam:charset" | 387 '("xesam:author" "xesam:cc" "xesam:charset" |
388 "xesam:contentType" "xesam:fileExtension" "xesam:id" | 388 "xesam:contentType" "xesam:fileExtension" |
389 "xesam:lineCount" "xesam:links" "xesam:mimeType" "xesam:name" | 389 "xesam:id" "xesam:lineCount" "xesam:links" |
390 "xesam:size" "xesam:sourceModified" "xesam:subject" | 390 "xesam:mimeType" "xesam:name" "xesam:size" |
391 "xesam:to" "xesam:url")) | 391 "xesam:sourceModified" "xesam:subject" "xesam:to" |
392 ((string-equal vendor-id "TrackerXesamSession") | 392 "xesam:url")) |
393 '("xesam:relevancyRating" "xesam:url")) | 393 ('TrackerXesamSession |
394 ;; xesam-tools yahoo service. | 394 '("xesam:relevancyRating" "xesam:url")) |
395 (t '("xesam:contentModified" "xesam:mimeType" "xesam:summary" | 395 ('Debbugs |
396 "xesam:title" "xesam:url" "yahoo:displayUrl")))) | 396 '("xesam:keyword" "xesam:owner" "xesam:title" |
397 "xesam:url" "xesam:sourceModified" "xesam:mimeType" | |
398 "debbugs:key")) | |
399 ;; xesam-tools yahoo service. | |
400 (t '("xesam:contentModified" "xesam:mimeType" "xesam:summary" | |
401 "xesam:title" "xesam:url" "yahoo:displayUrl")))) | |
397 | 402 |
398 (xesam-set-property engine "hit.fields" hit-fields) | 403 (xesam-set-property engine "hit.fields" hit-fields) |
399 (xesam-set-property engine "hit.fields.extended" '("xesam:snippet")) | 404 (xesam-set-property engine "hit.fields.extended" '("xesam:snippet")) |
400 | 405 |
401 ;; Let us notify, when the search engine disappears. | 406 ;; Let us notify, when the search engine disappears. |
558 ;; In case of HTML, we use a URL link. | 563 ;; In case of HTML, we use a URL link. |
559 ((and (widget-member widget :xesam:mimeType) | 564 ((and (widget-member widget :xesam:mimeType) |
560 (string-equal "text/html" (widget-get widget :xesam:mimeType))) | 565 (string-equal "text/html" (widget-get widget :xesam:mimeType))) |
561 (setcar widget 'url-link)) | 566 (setcar widget 'url-link)) |
562 | 567 |
568 ;; Debbugs hits shall be displayed. | |
569 ((and (widget-member widget :xesam:mimeType) | |
570 (string-equal "application/x-debbugs" | |
571 (widget-get widget :xesam:mimeType))) | |
572 (widget-put | |
573 widget :notify | |
574 '(lambda (widget &rest ignore) | |
575 ;; We toggle. If there are already children, we delete them. | |
576 (if (widget-get widget :children) | |
577 (widget-children-value-delete widget) | |
578 | |
579 ;; No children. Let's display the messages. | |
580 (widget-end-of-line) | |
581 ;; Get hit data. Loop over results. | |
582 (dolist (data | |
583 ;; "GetHitData" returns a list. But we have | |
584 ;; requested just one element only. | |
585 (car | |
586 (xesam-dbus-call-method | |
587 :session (car xesam-engine) xesam-path-search | |
588 xesam-interface-search "GetHitData" xesam-search | |
589 (list (widget-get widget :debbugs:key)) | |
590 '("debbugs:key")))) | |
591 (let ((child | |
592 (widget-create-child-and-convert | |
593 ;; The result is a variant. So we must apply `car'. | |
594 widget '(link) :format "\n%h" :doc (car data)))) | |
595 ;; Add child to parent's list. Needed, in order to be | |
596 ;; able to delete it next toggle. | |
597 (widget-put | |
598 widget | |
599 :children (cons child (widget-get widget :children))))))))) | |
600 | |
563 ;; For local files, we will open the file as default action. | 601 ;; For local files, we will open the file as default action. |
564 ((string-match "file" | 602 ((string-match "file" |
565 (url-type (url-generic-parse-url | 603 (url-type (url-generic-parse-url |
566 (widget-get widget :xesam:url)))) | 604 (widget-get widget :xesam:url)))) |
567 (widget-put | 605 (widget-put |
651 (xesam-get-hits | 689 (xesam-get-hits |
652 engine search | 690 engine search |
653 (min xesam-hits-per-page | 691 (min xesam-hits-per-page |
654 (- (min (+ xesam-hits-per-page xesam-to) xesam-count) | 692 (- (min (+ xesam-hits-per-page xesam-to) xesam-count) |
655 (length xesam-objects)))))) | 693 (length xesam-objects)))))) |
694 | |
695 ;; Add "DONE" widget. | |
696 (when (= xesam-current xesam-count) | |
697 (goto-char (point-max)) | |
698 (widget-create 'link :notify 'ignore "DONE") | |
699 (widget-beginning-of-line)) | |
656 | 700 |
657 ;; Return with save settings. | 701 ;; Return with save settings. |
658 (setq xesam-refreshing nil))))) | 702 (setq xesam-refreshing nil))))) |
659 | 703 |
660 | 704 |
760 xesam-interface-search "StartSearch" search) | 804 xesam-interface-search "StartSearch" search) |
761 | 805 |
762 ;; Return search id. | 806 ;; Return search id. |
763 search)) | 807 search)) |
764 | 808 |
809 ;;;###autoload | |
765 (defun xesam-search (engine query) | 810 (defun xesam-search (engine query) |
766 "Perform an interactive search. | 811 "Perform an interactive search. |
767 ENGINE is the Xesam search engine to be applied, it must be one of the | 812 ENGINE is the Xesam search engine to be applied, it must be one of the |
768 entries of `xesam-search-engines'. QUERY is the search string in the | 813 entries of `xesam-search-engines'. QUERY is the search string in the |
769 Xesam user query language. If the search engine does not support | 814 Xesam user query language. If the search engine does not support |