zsh-workers
 help / color / Atom feed
* PATCH: Add printing of the style to zstyle+ through option -p
@ 2019-10-15 18:57 Sebastian Gniazdowski
  2019-10-16  1:44 ` Daniel Shahaf
  0 siblings, 1 reply; 3+ messages in thread
From: Sebastian Gniazdowski @ 2019-10-15 18:57 UTC (permalink / raw)
  To: Zsh hackers list

[-- Attachment #1: Type: text/plain, Size: 557 bytes --]

Hello,
I think that many of us often dreamed about omitting the output
parameter and the following print when checking out a value of style:

zstyle -s :the:style:path style the_parameter; print $the_parameter

I've stumbled upon the interesting function zstyle+ and I thought
about adding an option -p to it that would print the style:

zstyle+ -p :the:style:path style

The simple patch adds the option.
-- 
Sebastian Gniazdowski
News: https://twitter.com/ZdharmaI
IRC: https://kiwiirc.com/client/chat.freenode.net:+6697/#zplugin
Blog: http://zdharma.org

[-- Attachment #2: 0001-Add-option-p-to-zstyle-printing-of-the-style-to-the-.patch.txt --]
[-- Type: text/plain, Size: 1166 bytes --]

From 5f770ab08febe83adc5afbef44103139f98666a8 Mon Sep 17 00:00:00 2001
From: Sebastian Gniazdowski <sgniazdowski@gmail.com>
Date: Tue, 15 Oct 2019 20:49:18 +0200
Subject: [PATCH] =?UTF-8?q?Add=20option=20-p=20to=20zstyle+=20=E2=80=93=20?=
 =?UTF-8?q?printing=20of=20the=20style=20to=20the=20stdout?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 Functions/Misc/zstyle+ | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/Functions/Misc/zstyle+ b/Functions/Misc/zstyle+
index 81b4f0552..66a4eb34b 100644
--- a/Functions/Misc/zstyle+
+++ b/Functions/Misc/zstyle+
@@ -17,8 +17,14 @@
 # the completion functions are autoloaded without alias expansion (the
 # -U option to the autoload builtin). The completion system normally
 # loads its functions with without alias expansion.
+#
+# Tue Oct 15 20:38:16 CEST 2019
+# The option -p prints the value of the style. The normal usage is to
+# use it in place of the option -s and to omit the output parameter.
 
 case "$1" in
+-p) shift; local value; zstyle -s "$@" value; print -r -- "$value";;
+
 -*) zstyle "$@";;
 
 *)  setopt localoptions noksharrays
-- 
2.21.0


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

* Re: PATCH: Add printing of the style to zstyle+ through option -p
  2019-10-15 18:57 PATCH: Add printing of the style to zstyle+ through option -p Sebastian Gniazdowski
@ 2019-10-16  1:44 ` Daniel Shahaf
  2019-10-16 21:08   ` Sebastian Gniazdowski
  0 siblings, 1 reply; 3+ messages in thread
From: Daniel Shahaf @ 2019-10-16  1:44 UTC (permalink / raw)
  To: Sebastian Gniazdowski, Zsh hackers list

Sebastian Gniazdowski wrote on Tue, 15 Oct 2019 18:57 +00:00:
> I think that many of us often dreamed about omitting the output
> parameter and the following print when checking out a value of style:
> 
> zstyle -s :the:style:path style the_parameter; print $the_parameter
> 
> I've stumbled upon the interesting function zstyle+ and I thought
> about adding an option -p to it that would print the style:
> 
> zstyle+ -p :the:style:path style
> 
> The simple patch adds the option.

Random idea, but how about a way to annotate a variable as "print
a `set -x`-like diagnostic every time this variable is assigned to"?
More or less like a gdb watchpoint.

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

* Re: PATCH: Add printing of the style to zstyle+ through option -p
  2019-10-16  1:44 ` Daniel Shahaf
@ 2019-10-16 21:08   ` Sebastian Gniazdowski
  0 siblings, 0 replies; 3+ messages in thread
From: Sebastian Gniazdowski @ 2019-10-16 21:08 UTC (permalink / raw)
  To: Daniel Shahaf; +Cc: Zsh hackers list

On Wed, 16 Oct 2019 at 03:44, Daniel Shahaf <d.s@daniel.shahaf.name> wrote:
>
> Sebastian Gniazdowski wrote on Tue, 15 Oct 2019 18:57 +00:00:
> > I think that many of us often dreamed about omitting the output
> > parameter and the following print when checking out a value of style:
> >
> > zstyle -s :the:style:path style the_parameter; print $the_parameter
> >
> > I've stumbled upon the interesting function zstyle+ and I thought
> > about adding an option -p to it that would print the style:
> >
> > zstyle+ -p :the:style:path style
> >
> > The simple patch adds the option.
>
> Random idea, but how about a way to annotate a variable as "print
> a `set -x`-like diagnostic every time this variable is assigned to"?
> More or less like a gdb watchpoint.

Yes this is doable, from C - a chunk of code would have to be added to
the few standard parameter setters.

-- 
Sebastian Gniazdowski
News: https://twitter.com/ZdharmaI
IRC: https://kiwiirc.com/client/chat.freenode.net:+6697/#zplugin
Blog: http://zdharma.org

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

end of thread, back to index

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-15 18:57 PATCH: Add printing of the style to zstyle+ through option -p Sebastian Gniazdowski
2019-10-16  1:44 ` Daniel Shahaf
2019-10-16 21:08   ` Sebastian Gniazdowski

zsh-workers

Archives are clonable: git clone --mirror http://inbox.vuxu.org/zsh-workers

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://inbox.vuxu.org/vuxu.archive.zsh.workers


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git