From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Mauro Aranda Newsgroups: gmane.emacs.bugs Subject: bug#15925: 24.3.50; error when customizing whitespace-display-mappings Date: Tue, 22 Sep 2020 12:42:01 -0300 Message-ID: References: <87mwl0vo36.wl%claudio.bley@gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="000000000000a7eba705afe8cf90" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="16952"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Glenn Morris , claudio.bley@googlemail.com To: 15925@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Sep 22 17:48:13 2020 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kKkWb-0004JZ-SE for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 22 Sep 2020 17:48:13 +0200 Original-Received: from localhost ([::1]:49100 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kKkWZ-0007LO-IX for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 22 Sep 2020 11:48:12 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:40516) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kKkRa-0004ec-R4 for bug-gnu-emacs@gnu.org; Tue, 22 Sep 2020 11:43:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:49646) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kKkRa-00013c-Gs for bug-gnu-emacs@gnu.org; Tue, 22 Sep 2020 11:43:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kKkRa-0008Fk-F4 for bug-gnu-emacs@gnu.org; Tue, 22 Sep 2020 11:43:02 -0400 X-Loop: help-debbugs@gnu.org In-Reply-To: <87mwl0vo36.wl%claudio.bley@gmail.com> Resent-From: Mauro Aranda Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 22 Sep 2020 15:43:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 15925 X-GNU-PR-Package: emacs Original-Received: via spool by 15925-submit@debbugs.gnu.org id=B15925.160078934331654 (code B ref 15925); Tue, 22 Sep 2020 15:43:02 +0000 Original-Received: (at 15925) by debbugs.gnu.org; 22 Sep 2020 15:42:23 +0000 Original-Received: from localhost ([127.0.0.1]:32955 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kKkQx-0008EU-1C for submit@debbugs.gnu.org; Tue, 22 Sep 2020 11:42:23 -0400 Original-Received: from mail-wr1-f54.google.com ([209.85.221.54]:39544) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kKkQv-0008EF-DY for 15925@debbugs.gnu.org; Tue, 22 Sep 2020 11:42:22 -0400 Original-Received: by mail-wr1-f54.google.com with SMTP id a17so17587379wrn.6 for <15925@debbugs.gnu.org>; Tue, 22 Sep 2020 08:42:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to:cc; bh=H6PofeYKkMaMiqfdNG4uTTxp3hWRjgFXFXGqYnh+Cl4=; b=rl4ruuTAPgjo68wkrqy4yCQ4YKNlFdmR7T2wsHpsUMM95Fn9tlZQ53slRBwYslTVPZ jyy/wiNWdL0N3fx/IRuZEunB+cz9Tt6LG7CWN/5n10JiTWPB1bqFYWvRHuJWhIN0jgl6 gbsCB8YLjZVlhRg4CcYoVuEXFJ/kNnpkyueUExx3FB0BNXm+e55AD1idYep6Ti8JYwxf zn7Ad84vnZaly4VZVvolH/mI/MjLtSvDE8EVNphvLKDg0bGn0BqQFHOAzjUp8Nr5f+Po wfdMrn5G016deoP1PHW/OaQFjSJq3pv12IbDB+v0d5AlrsKda91VlPeZoAV6JiuCdwSh XJJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to:cc; bh=H6PofeYKkMaMiqfdNG4uTTxp3hWRjgFXFXGqYnh+Cl4=; b=s1MKaH4ePZ1hGR3czEQ224eUcE76c3GkzC8tPS7Efy1s2rEIRfjXav7x4EDiUm8gVE CRFX/q4aCE4HERThO+wWgbUuzVyDvGqfHvil3erdAukyc4075MpBFB6F21+vIMzrgeFe VLdYDtjcRHYUnd7poQIe2YGgcg1CQPViW5QF3S/eA7ZnWFzSq64B+/yL1Rk5dd4qcjbB sD1k7Oms1Ztb3b8v8GG7JfBLqtlwHk7r+tquI24LdU/qHdFFZVf1VIA6uI5sl+DHz2Z6 Mm8LYtcadT4R1hssdyTO0iFM9tN4M5erZwoIFrnh0E98Pf0BDrM3WwqmrgTuVfHYh7Vn G8bg== X-Gm-Message-State: AOAM533kskeAPcXAgN3tdkHiywtQrXhd/l/v1AObVzP8kaywrsrxGNAb kqE48OpILmTFSOVzK3/OOvzOba+85kFnpCDPKcQTWsNcJ50Wuw== X-Google-Smtp-Source: ABdhPJyBlTHH5AhCvHN6+G0m8VpXLTPpG7O06aN8PE+1HpdBb39+FCNGoSsGFQfNxDxVXRpHNnfT6tap5xYxCDnkNXo= X-Received: by 2002:adf:9f10:: with SMTP id l16mr6515608wrf.77.1600789334708; Tue, 22 Sep 2020 08:42:14 -0700 (PDT) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:188708 Archived-At: --000000000000a7eba705afe8cf90 Content-Type: multipart/alternative; boundary="000000000000a7eba505afe8cf8e" --000000000000a7eba505afe8cf8e Content-Type: text/plain; charset="UTF-8" Claudio Bley writes: > At Tue, 19 Nov 2013 03:24:02 -0500, > Glenn Morris wrote: >> >> Claudio Bley wrote: >> >> > I think the regexp should be changed to "\\`\(.\|\n\)\\'" to allow a >> > single newline also. >> >> We already tried that once; it caused more problems than it solved: >> http://debbugs.gnu.org/2689 > > I see. So lets get this solved. > > At first, changing the regexp is just the right thing to do and > in itself, IMO, does not break anything. Indeed. > Alas, it does not solve the problem at hand because > `widget-specify-field' behaves /badly/ when the field ends with a > newline. > > So, actually, this hunk of your patch trying to work around > this behaviour broke other things. [...] > How about using a special :value-create function for character fields? I don't think that's needed. > Furthermore, the presentation of the character values is bad, > usability-wise, because for nonprintable chars you cannot see what > value the field actually has. > > How about displaying those chars in the buffer in another format? > E.g. use escape sequences like \n \r et cetera? Or we could do what Isearch does, and display TAB as ^I, and so on. > I (rather hackish) way to fix this would be to always insert a ?\n > as part of the value of a character field: > > (defun widget-field-char-create (widget) > "Create an editable character field." > (let ((value (widget-get widget :value)) > (from (point)) > ;; This is changed to a real overlay in `widget-setup'. We > ;; need the end points to behave differently until > ;; `widget-setup' is called. > (overlay (cons (make-marker) (make-marker)))) > (widget-put widget :field-overlay overlay) > (insert value) > (insert ?\n) ;; EEEK > (unless (memq widget widget-field-list) > (setq widget-field-new (cons widget widget-field-new))) > (move-marker (cdr overlay) (point)) > (set-marker-insertion-type (cdr overlay) nil) > (insert ?\n) > (move-marker (car overlay) from) > (set-marker-insertion-type (car overlay) t))) > > What do you think? I don't think this is needed. I attach a patch that should fix this (but that does not change the way the characters are displayed) and that doesn't introduce the breakage of Bug#3136 (for which I added a test). --000000000000a7eba505afe8cf8e Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Claudio Bley <claudio.bley@googlemail.com> writes:

