Subject: bug#11530: 24.1.50; electric-pair does not insert closer for double opener

From: Simon Law <[email-masked]>
Date: Sun, 20 May 2012 23:59:13 -0400

Reproduction steps:

$ emacs -Q
M-x electric-pair-mode
Type "(("

Expected result, where | is the point:
((|))

Actual result:
((|)

Notes:

Users expect typing two-openers will result in two matching closers, due
to the description of electric-pair-mode.

It looks like the bug is caused in
electric-pair-post-self-insert-function on line 354. Here is a patch:

diff -c -L /usr/share/emacs/24.1.50/lisp/electric.el.gz -L \#\<buffer\ electric.el.gz\> /tmp/jka-com15573B0q /tmp/buffer-content-15573AIA
*** /usr/share/emacs/24.1.50/lisp/electric.el.gz
--- #<buffer electric.el.gz>
***************
*** 351,357 ****
                 ;; I find it more often preferable not to pair when the
                 ;; same char is next.
                 (eq last-command-event (char-after))
-                (eq last-command-event (char-before (1- (point))))
                 ;; I also find it often preferable not to pair next to a word.
                 (eq (char-syntax (following-char)) ?w)))
        (save-excursion (insert closer))))))
--- 351,356 ----

The comment above the deleted line is actually valid, but the deleted
line does not reflect that comment at all.

In GNU Emacs 24.1.50.1 (x86_64-pc-linux-gnu, GTK+ Version 3.2.0)
 of 2012-05-10 on charichuelo, modified by Debian
 (emacs-snapshot package, version 2:20120510-1~ppa1~oneiric1)
Windowing system distributor `The X.Org Foundation', version 11.0.11004000
Configured using:
 `configure '--build' 'x86_64-linux-gnu' '--host' 'x86_64-linux-gnu'
 '--prefix=/usr' '--sharedstatedir=/var/lib' '--libexecdir=/usr/lib'
 '--localstatedir=/var' '--infodir=/usr/share/info'
 '--mandir=/usr/share/man' '--with-pop=yes'
 '--enable-locallisppath=/etc/emacs-snapshot:/etc/emacs:/usr/local/share/emacs/24.1.50/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/24.1.50/site-lisp:/usr/share/emacs/site-lisp'
 '--without-compress-info' '--with-crt-dir=/usr/lib/x86_64-linux-gnu/'
 '--with-x=yes' '--with-x-toolkit=gtk3' '--with-imagemagick=yes'
 'build_alias=x86_64-linux-gnu' 'host_alias=x86_64-linux-gnu'
 'CFLAGS=-DDEBIAN -DSITELOAD_PURESIZE_EXTRA=5000 -g -O2' 'LDFLAGS=-g
 -Wl,--as-needed -znocombreloc' 'CPPFLAGS=''

Important settings:
  value of $LC_ALL: nil
  value of $LC_COLLATE: en_CA.UTF-8
  value of $LC_CTYPE: en_CA.UTF-8
  value of $LC_MESSAGES: en_CA.UTF-8
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: nil
  value of $LANG: en_CA.UTF-8
  value of $XMODIFIERS: nil
  locale-coding-system: utf-8-unix
  default enable-multibyte-characters: t

Major mode: Lisp Interaction

Minor modes in effect:
  electric-pair-mode: t
  tooltip-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t

Recent input:
M-x e l e c t r i c - p a i <tab> <return> ( ( C-a 
C-SPC C-n M-w C-x b C-g C-x 4 m C-x k <return> C-x 
o <return> ( ( M-x r e p o r t - b <backspace> e <backspace> 
b u g - e m <tab> <M-backspace> <M-backspace> e m <tab> 
<return>

Recent messages:
For information about GNU Emacs and the GNU system, type C-h C-a.
Electric-Pair mode enabled
Mark set
byte-code: End of buffer
Quit

Load-path shadows:
/usr/share/emacs/24.1.50/site-lisp/debian-startup hides /usr/share/emacs/site-lisp/debian-startup

Features:
(shadow sort mail-extr emacsbug sendmail gnus-util message format-spec
rfc822 mml easymenu mml-sec mm-decode mm-bodies mm-encode mail-parse
rfc2231 rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mailabbrev
mail-utils gmm-utils mailheader cus-start cus-load electric time-date
tooltip ediff-hook vc-hooks lisp-float-type mwheel x-win x-dnd tool-bar
dnd fontset image regexp-opt fringe tabulated-list newcomment lisp-mode
register page menu-bar rfn-eshadow timer select scroll-bar mouse
jit-lock font-lock syntax facemenu font-core frame cham georgian
utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean
japanese hebrew greek romanian slovak czech european ethiopic indian
cyrillic chinese case-table epa-hook jka-cmpr-hook help simple abbrev
minibuffer loaddefs button faces cus-face files text-properties overlay
sha1 md5 base64 format env code-pages mule custom widget
hashtable-print-readable backquote make-network-process dbusbind
dynamic-setting system-font-setting font-render-setting move-toolbar gtk
x-toolkit x multi-tty emacs)