I use Wikipedia a lot, so I made a source similar to Google Suggest
for Wikipedia titles. Here it is if someone's interested:


(defvar anything-wikipedia-title-lookup-program nil
  "The program is called with one argument and it should return
  matching titles from Wikipedia.")


(setq anything-sources
 '(((name . "Wikipedia Titles")
    (candidates
     . (lambda ()
         (start-process "wp-process" nil
                        anything-wikipedia-title-lookup-program
                        (replace-regexp-in-string " " "_" anything-
pattern))))
    (candidate-transformer
     . (lambda (candidates)
         (mapcar (lambda (candidate)
                   (replace-regexp-in-string "_" " " candidate))
                 candidates)))
    (action . (("Look up Title" .
                (lambda (candidate)
                  (browse-url (concat "http://en.wikipedia.org/wiki/";
                                      (url-hexify-string
candidate)))))))
    (requires-pattern . 3)
    (delayed))))


In order to get useful results exact title matches should be listed
first and substring matches afterwards. Currently, anything.el cannot
invoke two processes for the same source, one after the other, that's
why you need to supply an external program for the lookup.

It can be a simple shell script:

grep -i "^$1$" <title file>
grep -i "$1" <title file>


or a Windows batch file:

@echo off
grep.exe -i "^%1$" <title file>
grep.exe -i "%1" <title file>


The current title file can be downloaded from here:

http://download.wikimedia.org/enwiki/latest/enwiki-latest-all-titles-in-ns0.gz


Enjoy.

_______________________________________________
gnu-emacs-sources mailing list
gnu-emacs-sources@gnu.org
http://lists.gnu.org/mailman/listinfo/gnu-emacs-sources

Reply via email to