GNU bug report logs - #35480
insert-wide-parentheses

Previous Next

Package: emacs;

Reported by: 積丹尼 Dan Jacobson <jidanni <at> jidanni.org>

Date: Sun, 28 Apr 2019 20:39:01 UTC

Severity: wishlist

Done: Juri Linkov <juri <at> linkov.net>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 35480 in the body.
You can then email your comments to 35480 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#35480; Package emacs. (Sun, 28 Apr 2019 20:39:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to 積丹尼 Dan Jacobson <jidanni <at> jidanni.org>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Sun, 28 Apr 2019 20:39:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: 積丹尼 Dan Jacobson <jidanni <at> jidanni.org>
To: bug-gnu-emacs <at> gnu.org
Subject: insert-wide-parentheses
Date: Mon, 29 Apr 2019 04:38:10 +0800
M-( is insert-parentheses, so
M-( should be insert-wide-parentheses.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#35480; Package emacs. (Mon, 29 Apr 2019 20:21:03 GMT) Full text and rfc822 format available.

Message #8 received at 35480 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: 積丹尼 Dan Jacobson <jidanni <at> jidanni.org>
Cc: 35480 <at> debbugs.gnu.org
Subject: Re: bug#35480: insert-wide-parentheses
Date: Mon, 29 Apr 2019 23:00:38 +0300
> M-( is insert-parentheses, so
> M-( should be insert-wide-parentheses.

(define-key esc-map "(" 'insert-pair)
(add-to-list 'insert-pair-alist '(?\( ?\( ?\)))




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#35480; Package emacs. (Tue, 30 Apr 2019 02:01:02 GMT) Full text and rfc822 format available.

Message #11 received at 35480 <at> debbugs.gnu.org (full text, mbox):

From: 積丹尼 Dan Jacobson <jidanni <at> jidanni.org>
To: Juri Linkov <juri <at> linkov.net>
Cc: 35480 <at> debbugs.gnu.org
Subject: Re: bug#35480: insert-wide-parentheses
Date: Tue, 30 Apr 2019 09:59:57 +0800
>>>>> "JL" == Juri Linkov <juri <at> linkov.net> writes:
>> M-( is insert-parentheses, so
>> M-( should be insert-wide-parentheses.

JL> (define-key esc-map "(" 'insert-pair)
JL> (add-to-list 'insert-pair-alist '(?\( ?\( ?\)))

OK but now it looks like
perl -C -wple 's/\d+/chr $&/eg;'
((( ( ))
 (( ))
 ([ ])
 ({ })
 (< >)
 (" ")
 (' ')
 (` '))

So I bet just

   (add-to-list 'insert-pair-alist '(?\( ?\)))

is good enough. Anyways, I'm hoping the emacs authors will add this to
the defaults.

In fact they need to add wide versions of all those current narrow items there.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#35480; Package emacs. (Tue, 30 Apr 2019 20:24:01 GMT) Full text and rfc822 format available.

Message #14 received at 35480 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: 積丹尼 Dan Jacobson <jidanni <at> jidanni.org>
Cc: 35480 <at> debbugs.gnu.org
Subject: Re: bug#35480: insert-wide-parentheses
Date: Tue, 30 Apr 2019 23:15:27 +0300
>>> M-( is insert-parentheses, so
>>> M-( should be insert-wide-parentheses.
>
> JL> (define-key esc-map "(" 'insert-pair)
> JL> (add-to-list 'insert-pair-alist '(?\( ?\( ?\)))
>
> OK but now it looks like
> perl -C -wple 's/\d+/chr $&/eg;'
> ((( ( ))
>  (( ))
>  ([ ])
>  ({ })
>  (< >)
>  (" ")
>  (' ')
>  (` '))
>
> So I bet just
>
>    (add-to-list 'insert-pair-alist '(?\( ?\)))
>
> is good enough. Anyways, I'm hoping the emacs authors will add this to
> the defaults.
>
> In fact they need to add wide versions of all those current narrow items there.

OK, this adds all Unicode pairs to the default:

diff --git a/lisp/emacs-lisp/lisp.el b/lisp/emacs-lisp/lisp.el
index d10d5f0d10..f73dbb269d 100644
--- a/lisp/emacs-lisp/lisp.el
+++ b/lisp/emacs-lisp/lisp.el
@@ -646,7 +646,13 @@ narrow-to-defun
       (narrow-to-region beg end))))
 
 (defvar insert-pair-alist
-  '((?\( ?\)) (?\[ ?\]) (?\{ ?\}) (?\< ?\>) (?\" ?\") (?\' ?\') (?\` ?\'))
+  (append '((?\< ?\>) (?\" ?\") (?\' ?\') (?\` ?\'))
+          (let (alist)
+            (map-char-table
+             (lambda (open close)
+               (when (< open close) (push (list open close) alist)))
+             (unicode-property-table-internal 'paired-bracket))
+            (nreverse alist)))
   "Alist of paired characters inserted by `insert-pair'.
 Each element looks like (OPEN-CHAR CLOSE-CHAR) or (COMMAND-CHAR
 OPEN-CHAR CLOSE-CHAR).  The characters OPEN-CHAR and CLOSE-CHAR





Reply sent to Juri Linkov <juri <at> linkov.net>:
You have taken responsibility. (Sun, 05 May 2019 19:35:01 GMT) Full text and rfc822 format available.

Notification sent to 積丹尼 Dan Jacobson <jidanni <at> jidanni.org>:
bug acknowledged by developer. (Sun, 05 May 2019 19:35:02 GMT) Full text and rfc822 format available.

Message #19 received at 35480-done <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: 積丹尼 Dan Jacobson <jidanni <at> jidanni.org>
Cc: 35480-done <at> debbugs.gnu.org
Subject: Re: bug#35480: insert-wide-parentheses
Date: Sun, 05 May 2019 22:34:20 +0300
>>>> M-( is insert-parentheses, so
>>>> M-( should be insert-wide-parentheses.
>>
>> JL> (define-key esc-map "(" 'insert-pair)
>> JL> (add-to-list 'insert-pair-alist '(?\( ?\( ?\)))
>>
>> OK but now it looks like
>> perl -C -wple 's/\d+/chr $&/eg;'
>> ((( ( ))
>>  (( ))
>>  ([ ])
>>  ({ })
>>  (< >)
>>  (" ")
>>  (' ')
>>  (` '))
>>
>> So I bet just
>>
>>    (add-to-list 'insert-pair-alist '(?\( ?\)))
>>
>> is good enough. Anyways, I'm hoping the emacs authors will add this to
>> the defaults.
>>
>> In fact they need to add wide versions of all those current narrow items there.
>
> OK, this adds all Unicode pairs to the default:

Pushed to master and closed.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#35480; Package emacs. (Sun, 05 May 2019 22:28:01 GMT) Full text and rfc822 format available.

Message #22 received at 35480 <at> debbugs.gnu.org (full text, mbox):

From: Andreas Schwab <schwab <at> linux-m68k.org>
To: Juri Linkov <juri <at> linkov.net>
Cc: 35480 <at> debbugs.gnu.org,
 積丹尼 Dan Jacobson <jidanni <at> jidanni.org>
Subject: Re: bug#35480: insert-wide-parentheses
Date: Mon, 06 May 2019 00:27:20 +0200
On Apr 30 2019, Juri Linkov <juri <at> linkov.net> wrote:

> OK, this adds all Unicode pairs to the default:
>
> diff --git a/lisp/emacs-lisp/lisp.el b/lisp/emacs-lisp/lisp.el
> index d10d5f0d10..f73dbb269d 100644
> --- a/lisp/emacs-lisp/lisp.el
> +++ b/lisp/emacs-lisp/lisp.el
> @@ -646,7 +646,13 @@ narrow-to-defun
>        (narrow-to-region beg end))))
>  
>  (defvar insert-pair-alist
> -  '((?\( ?\)) (?\[ ?\]) (?\{ ?\}) (?\< ?\>) (?\" ?\") (?\' ?\') (?\` ?\'))
> +  (append '((?\< ?\>) (?\" ?\") (?\' ?\') (?\` ?\'))
> +          (let (alist)
> +            (map-char-table
> +             (lambda (open close)
> +               (when (< open close) (push (list open close) alist)))
> +             (unicode-property-table-internal 'paired-bracket))
> +            (nreverse alist)))

Loading /home/abuild/rpmbuild/BUILD/emacs-27.0.50/lisp/emacs-lisp/lisp.el (source)...
Wrong type argument: char-table-p, nil
make[2]: *** [Makefile:808: bootstrap-emacs.pdmp] Error 255

Andreas.

-- 
Andreas Schwab, schwab <at> linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#35480; Package emacs. (Mon, 06 May 2019 02:36:02 GMT) Full text and rfc822 format available.

Message #25 received at 35480 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Andreas Schwab <schwab <at> linux-m68k.org>
Cc: jidanni <at> jidanni.org, 35480 <at> debbugs.gnu.org, juri <at> linkov.net
Subject: Re: bug#35480: insert-wide-parentheses
Date: Mon, 06 May 2019 05:35:12 +0300
> From: Andreas Schwab <schwab <at> linux-m68k.org>
> Date: Mon, 06 May 2019 00:27:20 +0200
> Cc: 積丹尼 Dan Jacobson <jidanni <at> jidanni.org>,
> 	35480 <at> debbugs.gnu.org
> 
> > OK, this adds all Unicode pairs to the default:
> >
> > diff --git a/lisp/emacs-lisp/lisp.el b/lisp/emacs-lisp/lisp.el
> > index d10d5f0d10..f73dbb269d 100644
> > --- a/lisp/emacs-lisp/lisp.el
> > +++ b/lisp/emacs-lisp/lisp.el
> > @@ -646,7 +646,13 @@ narrow-to-defun
> >        (narrow-to-region beg end))))
> >  
> >  (defvar insert-pair-alist
> > -  '((?\( ?\)) (?\[ ?\]) (?\{ ?\}) (?\< ?\>) (?\" ?\") (?\' ?\') (?\` ?\'))
> > +  (append '((?\< ?\>) (?\" ?\") (?\' ?\') (?\` ?\'))
> > +          (let (alist)
> > +            (map-char-table
> > +             (lambda (open close)
> > +               (when (< open close) (push (list open close) alist)))
> > +             (unicode-property-table-internal 'paired-bracket))
> > +            (nreverse alist)))
> 
> Loading /home/abuild/rpmbuild/BUILD/emacs-27.0.50/lisp/emacs-lisp/lisp.el (source)...
> Wrong type argument: char-table-p, nil
> make[2]: *** [Makefile:808: bootstrap-emacs.pdmp] Error 255

This change has another, IMO more serious, problem: it uses the
bidi-bracket property of characters entirely out of its intended
domain.  The _only_ valid usage of that property is in the context of
the UBA, the Unicode Bidirectional Algorithm, used for reordering
bidirectional text for display.  Pairing syntactical units in program
text is something entirely different.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#35480; Package emacs. (Mon, 06 May 2019 19:34:02 GMT) Full text and rfc822 format available.

Message #28 received at 35480 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 35480 <at> debbugs.gnu.org, Andreas Schwab <schwab <at> linux-m68k.org>,
 jidanni <at> jidanni.org
Subject: Re: bug#35480: insert-wide-parentheses
Date: Mon, 06 May 2019 22:33:18 +0300
>> Loading /home/abuild/rpmbuild/BUILD/emacs-27.0.50/lisp/emacs-lisp/lisp.el (source)...
>> Wrong type argument: char-table-p, nil
>> make[2]: *** [Makefile:808: bootstrap-emacs.pdmp] Error 255

This is very strange.  I recompiled several times and had no such error.

> This change has another, IMO more serious, problem: it uses the
> bidi-bracket property of characters entirely out of its intended
> domain.  The _only_ valid usage of that property is in the context of
> the UBA, the Unicode Bidirectional Algorithm, used for reordering
> bidirectional text for display.  Pairing syntactical units in program
> text is something entirely different.

I reverted to the old default value, and changed defvar to defcustom.

Also tried to add a button that would pre-fill the default value
with Unicode bracket pairs, but I see no way to do this because
customize's :options is limited to ‘hook’, ‘plist’, ‘alist’ types
only, alas.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#35480; Package emacs. (Mon, 06 May 2019 22:49:02 GMT) Full text and rfc822 format available.

Message #31 received at 35480 <at> debbugs.gnu.org (full text, mbox):

From: Noam Postavsky <npostavs <at> gmail.com>
To: Juri Linkov <juri <at> linkov.net>
Cc: Eli Zaretskii <eliz <at> gnu.org>, jidanni <at> jidanni.org,
 Andreas Schwab <schwab <at> linux-m68k.org>, 35480 <at> debbugs.gnu.org
Subject: Re: bug#35480: insert-wide-parentheses
Date: Mon, 06 May 2019 18:47:59 -0400
Juri Linkov <juri <at> linkov.net> writes:

> Also tried to add a button that would pre-fill the default value
> with Unicode bracket pairs, but I see no way to do this because
> customize's :options is limited to ‘hook’, ‘plist’, ‘alist’ types
> only, alas.

Can't you use the alist type?  The options is called insert-pair-ALIST
after all.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#35480; Package emacs. (Tue, 07 May 2019 20:31:02 GMT) Full text and rfc822 format available.

Message #34 received at 35480 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Noam Postavsky <npostavs <at> gmail.com>
Cc: Eli Zaretskii <eliz <at> gnu.org>, jidanni <at> jidanni.org,
 Andreas Schwab <schwab <at> linux-m68k.org>, 35480 <at> debbugs.gnu.org
Subject: Re: bug#35480: insert-wide-parentheses
Date: Tue, 07 May 2019 23:21:57 +0300
>> Also tried to add a button that would pre-fill the default value
>> with Unicode bracket pairs, but I see no way to do this because
>> customize's :options is limited to ‘hook’, ‘plist’, ‘alist’ types
>> only, alas.
>
> Can't you use the alist type?  The options is called insert-pair-ALIST
> after all.

I tried the alist type:

(defcustom insert-pair-alist
  '((?\( ?\)) (?\[ ?\]) (?\{ ?\}) (?\< ?\>) (?\" ?\") (?\' ?\') (?\` ?\'))
  "Alist of paired characters inserted by `insert-pair'."
  :type '(alist :key-type (character :tag "Open/Command")
                :value-type (choice
                             (list :tag "Pair"
                                   (character :tag "Close"))
                             (list :tag "Triplet"
                                   (character :tag "Open")
                                   (character :tag "Close"))))
  :options '(?\()
  :group 'lisp
  :version "27.1")

but its :options allows specifying only keys, not alist values.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Wed, 05 Jun 2019 11:24:05 GMT) Full text and rfc822 format available.

This bug report was last modified 4 years and 320 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.