unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#8439: [PATCH] ffap.el -- detect paths with spaces
@ 2011-04-07 15:24 Jari Aalto
  2011-07-03 23:29 ` Lars Magne Ingebrigtsen
                   ` (2 more replies)
  0 siblings, 3 replies; 29+ messages in thread
From: Jari Aalto @ 2011-04-07 15:24 UTC (permalink / raw)
  To: 8439

[-- Attachment #1: Type: text/plain, Size: 1015 bytes --]

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@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


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-lisp-ffap.el-ffap-string-at-point-Support-spaces-in-.patch --]
[-- Type: text/x-diff, Size: 2950 bytes --]

From 0706445da3f7e10aceef8b371d458deb4ec1c39d Mon Sep 17 00:00:00 2001
From: Jari Aalto <jari.aalto@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@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


^ permalink raw reply related	[flat|nested] 29+ messages in thread

end of thread, other threads:[~2020-08-15 10:13 UTC | newest]

Thread overview: 29+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-04-07 15:24 bug#8439: [PATCH] ffap.el -- detect paths with spaces Jari Aalto
2011-07-03 23:29 ` Lars Magne Ingebrigtsen
2012-10-19  7:39 ` bug#8439: [PATCH] ffap.el -- detect paths with spaces (v2) Jari Aalto
2012-10-19  9:49   ` Eli Zaretskii
2012-10-19 10:05     ` jari
2012-10-19 11:15       ` Yigal Hochberg
2012-10-19 11:22       ` Eli Zaretskii
2012-10-19 12:15       ` Nicolas Richard
2012-10-19 21:47     ` Andrew W. Nosenko
2012-10-19 22:23       ` Eli Zaretskii
2012-10-19 22:36       ` Yigal Hochberg
2012-10-19 22:57         ` Andrew W. Nosenko
2012-10-19 23:24         ` Yigal Hochberg
2012-10-20  1:45       ` Stefan Monnier
2012-10-20 11:01       ` Juri Linkov
2012-10-19  8:35 ` Jari Aalto
2012-10-20  1:44   ` Stefan Monnier
2012-10-20  1:49     ` Daniel Colascione
2012-10-20  7:56     ` bug#8439: [PATCH] ffap.el -- detect paths with spaces (v3) jari
2012-10-20  8:45       ` bug#8439: [PATCH] ffap.el -- detect paths with spaces (v4) jari
2012-10-20 10:20         ` Eli Zaretskii
2012-10-21  0:18         ` Stefan Monnier
2012-10-21  8:07           ` Jari Aalto
2019-11-23 13:31         ` bug#6695: " Lars Ingebrigtsen
2020-08-14 13:08           ` Lars Ingebrigtsen
2020-08-15  9:07             ` Eli Zaretskii
2020-08-15 10:13               ` Lars Ingebrigtsen
2012-10-20  8:11     ` bug#8439: [PATCH] ffap.el -- detect paths with spaces (v2) Eli Zaretskii
2012-10-21  0:16       ` Stefan Monnier

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).