zsh-users
 help / color / mirror / code / Atom feed
* Assorted questions
@ 2010-06-05 19:23 Simon Friedberger
  2010-06-07 16:44 ` Richard Hartmann
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Simon Friedberger @ 2010-06-05 19:23 UTC (permalink / raw)
  To: zsh-users

Hello everybody,

I'll just make a list with my questions. :)

1.	Can I give background color to empty spaces.
	I've adapted the example in the wiki at
	http://zshwiki.org/home/examples/zlewidgets#vi_keys_-_show_mode
	to show a different background color when in vi command mode.
	You can see what I did here
	https://simon.a-oben.org/blog/?p=233
	Just in case that the details matter.

	This approach has two problems.
	a) The empty background isn't colored. This isn't really a
	problem but it would be nice if it was. Is it possible?
	b) I have a little smily in my prompt for return status 0 and
	the return status for anything else. This is reset when I change
	mode but it shouldn't. Any fixes?

2.	I'm a fan of keeping things simple so I'm a bit irritaded by
	some of the options. Maybe you can explain a good use-case to me.
	a)	accept-and-hold seems to be the same as <ENTER>^p 
	b)	history-search-back(for)ward and
		history-beginning-search-back(for)ward
		seem to be the same as ^r
		I know that there is a subtle difference but I don't see
		how it matters in practice.

3.	The zle section of the guide suggests a binding with
	bindkey -rpM viins '\e['
	to make <ESC> unambiguous but I tried with $KEYTIMEOUT set to
	something high and it doesn't seem to make a difference if I
	have that binding or not. Can anybody suggest an experiment
	where the difference shows?

4.	I would like to have some history magic. It would be nice if
	^p/^n (or up/down) just switched through the local history but
	^r/^s searched through all history entries. I used to have
	shared history set but it irks me that when a long command
	finished I cannot just press up and change a paramter and run it
	again.
	The man page suggests that there is a set-local-history binding
	but I cannot find any documentation on it.

Alright, that's all for now. heh

Thanks
Simon


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

* Re: Assorted questions
  2010-06-05 19:23 Assorted questions Simon Friedberger
@ 2010-06-07 16:44 ` Richard Hartmann
  2010-06-07 16:50   ` Simon Friedberger
  2010-06-07 17:11 ` Mikael Magnusson
  2010-06-07 23:23 ` Wayne Davison
  2 siblings, 1 reply; 9+ messages in thread
From: Richard Hartmann @ 2010-06-07 16:44 UTC (permalink / raw)
  To: Simon Friedberger; +Cc: zsh-users

On Sat, Jun 5, 2010 at 21:23, Simon Friedberger <simon+zsh@a-oben.org> wrote:

>  a)      accept-and-hold seems to be the same as <ENTER>^p

Yes, but now it's only one key press. You can't (easily) script a
^p.


>                seem to be the same as ^r

^r is realized with the functions you mention. Not having them
means not having ^r.


>                I know that there is a subtle difference but I don't see
>                how it matters in practice.


If you see the subtle differences, you know why there are
different versions. Just pick the one which you like best.


> 4.      I would like to have some history magic. It would be nice if
>        ^p/^n (or up/down) just switched through the local history but
>        ^r/^s searched through all history entries.

I would consider this useful, as well.


> Alright, that's all for now. heh

Unless you are Swiss (they are allowed, by law, to append "oder"
to every sentence ;), appending "lol", "heh" or similar is annoying
to most people.
You are, of course, entitled to your own style, but generally
speaking, I have found that seemingly little things like that can
make a difference.

Point in case, I almost did not send this reply due to the "heh".
It might seem petty, but at least I am being honest. _And_ I
took the time to explain it in depth.


Richard


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

* Re: Assorted questions
  2010-06-07 16:44 ` Richard Hartmann
