Command to re-run most recent search with different engine?

77 views
Skip to first unread message

muys...@gmail.com

unread,
Feb 19, 2016, 4:06:04 PM2/19/16
to Pentadactyl
I frequently find myself re-running the same search on a different engine. In order to do that I need to hit colon again, go to the start of the line with ^a, remove "tab" from tabopen so it opens in the same window, and change the search engine. 

Is there a better way to do that? 

If not, I'm considering trying to make a patch where searching will cache the most recent query and if the query is blank will instead use the last one.

Arkadiusz Drabczyk

unread,
Feb 23, 2016, 5:28:54 AM2/23/16
to penta...@googlegroups.com
On 2016-02-19, muys...@gmail.com <muys...@gmail.com> wrote:
> ------=_Part_1134_968536322.1455915964885
> Content-Type: multipart/alternative;
> boundary="----=_Part_1135_1908481315.1455915964885"
>
> ------=_Part_1135_1908481315.1455915964885
> Content-Type: text/plain; charset=UTF-8
How about creating a macro? For example, add this to your
~/.pentadactyl/info/default/registers:

{"q":{"text":"o<C-p><C-a><C-Right><C-Right><C-w>duckduckgo<Return>","isLine":0,"timestamp":1456222182342000}}

Now inside pentadactyl press `s' to perform a search using your
default search engine. When it is finished press `@ q' to execute
above macro - it will replace your default search engine with
duckduckgo. You can also leave a name of a new search engine blank -
I think is what you want to achieve.

The only problem is that a macro like this would work only if
searching was the last executed command in pentadactyl command line.
--
Arkadiusz Drabczyk <arka...@drabczyk.org>

troyp

unread,
Mar 19, 2017, 7:16:17 PM3/19/17
to Pentadactyl

Just noticed this question. If you're still interested in this, here's my code for it:

map -modes command-line <cb-change-first-arg> -js var cmd=dactyl.clipboardRead(0).split(/\s+/); dactyl.clipboardWrite(cmd[0]+' '+cmd.slice(2).join(' '));
map -modes command-line <C-r> <up><A-a><C-v><C-c><down><cb-change-first-arg><C-v><C-v><Home><C-Right><Space>
map <leader>r :<C-r>
 
I think that's all you need. (Of course, if you don't define a <leader> key, you need to change the binding.) You can check it out in context in my .pentadactylrc.

troyp

unread,
Mar 19, 2017, 7:25:01 PM3/19/17
to Pentadactyl


To elaborate, the code above:
  • binds <C-r> while in the command-line to recall the previous command line, delete the first argument to the command and leave the cursor in place to replace it.
  • binds <leader>r in normal mode to open the command-line and execute <C-r>

So from normal mode you can just hit <leader>r, then type the new search keyword and hit enter.

troyp

unread,
Mar 19, 2017, 7:35:44 PM3/19/17
to Pentadactyl

Sorry, a couple of things I forgot to mention...

  • The binding above currently uses the clipboard to store a value (since I'm not sure how to access the command-line history programmatically), so you'll lose anything in it.
  • It doesn't work with the default search (which doesn't use a keyword). I have another binding to repeat the search after a default search:

map <leader>R :<up><Home><forward-word><Space>

Reply all
Reply to author
Forward
0 new messages