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

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

hydra: Have hint shown immediately


From: Florian Lindner
Subject: hydra: Have hint shown immediately
Date: Wed, 29 Apr 2015 10:02:33 +0200
User-agent: KNode/4.14.7

Hello,

I wonder if anyone is familiar with the hydra package: 
https://github.com/abo-abo/hydra

I have an hydra to call search engines:

(defhydra hydra-google (global-map "C-c /" :color blue)
  "Search Engines"
  ("c" (lambda ()
         (interactive)
         (flo/start-search 
"http://en.cppreference.com/mwiki/index.php?title=Special:Search&search=%s";))
   "C++ Reference")
  ("g" (lambda ()
         (interactive)
         (flo/start-search "https://google.de/#q=%s";))
   "Google")
  )

flo/start-search looks like that:

(defun flo/start-search (url)
  (interactive)
  (browse-url (replace-regexp-in-string
               (regexp-quote "%s")
               (if (region-active-p)
                   (buffer-substring (region-beginning) (region-end))
                 (read-string "Search for: " (thing-at-point 'symbol) 
"searches" nil t)
                 )
               url)
              )
  )


interactive is just for testing, it will vanish probably. Since this is my 
first elisp "program" please criticise!


My question: How can I make the hydra menu to be shown as soon as I press C-
c /? Becaue I exit the hydra after pressing the key I'll never see the menu 
and forget option when more search engines are aded.

Thanks,
Florian




reply via email to

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