unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#35480: insert-wide-parentheses
@ 2019-04-28 20:38 積丹尼 Dan Jacobson
  2019-04-29 20:00 ` Juri Linkov
  0 siblings, 1 reply; 10+ messages in thread
From: 積丹尼 Dan Jacobson @ 2019-04-28 20:38 UTC (permalink / raw)
  To: 35480

M-( is insert-parentheses, so
M-( should be insert-wide-parentheses.





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

* bug#35480: insert-wide-parentheses
  2019-04-28 20:38 bug#35480: insert-wide-parentheses 積丹尼 Dan Jacobson
@ 2019-04-29 20:00 ` Juri Linkov
  2019-04-30  1:59   ` 積丹尼 Dan Jacobson
  0 siblings, 1 reply; 10+ messages in thread
From: Juri Linkov @ 2019-04-29 20:00 UTC (permalink / raw)
  To: 積丹尼 Dan Jacobson; +Cc: 35480

> M-( is insert-parentheses, so
> M-( should be insert-wide-parentheses.

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





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

* bug#35480: insert-wide-parentheses
  2019-04-29 20:00 ` Juri Linkov
@ 2019-04-30  1:59   ` 積丹尼 Dan Jacobson
  2019-04-30 20:15     ` Juri Linkov
  0 siblings, 1 reply; 10+ messages in thread
From: 積丹尼 Dan Jacobson @ 2019-04-30  1:59 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 35480

>>>>> "JL" == Juri Linkov <juri@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.





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

* bug#35480: insert-wide-parentheses
  2019-04-30  1:59   ` 積丹尼 Dan Jacobson
@ 2019-04-30 20:15     ` Juri Linkov
  2019-05-05 19:34       ` Juri Linkov
  2019-05-05 22:27       ` Andreas Schwab
  0 siblings, 2 replies; 10+ messages in thread
From: Juri Linkov @ 2019-04-30 20:15 UTC (permalink / raw)
  To: 積丹尼 Dan Jacobson; +Cc: 35480

>>> 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






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

* bug#35480: insert-wide-parentheses
  2019-04-30 20:15     ` Juri Linkov
@ 2019-05-05 19:34       ` Juri Linkov
  2019-05-05 22:27       ` Andreas Schwab
  1 sibling, 0 replies; 10+ messages in thread
From: Juri Linkov @ 2019-05-05 19:34 UTC (permalink / raw)
  To: 積丹尼 Dan Jacobson; +Cc: 35480-done

>>>> 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.





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

* bug#35480: insert-wide-parentheses
  2019-04-30 20:15     ` Juri Linkov
  2019-05-05 19:34       ` Juri Linkov
@ 2019-05-05 22:27       ` Andreas Schwab
  2019-05-06  2:35         ` Eli Zaretskii
  1 sibling, 1 reply; 10+ messages in thread
From: Andreas Schwab @ 2019-05-05 22:27 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 積丹尼 Dan Jacobson, 35480

On Apr 30 2019, Juri Linkov <juri@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@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."





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

* bug#35480: insert-wide-parentheses
  2019-05-05 22:27       ` Andreas Schwab
@ 2019-05-06  2:35         ` Eli Zaretskii
  2019-05-06 19:33           ` Juri Linkov
  0 siblings, 1 reply; 10+ messages in thread
From: Eli Zaretskii @ 2019-05-06  2:35 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: juri, 35480, jidanni

> From: Andreas Schwab <schwab@linux-m68k.org>
> Date: Mon, 06 May 2019 00:27:20 +0200
> Cc: 積丹尼 Dan Jacobson <jidanni@jidanni.org>,
> 	35480@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.





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

* bug#35480: insert-wide-parentheses
  2019-05-06  2:35         ` Eli Zaretskii
@ 2019-05-06 19:33           ` Juri Linkov
  2019-05-06 22:47             ` Noam Postavsky
  0 siblings, 1 reply; 10+ messages in thread
From: Juri Linkov @ 2019-05-06 19:33 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: jidanni, Andreas Schwab, 35480

>> 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.





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

* bug#35480: insert-wide-parentheses
  2019-05-06 19:33           ` Juri Linkov
@ 2019-05-06 22:47             ` Noam Postavsky
  2019-05-07 20:21               ` Juri Linkov
  0 siblings, 1 reply; 10+ messages in thread
From: Noam Postavsky @ 2019-05-06 22:47 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 35480, Andreas Schwab, jidanni

Juri Linkov <juri@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.





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

* bug#35480: insert-wide-parentheses
  2019-05-06 22:47             ` Noam Postavsky
@ 2019-05-07 20:21               ` Juri Linkov
  0 siblings, 0 replies; 10+ messages in thread
From: Juri Linkov @ 2019-05-07 20:21 UTC (permalink / raw)
  To: Noam Postavsky; +Cc: 35480, Andreas Schwab, jidanni

>> 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.





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

end of thread, other threads:[~2019-05-07 20:21 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-04-28 20:38 bug#35480: insert-wide-parentheses 積丹尼 Dan Jacobson
2019-04-29 20:00 ` Juri Linkov
2019-04-30  1:59   ` 積丹尼 Dan Jacobson
2019-04-30 20:15     ` Juri Linkov
2019-05-05 19:34       ` Juri Linkov
2019-05-05 22:27       ` Andreas Schwab
2019-05-06  2:35         ` Eli Zaretskii
2019-05-06 19:33           ` Juri Linkov
2019-05-06 22:47             ` Noam Postavsky
2019-05-07 20:21               ` Juri Linkov

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).