[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#35480: insert-wide-parentheses
From: |
Juri Linkov |
Subject: |
bug#35480: insert-wide-parentheses |
Date: |
Tue, 30 Apr 2019 23:15:27 +0300 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (x86_64-pc-linux-gnu) |
>>> 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