zsh-workers
 help / color / mirror / code / Atom feed
* matlab-history-beginning-search-backward
@ 2009-09-30 16:52 Guido van Steen
  2009-12-13 23:25 ` matlab-history-beginning-search-backward Bart Schaefer
  0 siblings, 1 reply; 2+ messages in thread
From: Guido van Steen @ 2009-09-30 16:52 UTC (permalink / raw)
  To: zsh-workers

Dear list, 

I use the "history-beginning-search-backward" widget quite frequently. It searches for commands in the command history that START WITH "LBUFFER". 

I like this behaviour. It is simple and it keeps my attention fixed on one line. What I don't like about the widget is that ONLY searches for commands that start with "LBUFFER". Instead I would prefer a similar widget that searches for commands in the command history, in such a way that "LBUFFER" is a SUBSTRING of these commands. (This is the default history management in MATLAB and FISH.) 

I know there is the "history-incremental-search-backward" widget, which is bound to "^r" by default. This widget does more-or-less what I want. However, it shows two prompts, which I don't seem to like that much. Moreover, if requires the userto invoke it first and then start typing what he looks for. Usually I seem to start typing something and then find out that I do not remember the command that I want to type anymore. So I would like to involve the widget after I type, as can be done with the "history-beginning-search-backward" widget. 

So, my question is: Has anyone ever come across such a "matlab-history-beginning-search-backward" kind of widget? Or, if not, can anyone provide me with pointers on how to write one by myself. I have to add that I am not very fluent at C. 

I hope I phrased my question clear enough. 

Cheers! 

Guido 




      


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: matlab-history-beginning-search-backward
  2009-09-30 16:52 matlab-history-beginning-search-backward Guido van Steen
@ 2009-12-13 23:25 ` Bart Schaefer
  0 siblings, 0 replies; 2+ messages in thread
From: Bart Schaefer @ 2009-12-13 23:25 UTC (permalink / raw)
  To: Guido van Steen, zsh-workers

Nobody ever responded to this thread ...

On Sep 30,  9:52am, Guido van Steen wrote:
} Subject: matlab-history-beginning-search-backward
}
} I would prefer a similar [to history-beginning-search-backward]
} widget that searches for commands in the command history, in such a
} way that "LBUFFER" is a SUBSTRING of these commands. (This is the
} default history management in MATLAB and FISH.)
}
} I know there is the "history-incremental-search-backward" widget,
} which is bound to "^r" by default. This widget does more-or-less what
} I want. However, it shows two prompts, which I don't seem to like that
} much. Moreover, if requires the userto invoke it first and then start
} typing what he looks for.

Ignoring the issue of the extra prompt, what you want can be accomplished
like so:

matlab-history-beginning-search-backward() {
   local search="$LBUFFER"
   zle up-line-or-history
   zle end-of-line
   zle history-incremental-search-backward "$search"
}
zle -N matlab-history-beginning-search-backward
bindkey ^X^P matlab-history-beginning-search-backward
bindkey -M isearch ^X^P history-incremental-search-backward

The tricky bit there is that you use one keybinding to enter incremental
search mode, and then bind the same keys in the special isearch map to
repeat that search.  The other point to note is that you can start an
incremental search with an initial string by passing it as an argument.


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2009-12-14  0:26 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-09-30 16:52 matlab-history-beginning-search-backward Guido van Steen
2009-12-13 23:25 ` matlab-history-beginning-search-backward Bart Schaefer

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).