Subject: bug#44245: 27.1; electric-pair-mode may interfere with delete-selection-mode

From: Dale Sedivec <[email-masked]>
Date: Mon, 26 Oct 2020 15:01:36 -0500

Steps to reproduce:

1. emacs -Q

2. Enter *scratch*

3. Enable `delete-selection-mode': M-x delete-selection-mode RET

4. Enable `electric-pair-local-mode': M-x electric-pair-local-mode RET

5. Disable `electric-pair-local-mode': M-x electric-pair-local-mode RET

Note that this has left `electric-pair-will-use-region' in
`self-insert-uses-region-functions'.

6. Make some text and select it: foo C-SPC C-a

7. Type (

Expected behavior: "foo" is replaced by "("

Observed behavior: "(" is inserted, "foo" remains, region is deactivated

My ideas for fixing this are to either (1) make
`electric-pair-will-use-region' check the value of `electric-pair-mode';
or (2) add `electric-pair-will-use-region' to
`self-insert-uses-region-functions' as a buffer-local value, and then
remove it when elec-pair is turned off in the buffer.

In GNU Emacs 27.1 (build 1, x86_64-apple-darwin19.6.0, NS appkit-1894.60 Version 10.15.6 (Build 19G2021))
of 2020-09-14 built on catalina.internal.macports.net
Windowing system distributor 'Apple', version 10.3.1894
System Description:  Mac OS X 10.15.7

Recent messages:
For information about GNU Emacs and the GNU system, type C-h C-a.
Mark set
Delete-Selection mode enabled
Mark set
Electric-Pair-Local mode enabled in current buffer
execute-extended-command: ‘’ is not a valid command name
Electric-Pair-Local mode disabled in current buffer
Mark set

Configured using:
'configure --prefix=/opt/local --without-dbus --without-gconf
--without-libotf --without-m17n-flt --with-gmp --with-gnutls
--with-json --with-xml2 --with-modules --infodir
/opt/local/share/info/emacs --with-ns --with-lcms2 --without-harfbuzz
--without-imagemagick --without-xaw3d --with-rsvg 'CFLAGS=-pipe -Os
-isysroot/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk -arch
x86_64' 'CPPFLAGS=-I/opt/local/include
-isysroot/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk'
'LDFLAGS=-L/opt/local/lib -Wl,-headerpad_max_install_names -Wl,-no_pie
-Wl,-syslibroot,/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk
-arch x86_64''

Configured features:
RSVG GLIB NOTIFY KQUEUE ACL GNUTLS LIBXML2 ZLIB TOOLKIT_SCROLL_BARS XIM
NS MODULES THREADS JSON PDUMPER LCMS2 GMP

Important settings:
  value of $LC_COLLATE: C
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8-unix

Major mode: Lisp Interaction

Minor modes in effect:
  delete-selection-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  eldoc-mode: t
  electric-indent-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

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug message rmc puny dired dired-loaddefs
format-spec rfc822 mml mml-sec epa derived epg epg-config gnus-util
rmail rmail-loaddefs text-property-search time-date mm-decode mm-bodies
mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail
rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils elec-pair
cus-start cus-load delsel finder-inf package easymenu browse-url
url-handlers url-parse auth-source cl-seq eieio eieio-core cl-macs
eieio-loaddefs password-cache json subr-x map url-vars seq byte-opt gv
bytecomp byte-compile cconv cl-loaddefs cl-lib tooltip eldoc electric
uniquify ediff-hook vc-hooks lisp-float-type mwheel term/ns-win ns-win
ucs-normalize mule-util term/common-win tool-bar dnd fontset image
regexp-opt fringe tabulated-list replace newcomment text-mode elisp-mode
lisp-mode prog-mode register page tab-bar menu-bar rfn-eshadow isearch
timer select scroll-bar mouse jit-lock font-lock syntax facemenu
font-core term/tty-colors frame minibuffer cl-generic cham georgian
utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean
japanese eucjp-ms cp51932 hebrew greek romanian slovak czech european
ethiopic indian cyrillic chinese composite charscript charprop
case-table epa-hook jka-cmpr-hook help simple abbrev obarray
cl-preloaded nadvice loaddefs button faces cus-face macroexp files
text-properties overlay sha1 md5 base64 format env code-pages mule
custom widget hashtable-print-readable backquote threads kqueue cocoa ns
lcms2 multi-tty make-network-process emacs)

Memory information:
((conses 16 200100 10989)
(symbols 48 13283 1)
(strings 32 66300 2365)
(string-bytes 1 1661608)
(vectors 16 18294)
(vector-slots 8 250505 8722)
(floats 8 22 25)
(intervals 56 241 0)
(buffers 1000 12))

-- 
Dale Sedivec
[email-masked]