aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Albinus2008-07-26 18:55:02 +0000
committerMichael Albinus2008-07-26 18:55:02 +0000
commitde8bb89eb29db44e0a9f0d89c81b4931f50a6566 (patch)
tree29092065224fa68bfa16cca242e71a773637669d
parent9064669d013ddd167e85231c0b80237e8b36a9bb (diff)
downloademacs-de8bb89eb29db44e0a9f0d89c81b4931f50a6566.tar.gz
emacs-de8bb89eb29db44e0a9f0d89c81b4931f50a6566.zip
* net/xesam.el (xesam-from): Remove defvar.
(xesam-mode): Derive from `special-mode'. Extend `xesam-mode-map' and `mode-line-position'. (xesam-refresh-entry): Remove argument `hit-number'. Add debug information to the widgets. Don't set `mode-line-position'. (xesam-refresh-search-buffer): Correct hit number computing. Don't set `mode-line-position'. (xesam-new-search): Add debug information to the mode line.
-rw-r--r--lisp/ChangeLog23
-rw-r--r--lisp/net/xesam.el143
2 files changed, 94 insertions, 72 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index ce3a81033b3..af55d6d8ed3 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,26 @@
12008-07-26 Michael Albinus <michael.albinus@gmx.de>
2
3 * net/tramp.el (tramp-handle-start-file-process): Set
4 query-on-exit flag. Kill temporary buffer.
5 (tramp-process-sentinel): Remove defun.
6 (tramp-do-copy-or-rename-file-out-of-band)
7 (tramp-maybe-open-connection):Don't call it.
8
9 * net/tramp-fish.el (tramp-fish-maybe-open-connection): Don't call
10 `tramp-process-sentinel'.
11
12 * net/tramp-smb.el (tramp-smb-maybe-open-connection): Don't call
13 `tramp-process-sentinel'.
14
15 * net/xesam.el (xesam-from): Remove defvar.
16 (xesam-mode): Derive from `special-mode'. Extend `xesam-mode-map'
17 and `mode-line-position'.
18 (xesam-refresh-entry): Remove argument `hit-number'. Add debug
19 information to the widgets. Don't set `mode-line-position'.
20 (xesam-refresh-search-buffer): Correct hit number computing.
21 Don't set `mode-line-position'.
22 (xesam-new-search): Add debug information to the mode line.
23
12008-07-25 Vinicius Jose Latorre <viniciusjl@ig.com.br> 242008-07-25 Vinicius Jose Latorre <viniciusjl@ig.com.br>
2 25
3 * diff-mode.el (diff-show-trailing-blanks): Renamed to 26 * diff-mode.el (diff-show-trailing-blanks): Renamed to
diff --git a/lisp/net/xesam.el b/lisp/net/xesam.el
index 2d4b2658a07..b508f9f497b 100644
--- a/lisp/net/xesam.el
+++ b/lisp/net/xesam.el
@@ -146,7 +146,7 @@
146 :type 'integer) 146 :type 'integer)
147 147
148(defvar xesam-debug nil 148(defvar xesam-debug nil
149 "Insert debug information.") 149 "Insert debug information in the help echo.")
150 150
151(defconst xesam-service-search "org.freedesktop.xesam.searcher" 151(defconst xesam-service-search "org.freedesktop.xesam.searcher"
152 "The D-Bus name used to talk to Xesam.") 152 "The D-Bus name used to talk to Xesam.")
@@ -283,7 +283,6 @@ from VALUE, depending on what the search engine accepts."
283(defvar xesam-search nil) 283(defvar xesam-search nil)
284(defvar xesam-current nil) 284(defvar xesam-current nil)
285(defvar xesam-count nil) 285(defvar xesam-count nil)
286(defvar xesam-from nil)
287(defvar xesam-to nil) 286(defvar xesam-to nil)
288(defvar xesam-refreshing nil) 287(defvar xesam-refreshing nil)
289 288
@@ -369,34 +368,42 @@ If there is no registered search engine at all, the function returns `nil'."
369 368
370;;; Search buffers. 369;;; Search buffers.
371 370
372(define-derived-mode xesam-mode nil "Xesam" 371(define-derived-mode xesam-mode special-mode "Xesam"
373 "Major mode for presenting search results of a Xesam search. 372 "Major mode for presenting search results of a Xesam search.
374In this mode, widgets represent the search results. 373In this mode, widgets represent the search results.
375 374
376\\{xesam-mode-map} 375\\{xesam-mode-map}
377Turning on Xesam mode runs the normal hook `xesam-mode-hook'." 376Turning on Xesam mode runs the normal hook `xesam-mode-hook'."
378 ;; Initialize buffer. 377 (when (not (interactive-p))
379 (setq buffer-read-only t) 378 ;; Initialize buffer.
380 (let ((inhibit-read-only t)) 379 (setq buffer-read-only t)
381 (erase-buffer)) 380 (let ((inhibit-read-only t))
382 381 (erase-buffer))
383 ;; Keymap. 382
384 (set-keymap-parent xesam-mode-map widget-keymap) 383 ;; Keymap.
385 (define-key xesam-mode-map "q" 'quit-window) 384 (setq xesam-mode-map (copy-keymap special-mode-map))
386 385 (set-keymap-parent xesam-mode-map widget-keymap)
387 ;; Local variables. 386 (define-key xesam-mode-map "z" 'kill-this-buffer)
388 (set (make-local-variable 'mode-line-position) (list "%p (0/0)")) 387
389 ;; `xesam-engine' and `xesam-search' will be set in `xesam-new-search'. 388 ;; Maybe we implement something useful, later on.
390 (set (make-local-variable 'xesam-engine) nil) 389 (set (make-local-variable 'revert-buffer-function) 'ignore)
391 (set (make-local-variable 'xesam-search) nil) 390 ;; `xesam-engine' and `xesam-search' will be set in `xesam-new-search'.
392 (set (make-local-variable 'xesam-current) 1) 391 (set (make-local-variable 'xesam-engine) nil)
393 (set (make-local-variable 'xesam-count) 0) 392 (set (make-local-variable 'xesam-search) nil)
394 (set (make-local-variable 'xesam-from) 1) 393 ;; `xesam-current' is the last hit put into the search buffer,
395 (set (make-local-variable 'xesam-to) xesam-hits-per-page) 394 (set (make-local-variable 'xesam-current) 0)
396 ;; `xesam-refreshing' is an indicator, whether the buffer is just 395 ;; `xesam-count' is the number of hits reported by the search engine.
397 ;; being updated. Needed, because `xesam-refresh-search-buffer' 396 (set (make-local-variable 'xesam-count) 0)
398 ;; can be triggered by an event. 397 ;; `xesam-to' is the upper hit number to be presented.
399 (set (make-local-variable 'xesam-refreshing) nil)) 398 (set (make-local-variable 'xesam-to) xesam-hits-per-page)
399 ;; `xesam-refreshing' is an indicator, whether the buffer is just
400 ;; being updated. Needed, because `xesam-refresh-search-buffer'
401 ;; can be triggered by an event.
402 (set (make-local-variable 'xesam-refreshing) nil)
403 ;; Mode line position returns hit counters.
404 (set (make-local-variable 'mode-line-position)
405 (list '(-3 "%p%")
406 '(10 (:eval (format " (%d/%d)" xesam-current xesam-count)))))))
400 407
401(defun xesam-buffer-name (service search) 408(defun xesam-buffer-name (service search)
402 "Return the buffer name where to present search results. 409 "Return the buffer name where to present search results.
@@ -404,7 +411,7 @@ SERVICE is the D-Bus unique service name of the Xesam search engine.
404SEARCH is the search identification in that engine. Both must be strings." 411SEARCH is the search identification in that engine. Both must be strings."
405 (format "*%s/%s*" service search)) 412 (format "*%s/%s*" service search))
406 413
407(defun xesam-refresh-entry (engine search hit-number) 414(defun xesam-refresh-entry (engine search)
408 "Refreshes one entry in the search buffer." 415 "Refreshes one entry in the search buffer."
409 (let* ((result 416 (let* ((result
410 (car 417 (car
@@ -419,17 +426,22 @@ SEARCH is the search identification in that engine. Both must be strings."
419; (dbus-call-method 426; (dbus-call-method
420; :session (car engine) xesam-path-search 427; :session (car engine) xesam-path-search
421; xesam-interface-search "GetHitData" 428; xesam-interface-search "GetHitData"
422; search (list hit-number) '("snippet"))))) 429; search (list xesam-current) '("snippet")))))
423 widget) 430 widget)
424 431
425 ;; Create widget. 432 ;; Create widget.
426 (setq widget (widget-convert 'link)) 433 (setq widget (widget-convert 'link))
434 (when xesam-debug
435 (widget-put widget :help-echo ""))
427 436
428 ;; Take all results. 437 ;; Take all results.
429 (dolist (field (xesam-get-property engine "hit.fields")) 438 (dolist (field (xesam-get-property engine "hit.fields"))
430 (when (not (zerop (length (caar result)))) 439 (when (not (zerop (length (caar result))))
431 (when xesam-debug 440 (when xesam-debug
432 (widget-insert (format "%s: %s\n" field (caar result)))) 441 (widget-put
442 widget :help-echo
443 (format "%s%s: %s\n"
444 (widget-get widget :help-echo) field (caar result))))
433 (widget-put widget (intern (concat ":" field)) (caar result))) 445 (widget-put widget (intern (concat ":" field)) (caar result)))
434 (setq result (cdr result))) 446 (setq result (cdr result)))
435 447
@@ -501,7 +513,7 @@ SEARCH is the search identification in that engine. Both must be strings."
501 ;; Format the widget. 513 ;; Format the widget.
502 (widget-put 514 (widget-put
503 widget :format 515 widget :format
504 (format "%d. %s%%[%%v%%]\n%s\n" hit-number 516 (format "%d. %s%%[%%v%%]\n%s\n" xesam-current
505 (if (widget-member widget :tag) "%{%t%}\n" "") 517 (if (widget-member widget :tag) "%{%t%}\n" "")
506 (if (widget-member widget :doc) "%h" ""))) 518 (if (widget-member widget :doc) "%h" "")))
507 519
@@ -509,8 +521,7 @@ SEARCH is the search identification in that engine. Both must be strings."
509 (goto-char (point-max)) 521 (goto-char (point-max))
510 (widget-default-create widget) 522 (widget-default-create widget)
511 (set-buffer-modified-p nil) 523 (set-buffer-modified-p nil)
512 (setq mode-line-position 524 (force-mode-line-update)
513 (list (format "%%p (%d/%d)" xesam-current xesam-count)))
514 (redisplay))) 525 (redisplay)))
515 526
516(defun xesam-refresh-search-buffer (engine search) 527(defun xesam-refresh-search-buffer (engine search)
@@ -520,30 +531,23 @@ SEARCH is the search identification in that engine. Both must be strings."
520 (unless xesam-refreshing 531 (unless xesam-refreshing
521 (setq xesam-refreshing t) 532 (setq xesam-refreshing t)
522 (unwind-protect 533 (unwind-protect
523 ;; `xesam-from' is the first result id to be presented. 534 (let (widget updated)
524 ;; `xesam-current' is the last result which has been presented.
525 ;; `xesam-to' is the upper result to be presented.
526 ;; All of them are buffer-local variables.
527 (let ((from (max xesam-from xesam-current))
528 widget next)
529 ;; Add all result widgets. The upper boundary is always 535 ;; Add all result widgets. The upper boundary is always
530 ;; computed, because new hits might have arrived while 536 ;; computed, because new hits might have arrived while
531 ;; running. 537 ;; running.
532 (while (<= from (min xesam-to xesam-count)) 538 (while (< xesam-current (min xesam-to xesam-count))
533 (xesam-refresh-entry engine search from) 539 (setq updated t
534 (setq next t 540 xesam-current (1+ xesam-current))
535 from (1+ from) 541 (xesam-refresh-entry engine search))
536 xesam-current from))
537 542
538 ;; Add "NEXT" widget. 543 ;; Add "NEXT" widget.
539 (when (and next (> xesam-count xesam-to)) 544 (when (and updated (> xesam-count xesam-to))
540 (goto-char (point-max)) 545 (goto-char (point-max))
541 (widget-create 546 (widget-create
542 'link 547 'link
543 :notify 548 :notify
544 '(lambda (widget &rest ignore) 549 '(lambda (widget &rest ignore)
545 (setq xesam-from (+ xesam-from xesam-hits-per-page) 550 (setq xesam-to (+ xesam-to xesam-hits-per-page))
546 xesam-to (+ xesam-to xesam-hits-per-page))
547 (widget-delete widget) 551 (widget-delete widget)
548 (xesam-refresh-search-buffer xesam-engine xesam-search)) 552 (xesam-refresh-search-buffer xesam-engine xesam-search))
549 "NEXT") 553 "NEXT")
@@ -567,9 +571,7 @@ SEARCH is the search identification in that engine. Both must be strings."
567 (cond 571 (cond
568 572
569 ((string-equal member "HitsAdded") 573 ((string-equal member "HitsAdded")
570 (setq xesam-count (+ xesam-count (nth 1 args)) 574 (setq xesam-count (+ xesam-count (nth 1 args)))
571 mode-line-position
572 (list (format "%%p (%d/%d)" (1- xesam-current) xesam-count)))
573 ;; We use `run-at-time' in order to not block the event queue. 575 ;; We use `run-at-time' in order to not block the event queue.
574 (run-at-time 576 (run-at-time
575 0 nil 577 0 nil
@@ -591,6 +593,7 @@ returned."
591 (search (dbus-call-method 593 (search (dbus-call-method
592 :session service xesam-path-search 594 :session service xesam-path-search
593 xesam-interface-search "NewSearch" session query))) 595 xesam-interface-search "NewSearch" session query)))
596
594 ;; Let us notify for relevant signals. We ignore "HitsRemoved", 597 ;; Let us notify for relevant signals. We ignore "HitsRemoved",
595 ;; "HitsModified" and "StateChanged"; there is nothing to do for 598 ;; "HitsModified" and "StateChanged"; there is nothing to do for
596 ;; us. 599 ;; us.
@@ -605,6 +608,7 @@ returned."
605 (dbus-call-method 608 (dbus-call-method
606 :session (car engine) xesam-path-search 609 :session (car engine) xesam-path-search
607 xesam-interface-search "StartSearch" search) 610 xesam-interface-search "StartSearch" search)
611
608 ;; Create the search buffer. 612 ;; Create the search buffer.
609 (with-current-buffer 613 (with-current-buffer
610 (generate-new-buffer (xesam-buffer-name service search)) 614 (generate-new-buffer (xesam-buffer-name service search))
@@ -612,30 +616,23 @@ returned."
612 (xesam-mode) 616 (xesam-mode)
613 (setq xesam-engine engine 617 (setq xesam-engine engine
614 xesam-search search 618 xesam-search search
619 ;; The buffer identification shall indicate the search
620 ;; engine. The `help-echo' property is used for debug
621 ;; information, when applicable.
615 mode-line-buffer-identification 622 mode-line-buffer-identification
616 (xesam-get-property engine "vendor.id")) 623 (if (not xesam-debug)
617 (when xesam-debug 624 (list
618 (widget-insert 625 12 (propertized-buffer-identification
619 (format "vendor.id: %s\n" 626 (xesam-get-property engine "vendor.id")))
620 (xesam-get-property engine "vendor.id")) 627 (propertize
621 (format "vendor.version: %s\n" 628 (xesam-get-property engine "vendor.id") 'help-echo
622 (xesam-get-property engine "vendor.version")) 629 (mapconcat
623 (format "vendor.display: %s\n" 630 '(lambda (x) (format "%s: %s" x (xesam-get-property engine x)))
624 (xesam-get-property engine "vendor.display")) 631 '("vendor.id" "vendor.version" "vendor.display" "vendor.xesam"
625 (format "vendor.xesam: %s\n" 632 "vendor.ontology.fields" "vendor.ontology.contents"
626 (xesam-get-property engine "vendor.xesam")) 633 "vendor.ontology.sources" "vendor.extensions"
627 (format "vendor.ontology.fields: %s\n" 634 "vendor.ontologies" "vendor.maxhits")
628 (xesam-get-property engine "vendor.ontology.fields")) 635 "\n")))))
629 (format "vendor.ontology.contents: %s\n"
630 (xesam-get-property engine "vendor.ontology.contents"))
631 (format "vendor.ontology.sources: %s\n"
632 (xesam-get-property engine "vendor.ontology.sources"))
633 (format "vendor.extensions: %s\n"
634 (xesam-get-property engine "vendor.extensions"))
635 (format "vendor.ontologies: %s\n"
636 (xesam-get-property engine "vendor.ontologies"))
637 (format "vendor.maxhits: %s\n\n"
638 (xesam-get-property engine "vendor.maxhits")))))
639 636
640 ;; Return search id. 637 ;; Return search id.
641 search)) 638 search))
@@ -687,7 +684,9 @@ Example:
687;; * Retrieve several results at once. 684;; * Retrieve several results at once.
688;; * Improve mode-line handling. Show search string etc. 685;; * Improve mode-line handling. Show search string etc.
689;; * Minibuffer completion for user queries. 686;; * Minibuffer completion for user queries.
690 687;; * `revert-buffer-function' implementation.
688;; * Close search when search buffer is killed.
689;;
691;; * Mid term 690;; * Mid term
692;; - If available, use ontologies for field selection. 691;; - If available, use ontologies for field selection.
693;; - Search engines for Emacs bugs database, wikipedia, google, 692;; - Search engines for Emacs bugs database, wikipedia, google,