From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: YAMAMOTO Mitsuharu Newsgroups: gmane.emacs.devel Subject: Re: Your last change to browse-url is bogus. Date: Mon, 17 Sep 2007 13:40:49 +0900 Organization: Faculty of Science, Chiba University Message-ID: References: <87ejh42mo4.fsf@cadilhac.name> <20070912.215405.160495149.mituharu@math.s.chiba-u.ac.jp> <87sl5k10yl.fsf@cadilhac.name> <20070912.231800.210864712.mituharu@math.s.chiba-u.ac.jp> <87fy1j1orw.fsf@cadilhac.name> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: sea.gmane.org 1190004062 14750 80.91.229.12 (17 Sep 2007 04:41:02 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Mon, 17 Sep 2007 04:41:02 +0000 (UTC) Cc: hannes@saeurebad.de, emacs-devel@gnu.org To: michael@cadilhac.name (=?ISO-8859-1?Q?Micha=EBl?= Cadilhac) Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Sep 17 06:40:59 2007 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1IX8Pr-0005Zu-De for ged-emacs-devel@m.gmane.org; Mon, 17 Sep 2007 06:40:59 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IX8Pq-0001l9-4D for ged-emacs-devel@m.gmane.org; Mon, 17 Sep 2007 00:40:58 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1IX8Pn-0001l1-CD for emacs-devel@gnu.org; Mon, 17 Sep 2007 00:40:55 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1IX8Pm-0001kn-VL for emacs-devel@gnu.org; Mon, 17 Sep 2007 00:40:55 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IX8Pm-0001kk-M3 for emacs-devel@gnu.org; Mon, 17 Sep 2007 00:40:54 -0400 Original-Received: from ntp.math.s.chiba-u.ac.jp ([133.82.132.2] helo=mathmail.math.s.chiba-u.ac.jp) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1IX8Pm-0003bh-0H for emacs-devel@gnu.org; Mon, 17 Sep 2007 00:40:54 -0400 Original-Received: from church.math.s.chiba-u.ac.jp (church [133.82.132.36]) by mathmail.math.s.chiba-u.ac.jp (Postfix) with ESMTP id 40C3E2C43; Mon, 17 Sep 2007 13:40:49 +0900 (JST) In-Reply-To: <87fy1j1orw.fsf@cadilhac.name> User-Agent: Wanderlust/2.14.0 (Africa) SEMI/1.14.6 (Maruoka) FLIM/1.14.8 (=?ISO-8859-4?Q?Shij=F2?=) APEL/10.6 Emacs/23.0.50 (sparc-sun-solaris2.8) MULE/5.0 (SAKAKI) X-Detected-Kernel: NetBSD 3.0 (DF) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:79081 Archived-At: Your point of view is low-level (string operation), and mine is high-level (URL operation). The problems is that the current implementation of browse-url-encode-url is neither of them: it looks like a result of superficial code factoring. (defun browse-url-encode-url (url &optional filename-p) "Encode all `confusing' characters in URL. If FILENAME-P is nil, the confusing characters are [,)$]. Otherwise, the confusing characters are [*\"()',=3D;?% ]." (let ((conf-char (if filename-p "[*\"()',=3D;?% ]" "[,)$]")) (encoded-url (copy-sequence url)) (s 0)) (while (setq s (string-match conf-char encoded-url s)) (setq encoded-url (replace-match (format "%%%x" (string-to-char (match-string 0 encoded-url))) t t encoded-url) s (1+ s))) encoded-url)) It is inappropriate from a high-level view because it is a mixture of two semantically different operations. Also inappropriate from a low-level view because it is not general enough and the function name doesn't represent what it does. >>>>> On Thu, 13 Sep 2007 00:50:59 +0200, michael@cadilhac.name (Micha=EBl = Cadilhac) said: >>> What would you do? >>=20 >> Maybe I would revert browse-url-file-url to the one that doesn't >> use browse-url-encode-url [...]. Also I would use more explicit >> and specific name in place of browse-url-encode-url (e.g., >> browse-url-escape-confusing-characters). >> An alternative way would be, as you suggested, to give characters >> to be escaped as an argument to browse-url-encode-url, but rename >> the function so it looks like a low-level string operation. > Well, for now on I'm not sure which one of the possibilities is the > good one (and I'm getting sleepy=A0:)). If someone has a strong > feeling about that around here, it'd be nice to hear him! I propose the combination of above two, which is similar to what Davis suggested: 1. Add a low-level string replacing function (say, browse-url-encode-chars-in-string as you mentioned) that takes an argument representing the characters to be escaped. 2. In browse-url-file-url, directly call the above low-level function instead of calling browse-url-encode-url. 3. Change browse-url-encode-url so it calls the the low-level function introduced in 1, and just do one task (URL -> URL). The difference between direct and indirect calls to the low-level function comes from whether it is meaningful as a self-contained task or not. Escaping confusing characters in a URL deserves a specialized function, but escaping characters in a filename string is just a part of the conversion from the filename to a URL. YAMAMOTO Mitsuharu mituharu@math.s.chiba-u.ac.jp