]> git.eshelyaron.com Git - emacs.git/commitdiff
Make ffap correctly guess remote file names at point
authorVisuwesh <visuweshm@gmail.com>
Tue, 12 Dec 2023 15:44:12 +0000 (21:14 +0530)
committerEshel Yaron <me@eshelyaron.com>
Sat, 23 Dec 2023 09:32:43 +0000 (10:32 +0100)
* lisp/ffap.el (ffap-lax-url): Set it to nil so that remote file
names may be matched.
(ffap-fixup-email): New function.
(ffap-guesser): Specially handle email addresses now that
'ffap-lax-url' is nil, as user@host fails to be matched as an
email address with that setting.  (Bug#67688)

* etc/NEWS: Announce the new value of the defcustom.

(cherry picked from commit cbbb19ced674dc8c42c95238577abb9849a75b87)

etc/NEWS
lisp/ffap.el

index 759a342a02e891d3f75fbdbd1abf41d0f204d37c..4c5c176bcce7bcd6ba19e3a2a4dff2cfc2dec0b9 100644 (file)
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -291,6 +291,10 @@ actually jump to in the *Register Preview* buffer.
 When answering the prompt with "diff" or "=", it now shows the diffs
 between the auto save file and the current file.
 
+---
+** 'ffap-lax-url' now defaults to nil.
+Previously, it was set to 'ffap-lax-url' to t but this broke remote file
+name detection.
 
 \f
 * Editing Changes in Emacs 30.1
index 530e3da182e482e9adfa785c74974bede928b2a7..9cea11cf540610a2b1e683398ba8c5cdb906a84d 100644 (file)
@@ -152,15 +152,15 @@ schemes (e.g. \"ftp\"); in that case, only convert those URLs."
   :group 'ffap
   :version "24.3")
 
-(defcustom ffap-lax-url t
+(defcustom ffap-lax-url nil
   "If non-nil, allow lax URL matching.
 The default non-nil value might produce false URLs in C++ code
 with symbols like \"std::find\".  On the other hand, setting
 this to nil will disable recognition of URLs that are not
-well-formed, such as \"user@host\" or \"<user@host>\"."
+well-formed."
   :type 'boolean
   :group 'ffap
-  :version "25.2")                      ; nil -> t
+  :version "30.1")
 
 (defcustom ffap-ftp-default-user "anonymous"
   "User name in FTP file names generated by `ffap-host-to-filename'.
@@ -609,6 +609,13 @@ Looks at `ffap-ftp-default-user', returns \"\" for \"localhost\"."
    ((and ffap-url-unwrap-remote (ffap-url-unwrap-remote url)))
    (url)))
 
+(defun ffap-fixup-email (email)
+  "Clean up EMAIL and return it as a mailto: URL."
+  (when (stringp email)
+    (if (string-prefix-p "mailto:" email)
+        email
+      (concat "mailto:" email))))
+
 \f
 ;;; File Name Handling:
 
@@ -1571,6 +1578,7 @@ Uses the face `ffap' if it is defined, or else `highlight'."
           (ffap-fixup-url (or (ffap-url-at-point)
                               (ffap-gopher-at-point))))
       (ffap-file-at-point)             ; may yield url!
+      (ffap-fixup-email (thing-at-point 'email))
       (ffap-fixup-machine (ffap-machine-at-point))))
 
 (defun ffap-prompter (&optional guess suffix)