all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#8439: [PATCH] ffap.el -- detect paths with spaces
@ 2011-04-07 15:24 Jari Aalto
  2012-10-19  8:35 ` bug#8439: [PATCH] ffap.el -- detect paths with spaces (v2) Jari Aalto
  0 siblings, 1 reply; 5+ 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] 5+ messages in thread

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

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <<87pqoyaxu0.fsf@blue.sea.net>
     [not found] ` <<87zk3i7tbu.fsf@picasso.cante.net>
     [not found]   ` <<jwvzk3ihr2i.fsf-monnier+emacs@gnu.org>
     [not found]     ` <<20121020075601.GD29154@picasso.cante.net>
     [not found]       ` <<20121020084551.GE29154@picasso.cante.net>
     [not found]         ` <<87mucmn2gs.fsf@gnus.org>
     [not found]           ` <<87tux574te.fsf@gnus.org>
     [not found]             ` <<83v9hkjmzb.fsf@gnu.org>
2020-08-15 19:33               ` bug#6695: bug#8439: [PATCH] ffap.el -- detect paths with spaces (v4) Drew Adams
2011-04-07 15:24 bug#8439: [PATCH] ffap.el -- detect paths with spaces Jari Aalto
2012-10-19  8:35 ` bug#8439: [PATCH] ffap.el -- detect paths with spaces (v2) Jari Aalto
2012-10-20  1:44   ` Stefan Monnier
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
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

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.