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 Date: Thu, 07 Apr 2011 18:24:39 +0300 Message-ID: <87pqoyaxu0.fsf@blue.sea.net> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: dough.gmane.org 1302190649 882 80.91.229.12 (7 Apr 2011 15:37:29 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 7 Apr 2011 15:37:29 +0000 (UTC) To: 8439@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Apr 07 17:37:25 2011 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Q7rGu-0002zQ-51 for geb-bug-gnu-emacs@m.gmane.org; Thu, 07 Apr 2011 17:37:24 +0200 Original-Received: from localhost ([127.0.0.1]:36701 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Q7rGt-0006XX-J4 for geb-bug-gnu-emacs@m.gmane.org; Thu, 07 Apr 2011 11:37:23 -0400 Original-Received: from [140.186.70.92] (port=57142 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Q7rGo-0006XJ-Ll for bug-gnu-emacs@gnu.org; Thu, 07 Apr 2011 11:37:19 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Q7rGn-0002R4-Bz for bug-gnu-emacs@gnu.org; Thu, 07 Apr 2011 11:37:18 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:54778) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Q7rGn-0002Qu-8U for bug-gnu-emacs@gnu.org; Thu, 07 Apr 2011 11:37:17 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1Q7r4w-0001wD-AY; Thu, 07 Apr 2011 11:25:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Jari Aalto Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: owner@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 07 Apr 2011 15:25:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 8439 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: submit@debbugs.gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.13021898927432 (code B ref -1); Thu, 07 Apr 2011 15:25:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 7 Apr 2011 15:24:52 +0000 Original-Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Q7r4m-0001vo-BO for submit@debbugs.gnu.org; Thu, 07 Apr 2011 11:24:52 -0400 Original-Received: from emh05.mail.saunalahti.fi ([62.142.5.111]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Q7r4j-0001vc-PY for submit@debbugs.gnu.org; Thu, 07 Apr 2011 11:24:51 -0400 Original-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 ; Thu, 7 Apr 2011 18:24:43 +0300 (EEST) Original-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 Original-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 ; Thu, 7 Apr 2011 18:24:39 +0300 (EEST) Mail-Copies-To: poster X-Antivirus: VAMS X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Resent-Date: Thu, 07 Apr 2011 11:25:02 -0400 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) 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: , Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:45678 Archived-At: --=-=-= 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 * 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 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 --- 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 --=-=-=--