[Date Prev] [Date Next] [Thread Prev] [Thread Next] Date Index Thread Index Search archive:
Date:Mon Sep 12 14:48:56 1994 
Subject:Re: ved_q (Simplified slightly) 
From:johnw (John Williams) 
Volume-ID:940912.03 

>Even simpler would be the following, which does not require the old
>value of ved_q to be saved.
>
>define ved_q();
>    ;;; quit current ved buffer and, if appropriate, run the command
>	;;; given as argument to ved_q, using old window if necessary.
>    if vedargument /= nullstring then
>      	vedqget(veddo(%vedargument%));  ;;; See HELP VEDDO
>      	;;; or possibly
>      	;;;     vedqget(vedargument, veddo)
>    else
>		vedqget(identfn)
>    endif;
>enddefine;
>
>It seems to work, perhaps surprisingly.
>
>The only snag with redefining ved_q like this is that it is no longer
>safe to call ved_q in arbitrary contexts (e.g. mapped to a key
>sequence, or invoked from another VED procedure), because it may pick up
>an unintended version of vedargument.


You could try using the following hack to check that -ved_q- is being
called from the status line:

  define called_from_status_line(command);
      lvars command, i;
      (iscaller(veddocommand) ->> i)
          and
      caller(i + 1) == veddocr
          and
	  isstartstring(command, caller_valof(ident vedcommand, i))
  enddefine;

and then define -ved_q- as:

  define ved_q();
      ;;; quit current ved buffer and run the command given as
      ;;; argument to ved_qand
      if vedargument /= nullstring
      and called_from_status_line('q ') then
          vedqget(veddo(% vedargument %))
      else
          vedqget(identfn)
      endif
  enddefine;

To test it, compare the effects of
	<ENTER> q date
and
	<ENTER> wq date

(-ved_wq- calls -ved_q-).

John.