GNU bug report logs - #8439
[PATCH] ffap.el -- detect paths with spaces

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Severity: minor; Reported by: Jari Aalto <jari.aalto <at> cante.net>; Keywords: patch; merged with #6695; dated Thu, 7 Apr 2011 15:25:02 UTC; Maintainer for emacs is bug-gnu-emacs <at> gnu.org.
Forcibly Merged 6695 8439. Request was from Lars Magne Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. Full text available.

Message received at 8439 <at> debbugs.gnu.org:


Received: (at 8439) by debbugs.gnu.org; 3 Jul 2011 23:29:38 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Jul 03 19:29:38 2011
Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1QdW6c-0006jV-0U
	for submit <at> debbugs.gnu.org; Sun, 03 Jul 2011 19:29:38 -0400
Received: from hermes.netfonds.no ([80.91.224.195])
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <larsi <at> gnus.org>) id 1QdW6Z-0006jD-OY
	for 8439 <at> debbugs.gnu.org; Sun, 03 Jul 2011 19:29:36 -0400
Received: from cm-84.215.51.58.getinternet.no ([84.215.51.58]
	helo=quimbies.gnus.org)
	by hermes.netfonds.no with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16)
	(Exim 4.72) (envelope-from <larsi <at> gnus.org>)
	id 1QdW6O-0000Mv-J9; Mon, 04 Jul 2011 01:29:24 +0200
