Merge changes from emacs-23 branch.
[bpt/emacs.git] / lisp / net / xesam.el
index a877dbf..03c1880 100644 (file)
@@ -1,6 +1,6 @@
 ;;; xesam.el --- Xesam interface to search engines.
 
-;; Copyright (C) 2008 Free Software Foundation, Inc.
+;; Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc.
 
 ;; Author: Michael Albinus <michael.albinus@gmx.de>
 ;; Keywords: tools, hypermedia
 (defgroup xesam nil
   "Xesam compatible interface to search engines."
   :group 'extensions
-  :group 'hypermedia
+  :group 'comm
   :version "23.1")
 
 (defcustom xesam-query-type 'user-query
@@ -269,6 +269,8 @@ fields are supported.")
 </request>"
   "The Xesam fulltext query XML.")
 
+(declare-function dbus-get-unique-name "dbusbind.c" (bus))
+
 (defvar xesam-dbus-unique-names
   (list (cons :system (dbus-get-unique-name :system))
        (cons :session (dbus-get-unique-name :session)))
@@ -375,6 +377,8 @@ If PROPERTY is not existing, retrieve it from ENGINE first."
   (setq xesam-search-engines
        (delete (assoc (car args) xesam-search-engines) xesam-search-engines)))
 
+(defvar dbus-debug)
+
 (defun xesam-search-engines ()
   "Return Xesam search engines, stored in `xesam-search-engines'.
 The first search engine is the name owner of `xesam-service-search'.
@@ -498,7 +502,7 @@ engine specific, widget :notify function to visualize xesam:url."
                       'face 'xesam-mode-line
                       'help-echo (when xesam-debug xesam-xml-string)))))))
 
-  (when (not (interactive-p))
+  (when (not (called-interactively-p 'interactive))
     ;; Initialize buffer.
     (setq buffer-read-only t)
     (let ((inhibit-read-only t))
@@ -779,9 +783,10 @@ Return propertized STRING."
 (defun xesam-kill-buffer-function ()
   "Send the CloseSearch indication."
   (when (and (eq major-mode 'xesam-mode) (stringp xesam-search))
-    (xesam-dbus-call-method
-     :session (car xesam-engine) xesam-path-search
-     xesam-interface-search "CloseSearch" xesam-search)))
+    (ignore-errors ;; The D-Bus service could have disappeared.
+      (xesam-dbus-call-method
+       :session (car xesam-engine) xesam-path-search
+       xesam-interface-search "CloseSearch" xesam-search))))
 
 (defun xesam-new-search (engine type query)
   "Create a new search session.