@ 2010-06-07 16:50   ` Simon Friedberger
  0 siblings, 0 replies; 9+ messages in thread
From: Simon Friedberger @ 2010-06-07 16:50 UTC (permalink / raw)
  To: zsh-users

On 18:44 Mon 07.06.10, Richard Hartmann wrote:
> On Sat, Jun 5, 2010 at 21:23, Simon Friedberger <simon+zsh@a-oben.org> wrote:
> > 4.      I would like to have some history magic. It would be nice if
> >        ^p/^n (or up/down) just switched through the local history but
> >        ^r/^s searched through all history entries.
> 
> I would consider this useful, as well.
Let's hope then that somebody knows how to use that set-local-history
binding.

> > Alright, that's all for now. heh
> 
> Unless you are Swiss (they are allowed, by law, to append "oder"
> to every sentence ;), appending "lol", "heh" or similar is annoying
> to most people.
> You are, of course, entitled to your own style, but generally
> speaking, I have found that seemingly little things like that can
> make a difference.
> 
> Point in case, I almost did not send this reply due to the "heh".
> It might seem petty, but at least I am being honest. _And_ I
> took the time to explain it in depth.
OK.

Thanks for replying.
I guess asking so much at once and the rather more religious questions
first was risky.

Best
Simon


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

* Re: Assorted questions
  2010-06-05 19:23 Assorted questions Simon Friedberger
  2010-06-07 16:44 ` Richard Hartmann
@ 2010-06-07 17:11 ` Mikael Magnusson
  2010-06-07 23:23 ` Wayne Davison
  2 siblings, 0 replies; 9+ messages in thread
From: Mikael Magnusson @ 2010-06-07 17:11 UTC (permalink / raw)
  To: Simon Friedberger; +Cc: zsh-users

On 5 June 2010 21:23, Simon Friedberger <simon+zsh@a-oben.org> wrote:
> Hello everybody,
>
> I'll just make a list with my questions. :)
>
>        a)      accept-and-hold seems to be the same as <ENTER>^p

It's possibly more useful in conjunction with ^o
(accept-line-and-down-history) where it's important you stay in the
same place in history, not the new copy at the end of the history.
accept-and-hold also keeps the cursor position while ^p puts you on
the end of the line, which is annoying if you're changing some
parameter in the middle.

-- 
Mikael Magnusson


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

* Re: Assorted questions
  2010-06-05 19:23 Assorted questions Simon Friedberger
  2010-06-07 16:44 ` Richard Hartmann
  2010-06-07 17:11 ` Mikael Magnusson
