[Date Prev][Date Next][Thread Prev][][Date Index][Thread Index]

Re: emacs-w3m should better detect local files



On Wed, 10 May 2017 18:34:36 +0800, 積丹尼さん wrote:
> emacsclient -e '(w3m "./m.jidanni.org/facebook_notifications.html")'
> tries to go on the network. Only
> emacsclient -e '(w3m "/home/jidanni/m.jidanni.org/facebook_notifications.html")'
> finally tries the correct local file.
> In fact
> emacsclient -e '(w3m "m.jidanni.org/facebook_notifications.html")'
> should test if there is a local file there first, like other browsers do.

Ok.  I've committed the following changes:

,----
| Allow local file of which the name is not absolute ([emacs-w3m:12643])
|
| * w3m.el (w3m-canonicalize-url): Allow local file of relative name.
| * w3m-util.el (w3m-popup-buffer): Preserve the current directory.
`----

--- w3m-util.el~	2017-02-19 23:36:34 +0000
+++ w3m-util.el	2017-05-10 23:41:25 +0000
@@ -680,10 +680,12 @@
 	      (w3m-static-when (featurep 'xemacs)
 		(focus-frame frame))))
 	;; Simply switch to BUFFER in the current frame.
-	(if (w3m-popup-window-p)
-	    (let ((pop-up-windows t))
-	      (pop-to-buffer buffer))
-	  (switch-to-buffer buffer))
+	(let ((cd default-directory))
+	  (if (w3m-popup-window-p)
+	      (let ((pop-up-windows t))
+		(pop-to-buffer buffer))
+	    (switch-to-buffer buffer))
+	  (setq default-directory cd))
 	(w3m-history-restore-position)))))
 
 (eval-when-compile
--- w3m.el~	2017-02-03 06:47:46 +0000
+++ w3m.el	2017-05-10 23:41:25 +0000
@@ -213,7 +213,7 @@
 
 (defconst emacs-w3m-version
   (eval-when-compile
-    (let ((rev "$Revision: 1.1656 $"))
+    (let ((rev "$Revision: 1.1655 $"))
       (and (string-match "\\.\\([0-9]+\\) \\$\\'" rev)
 	   (setq rev (- (string-to-number (match-string 1 rev)) 1136))
 	   (format "1.4.%d" (+ rev 50)))))
@@ -4622,6 +4622,8 @@
 	(concat "\
 http://www.google.com/search?btnI=I%%27m+Feeling+Lucky&ie=UTF-8&oe=UTF-8&q="
 		(w3m-url-encode-string url nil t)))
+       ((file-exists-p url)
+	(concat "file://" (expand-file-name url)))
        (t
 	(concat "http://" url))))))