help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Is Emacs very alive, active and improving?


From: Emanuel Berg
Subject: Re: Is Emacs very alive, active and improving?
Date: Thu, 29 Aug 2013 05:06:47 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.4 (gnu/linux)

Emanuel Berg <embe8573@student.uu.se> writes:

> I wrote something cool recently to make Wikipedia searches from
> Emacs. It is actually only the last couple of lines that do it -
> the rest is just fancy stuff - it will default to the region, if
> there is one, or the word at point, and it will show it if it
> isn't too long, etc. Anyhow:

Made some improvements. First, it is not "search", it is
"show". Second, now it doesn't show "(nil)" in the PS when there
isn't a default (neither region or word at point).

(defun wiki-article (str)
  "Show the Wikipedia article STR, the \"printable\" version."
  (interactive
   (let*((default-search (if (region-active-p) (region-to-string)
                           (thing-at-point 'word) ))
         (max-len 20)
         (peek (if (> (length default-search) max-len)
                   (format "%s..."
                           (substring default-search 0 max-len) )
                 default-search) )
         (ps " article"))
     (list (read-string
            (if peek (format "%s (%s): " ps peek)
              (format "%s: " ps))
            nil nil default-search ))))
  (w3m-new-tab)
  (w3m
   (format
    "https://en.wikipedia.org/w/index.php?title=%s\&printable=yes";
    str) ))

-- 
Emanuel Berg - programmer (hire me! CV below)
computer projects: http://user.it.uu.se/~embe8573
internet activity: http://home.student.uu.se/embe8573


reply via email to

[Prev in Thread] Current Thread [Next in Thread]