最近 Emacs22 を使いはじめて,
% dpkg -l 'emacs-snapshot*' | grep ^ii ii emacs-snapshot 20061221-1 The GNU Emacs editor (development snapshot) ii emacs-snapshot-bin-common 20061221-1 The GNU Emacs editor's shared, architecture ii emacs-snapshot-common 20061221-1 The GNU Emacs editor's common infrastructure
で,
GNU Emacs 22.0.92.1 (i486-pc-linux-gnu, X toolkit, Xaw3d scroll bars) of 2006-12-22 on pacem, modified by Debian
みたいな環境なのであるが,なんだか自前の関数の挙動が変だなぁと思ってい たら split-string の挙動が Emacs21 と異っているっぽい.
GNU Emacs 22.0.92.1 (i486-pc-linux-gnu, X toolkit, Xaw3d scroll bars) of 2006-12-22 on pacem, modified by Debian
(split-string "0123456789" "")
=>("" "0" "1" "2" "3" "4" "5" "6" "7" "8" "9" "")
(split-string "0123456789" "" t)
=>("0" "1" "2" "3" "4" "5" "6" "7" "8" "9")GNU Emacs 21.4.1 (i486-pc-linux-gnu, X toolkit, Xaw3d scroll bars) of 2006-12-04 on raven, modified by Debian
(split-string "0123456789" "")
=>("0" "1" "2" "3" "4" "5" "6" "7" "8" "9")
(split-string "0123456789" "" t)
=>エラー上記の例だとわかりにくいが, たとえば以下だと Emacs22 の (subr.el の) 方が素直な気がする.
Emacs22
(split-string "0 1 2" " ") =>("0" "1" "2")
(split-string " 0 1 2" " ") =>("0" "1" "2")Emacs21
(split-string "0 1 2" " ") =>("0" "1" "2")
(split-string " 0 1 2" " ") =>("" "0" "1" "2")ちなみに関係ないが Ruby の String#split の場合は,
"0 1 2".split(/\s+/) =>["0", "1", "2"]
" 0 1 2".split(/\s+/) =>["", "0", "1", "2"]
"0 1 2".split(" ") =>["0", "1", "2"]
" 0 1 2".split(" ") =>["0", "1", "2"]
みたいな.
Last-modified: Wed May 06 00:14:17 +0900 2009