Subject: 24.3.91; Improvements for ffap

From: Ivan Andrus <[email-masked]>
Date: Sat, 7 Jun 2014 01:51:02 -0600

Find file at point has two annoyances for me (I've rebound C-x C-f to ffap).

The first is that closing xml tags take me to the root directory since
they start with "/".  I fixed by simply disallowing "/" as a valid match
in this case.

The second is that when editing C++ code, namespaced functions (like
std::find) get picked up as URLs.  I changed this by adding an option.
I personally haven't found a reason for it to be non-nil (use lax
matching), but I presume there must have been one so I defaulted to no
behavior change.

Here's a proposed ChangeLog entry (please let me know if the format is wrong):

2014-06-07  Ivan Andrus  <[email-masked]>

	* ffap.el (ffap-url-at-point): Added `ffap-lax-url' to disallow
	lax URL matching.
	(ffap-file-at-point): Disallow "/" so closing xml tags don't
	interfere.

Thanks,
Ivan

diff --git a/lisp/ffap.el b/lisp/ffap.el
index 119e0ad..e36e613 100644
--- a/lisp/ffap.el
+++ b/lisp/ffap.el
@@ -163,6 +163,12 @@ schemes (e.g. \"ftp\"); in that case, only convert those URLs."
   :group 'ffap
   :version "24.3")

+(defcustom ffap-lax-url t
+  "If non-nil, allow lax URL matching."
+  :type 'boolean
+  :group 'ffap
+  :version "24.4")
+
(defcustom ffap-ftp-default-user "anonymous"
   "User name in FTP file names generated by `ffap-host-to-path'.
Note this name may be omitted if it equals the default
@@ -1096,7 +1102,7 @@ Assumes the buffer has not changed."
	     (w3-view-this-url t))
	(let ((thing-at-point-beginning-of-url-regexp ffap-url-regexp)
	      (thing-at-point-default-mail-uri-scheme ffap-foo-at-bar-prefix))
-	  (thing-at-point-url-at-point t
+	  (thing-at-point-url-at-point ffap-lax-url
				       (if (use-region-p)
					   (cons (region-beginning)
						 (region-end))))))))
@@ -1253,7 +1259,8 @@ which may actually result in an URL rather than a filename."
                         (not (ffap-file-exists-string dir))
                         (not (equal dir (setq dir (file-name-directory
                                                    (directory-file-name dir)))))))
-            (ffap-file-exists-string dir)))
+            (and (not (string= dir "/"))
+		 (ffap-file-exists-string dir))))
	 )
       (set-match-data data))))