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.

Full log


View this message in rfc822 format

From: Juri Linkov <juri <at> linkov.net>
To: 積丹尼 Dan Jacobson <jidanni <at> jidanni.org>
Cc: 35480 <at> debbugs.gnu.org
Subject: 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





This bug report was last modified 6 years and 14 days ago.

Previous Next


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