aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Albinus2008-08-17 20:03:05 +0000
committerMichael Albinus2008-08-17 20:03:05 +0000
commit96038f81577a97c1f1d231d19d6752fde3035fd5 (patch)
tree86dfec0e634481f8941e874850a10c39596d1a5f
parent697f6b4371b1fdf1edebaec583d2b504c9b9422a (diff)
downloademacs-96038f81577a97c1f1d231d19d6752fde3035fd5.tar.gz
emacs-96038f81577a97c1f1d231d19d6752fde3035fd5.zip
* net/xesam.el (xesam-vendor, xesam-notify-function): New local
variables. (xesam-mode): Extend docstring. Initialize `xesam-notify-function'. (xesam-refresh-entry): Use `xesam-notify-function' if set. Remove Debbugs specific code; it shall be enabled via `xesam-mode-hooks'. (xesam-new-search): Initialize `xesam-vendor'.
-rw-r--r--lisp/ChangeLog9
-rw-r--r--lisp/net/xesam.el63
2 files changed, 33 insertions, 39 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 611b616d42a..801920d06a4 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,12 @@
12008-08-17 Michael Albinus <michael.albinus@gmx.de>
2
3 * net/xesam.el (xesam-vendor, xesam-notify-function): New local
4 variables.
5 (xesam-mode): Extend docstring. Initialize `xesam-notify-function'.
6 (xesam-refresh-entry): Use `xesam-notify-function' if set. Remove
7 Debbugs specific code; it shall be enabled via `xesam-mode-hooks'.
8 (xesam-new-search): Initialize `xesam-vendor'.
9
12008-08-15 Glenn Morris <rgm@gnu.org> 102008-08-15 Glenn Morris <rgm@gnu.org>
2 11
3 * eshell/esh-cmd.el (eshell-do-pipelines): Indicate the last command in 12 * eshell/esh-cmd.el (eshell-do-pipelines): Indicate the last command in
diff --git a/lisp/net/xesam.el b/lisp/net/xesam.el
index 719b5abd751..dda12607d9a 100644
--- a/lisp/net/xesam.el
+++ b/lisp/net/xesam.el
@@ -296,6 +296,10 @@ from VALUE, depending on what the search engine accepts."
296 "Interactive query history.") 296 "Interactive query history.")
297 297
298;; Pacify byte compiler. 298;; Pacify byte compiler.
299(defvar xesam-vendor nil)
300(make-variable-buffer-local 'xesam-vendor)
301(put 'xesam-vendor 'permanent-local t)
302
299(defvar xesam-engine nil) 303(defvar xesam-engine nil)
300(defvar xesam-search nil) 304(defvar xesam-search nil)
301(defvar xesam-type nil) 305(defvar xesam-type nil)
@@ -305,6 +309,7 @@ from VALUE, depending on what the search engine accepts."
305(defvar xesam-current nil) 309(defvar xesam-current nil)
306(defvar xesam-count nil) 310(defvar xesam-count nil)
307(defvar xesam-to nil) 311(defvar xesam-to nil)
312(defvar xesam-notify-function nil)
308(defvar xesam-refreshing nil) 313(defvar xesam-refreshing nil)
309 314
310 315
@@ -418,7 +423,11 @@ If there is no registered search engine at all, the function returns `nil'."
418In this mode, widgets represent the search results. 423In this mode, widgets represent the search results.
419 424
420\\{xesam-mode-map} 425\\{xesam-mode-map}
421Turning on Xesam mode runs the normal hook `xesam-mode-hook'." 426Turning on Xesam mode runs the normal hook `xesam-mode-hook'. It
427can be used to set `xesam-notify-function', which must a search
428engine specific, widget :notify function to visualize xesam:url."
429 (set (make-local-variable 'xesam-notify-function) nil)
430
422 ;; Keymap. 431 ;; Keymap.
423 (setq xesam-mode-map (copy-keymap special-mode-map)) 432 (setq xesam-mode-map (copy-keymap special-mode-map))
424 (set-keymap-parent xesam-mode-map widget-keymap) 433 (set-keymap-parent xesam-mode-map widget-keymap)
@@ -440,6 +449,9 @@ Turning on Xesam mode runs the normal hook `xesam-mode-hook'."
440 (set (make-local-variable 'xesam-count) 0) 449 (set (make-local-variable 'xesam-count) 0)
441 ;; `xesam-to' is the upper hit number to be presented. 450 ;; `xesam-to' is the upper hit number to be presented.
442 (set (make-local-variable 'xesam-to) xesam-hits-per-page) 451 (set (make-local-variable 'xesam-to) xesam-hits-per-page)
452 ;; `xesam-notify-function' can be a search engine specific function
453 ;; to visualize xesam:url. It can be overwritten in `xesam-mode'.
454 (set (make-local-variable 'xesam-notify-function) nil)
443 ;; `xesam-refreshing' is an indicator, whether the buffer is just 455 ;; `xesam-refreshing' is an indicator, whether the buffer is just
444 ;; being updated. Needed, because `xesam-refresh-search-buffer' 456 ;; being updated. Needed, because `xesam-refresh-search-buffer'
445 ;; can be triggered by an event. 457 ;; can be triggered by an event.
@@ -560,45 +572,16 @@ SEARCH is the search identification in that engine. Both must be strings."
560 (widget-put widget :value (widget-get widget :xesam:url)) 572 (widget-put widget :value (widget-get widget :xesam:url))
561 573
562 (cond 574 (cond
575 ;; A search engine can set `xesam-notify-function' via
576 ;; `xesam-mode-hooks'.
577 (xesam-notify-function
578 (widget-put widget :notify xesam-notify-function))
579
563 ;; In case of HTML, we use a URL link. 580 ;; In case of HTML, we use a URL link.
564 ((and (widget-member widget :xesam:mimeType) 581 ((and (widget-member widget :xesam:mimeType)
565 (string-equal "text/html" (widget-get widget :xesam:mimeType))) 582 (string-equal "text/html" (widget-get widget :xesam:mimeType)))
566 (setcar widget 'url-link)) 583 (setcar widget 'url-link))
567 584
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 (save-excursion
576 ;; We toggle. If there are already children, we delete them.
577 (if (widget-get widget :children)
578 (widget-children-value-delete widget)
579
580 ;; No children. Let's display the messages.
581 (widget-end-of-line)
582 ;; Get hit data. Loop over results.
583 (dolist (data
584 ;; "GetHitData" returns a list. But we have
585 ;; requested just one element only.
586 (car
587 (xesam-dbus-call-method
588 :session (car xesam-engine) xesam-path-search
589 xesam-interface-search "GetHitData" xesam-search
590 (list (widget-get widget :debbugs:key))
591 '("debbugs:key"))))
592 (let ((child
593 (widget-create-child-and-convert
594 ;; The result is a variant. So we must apply `car'.
595 widget '(link) :format "\n%h" :doc (car data))))
596 ;; Add child to parent's list. Needed, in order to be
597 ;; able to delete it next toggle.
598 (widget-put
599 widget
600 :children (cons child (widget-get widget :children))))))))))
601
602 ;; For local files, we will open the file as default action. 585 ;; For local files, we will open the file as default action.
603 ((string-match "file" 586 ((string-match "file"
604 (url-type (url-generic-parse-url 587 (url-type (url-generic-parse-url
@@ -768,6 +751,10 @@ search, is returned."
768 (with-current-buffer 751 (with-current-buffer
769 (generate-new-buffer (xesam-buffer-name service search)) 752 (generate-new-buffer (xesam-buffer-name service search))
770 (switch-to-buffer-other-window (current-buffer)) 753 (switch-to-buffer-other-window (current-buffer))
754 ;; Inialize buffer with `xesam-mode'. `xesam-vendor' must be
755 ;; set before calling `xesam-mode', because we want to give the
756 ;; hook functions a chance to identify their search engine.
757 (setq xesam-vendor (xesam-get-cached-property engine "vendor.id"))
771 (xesam-mode) 758 (xesam-mode)
772 (setq xesam-engine engine 759 (setq xesam-engine engine
773 xesam-search search 760 xesam-search search
@@ -782,11 +769,9 @@ search, is returned."
782 ;; information, when applicable. 769 ;; information, when applicable.
783 mode-line-buffer-identification 770 mode-line-buffer-identification
784 (if (not xesam-debug) 771 (if (not xesam-debug)
785 (list 772 (list 12 (propertized-buffer-identification xesam-vendor))
786 12 (propertized-buffer-identification
787 (xesam-get-cached-property engine "vendor.id")))
788 (propertize 773 (propertize
789 (xesam-get-cached-property engine "vendor.id") 774 xesam-vendor
790 'help-echo 775 'help-echo
791 (mapconcat 776 (mapconcat
792 (lambda (x) 777 (lambda (x)