zsh-users
 help / color / mirror / code / Atom feed
* up-line and down-line without history
@ 2011-06-01  7:45 Guido van Steen
  2011-06-01 15:00 ` Bart Schaefer
  0 siblings, 1 reply; 7+ messages in thread
From: Guido van Steen @ 2011-06-01  7:45 UTC (permalink / raw)
  To: zsh-users

Dear List, 

I have been trying to find out how to "just" navigate through a multiline buffer. 

I know the "up-line-or-history" and "down-line-or-history" widgets. It seems to me that the "up-line" and "down-line" parts of these widgets do exactly what I want. So the problem is that I would like to avoid the "or-history" part. 

Are there a similar widgets that exclusively control the navigation of multiline buffers, i.e. without the side-effect of potentially navigating the history file? 

Or could/should I create my own widgets based on "up-line-or-history" and "down-line-or-history", in which I just override the "or-history" part? 

Best wishes, 

Guido 


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

* Re: up-line and down-line without history
  2011-06-01  7:45 up-line and down-line without history Guido van Steen
@ 2011-06-01 15:00 ` Bart Schaefer
  2011-06-01 15:06   ` Richard Hartmann
  0 siblings, 1 reply; 7+ messages in thread
From: Bart Schaefer @ 2011-06-01 15:00 UTC (permalink / raw)
  To: zsh-users

On Jun 1, 12:45am, Guido van Steen wrote:
}
} I have been trying to find out how to "just" navigate through a
} multiline buffer.
}
} Are there a similar widgets that exclusively control the navigation
} of multiline buffers, i.e. without the side-effect of potentially
} navigating the history file?

No, but this should do it:

move-line-in-buffer() {
    local hno=$HISTNO curs=$CURSOR
    zle .${WIDGET:s/in-buffer/or-history} "$@" &&
        (( HISTNO != hno && (HISTNO=hno, CURSOR=curs) ))
    return 0
}
zle -N up-line-in-buffer move-line-in-buffer
zle -N down-line-in-buffer move-line-in-buffer

-- 


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

* Re: up-line and down-line without history
  2011-06-01 15:00 ` Bart Schaefer
@ 2011-06-01 15:06   ` Richard Hartmann
  0 siblings, 0 replies; 7+ messages in thread
From: Richard Hartmann @ 2011-06-01 15:06 UTC (permalink / raw)
  To: Bart Schaefer; +Cc: zsh-users

On Wed, Jun 1, 2011 at 17:00, Bart Schaefer <schaefer@brasslantern.com> wrote:

> move-line-in-buffer() {

Arguably, this should ship with zsh proper.


Richard


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

* Re: up-line and down-line without history
  2011-06-01 15:01   ` Bernhard Tittelbach
@ 2011-06-01 15:17     ` Guido van Steen
  0 siblings, 0 replies; 7+ messages in thread
From: Guido van Steen @ 2011-06-01 15:17 UTC (permalink / raw)
  To: zsh-users; +Cc: Bernhard Tittelbach

Bernard, Thanks a lot! I will try this one as well! 

Guido 

--- On Wed, 1/6/11, Bernhard Tittelbach <xro@realraum.at> wrote:

> From: Bernhard Tittelbach <xro@realraum.at>
> Subject: Re: up-line and down-line without history
> To: zsh-users@zsh.org
> Date: Wednesday, 1 June, 2011, 10:01 PM
> On 2011-06-01 16:32, Bernhard
> Tittelbach wrote:
> > On 2011-06-01 09:45, Guido van Steen wrote:
> >> Dear List,
> >>
> >> I have been trying to find out how to "just"
> navigate through a multiline buffer.
> >>
> >> I know the "up-line-or-history" and
> "down-line-or-history" widgets. It seems
> >> to me that the "up-line" and "down-line" parts of
> these widgets do exactly
> >> what I want. So the problem is that I would like
> to avoid the "or-history" part.
> >>
> >> Are there a similar widgets that exclusively
> control the navigation of
> >> multiline buffers, i.e. without the side-effect of
> potentially navigating the
> >> history file?
> >>
> >> Or could/should I create my own widgets based on
> "up-line-or-history" and
> >> "down-line-or-history", in which I just override
> the "or-history" part?
> >
> 
> as for writing it yourself, maybe, off the top of my head,
> something like this ??
> 
> function up-line
> {
>   local buflines chars_above chars_left
>   buflines=(${(f)LBUFFER})
>   chars_above="${#buflines[$#buflines-1]}"
>   chars_left="${#buflines[$#buflines]}"
>   [[ $chars_left -gt $chars_above ]] &&
> chars_above=$chars_left
>   CURSOR=$((CURSOR-chars_above-1))
> }
> zle -N up-line && bindkey "^[[A" up-line
> 
> > regards,
> > Bernhard
> >
> 
>


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

* Re: up-line and down-line without history
  2011-06-01 14:32 ` Bernhard Tittelbach
