# HG changeset patch # User Michael Albinus # Date 1219262896 0 # Node ID 9fb28094a3cf893b0e0cae49eb23310720c6e91e # Parent c532aa80972d207ebcfe322a32058515312ebd8c * net/xesam.el (xesam-highlight-string): Precise doc string. (xesam-highlight-buffer): New defun. (xesam-refresh-entry): Use it. Better check for sourceModified. diff -r c532aa80972d -r 9fb28094a3cf lisp/net/xesam.el --- a/lisp/net/xesam.el Wed Aug 20 17:53:23 2008 +0000 +++ b/lisp/net/xesam.el Wed Aug 20 20:08:16 2008 +0000 @@ -494,7 +494,8 @@ (format "*%s/%s*" service search)) (defun xesam-highlight-string (string) - "Highlight text enclosed by and ." + "Highlight text enclosed by and . +Return propertized STRING." (while (string-match "\\(.*\\)\\(\\)\\(.*\\)\\(\\)\\(.*\\)" string) (setq string (format @@ -504,6 +505,18 @@ (match-string 5 string)))) string) +(defun xesam-highlight-buffer (regexp &optional buffer) + "Highlight text matching REGEXP in BUFFER. +If BUFFER is nil, use the current buffer" + (with-current-buffer (or buffer (current-buffer)) + (save-excursion + (let ((case-fold-search t)) + (goto-char (point-min)) + (while (re-search-forward regexp nil t) + (overlay-put + (make-overlay + (match-beginning 0) (match-end 0)) 'face 'xesam-highlight)))))) + (defun xesam-refresh-entry (engine entry) "Refreshes one entry in the search buffer." (let* ((result (nth (1- xesam-current) xesam-objects)) @@ -557,7 +570,10 @@ widget :tag (xesam-highlight-string (widget-get widget :tag)))) ;; Last Modified. - (when (widget-member widget :xesam:sourceModified) + (when (and (widget-member widget :xesam:sourceModified) + (not + (zerop + (string-to-number (widget-get widget :xesam:sourceModified))))) (widget-put widget :tag (format @@ -589,8 +605,10 @@ (widget-put widget :notify (lambda (widget &rest ignore) - (find-file - (url-filename (url-generic-parse-url (widget-value widget)))))) + (let ((query xesam-query)) + (find-file + (url-filename (url-generic-parse-url (widget-value widget)))) + (xesam-highlight-buffer (regexp-opt (split-string query nil t)))))) (widget-put widget :value (url-filename (url-generic-parse-url (widget-get widget :xesam:url)))))) @@ -837,6 +855,7 @@ ;;; TODO: +;; * Buffer highlighting needs better analysis of query string. ;; * Accept input while retrieving prefetched hits. `run-at-time'? ;; * With prefix, let's choose search engine. ;; * Minibuffer completion for user queries.