From: Lars Magne Ingebrigtsen <larsi <at> gnus.org>
To: Jari Aalto <jari.aalto <at> cante.net>
Subject: Re: [PATCH] ffap.el -- detect paths with spaces
In-Reply-To: <87pqoyaxu0.fsf <at> blue.sea.net> (Jari Aalto's message of "Thu, 07
	Apr 2011 18:24:39 +0300")
Date: Mon, 04 Jul 2011 01:29:16 +0200
Message-ID: <m3fwmn7xkj.fsf <at> quimbies.gnus.org>
References: <87pqoyaxu0.fsf <at> blue.sea.net>
User-Agent: Gnus/5.110018 (No Gnus v0.18) Emacs/24.0.50 (gnu/linux)
X-Now-Playing: Michelle Shocked's _Deep Natural (1)_: "PeachFuzz"
X-Hashcash: 1:23:110703:8439 <at> debbugs.gnu.org::wHqKsk1fNJSIelLY:00000000000000000000000000000000000000000X4W2
X-Hashcash: 1:23:110703:jari.aalto <at> cante.net::17ETHjTHS1r6o8ql:00000000000000000000000000000000000000000ZxK2
MIME-Version: 1.0
Content-Type: text/plain
X-MailScanner-ID: 1QdW6O-0000Mv-J9
X-Netfonds-MailScanner: Found to be clean
X-Netfonds-MailScanner-From: larsi <at> gnus.org
MailScanner-NULL-Check: 1310340564.65664 <at> GwpJzzfpgvzLI6nBpBgmmQ
X-Spam-Status: No
X-Spam-Score: -2.8 (--)
X-Debbugs-Envelope-To: 8439
Cc: 8439 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.11
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/pipermail/debbugs-submit>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Sender: debbugs-submit-bounces <at> debbugs.gnu.org
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
X-Spam-Score: -2.8 (--)

Jari Aalto <jari.aalto <at> cante.net> writes:

> An example under Windows:
>
>    (locate-library "ffap.el")C-xC-e
>    c:/Program Files/emacs/emacs-23.3/lisp/ffap.el     M-x ffap on line
>
>    => c:/Program
>
>    With the patch, M-x ffap will offer:
>
>    => c:/Program Files/emacs/emacs-23.3/lisp/ffap.el

[...]

> +	              ;; FIXME: may need better tuning. Currenly matches "/paths like/exam ple.txt"
> +	              (if (looking-at ".*/.* [^[:space:]]*/.*[^[:space:]]")

Won't this be more problematic than helpful?  There may be more matches
of stuff that's not part of the file name.  And spaces in file names
aren't that common in non-Windowsey environments...

-- 
(domestic pets only, the antidote for overdose, milk.)
  bloggy blog http://lars.ingebrigtsen.no/




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#8439; Package emacs. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 7 Apr 2011 15:24:52 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Apr 07 11:24:52 2011
Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1Q7r4m-0001vo-BO
	for submit <at> debbugs.gnu.org; Thu, 07 Apr 2011 11:24:52 -0400
Received: from emh05.mail.saunalahti.fi ([62.142.5.111])
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <jari.aalto <at> cante.net>) id 1Q7r4j-0001vc-PY
	for submit <at> debbugs.gnu.org; Thu, 07 Apr 2011 11:24:51 -0400
Received: from saunalahti-vams (vs3-10.mail.saunalahti.fi [62.142.5.94])
	by emh05-2.mail.saunalahti.fi (Postfix) with SMTP id 6FA058C17E
	for <submit <at> debbugs.gnu.org>; Thu,  7 Apr 2011 18:24:43 +0300 (EEST)
Received: from emh04.mail.saunalahti.fi ([62.142.5.110])
	by vs3-10.mail.saunalahti.fi ([62.142.5.94])
	with SMTP (gateway) id A065CF6B3D6; Thu, 07 Apr 2011 18:24:43 +0300
Received: from cante.net (a91-155-187-216.elisa-laajakaista.fi
	[91.155.187.216])
	by emh04.mail.saunalahti.fi (Postfix) with ESMTP id 4A68741BE6
	for <submit <at> debbugs.gnu.org>; Thu,  7 Apr 2011 18:24:39 +0300 (EEST)
From: Jari Aalto <jari.aalto <at> cante.net>
To: submit <at> debbugs.gnu.org
Subject: [PATCH] ffap.el -- detect paths with spaces
Mail-Copies-To: poster
Date: Thu, 07 Apr 2011 18:24:39 +0300
Message-ID: <87pqoyaxu0.fsf <at> blue.sea.net>
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="=-=-="
X-Antivirus: VAMS
X-Spam-Score: -2.6 (--)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.11
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/pipermail/debbugs-submit>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Sender: debbugs-submit-bounces <at> debbugs.gnu.org
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
X-Spam-Score: -2.6 (--)

--=-=-=
Content-Type: text/plain

Package: emacs
Version: 23.2+1-7
Severity: normal
Tags: patch

An example under Windows:

   (locate-library "ffap.el")C-xC-e
   c:/Program Files/emacs/emacs-23.3/lisp/ffap.el     M-x ffap on line

   => c:/Program

   With the patch, M-x ffap will offer:

   => c:/Program Files/emacs/emacs-23.3/lisp/ffap.el

2011-04-07  Jari Aalto  <jari.aalto <at> cante.net>

        * ffap.el (ffap-string-at-point): Handle paths and file names with
        spaces.

-- System Information
Debian Release: wheezy/sid
  APT Prefers testing
  APT policy: (990, testing) (500, unstable) (1, experimental)
Architecture: amd64
Kernel: Linux picasso 2.6.32-5-amd64 #1 SMP Wed Jan 12 03:40:32 UTC 2011 x86_64 GNU/Linux
Locale: LANG=en_US.UTF-8, LC_ALL=

-- Versions of packages `emacs depends on'.
Depends:
emacs23         23.2+1-7        GNU Emacs is the extensible self-documenting
emacs23-lucid   23.2+1-7        GNU Emacs is the extensible self-documenting
emacs23-nox     23.2+1-7        GNU Emacs is the extensible self-documenting


--=-=-=
Content-Type: text/x-diff
Content-Disposition: inline;
 filename=0001-lisp-ffap.el-ffap-string-at-point-Support-spaces-in-.patch

From 0706445da3f7e10aceef8b371d458deb4ec1c39d Mon Sep 17 00:00:00 2001
From: Jari Aalto <jari.aalto <at> cante.net>
Date: Thu, 7 Apr 2011 18:20:17 +0300
Subject: [PATCH] lisp/ffap.el: (ffap-string-at-point): Support spaces in paths
Organization: Private
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit


Signed-off-by: Jari Aalto <jari.aalto <at> cante.net>
---
 lisp/ffap.el |   47 +++++++++++++++++++++++++++++------------------
 1 files changed, 29 insertions(+), 18 deletions(-)

diff --git a/lisp/ffap.el b/lisp/ffap.el
index 97105ed..dcc16f2 100644
--- a/lisp/ffap.el
+++ b/lisp/ffap.el
@@ -1006,24 +1006,35 @@ If MODE is not found, we use `file' instead of MODE.
 If the region is active, return a string from the region.
 Sets `ffap-string-at-point' and `ffap-string-at-point-region'."
   (let* ((args
-	  (cdr
-	   (or (assq (or mode major-mode) ffap-string-at-point-mode-alist)
-	       (assq 'file ffap-string-at-point-mode-alist))))
-	 (pt (point))
-	 (str
-	  (if (and transient-mark-mode mark-active)
-	      (buffer-substring
-	       (setcar ffap-string-at-point-region (region-beginning))
-	       (setcar (cdr ffap-string-at-point-region) (region-end)))
-	    (buffer-substring
-	     (save-excursion
-	       (skip-chars-backward (car args))
-	       (skip-chars-forward (nth 1 args) pt)
-	       (setcar ffap-string-at-point-region (point)))
-	     (save-excursion
-	       (skip-chars-forward (car args))
-	       (skip-chars-backward (nth 2 args) pt)
-	       (setcar (cdr ffap-string-at-point-region) (point)))))))
+          (cdr
+           (or (assq (or mode major-mode) ffap-string-at-point-mode-alist)
+               (assq 'file ffap-string-at-point-mode-alist))))
+         (pt (point))
+	  space-p
+	   end
+         (str
+          (if (and transient-mark-mode mark-active)
+              (buffer-substring
+               (setcar ffap-string-at-point-region (region-beginning))
+               (setcar (cdr ffap-string-at-point-region) (region-end)))
+            (buffer-substring
+             (save-excursion
+               (skip-chars-backward (car args))
+               (skip-chars-forward (nth 1 args) pt)
+	              ;; Paths may contains spaces, check those
+	              ;; FIXME: may need better tuning. Currenly matches "/paths like/exam ple.txt"
+	              (if (looking-at ".*/.* [^[:space:]]*/.*[^[:space:]]")
+			     (setq space-p (match-end 0)))
+               (setcar ffap-string-at-point-region (point)))
+             (save-excursion
+               (skip-chars-forward (car args))
+               (skip-chars-backward (nth 2 args) pt)
+	              (setq end (point))
+		             (if (and space-p
+				      (> space-p end)
+				      (memq mode '(file nil)))
+				    (setq end space-p))
+               (setcar (cdr ffap-string-at-point-region) end))))))
     (set-text-properties 0 (length str) nil str)
     (setq ffap-string-at-point str)))
 
-- 
1.7.4.1


--=-=-=--




Acknowledgement sent to Jari Aalto <jari.aalto <at> cante.net>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. Full text available.
Report forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#8439; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Tue, 20 Sep 2011 19:45:02 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.