[Top][All Lists]

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

[PATCH] checking eww download directory

From: Mark Oteiza
Subject: [PATCH] checking eww download directory
Date: Fri, 27 Jan 2017 14:10:51 -0500

Two things:

- it would be nice if eww looked a little harder for an existing
  downloads directory.  Perhaps what's below is too much, comments
- currently if eww-download-directory isn't accessible, emacs will
  download a file and the sentinel will fail, and one is left with a
  hidden buffer with the downloaded contents and no saved file.  Easy
  solution: fail early by checking with access-file

diff --git a/lisp/net/eww.el b/lisp/net/eww.el
index 0282fe68e6..6c62729849 100644
--- a/lisp/net/eww.el
+++ b/lisp/net/eww.el
@@ -55,9 +55,20 @@ eww-search-prefix
   :group 'eww
   :type 'string)
-(defcustom eww-download-directory "~/Downloads/"
+(defcustom eww-download-directory
+  (cond
+   ((memq system-type '(ms-dos windows-nt cygwin))
+    (expand-file-name "Downloads" (getenv "USERPROFILE")))
+   ((cl-some
+     (lambda (str)
+       (let ((f (expand-file-name str "~")))
+         (and (file-directory-p f)
+              (string-match-p "downloads?" (downcase f))
+              (abbreviate-file-name f))))
+     (directory-files "~")))
+   (t "~/Downloads/"))
   "Directory where files will downloaded."
-  :version "24.4"
+  :version "26.1"
   :group 'eww
   :type 'directory)
@@ -1501,6 +1512,7 @@ eww-copy-page-url
 (defun eww-download ()
   "Download URL under point to `eww-download-directory'."
+  (access-file eww-download-directory "Download failed")
   (let ((url (get-text-property (point) 'shr-url)))
     (if (not url)
         (message "No URL under point")

reply via email to

[Prev in Thread] Current Thread [Next in Thread]