Search at both stackoverflow and google code in Emacs

Two programming sites are most valuable to me:

stackoverflow.com
solution design and code prototype
google code search
code sample from real product

So I write some elisp code w3mext-hacker-search to automate the workflow.

Copy the into ~/.emacs and you can use hotkey “C-c ; s” to open search results in external browser (firefox, for example):

; external browser should be firefox
(setq browse-url-generic-program
      (cond
       (*is-a-mac* "open")
       (*linux* (executable-find "firefox"))
       ))

;; use external browser to search
(defun w3mext-hacker-search ()
  "search word under cursor in google code search and stackoverflow.com"
  (interactive)
  (require 'w3m)
  (let ((keyword (w3m-url-encode-string (thing-at-point 'symbol))))
    (browse-url-generic (concat "http://code.google.com/codesearch?q=" keyword))
    (browse-url-generic (concat "http://www.google.com.au/search?hl=en&q=" keyword "+site:stackoverflow.com" )))
  )

(add-hook 'prog-mode-hook '( lambda () (local-set-key (kbd "C-c ; s") 'w3mext-hacker-search)) )

One thought on “Search at both stackoverflow and google code in Emacs

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>