zsh-users
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: Zsh Users <zsh-users@zsh.org>
Subject: Line numbers and debugging verbosity
Date: Sun, 8 Apr 2018 22:19:44 -0700	[thread overview]
Message-ID: <CAH+w=7bxavbSX=Zuc+xRXDVnkVh=M90T5hu8Wz=_c5rVTdZV7w@mail.gmail.com> (raw)

On Fri, Apr 6, 2018 at 9:29 AM, Ray Andrews <rayandrews@eastlink.ca> wrote:
>
> What I'm actually trying to do is reduce verbosity of a function by
> redefining various message printer functions as null.  It works fine with
> functions, but if the message printers are aliases (which seem to be the
> only way to get:  ${(%):-%x %I} ... line information printed, it seems that
> can't be done in a function) ... then it goes sour.

On Sun, Apr 8, 2018 at 3:38 PM, Ray Andrews <rayandrews@eastlink.ca> wrote:
>
> Is there a new strategy that might work?  Nullify the function and/or the
> alias?  Really, just some way of stopping messages from printing at all?

There are several possible approaches.  For one, you could stop using
your own "echo"/"print" statements and instead turn tracing on and off
for the surrounding function:

  functions -T test1

If you want to keep printing your own messages instead of using the
xtrace facility, let's get you away from aliases.  The information for
%x and %l are in the $funcfiletrace variable, and will give you the
result you want from inside a function.

  warningmsg() {
    print -n "${funcfiletrace[1]}: " && magline "$*"
  }

For another approach, you had a perfectly good example:

>     [[ "$vverbose" < 3 ]] &&
>     {
>         warningmsg () { ; }
>      }

Just put a similar test in the definition of "warningmsg" e.g.

  warningmsg() {
    (( $dbg )) &&
    print -nr - "${funcfiletrace[1]}: " && magline "$*"
  }

Now you don't have to modify the function, you just assign dbg=1 or dbg=0.


             reply	other threads:[~2018-04-09  5:20 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-09  5:19 Bart Schaefer [this message]
2018-04-09 15:51 ` Ray Andrews

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='CAH+w=7bxavbSX=Zuc+xRXDVnkVh=M90T5hu8Wz=_c5rVTdZV7w@mail.gmail.com' \
    --to=schaefer@brasslantern.com \
    --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).