> At Tue, 19 No= v 2013 03:24:02 -0500,
> Glenn Morris wrote:
>>
>>= Claudio Bley wrote:
>>
>> > I think the regexp shoul= d be changed to "\\`\(.\|\n\)\\'" to allow a
>> >= single newline also.
>>
>> We already tried that once; = it caused more problems than it solved:
>> http://debbugs.gnu.org/2689
>
> I see. So = lets get this solved.
>
> At first, changing the regexp is just= the right thing to do and
> in itself, IMO, does not break anything.=

Indeed.

> Alas, it does not solve the problem at hand bec= ause
> `widget-specify-field' behaves /badly/ when the field ends= with a
> newline.
>
> So, actually, this hunk of your pa= tch trying to work around
> this behaviour broke other things.
[...]

> How about using a special :value-create function for cha= racter fields?

I don't think that's needed.

> Furt= hermore, the presentation of the character values is bad,
> usability= -wise, because for nonprintable chars you cannot see what
> value the= field actually has.
>
> How about displaying those chars in th= e buffer in another format?
> E.g. use escape sequences like \n \r et= cetera?

Or we could do what Isearch does, and display TAB as ^I, an= d so on.

> I (rather hackish) way to fix this would be to always = insert a ?\n
> as part of the value of a character field:
>
= > (defun widget-field-char-create (widget)
> =C2=A0 "Create a= n editable character field."
> =C2=A0 (let ((value (widget-get w= idget :value))
> (from (point))
> ;; This is changed to a rea= l overlay in `widget-setup'.=C2=A0 We
> ;; need the end points t= o behave differently until
> ;; `widget-setup' is called.
>= ; (overlay (cons (make-marker) (make-marker))))
> =C2=A0 =C2=A0 (wid= get-put widget :field-overlay overlay)
> =C2=A0 =C2=A0 (insert value)=
> =C2=A0 =C2=A0 (insert ?\n) ;; EEEK
> =C2=A0 =C2=A0 (unless (= memq widget widget-field-list)
> =C2=A0 =C2=A0 =C2=A0 (setq widget-fi= eld-new (cons widget widget-field-new)))
> =C2=A0 =C2=A0 (move-marker= (cdr overlay) (point))
> =C2=A0 =C2=A0 (set-marker-insertion-type (c= dr overlay) nil)
> =C2=A0 =C2=A0 (insert ?\n)
> =C2=A0 =C2=A0 (= move-marker (car overlay) from)
> =C2=A0 =C2=A0 (set-marker-insertion= -type (car overlay) t)))
>
> What do you think?

I don= 9;t think this is needed.

I attach a patch that should fix this (but= that does not change the
way the characters are displayed) and that doe= sn't introduce the
breakage of Bug#3136 (for which I added a test).<= /div> --000000000000a7eba505afe8cf8e-- --000000000000a7eba705afe8cf90 Content-Type: text/x-patch; charset="US-ASCII"; name="0001-Allow-the-newline-character-in-the-character-widget-.patch" Content-Disposition: attachment; filename="0001-Allow-the-newline-character-in-the-character-widget-.patch" Content-Transfer-Encoding: base64 Content-ID: X-Attachment-Id: f_kfe3wot40 RnJvbSBmYzJiMWE0ZTY1ZjBjNTI1YTVmNzhlMzEwOWNkM2QyZjY5N2FjNjAwIE1vbiBTZXAgMTcg MDA6MDA6MDAgMjAwMQpGcm9tOiBNYXVybyBBcmFuZGEgPG1hdXJvb2FyYW5kYUBnbWFpbC5jb20+ CkRhdGU6IFR1ZSwgMjIgU2VwIDIwMjAgMTE6MTA6MTUgLTAzMDAKU3ViamVjdDogW1BBVENIXSBB bGxvdyB0aGUgbmV3bGluZSBjaGFyYWN0ZXIgaW4gdGhlIGNoYXJhY3RlciB3aWRnZXQKIChCdWcj MTU5MjUpCgoqIGxpc3Avd2lkLWVkaXQuZWwgKHdpZGdldC1zcGVjaWZ5LWZpZWxkKTogRXh0ZW5k IGNoZWNrIGZvciBhZGRpbmcgdGhlCmJvdW5kYXJ5IG92ZXJsYXkuICBQbHVzLCBhIG1pbm9yIGNv bW1lbnQgaW5kZW50YXRpb24gZml4LgooY2hhcmFjdGVyIHdpZGdldCk6IFR3ZWFrIHRoZSB2YWxp ZC1yZWdleHAgdG8gYWxsb3cgdGhlIG5ld2xpbmUKY2hhcmFjdGVyLgoKKiB0ZXN0L2xpc3Avd2lk LWVkaXQtdGVzdHMuZWwgKH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