zsh-workers
 help / color / mirror / code / Atom feed
* Re: accessing full command line
       [not found] <23274.199509061646@stone.dcs.warwick.ac.uk>
@ 1995-09-06 17:07 ` Zoltan Hidvegi
  0 siblings, 0 replies; 3+ messages in thread
From: Zoltan Hidvegi @ 1995-09-06 17:07 UTC (permalink / raw)
  To: zefram

Zefram wrote:
> 
> >In my release I disabled up-history from vared.  This is the desired behaviour
> >if you use vared to edit a file or a function definition, but I understand
> >that is may be useful in cases you mention.  It would be very easy to
> >implement an option controlling this behaviour, and it is much simpler and
> >cleaner than disabling quote removal.  Presently all I do is setting the
> >in_vared global variable in builtin.c in function bin_vared() before calling
> >zleread() and reset it to zero after the call.  If a new option is
> >introdudced, the only necessary change is to replace the in_vared = 1; line to
> >in_vared = unset(VARED_HISTORY);.
> 
> Surely it would be better to add an option to vared to allow history,
> rather than using a global shell option?  The patch to do that is even
> trivialer.

You are right.  Somehow I forgot about this solution.  Here is the patch for
that.  It now obsolates the patches I sent a few minutes ago for the
VARED_HISTORY option.  Note that the documentation is missing.  It is for the
hzoli releases only.  After the patch vared -h gives access to the history.

Zoltan

*** 1.28	1995/09/06 16:09:05
--- Src/builtin.c	1995/09/06 17:02:07
***************
*** 192,198 ****
      {"unlimit", bin_unlimit, 0, -1, 0, 0, "h", NULL},
      {"unset", bin_unset, 1, -1, 0, 0, "m", NULL},
      {"unsetopt", bin_setopt, 0, -1, BINF_PLUSOPTS, 1, "0123456789BCDEFGHIJKLMNOPQRSTUWXYZabefghjklmnopsuvwxy", NULL},
!     {"vared", bin_vared, 1, 6, 0, 0, NULL, NULL},
      {"wait", bin_fg, 0, -1, 0, BIN_WAIT, NULL, NULL},
      {"whence", bin_whence, 0, -1, 0, 0, "pvcfam", NULL},
      {"where", bin_whence, 0, -1, 0, 0, "pm", "ca"},
--- 192,198 ----
      {"unlimit", bin_unlimit, 0, -1, 0, 0, "h", NULL},
      {"unset", bin_unset, 1, -1, 0, 0, "m", NULL},
      {"unsetopt", bin_setopt, 0, -1, BINF_PLUSOPTS, 1, "0123456789BCDEFGHIJKLMNOPQRSTUWXYZabefghjklmnopsuvwxy", NULL},
!     {"vared", bin_vared, 1, 7, 0, 0, NULL, NULL},
      {"wait", bin_fg, 0, -1, 0, BIN_WAIT, NULL, NULL},
      {"whence", bin_whence, 0, -1, 0, 0, "pvcfam", NULL},
      {"where", bin_whence, 0, -1, 0, 0, "pm", "ca"},
***************
*** 3218,3223 ****
--- 3218,3226 ----
  		    return 1;
  		}
  		break;
+ 	    case 'h':
+ 		ops['h'] = 1;
+ 		break;
  	    default:
  		/* unrecognised option character */
  		zwarnnam(name, "unknown option: %s", *args, 0);
***************
*** 3244,3250 ****
      permalloc();
      pushnode(bufstack, ztrdup(s));
      heapalloc();
!     in_vared = 1;
      t = (char *)zleread(p1, p2);
      in_vared = 0;
      if (!t || errflag)
--- 3247,3253 ----
      permalloc();
      pushnode(bufstack, ztrdup(s));
      heapalloc();
!     in_vared = !ops['h'];
      t = (char *)zleread(p1, p2);
      in_vared = 0;
      if (!t || errflag)


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

* Re: accessing full command line
  1995-09-06 16:22 ` Zoltan Hidvegi
