aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2019-11-09 13:32:20 -0500
committerStefan Monnier2019-11-09 17:34:45 -0500
commit8685db187b891bcadcf61e41dea3124e4c45b7d4 (patch)
tree741b5decdb0e36ab9ca4f8da2487f440b164b12d
parent027f218ad227c3966df94b22566c2e89a307362d (diff)
downloademacs-8685db187b891bcadcf61e41dea3124e4c45b7d4.tar.gz
emacs-8685db187b891bcadcf61e41dea3124e4c45b7d4.zip
* lisp/ffap.el (ffap-read-file-or-url): Don't use url-file-handler
Simplify accordingly (and don't call substitute-in-file-name redundantly).
-rw-r--r--lisp/ffap.el39
1 files changed, 12 insertions, 27 deletions
diff --git a/lisp/ffap.el b/lisp/ffap.el
index a3a191c5ae0..2954faa88a8 100644
--- a/lisp/ffap.el
+++ b/lisp/ffap.el
@@ -1405,34 +1405,19 @@ which may actually result in an URL rather than a filename."
1405 (or guess (setq guess default-directory)) 1405 (or guess (setq guess default-directory))
1406 ;; Tricky: guess may have or be a local directory, like "w3/w3.elc" 1406 ;; Tricky: guess may have or be a local directory, like "w3/w3.elc"
1407 ;; or "w3/" or "../el/ffap.el" or "../../../" 1407 ;; or "w3/" or "../el/ffap.el" or "../../../"
1408 (unless (or (ffap-url-p guess) 1408 (if (ffap-url-p guess)
1409 (ffap-file-remote-p guess)) 1409 ;; FIXME: We earlier tried to make use of `url-file-handler' so
1410 (setq guess 1410 ;; `read-file-name' could also be used for URLs, but it
1411 (abbreviate-file-name (expand-file-name guess)))) 1411 ;; introduced all kinds of subtle breakage such as:
1412 (if (and (ffap-url-p guess) 1412 ;; - (file-name-directory "http://a") returning "http://a/"
1413 ;; Exclude non-filename-like URLs like "mailto:..." 1413 ;; - Trying to contact remote hosts with no justification
1414 (not (string-match "\\`[a-z]+://" guess))) 1414 ;; These should be fixed in url-handler-mode before we can try
1415 ;; using it here again.
1415 (read-string prompt guess nil nil t) 1416 (read-string prompt guess nil nil t)
1416 (let ((fnh-elem (cons ffap-url-regexp #'url-file-handler))) 1417 (unless (ffap-file-remote-p guess)
1417 ;; Explain to `rfn-eshadow' that we can use URLs here. 1418 (setq guess (abbreviate-file-name (expand-file-name guess))))
1418 (push fnh-elem file-name-handler-alist) 1419 (read-file-name prompt (file-name-directory guess) nil nil
1419 (unwind-protect 1420 (file-name-nondirectory guess))))
1420 (let* ((dir (file-name-directory guess))
1421 ;; FIXME: If `guess' is "http://a" url-handler
1422 ;; somehow returns "https://a/" for the directory and
1423 ;; "a" for the non-directory!
1424 (broken-dir (> (length dir) (length guess))))
1425 (setq guess
1426 (read-file-name prompt (if broken-dir guess dir) nil nil
1427 (unless broken-dir
1428 (file-name-nondirectory guess)))))
1429 ;; Remove the special handler manually. We used to just let-bind
1430 ;; file-name-handler-alist to preserve its value, but that caused
1431 ;; other modifications to be lost (e.g. when Tramp gets loaded
1432 ;; during the completing-read call).
1433 (setq file-name-handler-alist (delq fnh-elem file-name-handler-alist))))
1434 (or (ffap-url-p guess)
1435 (substitute-in-file-name guess))))
1436 1421
1437;; The rest of this page is just to work with package complete.el. 1422;; The rest of this page is just to work with package complete.el.
1438;; This code assumes that you load ffap.el after complete.el. 1423;; This code assumes that you load ffap.el after complete.el.