@ 2010-06-07 23:23 ` Wayne Davison
  2010-06-08  9:12   ` Simon Friedberger
  2010-06-09 11:40   ` zle set-local-history binding Was: " Simon Friedberger
  2 siblings, 2 replies; 9+ messages in thread
From: Wayne Davison @ 2010-06-07 23:23 UTC (permalink / raw)
  To: Simon Friedberger; +Cc: zsh-users

[-- Attachment #1: Type: text/plain, Size: 3719 bytes --]

On Sat, Jun 5, 2010 at 12:23 PM, Simon Friedberger
<simon+zsh@a-oben.org<simon%2Bzsh@a-oben.org>
> wrote:

> Hello everybody,
>
> I'll just make a list with my questions. :)
>
> 1.      Can I give background color to empty spaces.
>        I've adapted the example in the wiki at
>        http://zshwiki.org/home/examples/zlewidgets#vi_keys_-_show_mode
>        to show a different background color when in vi command mode.
>        You can see what I did here
>        https://simon.a-oben.org/blog/?p=233
>        Just in case that the details matter.
>
>        This approach has two problems.
>        a) The empty background isn't colored. This isn't really a
>        problem but it would be nice if it was. Is it possible?
>        b) I have a little smily in my prompt for return status 0 and
>        the return status for anything else. This is reset when I change
>        mode but it shouldn't. Any fixes?
>
> 2.      I'm a fan of keeping things simple so I'm a bit irritaded by
>        some of the options. Maybe you can explain a good use-case to me.
>        a)      accept-and-hold seems to be the same as <ENTER>^p
>        b)      history-search-back(for)ward and
>                history-beginning-search-back(for)ward
>                seem to be the same as ^r
>                I know that there is a subtle difference but I don't see
>                how it matters in practice.
>
> 3.      The zle section of the guide suggests a binding with
>        bindkey -rpM viins '\e['
>        to make <ESC> unambiguous but I tried with $KEYTIMEOUT set to
>        something high and it doesn't seem to make a difference if I
>        have that binding or not. Can anybody suggest an experiment
>        where the difference shows?
>
> 4.      I would like to have some history magic. It would be nice if
>        ^p/^n (or up/down) just switched through the local history but
>        ^r/^s searched through all history entries.


Since I'm a touch typist, I almost alway use Ctrl-P and Ctrl-N to browse the
history list, so I have them set to only visit local history.  I then leave
up-arrow and down-arrow set to browse the whole list (as does searching).
 Here's how I do it:

bindkey '^p' up-line-or-local-history
bindkey '^n' down-line-or-local-history

up-line-or-local-history() {
    zle set-local-history 1
    zle up-line-or-history
    zle set-local-history 0
}
zle -N up-line-or-local-history
down-line-or-local-history() {
    zle set-local-history 1
    zle down-line-or-history
    zle set-local-history 0
}
zle -N down-line-or-local-history

Keep in mind that those fuctions assume that it is OK to set-local-history
back to 0 -- if you don't normally toggle local history manually, then it
should be fine.

Someone who likes to use Up-arrow and Ctrl-P interchangeably could either
bind those functions to the arrow keys, or you could set local history on by
default and turn it off for the search functions.  But keep in mind that you
may want full-list searching for things like Esc-P
(history-beginning-search-backward) too.

For manually toggling shared history browsing:

bindkey '^[/' set-local-history

I used to have shared history set but it irks me that when a long
> command finished I cannot just press up and change a paramter and run
> it again.
>

That should not be the case.  When you enter a command, zsh always imports
all the shared lines first, and then appends your just-entered command last.
 That way any prior-line visitation is always to the command you just ran.
 If you entered no command, then it just slurps in new history lines, and
thus the prior command could indeed be a non-local line (since there was no
local line to follow the new ones).

..wayne..

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

* Re: Assorted questions
  2010-06-07 23:23 ` Wayne Davison
@ 2010-06-08  9:12   ` Simon Friedberger
  2010-06-09 19:50     ` Wayne Davison
  2010-06-09 11:40   ` zle set-local-history binding Was: " Simon Friedberger
  1 sibling, 1 reply; 9+ messages in thread
From: Simon Friedberger @ 2010-06-08  9:12 UTC (permalink / raw)
  To: zsh-users

On 16:23 Mon 07.06.10, Wayne Davison wrote:
> bindkey '^p' up-line-or-local-history
> bindkey '^n' down-line-or-local-history
> 
> up-line-or-local-history() {
>     zle set-local-history 1
>     zle up-line-or-history
>     zle set-local-history 0
> }
> zle -N up-line-or-local-history
> down-line-or-local-history() {
>     zle set-local-history 1
>     zle down-line-or-history
>     zle set-local-history 0
> }
> zle -N down-line-or-local-history

Oh this is quite wonderful. Exactly what I've been looking for.
Now, I'm not sure that's the way I want to do it because I'm a little
overwhelmed by the many different options of history search right now
but this is what I tried first:

  1 zle set-local-history 1
  2 global-history-incremental-pattern-search-backward() {
  3     zle set-local-history 0
  4     zle history-incremental-pattern-search-backward
  5     zle set-local-history 1
  6 }
  7 zle -N global-history-incremental-pattern-search-backward
  8 
  9 global-history-incremental-pattern-search-forward() {
 10     zle set-local-history 0
 11     zle history-incremental-pattern-search-forward
 12     zle set-local-history 1
 13 }
 14 zle -N global-history-incremental-pattern-search-forward

This has several problems. For starters the first line fails with:
"widgets can only be called when ZLE is active"
Then there seems to be a problem when repeatedly pressing ^r. While
normally this will search for the next occurrence but in this case it
resets the search.
Does anybody with more zle widget experience know how to fix this?

Best regards
Simon


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

* zle set-local-history binding Was: Assorted questions
  2010-06-07 23:23 ` Wayne Davison
  2010-06-08  9:12   ` Simon Friedberger
@ 2010-06-09 11:40   ` Simon Friedberger
  1 sibling, 0 replies; 9+ messages in thread
