From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: Feature Request: Function to quote filenames Date: Wed, 24 Jun 2015 18:53:27 +0300 Message-ID: <83r3p1drwo.fsf@gnu.org> References: Reply-To: Eli Zaretskii NNTP-Posting-Host: plane.gmane.org X-Trace: ger.gmane.org 1435161295 25220 80.91.229.3 (24 Jun 2015 15:54:55 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 24 Jun 2015 15:54:55 +0000 (UTC) Cc: emacs-devel@gnu.org To: raman Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Jun 24 17:54:47 2015 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Z7n0f-00045a-Dz for ged-emacs-devel@m.gmane.org; Wed, 24 Jun 2015 17:54:45 +0200 Original-Received: from localhost ([::1]:51473 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z7n0e-0004fx-OH for ged-emacs-devel@m.gmane.org; Wed, 24 Jun 2015 11:54:44 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:40194) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z7mzf-0003hK-Bk for emacs-devel@gnu.org; Wed, 24 Jun 2015 11:53:44 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z7mzc-0003wz-15 for emacs-devel@gnu.org; Wed, 24 Jun 2015 11:53:43 -0400 Original-Received: from mtaout24.012.net.il ([80.179.55.180]:45159) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z7mzb-0003wg-Ok for emacs-devel@gnu.org; Wed, 24 Jun 2015 11:53:39 -0400 Original-Received: from conversion-daemon.mtaout24.012.net.il by mtaout24.012.net.il (HyperSendmail v2007.08) id <0NQG00E00GYKWQ00@mtaout24.012.net.il> for emacs-devel@gnu.org; Wed, 24 Jun 2015 18:45:03 +0300 (IDT) Original-Received: from HOME-C4E4A596F7 ([87.69.4.28]) by mtaout24.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0NQG008R1H33CS60@mtaout24.012.net.il>; Wed, 24 Jun 2015 18:45:03 +0300 (IDT) In-reply-to: X-012-Sender: halo1@inter.net.il X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 80.179.55.180 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:187484 Archived-At: > From: raman > Date: Wed, 24 Jun 2015 08:26:52 -0700 > > Motivated by the increasing number of filenames that show up with spc, > "'" and other punctuation characters in their name. > > The only helper function Emacs provides today is shell-quote-argument -- > which often doesn't do the trick. > > As an example: Given the filename: > > Alice's Adventures in Wonderland > > (setq f (shell-quote-argument "Alice's Adventures in Wonderland")) > returns > "Alice\\'s\\ Adventures\\ in\\ Wonderland" > > But invocations like > (shell-command (format "ls %s" f)) > > throw an error It does? What error? I see no error, just a return value meaning there's no such file. > it's never obvious what quoting magic to use to get all the cases > right. > > Would be nice if we had a shell-quote-filename elisp function that did > all of the magic quoting. The magic, if there is one, depends on the application, because only the application knows the semantics of the file-name argument for the program to be invoked. So I don't see how a general-purpose utility function could solve the problem. Unless I misunderstand the problem you have.