Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: region_highlight converts `fg=default` to `none`, which is not the same
- X-seq: zsh-workers 47465
- From: "Daniel Shahaf" <d.s@xxxxxxxxxxxxxxxxxx>
- To: "Roman Perepelitsa" <roman.perepelitsa@xxxxxxxxx>
- Subject: Re: region_highlight converts `fg=default` to `none`, which is not the same
- Date: Fri, 16 Oct 2020 13:28:35 +0000
- Archived-at: <https://zsh.org/workers/47465>
- Archived-at: <http://www.zsh.org/sympa/arcsearch_id/zsh-workers/2020-10/cd3c7101-2735-4e4e-a40f-76d0850f471d%40www.fastmail.com>
- Authentication-results: zsh.org; iprev=pass (out2-smtp.messagingengine.com) smtp.remote-ip=66.111.4.26; dkim=pass header.d=daniel.shahaf.name header.s=fm1 header.a=rsa-sha256; dkim=pass header.d=messagingengine.com header.s=fm1 header.a=rsa-sha256; dmarc=none header.from=daniel.shahaf.name; arc=none
- Cc: "Marlon Richert" <marlon.richert@xxxxxxxxx>, "Zsh hackers list" <zsh-workers@xxxxxxx>
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= daniel.shahaf.name; h=mime-version:message-id:in-reply-to :references:date:from:to:cc:subject:content-type :content-transfer-encoding; s=fm1; bh=gq5T51+5yo5XpVFhiPCfoj1yx6 k5bd0XdsNs/TG4M34=; b=KzQGdkav5LoeVCNWUvf3yO4++dqjue15BpEKpgyGoA Nuuc9DThpTb4KA/mJtW0nMV88FX7Ph0lLlPICJnUdgR9rcrcdYgzo9YIJvOrQHq8 CP/YirAxfNpsayQZc3MBnUmpKK0hdqulettI22iqm0aVDabhbievocQ2Gpi3MuHn mw8z8haJbJqAqnupuHoihsFBDSY77IwwgLxbiucn7R5BOEqGOnaq79O5IF4pgzAB RLt53pHrAmTEnXdiTnH1ses7MeGBxx+Q9HBRnVVSYdBmHeXDbylUQV84iHF/+Mko t9t9IGJ59TPen6qro7KjWfn4fa41yJ+SOGtdmDo/MZ+w==
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; bh=gq5T51+5yo5XpVFhiPCfoj1yx6k5bd0XdsNs/TG4M 34=; b=hmNCVVYSoSKzf6YWDO3FtCZFK2dzf1vfGVoONfYxLJmPejZAJMOn5P+vj oDiX0tOf1+GnL6WdZ1c97G9tDZRj/EFHZ3tGNnjVML0YTIQvQ7Lz29//dO1os/j3 oLDqfYoEPQVnM3lOyLl/ymjwaYPi7UIZHzVoNgJ7PFljlLRRL/tXv1L/bKJXS1mj HEUwfk8VRlXLvWzVTDXKEV24kZDwNkN0ZUcKhwFQ+PPCNc3VW+5bkqwrTtP00RdD HYqEGBJ9jgwEViUtavaG+N6DrdpJ5SU1bGhcEmSQjxR+LN6LVGyvMUxaoekOPtfx GYMYHxiby/0OvLMJTFXlRAPVmHr8w==
- In-reply-to: <CAN=4vMqencidrpknTheyjAYQRT9BHN8ZLXRFk2Z38Gfwx9mxyQ@mail.gmail.com>
- List-archive: <http://www.zsh.org/sympa/arc/zsh-workers>
- List-help: <mailto:sympa@zsh.org?subject=help>
- List-id: <zsh-workers.zsh.org>
- List-owner: <mailto:zsh-workers-request@zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- List-subscribe: <mailto:sympa@zsh.org?subject=subscribe%20zsh-workers>
- List-unsubscribe: <mailto:sympa@zsh.org?subject=unsubscribe%20zsh-workers>
- References: <CAHLkEDv9ch+nhtpYF3So+029J6GMv5iU-8=RzHRHLa7OYzc3kg@mail.gmail.com> <CAN=4vMq1CjLKiwM0_HWfQf5=xLTGQ7z9mVs=QEsCp05suLK-fA@mail.gmail.com> <20201014204621.4cf5b2b0@tarpaulin.shahaf.local2> <CAN=4vMqencidrpknTheyjAYQRT9BHN8ZLXRFk2Z38Gfwx9mxyQ@mail.gmail.com>
- Sender: zsh-workers-request@xxxxxxx
Roman Perepelitsa wrote on Thu, 15 Oct 2020 07:37 +00:00:
> I could imagine two simple merging strategies:
>
> 1. All attributes are merged, so fg=1 + bg=2 + underline would result
> in underlined red text on green background.
> 2. The second highlight completely overrides the first. fg=1 + bg=2 +
> underline results in underlined text with the default color and no
> background.
>
> The meaning of "none" naturally follows from the choice of merging
> strategy. In the first case region highlight with "none" spec has no
> effect (X + none => X). In the second case such a region is displayed
> without any highlighting (X + none => no highlighting).
>
> The actual code does something else. If a spec has fg or bg with any
> value other than "default", then the spec completely overrides the
> previous spec. Otherwise the spec is merged with the previous spec
> with one exception: fg=default and bg=default have no effect (fg=1 +
> fg=default,underline => fg=1,underline).
>
> Note: "special" highlight is merged with a different algorithm. All
> other highlights, including "region", "isearch" and "paste", are
> merged the same way as the elements of region_highlights.
>
> A few examples of what the current code does:
>
> - fg=1 + bg=2 => bg=2
> * the second spec completely overrides the first
> - fg=1 + underline => fg=1,underline
> * specs are merged
> - underline + fg=1 => fg=1
> * the second spec completely overrides the first
> - fg=1 + none => fg=1
> * specs are merged
> - fg=1 + fg=default,underline => fg=1,underline
> * specs are merged except that fg=default has no effect
>
> This doesn't look ideal. So, how can we fix it?
⋮
> Thoughts?
The inconsistent augmentation semantics have bugged me since I first ran
into them. I'd love to see them rationalized.
Short on time, but in general terms:
1. Heed PEP 20. (E.g., the points about explicitness and ambiguity)
2. Proposed acceptance test: When two specs are added, A+B, for any
desired visual outcome there should be a value of B that, _regardless
of the value of A_, achieves that outcome.
Not sure how to get from the current semantics to acceptable ones. Maybe we could do, say:
- fg=1 + bg=2,fg=inherit ⇒ fg=1,bg=2
- underline + fg=1,underline=inherit ⇒ fg=1,underline
- none + fg=1,underline=inherit ⇒ fg=1 [no underline]
As to «fg=1 + fg=default ⇒ fg=1», I think we can treat it as a bug and break compatibility?
Messages sorted by:
Reverse Date,
Date,
Thread,
Author