From: Simon Friedberger @ 2010-06-09 11:40 UTC (permalink / raw)
  To: zsh-users

On 16:23 Mon 07.06.10, Wayne Davison wrote:
> bindkey '^[/' set-local-history

This look actually pretty interesting as well. Is there a way to display
the current setting in the prompt?


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

* Re: Assorted questions
  2010-06-08  9:12   ` Simon Friedberger
@ 2010-06-09 19:50     ` Wayne Davison
       [not found]       ` <AANLkTimeIv_xV6qHnFUpHqjD3LmVJqY_r5IQJQGtaKjo@mail.gmail.com>
  0 siblings, 1 reply; 9+ messages in thread
From: Wayne Davison @ 2010-06-09 19:50 UTC (permalink / raw)
  To: Simon Friedberger; +Cc: zsh-users

[-- Attachment #1: Type: text/plain, Size: 803 bytes --]

On Tue, Jun 8, 2010 at 2:12 AM, Simon Friedberger
<simon+zsh@a-oben.org<simon%2Bzsh@a-oben.org>
> wrote:
>
> This has several problems. For starters the first line fails with:
> "widgets can only be called when ZLE is active"
>

Yeah, I don't know how to use set-local-history outside of a zle key
binding.  I'd imagine that you could use zle -U str to push a keystroke that
runs "zle set-local-history 1", if you wanted to go to the trouble of
setting that up, though.  If there's a better way to do this, I haven't
learned it.

Then there seems to be a problem when repeatedly pressing ^r.


Yeah, so going that route is probably not going to be easy.  You'd probably
be better off re-binding all the various up-/down-line-or-history bindings
to use up-/down-line-or-local-history instead.

..wayne..

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

* Re: Assorted questions
       [not found]       ` <AANLkTimeIv_xV6qHnFUpHqjD3LmVJqY_r5IQJQGtaKjo@mail.gmail.com>
@ 2010-06-10  6:41         ` Bart Schaefer
  0 siblings, 0 replies; 9+ messages in thread
From: Bart Schaefer @ 2010-06-10  6:41 UTC (permalink / raw)
  To: Zsh Users

(Oops, accidentally sent this to Wayne instead of to the list.)

On Wed, Jun 9, 2010 at 12:50 PM, Wayne Davison
<wayned@users.sourceforge.net> wrote:
> On Tue, Jun 8, 2010 at 2:12 AM, Simon Friedberger
> <simon+zsh@a-oben.org<simon%2Bzsh@a-oben.org>
>> wrote:
>>
>> This has several problems. For starters the first line fails with:
>> "widgets can only be called when ZLE is active"
>>
>
> Yeah, I don't know how to use set-local-history outside of a zle key
> binding.

This is what zle-line-init is for ...

zle-line-init() { zle set-local-history 1 }
zle -N zle-line-init

(Why is there no doc for set-local-history other than a passing
mention under options?)


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

end of thread, other threads:[~2010-06-10  6:41 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-06-05 19:23 Assorted questions Simon Friedberger
2010-06-07 16:44 ` Richard Hartmann
2010-06-07 16:50   ` Simon Friedberger
2010-06-07 17:11 ` Mikael Magnusson
2010-06-07 23:23 ` Wayne Davison
2010-06-08  9:12   ` Simon Friedberger
2010-06-09 19:50     ` Wayne Davison
     [not found]       ` <AANLkTimeIv_xV6qHnFUpHqjD3LmVJqY_r5IQJQGtaKjo@mail.gmail.com>
2010-06-10  6:41         ` Bart Schaefer
2010-06-09 11:40   ` zle set-local-history binding Was: " Simon Friedberger

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).