* bug#21275: 24.5; Selection deleted with electric pair mode in cc mode
@ 2015-08-16 13:31 N. Jackson
[not found] ` <mailman.8417.1439731993.904.bug-gnu-emacs@gnu.org>
0 siblings, 1 reply; 10+ messages in thread
From: N. Jackson @ 2015-08-16 13:31 UTC (permalink / raw)
To: 21275
In cc mode, with delete selection mode and electric pair mode both on,
entering a "(" when there is an active selection erroneously deletes the
selection (and inserts "()" in the buffer) rather than inserting a "("
before the selection and a ")" after it. This is inconsistent with the
seemingly correct [1] and useful behaviour in (for example) text mode,
fundamental mode, and lisp mode.
The bug affects both code and in comments.
STEPS TO REPRODUCE:
$ cat > test.c
/* This is a short comment. */
int test(void){
return 0;
}
^D
$ emacs -Q
M-x delete-selection-mode
M-x electric-pair-mode
C-x f test.c RET
;; Select the word "short" in the first line.
(
;; Now select the "0" in the return statement.
(
EXPECTED RESULT:
/* This is a (short) comment. */
int test(void){
return (0);
}
OBSERVED RESULT:
/* This is a () comment. */
int test(void){
return ();
}
[1] http://debbugs.gnu.org/cgi/bugreport.cgi?bug=11520
In GNU Emacs 24.5.1 (x86_64-unknown-linux-gnu, GTK+ Version 3.14.14)
of 2015-07-25 on moondust
Windowing system distributor `Fedora Project', version 11.0.11603000
System Description: Fedora release 21 (Twenty One)
Configured using:
`configure --prefix=/home/nlj/local/ --enable-checking=yes,glyphs
'CFLAGS=-O0 -g3 -ggdb''
Important settings:
value of $LC_MONETARY: en_DK.utf8
value of $LC_NUMERIC: en_DK.utf8
value of $LC_TIME: en_DK.utf8
value of $LANG: en_CA.utf8
value of $XMODIFIERS: @im=ibus
locale-coding-system: utf-8-unix
Major mode: C/l
Minor modes in effect:
flyspell-mode: t
recentf-mode: t
delete-selection-mode: t
show-paren-mode: t
savehist-mode: t
electric-pair-mode: t
display-time-mode: t
display-battery-mode: t
desktop-save-mode: t
cua-mode: t
tooltip-mode: t
electric-indent-mode: t
mouse-wheel-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
size-indication-mode: t
column-number-mode: t
line-number-mode: t
global-visual-line-mode: t
visual-line-mode: t
transient-mark-mode: t
abbrev-mode: t
Recent messages:
Auto-saving...done
Making completion list...
Type C-x 1 to delete the help window.
Undo! [2 times]
Auto-saving...
Updating buffer list...done
Commands: m, u, t, RET, g, k, S, D, Q; q to quit; h for help
Mark set
Mark saved where search started
Mark set
call-interactively: End of buffer
Load-path shadows:
/home/nlj/.emacs.d/elpa/org-20150810/ob-gnuplot hides /data/projects/vc/emacs/emacs-24.5/lisp/org/ob-gnuplot
/home/nlj/.emacs.d/elpa/org-20150810/org-eshell hides /data/projects/vc/emacs/emacs-24.5/lisp/org/org-eshell
/home/nlj/.emacs.d/elpa/org-20150810/ox-md hides /data/projects/vc/emacs/emacs-24.5/lisp/org/ox-md
/home/nlj/.emacs.d/elpa/org-20150810/ob-shen hides /data/projects/vc/emacs/emacs-24.5/lisp/org/ob-shen
/home/nlj/.emacs.d/elpa/org-20150810/org-timer hides /data/projects/vc/emacs/emacs-24.5/lisp/org/org-timer
/home/nlj/.emacs.d/elpa/org-20150810/ob-ruby hides /data/projects/vc/emacs/emacs-24.5/lisp/org/ob-ruby
/home/nlj/.emacs.d/elpa/org-20150810/ox hides /data/projects/vc/emacs/emacs-24.5/lisp/org/ox
/home/nlj/.emacs.d/elpa/org-20150810/ox-html hides /data/projects/vc/emacs/emacs-24.5/lisp/org/ox-html
/home/nlj/.emacs.d/elpa/org-20150810/ob-latex hides /data/projects/vc/emacs/emacs-24.5/lisp/org/ob-latex
/home/nlj/.emacs.d/elpa/org-20150810/org-archive hides /data/projects/vc/emacs/emacs-24.5/lisp/org/org-archive
/home/nlj/.emacs.d/elpa/org-20150810/ob-org hides /data/projects/vc/emacs/emacs-24.5/lisp/org/ob-org
/home/nlj/.emacs.d/elpa/org-20150810/org-install hides /data/projects/vc/emacs/emacs-24.5/lisp/org/org-install
/home/nlj/.emacs.d/elpa/org-20150810/ox-latex hides /data/projects/vc/emacs/emacs-24.5/lisp/org/ox-latex
/home/nlj/.emacs.d/elpa/org-20150810/ob-sass hides /data/projects/vc/emacs/emacs-24.5/lisp/org/ob-sass
/home/nlj/.emacs.d/elpa/org-20150810/ox-icalendar hides /data/projects/vc/emacs/emacs-24.5/lisp/org/ox-icalendar
/home/nlj/.emacs.d/elpa/org-20150810/ob-screen hides /data/projects/vc/emacs/emacs-24.5/lisp/org/ob-screen
/home/nlj/.emacs.d/elpa/org-20150810/org-bibtex hides /data/projects/vc/emacs/emacs-24.5/lisp/org/org-bibtex
/home/nlj/.emacs.d/elpa/org-20150810/org-footnote hides /data/projects/vc/emacs/emacs-24.5/lisp/org/org-footnote
/home/nlj/.emacs.d/elpa/org-20150810/org-datetree hides /data/projects/vc/emacs/emacs-24.5/lisp/org/org-datetree
/home/nlj/.emacs.d/elpa/org-20150810/org-colview hides /data/projects/vc/emacs/emacs-24.5/lisp/org/org-colview
/home/nlj/.emacs.d/elpa/org-20150810/org-attach hides /data/projects/vc/emacs/emacs-24.5/lisp/org/org-attach
/home/nlj/.emacs.d/elpa/org-20150810/org-mouse hides /data/projects/vc/emacs/emacs-24.5/lisp/org/org-mouse
/home/nlj/.emacs.d/elpa/org-20150810/ob-dot hides /data/projects/vc/emacs/emacs-24.5/lisp/org/ob-dot
/home/nlj/.emacs.d/elpa/org-20150810/ob-scala hides /data/projects/vc/emacs/emacs-24.5/lisp/org/ob-scala
/home/nlj/.emacs.d/elpa/org-20150810/org-compat hides /data/projects/vc/emacs/emacs-24.5/lisp/org/org-compat
/home/nlj/.emacs.d/elpa/org-20150810/ob-core hides /data/projects/vc/emacs/emacs-24.5/lisp/org/ob-core
/home/nlj/.emacs.d/elpa/org-20150810/ob-awk hides /data/projects/vc/emacs/emacs-24.5/lisp/org/ob-awk
/home/nlj/.emacs.d/elpa/org-20150810/ob-makefile hides /data/projects/vc/emacs/emacs-24.5/lisp/org/ob-makefile
/home/nlj/.emacs.d/elpa/org-20150810/org-macro hides /data/projects/vc/emacs/emacs-24.5/lisp/org/org-macro
/home/nlj/.emacs.d/elpa/org-20150810/org-ctags hides /data/projects/vc/emacs/emacs-24.5/lisp/org/org-ctags
/home/nlj/.emacs.d/elpa/org-20150810/org-capture hides /data/projects/vc/emacs/emacs-24.5/lisp/org/org-capture
/home/nlj/.emacs.d/elpa/org-20150810/ox-beamer hides /data/projects/vc/emacs/emacs-24.5/lisp/org/ox-beamer
/home/nlj/.emacs.d/elpa/org-20150810/org-mobile hides /data/projects/vc/emacs/emacs-24.5/lisp/org/org-mobile
/home/nlj/.emacs.d/elpa/org-20150810/org-indent hides /data/projects/vc/emacs/emacs-24.5/lisp/org/org-indent
/home/nlj/.emacs.d/elpa/org-20150810/ob-lilypond hides /data/projects/vc/emacs/emacs-24.5/lisp/org/ob-lilypond
/home/nlj/.emacs.d/elpa/org-20150810/ob-asymptote hides /data/projects/vc/emacs/emacs-24.5/lisp/org/ob-asymptote
/home/nlj/.emacs.d/elpa/org-20150810/ox-odt hides /data/projects/vc/emacs/emacs-24.5/lisp/org/ox-odt
/home/nlj/.emacs.d/elpa/org-20150810/org-w3m hides /data/projects/vc/emacs/emacs-24.5/lisp/org/org-w3m
/home/nlj/.emacs.d/elpa/org-20150810/ob-plantuml hides /data/projects/vc/emacs/emacs-24.5/lisp/org/ob-plantuml
/home/nlj/.emacs.d/elpa/org-20150810/ob-table hides /data/projects/vc/emacs/emacs-24.5/lisp/org/ob-table
/home/nlj/.emacs.d/elpa/org-20150810/ob-ocaml hides /data/projects/vc/emacs/emacs-24.5/lisp/org/ob-ocaml
/home/nlj/.emacs.d/elpa/org-20150810/org-crypt hides /data/projects/vc/emacs/emacs-24.5/lisp/org/org-crypt
/home/nlj/.emacs.d/elpa/org-20150810/ob-js hides /data/projects/vc/emacs/emacs-24.5/lisp/org/ob-js
/home/nlj/.emacs.d/elpa/org-20150810/ob-clojure hides /data/projects/vc/emacs/emacs-24.5/lisp/org/ob-clojure
/home/nlj/.emacs.d/elpa/org-20150810/ob-haskell hides /data/projects/vc/emacs/emacs-24.5/lisp/org/ob-haskell
/home/nlj/.emacs.d/elpa/org-20150810/org-version hides /data/projects/vc/emacs/emacs-24.5/lisp/org/org-version
/home/nlj/.emacs.d/elpa/org-20150810/ob-scheme hides /data/projects/vc/emacs/emacs-24.5/lisp/org/ob-scheme
/home/nlj/.emacs.d/elpa/org-20150810/org-table hides /data/projects/vc/emacs/emacs-24.5/lisp/org/org-table
/home/nlj/.emacs.d/elpa/org-20150810/ob-C hides /data/projects/vc/emacs/emacs-24.5/lisp/org/ob-C
/home/nlj/.emacs.d/elpa/org-20150810/ob-ledger hides /data/projects/vc/emacs/emacs-24.5/lisp/org/ob-ledger
/home/nlj/.emacs.d/elpa/org-20150810/ob-fortran hides /data/projects/vc/emacs/emacs-24.5/lisp/org/ob-fortran
/home/nlj/.emacs.d/elpa/org-20150810/ob-sql hides /data/projects/vc/emacs/emacs-24.5/lisp/org/ob-sql
/home/nlj/.emacs.d/elpa/org-20150810/org hides /data/projects/vc/emacs/emacs-24.5/lisp/org/org
/home/nlj/.emacs.d/elpa/org-20150810/org-loaddefs hides /data/projects/vc/emacs/emacs-24.5/lisp/org/org-loaddefs
/home/nlj/.emacs.d/elpa/org-20150810/org-list hides /data/projects/vc/emacs/emacs-24.5/lisp/org/org-list
/home/nlj/.emacs.d/elpa/org-20150810/ob-lisp hides /data/projects/vc/emacs/emacs-24.5/lisp/org/ob-lisp
/home/nlj/.emacs.d/elpa/org-20150810/org-docview hides /data/projects/vc/emacs/emacs-24.5/lisp/org/org-docview
/home/nlj/.emacs.d/elpa/org-20150810/ob-eval hides /data/projects/vc/emacs/emacs-24.5/lisp/org/ob-eval
/home/nlj/.emacs.d/elpa/org-20150810/org-element hides /data/projects/vc/emacs/emacs-24.5/lisp/org/org-element
/home/nlj/.emacs.d/elpa/org-20150810/ob hides /data/projects/vc/emacs/emacs-24.5/lisp/org/ob
/home/nlj/.emacs.d/elpa/org-20150810/ox-ascii hides /data/projects/vc/emacs/emacs-24.5/lisp/org/ox-ascii
/home/nlj/.emacs.d/elpa/org-20150810/org-info hides /data/projects/vc/emacs/emacs-24.5/lisp/org/org-info
/home/nlj/.emacs.d/elpa/org-20150810/ob-css hides /data/projects/vc/emacs/emacs-24.5/lisp/org/ob-css
/home/nlj/.emacs.d/elpa/org-20150810/org-rmail hides /data/projects/vc/emacs/emacs-24.5/lisp/org/org-rmail
/home/nlj/.emacs.d/elpa/org-20150810/org-irc hides /data/projects/vc/emacs/emacs-24.5/lisp/org/org-irc
/home/nlj/.emacs.d/elpa/org-20150810/ob-tangle hides /data/projects/vc/emacs/emacs-24.5/lisp/org/ob-tangle
/home/nlj/.emacs.d/elpa/org-20150810/ob-ditaa hides /data/projects/vc/emacs/emacs-24.5/lisp/org/ob-ditaa
/home/nlj/.emacs.d/elpa/org-20150810/org-feed hides /data/projects/vc/emacs/emacs-24.5/lisp/org/org-feed
/home/nlj/.emacs.d/elpa/org-20150810/org-clock hides /data/projects/vc/emacs/emacs-24.5/lisp/org/org-clock
/home/nlj/.emacs.d/elpa/org-20150810/org-habit hides /data/projects/vc/emacs/emacs-24.5/lisp/org/org-habit
/home/nlj/.emacs.d/elpa/org-20150810/org-pcomplete hides /data/projects/vc/emacs/emacs-24.5/lisp/org/org-pcomplete
/home/nlj/.emacs.d/elpa/org-20150810/org-entities hides /data/projects/vc/emacs/emacs-24.5/lisp/org/org-entities
/home/nlj/.emacs.d/elpa/org-20150810/ob-io hides /data/projects/vc/emacs/emacs-24.5/lisp/org/ob-io
/home/nlj/.emacs.d/elpa/org-20150810/ob-octave hides /data/projects/vc/emacs/emacs-24.5/lisp/org/ob-octave
/home/nlj/.emacs.d/elpa/org-20150810/org-faces hides /data/projects/vc/emacs/emacs-24.5/lisp/org/org-faces
/home/nlj/.emacs.d/elpa/org-20150810/ob-perl hides /data/projects/vc/emacs/emacs-24.5/lisp/org/ob-perl
/home/nlj/.emacs.d/elpa/org-20150810/org-src hides /data/projects/vc/emacs/emacs-24.5/lisp/org/org-src
/home/nlj/.emacs.d/elpa/org-20150810/org-protocol hides /data/projects/vc/emacs/emacs-24.5/lisp/org/org-protocol
/home/nlj/.emacs.d/elpa/org-20150810/ox-man hides /data/projects/vc/emacs/emacs-24.5/lisp/org/ox-man
/home/nlj/.emacs.d/elpa/org-20150810/ob-python hides /data/projects/vc/emacs/emacs-24.5/lisp/org/ob-python
/home/nlj/.emacs.d/elpa/org-20150810/ob-mscgen hides /data/projects/vc/emacs/emacs-24.5/lisp/org/ob-mscgen
/home/nlj/.emacs.d/elpa/org-20150810/ox-texinfo hides /data/projects/vc/emacs/emacs-24.5/lisp/org/ox-texinfo
/home/nlj/.emacs.d/elpa/org-20150810/ob-exp hides /data/projects/vc/emacs/emacs-24.5/lisp/org/ob-exp
/home/nlj/.emacs.d/elpa/org-20150810/org-inlinetask hides /data/projects/vc/emacs/emacs-24.5/lisp/org/org-inlinetask
/home/nlj/.emacs.d/elpa/org-20150810/ox-publish hides /data/projects/vc/emacs/emacs-24.5/lisp/org/ox-publish
/home/nlj/.emacs.d/elpa/org-20150810/ob-java hides /data/projects/vc/emacs/emacs-24.5/lisp/org/ob-java
/home/nlj/.emacs.d/elpa/org-20150810/ob-sqlite hides /data/projects/vc/emacs/emacs-24.5/lisp/org/ob-sqlite
/home/nlj/.emacs.d/elpa/org-20150810/org-mhe hides /data/projects/vc/emacs/emacs-24.5/lisp/org/org-mhe
/home/nlj/.emacs.d/elpa/org-20150810/ox-org hides /data/projects/vc/emacs/emacs-24.5/lisp/org/ox-org
/home/nlj/.emacs.d/elpa/org-20150810/ob-R hides /data/projects/vc/emacs/emacs-24.5/lisp/org/ob-R
/home/nlj/.emacs.d/elpa/org-20150810/ob-lob hides /data/projects/vc/emacs/emacs-24.5/lisp/org/ob-lob
/home/nlj/.emacs.d/elpa/org-20150810/ob-picolisp hides /data/projects/vc/emacs/emacs-24.5/lisp/org/ob-picolisp
/home/nlj/.emacs.d/elpa/org-20150810/org-agenda hides /data/projects/vc/emacs/emacs-24.5/lisp/org/org-agenda
/home/nlj/.emacs.d/elpa/org-20150810/ob-matlab hides /data/projects/vc/emacs/emacs-24.5/lisp/org/ob-matlab
/home/nlj/.emacs.d/elpa/org-20150810/org-gnus hides /data/projects/vc/emacs/emacs-24.5/lisp/org/org-gnus
/home/nlj/.emacs.d/elpa/org-20150810/org-macs hides /data/projects/vc/emacs/emacs-24.5/lisp/org/org-macs
/home/nlj/.emacs.d/elpa/org-20150810/org-id hides /data/projects/vc/emacs/emacs-24.5/lisp/org/org-id
/home/nlj/.emacs.d/elpa/org-20150810/ob-keys hides /data/projects/vc/emacs/emacs-24.5/lisp/org/ob-keys
/home/nlj/.emacs.d/elpa/org-20150810/ob-comint hides /data/projects/vc/emacs/emacs-24.5/lisp/org/ob-comint
/home/nlj/.emacs.d/elpa/org-20150810/ob-ref hides /data/projects/vc/emacs/emacs-24.5/lisp/org/ob-ref
/home/nlj/.emacs.d/elpa/org-20150810/org-bbdb hides /data/projects/vc/emacs/emacs-24.5/lisp/org/org-bbdb
/home/nlj/.emacs.d/elpa/org-20150810/ob-calc hides /data/projects/vc/emacs/emacs-24.5/lisp/org/ob-calc
/home/nlj/.emacs.d/elpa/org-20150810/ob-emacs-lisp hides /data/projects/vc/emacs/emacs-24.5/lisp/org/ob-emacs-lisp
/home/nlj/.emacs.d/elpa/org-20150810/ob-maxima hides /data/projects/vc/emacs/emacs-24.5/lisp/org/ob-maxima
/home/nlj/.emacs.d/elpa/org-20150810/org-plot hides /data/projects/vc/emacs/emacs-24.5/lisp/org/org-plot
~/.emacs.d/modules/emms/lisp/tq hides /data/projects/vc/emacs/emacs-24.5/lisp/emacs-lisp/tq
Features:
(shadow emacsbug help-mode url-queue eww gnus-fun flow-fill shr-color
color mailalias smtpmail bbdb-message sendmail nnir gnus-dup solar
cal-dst holidays hol-loaddefs mule-util cal-move bookmark org-clock
tabify org-capture ibuf-ext ibuffer shr gnus-html browse-url smiley
gnus-cite gnus-bcklg pp gnus-async qp mail-extr gnus-ml disp-table
misearch multi-isearch nndraft nnmh mm-archive url-http url-gw url-cache
url-auth url-handlers nnrss xml mm-url utf-7 nnimap utf7 gnutls nnfolder
parse-time bbdb-gnus bbdb-mua epa-file epa derived epg netrc
network-stream starttls tls gnus-agent gnus-srvr gnus-score score-mode
nnvirtual gnus-msg gnus-art mm-uu mml2015 epg-config mm-view mml-smime
smime dig nntp gnus-cache gnus-sum nnoo gnus-group gnus-undo nnmail
mail-source gnus-start gnus-spec gnus-int gnus-range message rfc822 mml
mml-sec mm-decode mm-bodies mm-encode mail-parse rfc2231 rfc2047 rfc2045
ietf-drums gmm-utils mailheader gnus-win gnus gnus-ems nnheader
mail-utils flyspell ispell cc-langs cc-mode cc-fonts cc-guess cc-menus
cc-cmds cc-styles cc-align cc-engine cc-vars cc-defs sage sage-load cl
rx emms-bookmarks emms-cue emms-mode-line-icon emms-browser sort
emms-playlist-sort emms-last-played emms-player-xine emms-player-mpd tq
emms-playing-time emms-lyrics emms-url url url-proxy url-privacy
url-expand url-methods url-history url-cookie url-domsuf url-util
url-parse auth-source eieio byte-opt bytecomp byte-compile cl-extra
cconv eieio-core mm-util mail-prsvr password-cache url-vars mailcap
emms-streams emms-tag-editor emms-mark emms-mode-line emms-cache
emms-info-ogginfo emms-info-mp3info emms-info later-do
emms-playlist-mode emms-player-vlc emms-player-mplayer
emms-player-simple emms-source-playlist emms-source-file locate
emms-setup emms emms-compat compile cl-macs gv org-rmail org-mhe org-irc
org-info org-gnus gnus-util org-docview doc-view jka-compr image-mode
dired org-bibtex bibtex org-bbdb org-element avl-tree org-w3m org-agenda
org advice help-fns org-macro org-footnote org-pcomplete pcomplete
org-list org-faces org-entities noutline outline easy-mmode org-version
ob-emacs-lisp ob ob-tangle ob-ref ob-lob ob-table ob-exp org-src ob-keys
ob-comint comint ansi-color ring ob-core ob-eval org-compat org-macs
org-loaddefs format-spec find-func bbdb-anniv diary-lib diary-loaddefs
cal-menu calendar cal-loaddefs bbdb-com crm mailabbrev bbdb bbdb-site
timezone bbdb-loaddefs tex-site info package edmacro kmacro recentf
tree-widget wid-edit easymenu saveplace wheatgrass-theme delsel paren
savehist elec-pair time battery desktop frameset cl-loaddefs cl-lib
cua-base cus-start cus-load time-date tooltip electric uniquify
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
prog-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 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 make-network-process
dbusbind gfilenotify dynamic-setting system-font-setting
font-render-setting move-toolbar gtk x-toolkit x multi-tty emacs)
Memory information:
((conses 16 555789 98749)
(symbols 48 60041 0)
(miscs 40 6345 6191)
(strings 32 143249 27034)
(string-bytes 1 5112701)
(vectors 16 49403)
(vector-slots 8 1734765 261112)
(floats 8 922 1502)
(intervals 56 9732 685)
(buffers 960 103)
(heap 1024 112144 35561))
^ permalink raw reply [flat|nested] 10+ messages in thread
* bug#21275: 24.5; Selection deleted with electric pair mode in cc mode
[not found] ` <mailman.8417.1439731993.904.bug-gnu-emacs@gnu.org>
@ 2015-08-18 15:04 ` Alan Mackenzie
2015-08-18 16:43 ` N. Jackson
` (2 more replies)
2015-08-19 17:22 ` Alan Mackenzie
1 sibling, 3 replies; 10+ messages in thread
From: Alan Mackenzie @ 2015-08-18 15:04 UTC (permalink / raw)
To: N. Jackson; +Cc: 21275
Hello, N.
In article <mailman.8417.1439731993.904.bug-gnu-emacs@gnu.org> you wrote:
> In cc mode, with delete selection mode and electric pair mode both on,
> entering a "(" when there is an active selection erroneously deletes the
> selection (and inserts "()" in the buffer) rather than inserting a "("
> before the selection and a ")" after it. This is inconsistent with the
> seemingly correct [1] and useful behaviour in (for example) text mode,
> fundamental mode, and lisp mode.
> The bug affects both code and in comments.
And it also affects braces as well as parens.
Thanks for taking the trouble to report this bug, and thanks even more
for making your report so clear and well structured.
> STEPS TO REPRODUCE:
> $ cat > test.c
> /* This is a short comment. */
> int test(void){
> return 0;
> }
> ^D
> $ emacs -Q
> M-x delete-selection-mode
> M-x electric-pair-mode
> C-x f test.c RET
> ;; Select the word "short" in the first line.
> (
> ;; Now select the "0" in the return statement.
> (
> EXPECTED RESULT:
> /* This is a (short) comment. */
> int test(void){
> return (0);
> }
> OBSERVED RESULT:
> /* This is a () comment. */
> int test(void){
> return ();
> }
> [1] http://debbugs.gnu.org/cgi/bugreport.cgi?bug=11520
> In GNU Emacs 24.5.1 (x86_64-unknown-linux-gnu, GTK+ Version 3.14.14)
> of 2015-07-25 on moondust
> Windowing system distributor `Fedora Project', version 11.0.11603000
> System Description: Fedora release 21 (Twenty One)
I think the following patch should fix it. To apply it, go to the
directory ..../emacs-24.5/lisp and apply the patch from there. If `patch'
complains at not finding the second file, and prompts you for it, this
will be .../emacs-24.5/lisp/progmodes/cc-cmds.el. After byte-compiling
both files (either with M-x byte-compile-file from inside emacs, or with
$ emacs -Q -batch -f batch-byte-compile delsel.el progmodes/cc-cmds.el
from a command line), just load the two files.elc into Emacs with
M-x load-file (or restart Emacs).
Would you please confirm that the problem has been fixed, or tell us what
is still not working. Thanks in advance!
Here's the patch:
diff --git a/lisp/delsel.el b/lisp/delsel.el
index 740b603..6a77d75 100644
--- a/lisp/delsel.el
+++ b/lisp/delsel.el
@@ -231,10 +231,15 @@ See `delete-selection-helper'."
(delete-selection-helper (and (symbolp this-command)
(get this-command 'delete-selection)))))
-(put 'self-insert-command 'delete-selection
- (lambda ()
- (not (run-hook-with-args-until-success
- 'self-insert-uses-region-functions))))
+(defun delete-selection-uses-region-p ()
+ "Return non-nil when the current command uses the region.
+This function is intended for use as the value of the
+ `delete-selection' property of a command, and shouldn't be used for
+ anything else."
+ (not (run-hook-with-args-until-success
+ 'self-insert-uses-region-functions)))
+
+(put 'self-insert-command 'delete-selection 'delete-selection-uses-region-p)
(put 'insert-char 'delete-selection t)
(put 'quoted-insert 'delete-selection t)
diff --git a/lisp/progmodes/cc-cmds.el b/lisp/progmodes/cc-cmds.el
index c9f5945..40ec4bd 100644
--- a/lisp/progmodes/cc-cmds.el
+++ b/lisp/progmodes/cc-cmds.el
@@ -2860,13 +2860,18 @@ sentence motion in or near comments and multiline strings."
(put sym 'delete-selection t) ; for delsel (Emacs)
(put sym 'pending-delete t))) ; for pending-del (XEmacs)
'(c-electric-pound
- c-electric-brace
+; c-electric-brace
c-electric-slash
c-electric-star
c-electric-semi&comma
c-electric-lt-gt
c-electric-colon
- c-electric-paren))
+; c-electric-paren
+ ))
+(put 'c-electric-brace 'delete-selection 'delete-selection-uses-region-p)
+(put 'c-electric-brace 'pending-delete 't)
+(put 'c-electric-paren 'delete-selection 'delete-selection-uses-region-p)
+(put 'c-electric-paren 'pending-delete 't)
(put 'c-electric-delete 'delete-selection 'supersede) ; delsel
(put 'c-electric-delete 'pending-delete 'supersede) ; pending-del
(put 'c-electric-backspace 'delete-selection 'supersede) ; delsel
--
Alan Mackenzie (Nuremberg, Germany).
^ permalink raw reply related [flat|nested] 10+ messages in thread
* bug#21275: 24.5; Selection deleted with electric pair mode in cc mode
2015-08-18 15:04 ` Alan Mackenzie
@ 2015-08-18 16:43 ` N. Jackson
2015-08-19 21:52 ` Stefan Monnier
[not found] ` <jwv37zfosr4.fsf-monnier+emacsbugs@gnu.org>
2 siblings, 0 replies; 10+ messages in thread
From: N. Jackson @ 2015-08-18 16:43 UTC (permalink / raw)
To: Alan Mackenzie; +Cc: 21275
At 12:04 -0300 on Tuesday 2015-08-18, Alan Mackenzie wrote:
> I think the following patch should fix it.
> Would you please confirm that the problem has been fixed, or tell us
> what is still not working. Thanks in advance!
Thanks Alan. Yes, the patch does indeed fix the problem in my Emacs.
^ permalink raw reply [flat|nested] 10+ messages in thread
* bug#21275: 24.5; Selection deleted with electric pair mode in cc mode
[not found] ` <mailman.8417.1439731993.904.bug-gnu-emacs@gnu.org>
2015-08-18 15:04 ` Alan Mackenzie
@ 2015-08-19 17:22 ` Alan Mackenzie
1 sibling, 0 replies; 10+ messages in thread
From: Alan Mackenzie @ 2015-08-19 17:22 UTC (permalink / raw)
To: 21275-done; +Cc: N. Jackson
Bug fixed in savannah master branch.
--
Alan Mackenzie (Nuremberg, Germany).
^ permalink raw reply [flat|nested] 10+ messages in thread
* bug#21275: 24.5; Selection deleted with electric pair mode in cc mode
2015-08-18 15:04 ` Alan Mackenzie
2015-08-18 16:43 ` N. Jackson
@ 2015-08-19 21:52 ` Stefan Monnier
[not found] ` <jwv37zfosr4.fsf-monnier+emacsbugs@gnu.org>
2 siblings, 0 replies; 10+ messages in thread
From: Stefan Monnier @ 2015-08-19 21:52 UTC (permalink / raw)
To: Alan Mackenzie; +Cc: N. Jackson, 21275
> +(defun delete-selection-uses-region-p ()
The way I read it, this name says "a function which tells us if
delete-selection uses the region".
> + "Return non-nil when the current command uses the region.
It's not about "the current command" but about self-insert-command
(which may be the current command or may be called by the current command).
> +(put 'c-electric-brace 'delete-selection 'delete-selection-uses-region-p)
> +(put 'c-electric-brace 'pending-delete 't)
> +(put 'c-electric-paren 'delete-selection 'delete-selection-uses-region-p)
> +(put 'c-electric-paren 'pending-delete 't)
An alternative would be to copy the `delete-selection' (and
`pending-delete') property of `self-insert-command'. Probably in an
after-load, tho.
Stefan
^ permalink raw reply [flat|nested] 10+ messages in thread
* bug#21275: 24.5; Selection deleted with electric pair mode in cc mode
[not found] ` <jwv37zfosr4.fsf-monnier+emacsbugs@gnu.org>
@ 2015-08-20 21:35 ` Drew Adams
2015-08-20 21:55 ` Alan Mackenzie
0 siblings, 1 reply; 10+ messages in thread
From: Drew Adams @ 2015-08-20 21:35 UTC (permalink / raw)
To: Stefan Monnier, Alan Mackenzie; +Cc: N. Jackson, 21275
> > +(defun delete-selection-uses-region-p ()
>
> The way I read it, this name says "a function which tells us if
> delete-selection uses the region".
No idea what this is all about, but if this is for
`electric-pair-mode' and not for `delete-selection-mode' then
the name should reflect that - call it `electric-pair-SOMETHING'.
Is this something that `delete-selection-mode' needs? Or is it
for something else?
> > + "Return non-nil when the current command uses the region.
What does it mean for a command to "use the region"?
> It's not about "the current command" but about self-insert-command
> (which may be the current command or may be called by the current
> command).
What does it mean for such a command (or any other command) to
"use the region"? That info should presumably be in the doc string.
^ permalink raw reply [flat|nested] 10+ messages in thread
* bug#21275: 24.5; Selection deleted with electric pair mode in cc mode
2015-08-20 21:35 ` Drew Adams
@ 2015-08-20 21:55 ` Alan Mackenzie
2015-08-21 5:46 ` Drew Adams
0 siblings, 1 reply; 10+ messages in thread
From: Alan Mackenzie @ 2015-08-20 21:55 UTC (permalink / raw)
To: Drew Adams; +Cc: N. Jackson, 21275
Hello, Drew.
On Thu, Aug 20, 2015 at 02:35:43PM -0700, Drew Adams wrote:
> > > +(defun delete-selection-uses-region-p ()
> >
> > The way I read it, this name says "a function which tells us if
> > delete-selection uses the region".
> No idea what this is all about, ....
It's for when delete-selection-mode and electric-pair-mode are both
enabled. What was happening (in C Mode, etc.) was that the user would
mark an object and type "(", expecting e-p-m to put a pair of parens
around the marked object; however d-s-m got in first, and deleted
(?killed) the region before the parens were put around the now empty
region.
There was already a solution for this for when "(" is bound to
self-insert-command - this is fairly arcane, and involves setting a
particular variable to function which returns t in the pertinent
circumstances.
This function was previously coded as a lambda. However, I needed to
use it for the pertinent CC Mode functions too, so I extracted it into a
defun, giving it the name `delete-selection-uses-region-p'. The
"delete-seleection" bit is the prefix, shared by the other
de\(fun\|var\)s in the file.
> .... but if this is for `electric-pair-mode' and not for
> `delete-selection-mode' then the name should reflect that - call it
> `electric-pair-SOMETHING'.
It's for when BOTH minor modes are enabled, to enable them to play
nicely with eachother. But it's in delsel.el, hence the prefix.
> Is this something that `delete-selection-mode' needs? Or is it
> for something else?
See above.
> > > + "Return non-nil when the current command uses the region.
> What does it mean for a command to "use the region"?
That isn't very good, is it? It basically means, from e-p-m's point of
view "I'm going to be "using" the region, so don't you go and delete
it!".
> > It's not about "the current command" but about self-insert-command
> > (which may be the current command or may be called by the current
> > command).
> What does it mean for such a command (or any other command) to
> "use the region"? That info should presumably be in the doc string.
I think you're right, here. I'll have another look at it.
--
Alan Mackenzie (Nuremberg, Germany).
^ permalink raw reply [flat|nested] 10+ messages in thread
* bug#21275: 24.5; Selection deleted with electric pair mode in cc mode
2015-08-20 21:55 ` Alan Mackenzie
@ 2015-08-21 5:46 ` Drew Adams
2015-08-21 13:42 ` Stefan Monnier
0 siblings, 1 reply; 10+ messages in thread
From: Drew Adams @ 2015-08-21 5:46 UTC (permalink / raw)
To: Alan Mackenzie; +Cc: N. Jackson, 21275
Hi Alan,
Yes, it's a workaround for electric-pair mode. And yes, delete-selection mode got there first. A few decades earlier. ;-)
My point is that this workaround for electric-pair should have an "electric-pair" name, not a "delete-selection" name. It is not something used by delete-selection.
> > > > +(defun delete-selection-uses-region-p ()
> > >
> > > The way I read it, this name says "a function which tells us if
> > > delete-selection uses the region".
>
> > No idea what this is all about, ....
>
> It's for when delete-selection-mode and electric-pair-mode are both
> enabled. What was happening (in C Mode, etc.) was that the user
> would mark an object and type "(", expecting e-p-m to put a pair
> of parens around the marked object; however d-s-m got in first,
> and deleted (?killed) the region before the parens were put around
> the now empty region.
>
> There was already a solution for this for when "(" is bound to
> self-insert-command - this is fairly arcane, and involves setting a
> particular variable to function which returns t in the pertinent
> circumstances.
>
> This function was previously coded as a lambda. However, I needed
> to use it for the pertinent CC Mode functions too, so I extracted
> it into a defun, giving it the name `delete-selection-uses-region-p'.
> The "delete-seleection" bit is the prefix, shared by the other
> de\(fun\|var\)s in the file.
In what file? Why is the prefix "delete-selection", and not
"electric-pair"?
> > .... but if this is for `electric-pair-mode' and not for
> > `delete-selection-mode' then the name should reflect that -\
> > call it `electric-pair-SOMETHING'.
>
> It's for when BOTH minor modes are enabled, to enable them to play
> nicely with eachother. But it's in delsel.el, hence the prefix.
It's for electric-pair to move into the delete-selection
neighborhood. It's an electric-pair thing. Delete-selection
mode doesn't need it - never has.
> > Is this something that `delete-selection-mode' needs?
> > Or is it for something else?
>
> See above.
AFAICT, it is not for delete-selection mode. It is a hack
so that electric-pair mode can adapt to delete-selection
mode. Nothing wrong with that, in principle. When a new
feature is added, it often has to accommodate existing
behavior. My point is that the name should reflect the
fact that this is a workaround for electric-pair mode, so
that it DTRT. If you had to add another workaround for e-p
mode, so that it DTRT with commas or whatever, that would
be no different. Such things are about e-p; their names
should reflect that.
If you also want to refer, in the name, to the thing you
are working around for e-p mode, that's OK, but the prefix
of the name should be e-p: `elec-pair-hack-to-tolerate-delsel'
or whatever.
> > > > + "Return non-nil when the current command uses the region.
>
> > What does it mean for a command to "use the region"?
>
> That isn't very good, is it? It basically means, from e-p-m's
> point of view "I'm going to be "using" the region, so don't
> you go and delete it!".
That still doesn't speak to what "using the region" means.
It sounds like what is important is that you are protecting
the region for e-p. If so, the name and description should
reflect that need, not just "using the region".
> > > It's not about "the current command" but about
> > > self-insert-command (which may be the current command or
> > > may be called by the current command).
>
> > What does it mean for such a command (or any other command) to
> > "use the region"? That info should presumably be in the doc
> > string.
>
> I think you're right, here. I'll have another look at it.
Anyway, it's not very important. Just one opinion. I'd
recommend writing the explanation and names from the point
of view of e-p (only).
HTH - Drew
^ permalink raw reply [flat|nested] 10+ messages in thread
* bug#21275: 24.5; Selection deleted with electric pair mode in cc mode
2015-08-21 5:46 ` Drew Adams
@ 2015-08-21 13:42 ` Stefan Monnier
2015-08-21 15:01 ` Drew Adams
0 siblings, 1 reply; 10+ messages in thread
From: Stefan Monnier @ 2015-08-21 13:42 UTC (permalink / raw)
To: Drew Adams; +Cc: Alan Mackenzie, 21275, N. Jackson
> My point is that this workaround for electric-pair should have an
> "electric-pair" name, not a "delete-selection" name. It is not something
> used by delete-selection.
No. It's a feature of delete-selection (in the form of a hook).
Look at the code: it doesn't say anything about electric-pair.
This feature was added for electric-pair, indeed, but it's a feature of
delete-selection.
elec-pair.el has the other half of code (added to delete-selection's
hook), using the proper prefix.
Stefan
^ permalink raw reply [flat|nested] 10+ messages in thread
* bug#21275: 24.5; Selection deleted with electric pair mode in cc mode
2015-08-21 13:42 ` Stefan Monnier
@ 2015-08-21 15:01 ` Drew Adams
0 siblings, 0 replies; 10+ messages in thread
From: Drew Adams @ 2015-08-21 15:01 UTC (permalink / raw)
To: Stefan Monnier; +Cc: Alan Mackenzie, 21275, N. Jackson
> > My point is that this workaround for electric-pair should have an
> > "electric-pair" name, not a "delete-selection" name. It is not
> > something used by delete-selection.
>
> No. It's a feature of delete-selection (in the form of a hook).
> Look at the code: it doesn't say anything about electric-pair.
> This feature was added for electric-pair, indeed, but it's a feature
> of delete-selection.
>
> elec-pair.el has the other half of code (added to delete-selection's
> hook), using the proper prefix.
OK, my mistake, I guess. Thanks for thinking about it.
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2015-08-21 15:01 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-16 13:31 bug#21275: 24.5; Selection deleted with electric pair mode in cc mode N. Jackson
[not found] ` <mailman.8417.1439731993.904.bug-gnu-emacs@gnu.org>
2015-08-18 15:04 ` Alan Mackenzie
2015-08-18 16:43 ` N. Jackson
2015-08-19 21:52 ` Stefan Monnier
[not found] ` <jwv37zfosr4.fsf-monnier+emacsbugs@gnu.org>
2015-08-20 21:35 ` Drew Adams
2015-08-20 21:55 ` Alan Mackenzie
2015-08-21 5:46 ` Drew Adams
2015-08-21 13:42 ` Stefan Monnier
2015-08-21 15:01 ` Drew Adams
2015-08-19 17:22 ` Alan Mackenzie
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.