* bug#14207: 24.2; insert-file-contents clobbers match data
@ 2013-04-15 0:56 Aidan Gauland
2013-04-15 5:16 ` Eli Zaretskii
0 siblings, 1 reply; 3+ messages in thread
From: Aidan Gauland @ 2013-04-15 0:56 UTC (permalink / raw)
To: 14207
If (and only if) the match data is non-nil when `insert-file-contents'
is called, it clobbers the match-data.
To demonstrate:
*** Welcome to IELM *** Type (describe-mode) for help.
ELISP> (match-data)
nil
ELISP> (equal
(match-data)
(progn
(write-region "foo bar baz wiz" nil "/tmp/foo-file")
(with-temp-buffer (insert-file-contents "/tmp/foo-file"))
(match-data)))
t
ELISP> (match-data)
nil
ELISP> (search-backward "elisp" nil t)
340
ELISP> (match-data)
(#<marker at 340 in *ielm*> #<marker at 345 in *ielm*>)
ELISP> (equal
(match-data)
(progn
(write-region "foo bar baz wiz" nil "/tmp/foo-file")
(with-temp-buffer (insert-file-contents "/tmp/foo-file"))
(match-data)))
nil
ELISP> (match-data)
(0 0)
ELISP>
In GNU Emacs 24.2.1 (x86_64-pc-linux-gnu, GTK+ Version 2.20.1)
of 2013-04-03 on dimension8, modified by Debian
Windowing system distributor `The X.Org Foundation', version 11.0.10707000
Configured using:
`configure '--build' 'x86_64-linux-gnu' '--build' 'x86_64-linux-gnu'
'--prefix=/usr' '--sharedstatedir=/var/lib' '--libexecdir=/usr/lib'
'--localstatedir=/var/lib' '--infodir=/usr/share/info'
'--mandir=/usr/share/man' '--with-pop=yes'
'--enable-locallisppath=/etc/emacs24:/etc/emacs:/usr/local/share/emacs/24.2/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/24.2/site-lisp:/usr/share/emacs/site-lisp'
'--without-gconf' '--with-crt-dir=/usr/lib/' '--with-x=yes'
'--with-x-toolkit=gtk' '--with-toolkit-scroll-bars'
'build_alias=x86_64-linux-gnu' 'CFLAGS=-g -O2 -fstack-protector
--param=ssp-buffer-size=4 -Wformat -Werror=format-security -Wall'
'LDFLAGS=-Wl,-z,relro' 'CPPFLAGS=-D_FORTIFY_SOURCE=2''
Important settings:
value of $LC_ALL: nil
value of $LC_COLLATE: nil
value of $LC_CTYPE: nil
value of $LC_MESSAGES: nil
value of $LC_MONETARY: nil
value of $LC_NUMERIC: nil
value of $LC_TIME: nil
value of $LANG: en_NZ.utf8
value of $XMODIFIERS: nil
locale-coding-system: utf-8-unix
default enable-multibyte-characters: t
Major mode: IELM
Minor modes in effect:
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 i e l m <return> C-y <return> C-y <return> ( m
a t c h - d a t a ) <return> C-y <return> M-p M-p <return>
M-p M-p M-p M-p <return> M-p M-p <return> M-< C-n C-p
C-SPC M-> M-w M-x r e p o r <tab> <return>
Recent messages:
History item: 1
History item: 2
History item: 1
History item: 2
History item: 3
History item: 4
Wrote /tmp/foo-file
History item: 1
History item: 2
Mark set [2 times]
Load-path shadows:
/usr/share/emacs/24.2/site-lisp/debian-startup hides /usr/share/emacs/site-lisp/debian-startup
/usr/share/emacs/24.2/site-lisp/dictionaries-common/flyspell hides /usr/share/emacs/24.2/lisp/textmodes/flyspell
/usr/share/emacs/24.2/site-lisp/dictionaries-common/ispell hides /usr/share/emacs/24.2/lisp/textmodes/ispell
Features:
(shadow sort gnus-util mail-extr emacsbug message format-spec rfc822 mml
easymenu mml-sec mm-decode mm-bodies mm-encode mail-parse rfc2231
mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums
mm-util mail-prsvr mail-utils ielm pp comint regexp-opt ansi-color ring
time-date tooltip ediff-hook vc-hooks lisp-float-type mwheel x-win x-dnd
tool-bar dnd fontset image fringe 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 font-render-setting
move-toolbar gtk x-toolkit x multi-tty emacs)
^ permalink raw reply [flat|nested] 3+ messages in thread
* bug#14207: 24.2; insert-file-contents clobbers match data
2013-04-15 0:56 bug#14207: 24.2; insert-file-contents clobbers match data Aidan Gauland
@ 2013-04-15 5:16 ` Eli Zaretskii
2013-04-16 1:22 ` Aidan Gauland
0 siblings, 1 reply; 3+ messages in thread
From: Eli Zaretskii @ 2013-04-15 5:16 UTC (permalink / raw)
To: Aidan Gauland; +Cc: 14207
> From: Aidan Gauland <aidalgol@no8wireless.co.nz>
> Date: Mon, 15 Apr 2013 12:56:26 +1200
>
> If (and only if) the match data is non-nil when `insert-file-contents'
> is called, it clobbers the match-data.
And why is that a bug?
From the ELisp manual (node "Match Data"):
Notice that all functions are allowed to overwrite the match data
unless they're explicitly documented not to do so.
'insert-file-contents' is not documented to preserve match data.
^ permalink raw reply [flat|nested] 3+ messages in thread
* bug#14207: 24.2; insert-file-contents clobbers match data
2013-04-15 5:16 ` Eli Zaretskii
@ 2013-04-16 1:22 ` Aidan Gauland
0 siblings, 0 replies; 3+ messages in thread
From: Aidan Gauland @ 2013-04-16 1:22 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: 14207
Eli Zaretskii <eliz@gnu.org> writes:
>> From: Aidan Gauland <aidalgol@no8wireless.co.nz>
>> Date: Mon, 15 Apr 2013 12:56:26 +1200
>>
>> If (and only if) the match data is non-nil when `insert-file-contents'
>> is called, it clobbers the match-data.
>
> And why is that a bug?
>
> From the ELisp manual (node "Match Data"):
>
> Notice that all functions are allowed to overwrite the match data
> unless they're explicitly documented not to do so.
>
> 'insert-file-contents' is not documented to preserve match data.
Oh, OK. I thought it was the other way around: functions are supposed
to explicitly be documented as modifying the match data.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-04-16 1:22 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-04-15 0:56 bug#14207: 24.2; insert-file-contents clobbers match data Aidan Gauland
2013-04-15 5:16 ` Eli Zaretskii
2013-04-16 1:22 ` Aidan Gauland
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).