diff options
| author | Michael Albinus | 2008-08-20 20:08:50 +0000 |
|---|---|---|
| committer | Michael Albinus | 2008-08-20 20:08:50 +0000 |
| commit | f7a17e30c8635fd6f259706eba3ae15454d7d8d8 (patch) | |
| tree | 967f8f7a587cf345b8fadd80a9875ecf4323a3db /lisp | |
| parent | b8c63ae9edec74ffad844804992c2665b88d275b (diff) | |
| download | emacs-f7a17e30c8635fd6f259706eba3ae15454d7d8d8.tar.gz emacs-f7a17e30c8635fd6f259706eba3ae15454d7d8d8.zip | |
* net/xesam.el (xesam-highlight-string): Precise doc string.
(xesam-highlight-buffer): New defun.
(xesam-refresh-entry): Use it. Better check for sourceModified.
Diffstat (limited to 'lisp')
| -rw-r--r-- | lisp/ChangeLog | 6 | ||||
| -rw-r--r-- | lisp/net/xesam.el | 27 |
2 files changed, 29 insertions, 4 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index e696e85181b..5edc571cca9 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,9 @@ | |||
| 1 | 2008-08-20 Michael Albinus <michael.albinus@gmx.de> | ||
| 2 | |||
| 3 | * net/xesam.el (xesam-highlight-string): Precise doc string. | ||
| 4 | (xesam-highlight-buffer): New defun. | ||
| 5 | (xesam-refresh-entry): Use it. Better check for sourceModified. | ||
| 6 | |||
| 1 | 2008-08-19 Chong Yidong <cyd@stupidchicken.com> | 7 | 2008-08-19 Chong Yidong <cyd@stupidchicken.com> |
| 2 | 8 | ||
| 3 | * edmacro.el (edmacro-parse-keys): Catch events with spaces in | 9 | * edmacro.el (edmacro-parse-keys): Catch events with spaces in |
diff --git a/lisp/net/xesam.el b/lisp/net/xesam.el index dda12607d9a..a7b1cca8aa7 100644 --- a/lisp/net/xesam.el +++ b/lisp/net/xesam.el | |||
| @@ -494,7 +494,8 @@ SEARCH is the search identification in that engine. Both must be strings." | |||
| 494 | (format "*%s/%s*" service search)) | 494 | (format "*%s/%s*" service search)) |
| 495 | 495 | ||
| 496 | (defun xesam-highlight-string (string) | 496 | (defun xesam-highlight-string (string) |
| 497 | "Highlight text enclosed by <b> and </b>." | 497 | "Highlight text enclosed by <b> and </b>. |
| 498 | Return propertized STRING." | ||
| 498 | (while (string-match "\\(.*\\)\\(<b>\\)\\(.*\\)\\(</b>\\)\\(.*\\)" string) | 499 | (while (string-match "\\(.*\\)\\(<b>\\)\\(.*\\)\\(</b>\\)\\(.*\\)" string) |
| 499 | (setq string | 500 | (setq string |
| 500 | (format | 501 | (format |
| @@ -504,6 +505,18 @@ SEARCH is the search identification in that engine. Both must be strings." | |||
| 504 | (match-string 5 string)))) | 505 | (match-string 5 string)))) |
| 505 | string) | 506 | string) |
| 506 | 507 | ||
| 508 | (defun xesam-highlight-buffer (regexp &optional buffer) | ||
| 509 | "Highlight text matching REGEXP in BUFFER. | ||
| 510 | If BUFFER is nil, use the current buffer" | ||
| 511 | (with-current-buffer (or buffer (current-buffer)) | ||
| 512 | (save-excursion | ||
| 513 | (let ((case-fold-search t)) | ||
| 514 | (goto-char (point-min)) | ||
| 515 | (while (re-search-forward regexp nil t) | ||
| 516 | (overlay-put | ||
| 517 | (make-overlay | ||
| 518 | (match-beginning 0) (match-end 0)) 'face 'xesam-highlight)))))) | ||
| 519 | |||
| 507 | (defun xesam-refresh-entry (engine entry) | 520 | (defun xesam-refresh-entry (engine entry) |
| 508 | "Refreshes one entry in the search buffer." | 521 | "Refreshes one entry in the search buffer." |
| 509 | (let* ((result (nth (1- xesam-current) xesam-objects)) | 522 | (let* ((result (nth (1- xesam-current) xesam-objects)) |
| @@ -557,7 +570,10 @@ SEARCH is the search identification in that engine. Both must be strings." | |||
| 557 | widget :tag (xesam-highlight-string (widget-get widget :tag)))) | 570 | widget :tag (xesam-highlight-string (widget-get widget :tag)))) |
| 558 | 571 | ||
| 559 | ;; Last Modified. | 572 | ;; Last Modified. |
| 560 | (when (widget-member widget :xesam:sourceModified) | 573 | (when (and (widget-member widget :xesam:sourceModified) |
| 574 | (not | ||
| 575 | (zerop | ||
| 576 | (string-to-number (widget-get widget :xesam:sourceModified))))) | ||
| 561 | (widget-put | 577 | (widget-put |
| 562 | widget :tag | 578 | widget :tag |
| 563 | (format | 579 | (format |
| @@ -589,8 +605,10 @@ SEARCH is the search identification in that engine. Both must be strings." | |||
| 589 | (widget-put | 605 | (widget-put |
| 590 | widget :notify | 606 | widget :notify |
| 591 | (lambda (widget &rest ignore) | 607 | (lambda (widget &rest ignore) |
| 592 | (find-file | 608 | (let ((query xesam-query)) |
| 593 | (url-filename (url-generic-parse-url (widget-value widget)))))) | 609 | (find-file |
| 610 | (url-filename (url-generic-parse-url (widget-value widget)))) | ||
| 611 | (xesam-highlight-buffer (regexp-opt (split-string query nil t)))))) | ||
| 594 | (widget-put | 612 | (widget-put |
| 595 | widget :value | 613 | widget :value |
| 596 | (url-filename (url-generic-parse-url (widget-get widget :xesam:url)))))) | 614 | (url-filename (url-generic-parse-url (widget-get widget :xesam:url)))))) |
| @@ -837,6 +855,7 @@ Example: | |||
| 837 | 855 | ||
| 838 | ;;; TODO: | 856 | ;;; TODO: |
| 839 | 857 | ||
| 858 | ;; * Buffer highlighting needs better analysis of query string. | ||
| 840 | ;; * Accept input while retrieving prefetched hits. `run-at-time'? | 859 | ;; * Accept input while retrieving prefetched hits. `run-at-time'? |
| 841 | ;; * With prefix, let's choose search engine. | 860 | ;; * With prefix, let's choose search engine. |
| 842 | ;; * Minibuffer completion for user queries. | 861 | ;; * Minibuffer completion for user queries. |