zsh-users
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh-users@zsh.org
Cc: rooom <rooom@prokonto.pl>
Subject: Re: ZLE: missing edit-buffer widget
Date: Sun, 23 Aug 2015 14:45:46 -0700	[thread overview]
Message-ID: <150823144546.ZM8190@torch.brasslantern.com> (raw)
In-Reply-To: <40b4e87d.4fe9a6ca.55da2e85.b4319@prokonto.pl>

On Aug 23, 10:35pm, rooom wrote:
}
} I'm looking for widget "edit-line" or "edit-buffer" which move entire
} command line into editor buffer regardless if it is single line or 
} multi-line construct.

Look at the edit-command-line function in the distribution (probably
findable with   print -R $^fpath/edit-command-line(N)  )

You want to do what that does, except skip invoking the editor on a
file.  So something like:

    print -Rz - "$PREBUFFER$BUFFER"
    zle send-break

This is exactly what push-line-or-edit does except that if there is
only one line of input it skips the send-break.  (push-line-or-edit
was implemented before user-defined widgets were available.)

You could also write a little wrapper that's just a no-op if there
is only one line:

    edit-if-multi-line () {
      if [[ -n "$PREBUFFER" ]]; then
	zle .push-line-or-edit
      fi
      return 0
    }

} For some reason the simple definition doesn't work:
} 
} push-input-get-line () {
}     zle .push-input
}     zle .get-line
} }

You've discovered the reason push-line-or-edit exists.  In a multi-
line construct, the stuff entered at previous prompts (the value of
$PREBUFFER) has already passed through both the editor and the shell
parser and is only awaiting the completion of the parse to be run as
shell input.  In order to get it back and undo the parser state,
push-input has to abort the whole parser loop, so get-line never has
a chance to be executed.


      reply	other threads:[~2015-08-23 21:45 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-19 21:59 list last modified files rooom
2015-08-19 23:16 ` Vin Shelton
2015-08-20  4:33 ` Bart Schaefer
2015-08-20  5:20   ` Mikael Magnusson
2015-08-20 13:08   ` rooom
2015-08-20 13:29     ` Peter Stephenson
2015-08-20 15:34       ` Bart Schaefer
2015-08-20 15:55         ` Peter Stephenson
2015-08-20 17:13           ` Bart Schaefer
     [not found]         ` <20150820165552.2b5ec817__22391.7863135741$1440086232$gmane$org@pwslap01u.europe.root.pri>
2015-08-20 16:42           ` Stephane Chazelas
2015-08-20 17:09             ` Bart Schaefer
2015-08-23 20:35     ` ZLE: missing edit-buffer widget rooom
2015-08-23 21:45       ` Bart Schaefer [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=150823144546.ZM8190@torch.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --cc=rooom@prokonto.pl \
    --cc=zsh-users@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).