From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Jari Aalto Newsgroups: gmane.emacs.bugs Subject: bug#8439: [PATCH] ffap.el -- detect paths with spaces (v2) Date: Fri, 19 Oct 2012 10:39:36 +0300 Organization: Private Message-ID: <874nlq9ah3.fsf@picasso.cante.net> References: <87pqoyaxu0.fsf@blue.sea.net> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1350632444 6591 80.91.229.3 (19 Oct 2012 07:40:44 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 19 Oct 2012 07:40:44 +0000 (UTC) Cc: Yigal Hochberg To: 8439@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Oct 19 09:40:50 2012 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1TP7CL-0002Ec-Qq for geb-bug-gnu-emacs@m.gmane.org; Fri, 19 Oct 2012 09:40:49 +0200 Original-Received: from localhost ([::1]:50459 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TP7CE-0000se-Mw for geb-bug-gnu-emacs@m.gmane.org; Fri, 19 Oct 2012 03:40:42 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:44854) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TP7CC-0000sW-HN for bug-gnu-emacs@gnu.org; Fri, 19 Oct 2012 03:40:41 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TP7C6-000311-HH for bug-gnu-emacs@gnu.org; Fri, 19 Oct 2012 03:40:40 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:40712) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TP7C6-00030r-EI for bug-gnu-emacs@gnu.org; Fri, 19 Oct 2012 03:40:34 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1TP7DW-0004o9-BT for bug-gnu-emacs@gnu.org; Fri, 19 Oct 2012 03:42:02 -0400 X-Loop: help-debbugs@gnu.org In-Reply-To: <87pqoyaxu0.fsf@blue.sea.net> Resent-From: Jari Aalto Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 19 Oct 2012 07:42:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 8439 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 8439-submit@debbugs.gnu.org id=B8439.135063247318423 (code B ref 8439); Fri, 19 Oct 2012 07:42:02 +0000 Original-Received: (at 8439) by debbugs.gnu.org; 19 Oct 2012 07:41:13 +0000 Original-Received: from localhost ([127.0.0.1]:50963 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TP7Ci-0004n5-IU for submit@debbugs.gnu.org; Fri, 19 Oct 2012 03:41:13 -0400 Original-Received: from emh02.mail.saunalahti.fi ([62.142.5.108]:46802) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TP7Ce-0004mw-Un for 8439@debbugs.gnu.org; Fri, 19 Oct 2012 03:41:11 -0400 Original-Received: from saunalahti-vams (vs3-10.mail.saunalahti.fi [62.142.5.94]) by emh02.mail.saunalahti.fi (Postfix) with SMTP id 0D91E81895; Fri, 19 Oct 2012 10:39:39 +0300 (EEST) Original-Received: from emh03.mail.saunalahti.fi ([62.142.5.109]) by vs3-10.mail.saunalahti.fi ([62.142.5.94]) with SMTP (gateway) id A078A102BB2; Fri, 19 Oct 2012 10:39:39 +0300 Original-Received: from picasso.cante.net (a91-155-178-192.elisa-laajakaista.fi [91.155.178.192]) by emh03.mail.saunalahti.fi (Postfix) with ESMTP id 7725F188800; Fri, 19 Oct 2012 10:39:36 +0300 (EEST) Mail-Copies-To: poster User-Agent: Gnus/5.130006 (Ma Gnus v0.6) Emacs/24.1 (gnu/linux) X-Antivirus: VAMS X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:65724 Archived-At: With some more field testing, the following patch works better. 1. New variable ffap-paths-with-spaces controls if the behavior is in use. By default it is set to "t" in Windows/Cygwin where spaces in paths are encountered. 2. The "path skipping" is based on finding longest distance: - from first "drive letter", "/" or "\" - until last "/", "\" followed by last non-matching-char-not-usually-found-in-file-names 3. In Cygwin Emacs the paths are expected to be in "/cygdrive//" format. This is handled as a last step. Test by placing cursor anywhere of these path names and evaluating with "M-:" the lisp code "(ffap-string-at-point)" over them: ;; c:/Program Files/Open Text Evaluation Media/Open Text Exceed 14 x86/Program here.txt ;; c:/Program Files/Open Text Evaluation Media/Open Text Exceed 14 x86/Program Files/Hummingbird/ ;; c:\Program Files\Freescale\CW for MPC55xx and MPC56xx 2.10\PowerPC_EABI_Tools\Command_Line_Tools\CLT_Usage_Notes.txt It is not possible to test the above paths with "M-x ffap" as the code by design starts to chop path components if the path does not exist in current environment. See: (defun ffap-file-at-point () ...near the end.... ;; Try all parent directories by deleting the trailing directory ;; name until existing directory is found or name stops changing I'm sure the patch is not perfect as it's hard to come by a strategy to deal with spaces but it appears to give good results. I think users' would benefit from the space detection support. Thanks for Yigal Hochberg for testing the functionality in Windows, Jari