From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: "Stefan Monnier" Newsgroups: gmane.emacs.xemacs.design,gmane.emacs.devel Subject: Re: Rationale for split-string? Date: Thu, 17 Apr 2003 13:44:18 -0400 Sender: xemacs-design-admin@xemacs.org Message-ID: <200304171744.h3HHiJCx009215@rum.cs.yale.edu> References: <87brz57at2.fsf@tleepslib.sk.tsukuba.ac.jp> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: main.gmane.org 1050602334 15377 80.91.224.249 (17 Apr 2003 17:58:54 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Thu, 17 Apr 2003 17:58:54 +0000 (UTC) Cc: emacs-devel@gnu.org, xemacs-design@xemacs.org Original-X-From: xemacs-design-admin@xemacs.org Thu Apr 17 19:58:50 2003 Return-path: Original-Received: from gwyn.tux.org ([199.184.165.135]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 196DRh-00033Z-00 for ; Thu, 17 Apr 2003 19:45:13 +0200 Original-Received: from gwyn.tux.org (localhost.localdomain [127.0.0.1]) by gwyn.tux.org (8.11.6p2/8.9.1) with ESMTP id h3HHj3M21582; Thu, 17 Apr 2003 13:45:03 -0400 Original-Received: (from turnbull@localhost) by gwyn.tux.org (8.11.6p2/8.9.1) id h3HHiOv21184 for xemacs-design-mailman@xemacs.org; Thu, 17 Apr 2003 13:44:24 -0400 Original-Received: (from mail@localhost) by gwyn.tux.org (8.11.6p2/8.9.1) id h3HHiNi21171 for turnbull@tux.org; Thu, 17 Apr 2003 13:44:23 -0400 Original-Received: from rum.cs.yale.edu (rum.cs.yale.edu [128.36.229.169]) by gwyn.tux.org (8.11.6p2/8.9.1) with ESMTP id h3HHiKM21143; Thu, 17 Apr 2003 13:44:20 -0400 Original-Received: from rum.cs.yale.edu (localhost [127.0.0.1]) by rum.cs.yale.edu (8.12.8/8.12.8) with ESMTP id h3HHiJx6009217; Thu, 17 Apr 2003 13:44:19 -0400 Original-Received: (from monnier@localhost) by rum.cs.yale.edu (8.12.8/8.12.8/Submit) id h3HHiJCx009215; Thu, 17 Apr 2003 13:44:19 -0400 X-Mailer: exmh version 2.4 06/23/2000 with nmh-1.0.4 Original-To: "Stephen J. Turnbull" X-XEmacs-List: design Errors-To: xemacs-design-admin@xemacs.org X-BeenThere: xemacs-design@xemacs.org X-Mailman-Version: 2.0.13 Precedence: bulk List-Help: List-Post: List-Subscribe: , List-Id: Discussion of design and features for XEmacs. List-Unsubscribe: , Xref: main.gmane.org gmane.emacs.xemacs.design:2046 gmane.emacs.devel:13266 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:13266 > What is the rationale for the specification of `split-string'? > > That is, in GNU Emacs > > ;; an often convenient abbreviation > (split-string " data ") > => ("data") > > ;; weird > (split-string " data " " ") > => ("" "data" "") > > ;; urk (think "gnumeric just-say-no.xls" "save as" "csv") > (split-string ",,data,," ",") > => ("" "data" "") I think the reason is for the default case. In XEmacs we get: ELISP> (split-string " a b ") ("" "a" "b" "") What is usually desired here is to eliminate all empty parts. The `+' in the default regexp gets rid of the empty parts inside the string, but not at the beginning and at the end, so that's why Emacs gets rid of the empty string at the beginning and at the end. I agree that when the regexp used is "," or "[ \t]*,[ \t]*", then XEmacs's behavior makes a lot more sense. A gross hack is to test if the last char of the regexp is ?+ and if so get rid of empty strings at start and end. It should take care of 99% of the cases. Stefan