@ 1995-09-06 16:48   ` Zoltan Hidvegi
  0 siblings, 0 replies; 3+ messages in thread
From: Zoltan Hidvegi @ 1995-09-06 16:48 UTC (permalink / raw)
  To: zsh-workers

> In my release I disabled up-history from vared.  This is the desired behaviour
> if you use vared to edit a file or a function definition, but I understand
> that is may be useful in cases you mention.  It would be very easy to
> implement an option controlling this behaviour, and it is much simpler and
> cleaner than disabling quote removal.  Presently all I do is setting the
> in_vared global variable in builtin.c in function bin_vared() before calling
> zleread() and reset it to zero after the call.  If a new option is
> introdudced, the only necessary change is to replace the in_vared = 1; line to
> in_vared = unset(VARED_HISTORY);.
> 
> Below is a trivial patch to hzoli10.3 which implements this option (not tested
> too much).
> 
> Zoltan

I've just noticed that I sent a hunk from a patch from Peter with my patch.  I
forgot to check this in befor I modified the file.  Here is the patch again
with this hunk removed.  Sorry for the inconvinience.

Zoltan


*** 1.28	1995/09/06 16:09:05
--- Src/builtin.c	1995/09/06 16:14:55
***************
*** 3244,3250 ****
      permalloc();
      pushnode(bufstack, ztrdup(s));
      heapalloc();
!     in_vared = 1;
      t = (char *)zleread(p1, p2);
      in_vared = 0;
      if (!t || errflag)
--- 3244,3250 ----
      permalloc();
      pushnode(bufstack, ztrdup(s));
      heapalloc();
!     in_vared = unset(VAREDHISTORY);
      t = (char *)zleread(p1, p2);
      in_vared = 0;
      if (!t || errflag)
*** 1.9	1995/07/24 17:12:46
--- Src/zsh.h	1995/07/07 14:29:00
***************
*** 922,927 ****
--- 923,929 ----
  #define CSHJUNKIEHISTORY    '\037'
  #define MAGICEQUALSUBST     '\040'
  #define GLOBSUBST           '\041'
+ #define VAREDHISTORY        '\042'
  #define PROMPTSUBST         '\043'
  #define ALWAYSLASTPROMPT    '\044'
  #define COMPLETEALIASES     '\045'
*** 1.10	1995/07/24 17:12:46
--- Src/globals.h	1995/07/07 14:29:00
***************
*** 703,708 ****
--- 703,709 ----
      {"shwordsplit", SHWORDSPLIT},
      {"singlelinezle", SINGLELINEZLE},
      {"sunkeyboardhack", SUNKEYBOARDHACK},
+     {"varedhistory", VAREDHISTORY},
      {"verbose", VERBOSE},
      {"xtrace", XTRACE},
      {"zle", USEZLE},


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

* Re: accessing full command line
       [not found] <199509061541.AA16330@intruder.wiltel.com>
@ 1995-09-06 16:22 ` Zoltan Hidvegi
  1995-09-06 16:48   ` Zoltan Hidvegi
  0 siblings, 1 reply; 3+ messages in thread
From: Zoltan Hidvegi @ 1995-09-06 16:22 UTC (permalink / raw)
  To: alex_ramos; +Cc: zsh-workers

Alex Ramos wrote:
> > >I would like to know if there is any way (e.g. an undocumented
> > >feature or a source code patch) in zsh to access the full
> > >command line passed to a function or alias. For example, if
> > >'foo' is a function, and I type
> > >
> > >	foo "blah blah $$" $XYZ
> > >
> > >I'd like to (inside 'foo') have access to the string '"blah blah $$" $XYZ'
> > >as it was typed.
> > 
> > No, there's no way.  But if all you want to do is inhibit globbing, you
> > could do
> > 
> > alias foo="noglob foo"
> 
> I would like to inhibit globbing as well as quote removal.
> (never mind that the example implies I'd like to inhibit variable
> interpolation too. It was a poorly chosen example).
> 
> Some may ask, "and why the hell would you want to do THAT?".
> The reason is, I'm trying to use zsh for some "unusual"
> purposes.  For example, I open a co-process to an interactive
> application and use a zsh subshell with a small set of aliases
> and functions to act as a gateway between the user and the
> application, thus providing history, completion, editing, etc
> and allowing a brain-dead application to be useable. (I could
> also use 'vared', but I was told that vared's history feature
> is actually a bug, so I conclude it'll be removed in the future).

In my release I disabled up-history from vared.  This is the desired behaviour
if you use vared to edit a file or a function definition, but I understand
that is may be useful in cases you mention.  It would be very easy to
implement an option controlling this behaviour, and it is much simpler and
cleaner than disabling quote removal.  Presently all I do is setting the
in_vared global variable in builtin.c in function bin_vared() before calling
zleread() and reset it to zero after the call.  If a new option is
introdudced, the only necessary change is to replace the in_vared = 1; line to
in_vared = unset(VARED_HISTORY);.

Below is a trivial patch to hzoli10.3 which implements this option (not tested
too much).

Zoltan

*** 1.28	1995/09/06 16:09:05
--- Src/builtin.c	1995/09/06 16:14:55
***************
*** 3244,3250 ****
      permalloc();
      pushnode(bufstack, ztrdup(s));
      heapalloc();
!     in_vared = 1;
      t = (char *)zleread(p1, p2);
      in_vared = 0;
      if (!t || errflag)
--- 3244,3250 ----
      permalloc();
      pushnode(bufstack, ztrdup(s));
      heapalloc();
!     in_vared = unset(VAREDHISTORY);
      t = (char *)zleread(p1, p2);
      in_vared = 0;
      if (!t || errflag)
*** 1.9	1995/07/24 17:12:46
--- Src/zsh.h	1995/07/07 14:29:00
***************
*** 205,210 ****
--- 205,211 ----
  #define INP_ALIAS	2	/* alias or history mark at end of word */
  #define INP_CONT	4	/* continue onto previously stacked input */
  #define INP_SPACE	8	/* return space after expanded alias */
+ #define INP_OLDSPACE	16	/* internal flag:  INP_SPACE was swallowed */
  
  /* linked list abstract data type */
  
***************
*** 922,927 ****
--- 923,929 ----
  #define CSHJUNKIEHISTORY    '\037'
  #define MAGICEQUALSUBST     '\040'
  #define GLOBSUBST           '\041'
+ #define VAREDHISTORY        '\042'
  #define PROMPTSUBST         '\043'
  #define ALWAYSLASTPROMPT    '\044'
  #define COMPLETEALIASES     '\045'
*** 1.10	1995/07/24 17:12:46
--- Src/globals.h	1995/07/07 14:29:00
***************
*** 703,708 ****
--- 703,709 ----
      {"shwordsplit", SHWORDSPLIT},
      {"singlelinezle", SINGLELINEZLE},
      {"sunkeyboardhack", SUNKEYBOARDHACK},
+     {"varedhistory", VAREDHISTORY},
      {"verbose", VERBOSE},
      {"xtrace", XTRACE},
      {"zle", USEZLE},


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

end of thread, other threads:[~1995-09-06 17:33 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <23274.199509061646@stone.dcs.warwick.ac.uk>
1995-09-06 17:07 ` accessing full command line Zoltan Hidvegi
     [not found] <199509061541.AA16330@intruder.wiltel.com>
1995-09-06 16:22 ` Zoltan Hidvegi
1995-09-06 16:48   ` Zoltan Hidvegi

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