@ 2011-06-01 15:12   ` Bart Schaefer
  0 siblings, 0 replies; 7+ messages in thread
From: Bart Schaefer @ 2011-06-01 15:12 UTC (permalink / raw)
  To: zsh-users

On Jun 1,  4:32pm, Bernhard Tittelbach wrote:
} Subject: Re: up-line and down-line without history
}
} Curious,
} there really does not seem to be a up/down-line (without history
} search) widget or functionality for multiline buffers that I could
} find.

That's because the great majority of the time a buffer is only one
line, where it doesn't make sense to have an up-line widget that is a
no-op.  For multi-line editing outside of history, there's "vared"
which is what e.g. the "zed" function uses.


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

* Re: up-line and down-line without history
       [not found] ` <4DE64D77.2090908__48299.741469282$1306940266$gmane$org@realraum.at>
@ 2011-06-01 15:01   ` Bernhard Tittelbach
  2011-06-01 15:17     ` Guido van Steen
  0 siblings, 1 reply; 7+ messages in thread
From: Bernhard Tittelbach @ 2011-06-01 15:01 UTC (permalink / raw)
  To: zsh-users

On 2011-06-01 16:32, Bernhard Tittelbach wrote:
> On 2011-06-01 09:45, Guido van Steen wrote:
>> Dear List,
>>
>> I have been trying to find out how to "just" navigate through a multiline buffer.
>>
>> I know the "up-line-or-history" and "down-line-or-history" widgets. It seems
>> to me that the "up-line" and "down-line" parts of these widgets do exactly
>> what I want. So the problem is that I would like to avoid the "or-history" part.
>>
>> Are there a similar widgets that exclusively control the navigation of
>> multiline buffers, i.e. without the side-effect of potentially navigating the
>> history file?
>>
>> Or could/should I create my own widgets based on "up-line-or-history" and
>> "down-line-or-history", in which I just override the "or-history" part?
>

as for writing it yourself, maybe, off the top of my head, something like this ??

function up-line
{
  local buflines chars_above chars_left
  buflines=(${(f)LBUFFER})
  chars_above="${#buflines[$#buflines-1]}"
  chars_left="${#buflines[$#buflines]}"
  [[ $chars_left -gt $chars_above ]] && chars_above=$chars_left
  CURSOR=$((CURSOR-chars_above-1))
}
zle -N up-line && bindkey "^[[A" up-line

> regards,
> Bernhard
>


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

* Re: up-line and down-line without history
       [not found] <905914.60054.qm__35866.2271559753$1306914819$gmane$org@web65607.mail.ac4.yahoo.com>
@ 2011-06-01 14:32 ` Bernhard Tittelbach
  2011-06-01 15:12   ` Bart Schaefer
       [not found] ` <4DE64D77.2090908__48299.741469282$1306940266$gmane$org@realraum.at>
  1 sibling, 1 reply; 7+ messages in thread
From: Bernhard Tittelbach @ 2011-06-01 14:32 UTC (permalink / raw)
  To: zsh-users

On 2011-06-01 09:45, Guido van Steen wrote:
> Dear List,
>
> I have been trying to find out how to "just" navigate through a multiline buffer.
>
> I know the "up-line-or-history" and "down-line-or-history" widgets. It seems to me that the "up-line" and "down-line" parts of these widgets do exactly what I want. So the problem is that I would like to avoid the "or-history" part.
>
> Are there a similar widgets that exclusively control the navigation of multiline buffers, i.e. without the side-effect of potentially navigating the history file?
>
> Or could/should I create my own widgets based on "up-line-or-history" and "down-line-or-history", in which I just override the "or-history" part?

Curious,
there really does not seem to be a up/down-line (without history search) widget 
or functionality for multiline buffers that I could find.

While it should not be too hard to write one yourself
you might want to try the edit-command-line widget shipped with zsh.
might be more comfortable

i.e.:
autoload -U edit-command-line && zle -N edit-command-line && \
bindkey '\ee' edit-command-line

this way you can load and edit the current command line in your editor of choice 
by pressing ESC-e

regards,
Bernhard


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

end of thread, other threads:[~2011-06-01 15:24 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-06-01  7:45 up-line and down-line without history Guido van Steen
2011-06-01 15:00 ` Bart Schaefer
2011-06-01 15:06   ` Richard Hartmann
     [not found] <905914.60054.qm__35866.2271559753$1306914819$gmane$org@web65607.mail.ac4.yahoo.com>
2011-06-01 14:32 ` Bernhard Tittelbach
2011-06-01 15:12   ` Bart Schaefer
     [not found] ` <4DE64D77.2090908__48299.741469282$1306940266$gmane$org@realraum.at>
2011-06-01 15:01   ` Bernhard Tittelbach
2011-06-01 15:17     ` Guido van Steen

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