パスワードを忘れた? アカウント作成
12369344 journal
Google

finedaypicnicの日記: Emacs Lisp: search-on-browser.el

日記 by finedaypicnic

;;; search-on-browser.el --- Search term on browser
 
;; Copyright (C) 2015  Akihiro Kuroiwa
 
;; Author: Akihiro Kuroiwa
;; URL: http://akuroiwa.env-reform.com/
;; Keywords: browse-url
 
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
 
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; GNU General Public License for more details.
 
;; You should have received a copy of the GNU General Public License
;; along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
(defcustom search-engine '(
               ("google" . "http://www.google.com/search?q=%s")
               ("finance" . "http://www.google.com/finance?q=%s")
               ("stock-price-ja" . "https://www.google.co.jp/?gws_rd=ssl#q=株価+%s")
               ("translate" . "http://translate.google.com/?source=osdd#auto|auto|%s")
               ("github" . "https://github.com/search?q=%s")
               ("cookpad-us" . "https://cookpad.com/us/search/%s")
               ("cookpad-ja" . "http://cookpad.com/search/%s")
               )
  "Search engine alist"
  :type '(alist
      :key-type (string :tag "Name")
      :value-type (string :tag "URL"))
  :group 'search-on-browser
  )
 
(defun search-on-browser (engine str)
  "Search term in mini buffer."
  (interactive (list
        (completing-read "Search engine: " search-engine nil t "google")
        (read-string "Search term: ")))
  (browse-url
   (format
    (cdr (assoc engine search-engine))
    str)))
 
(defun search-on-browser-region (engine start end)
  "Search term in region."
  (interactive (let ((engine
              (completing-read "Search engine: " search-engine nil t "google")))
         (list engine (region-beginning) (region-end))))
  (save-excursion
    (browse-url
     (format
      (cdr (assoc engine search-engine))
      (buffer-substring start end)))))

この議論は賞味期限が切れたので、アーカイブ化されています。 新たにコメントを付けることはできません。
typodupeerror

日本発のオープンソースソフトウェアは42件 -- ある官僚

読み込み中...