all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [PATCH] checking eww download directory
@ 2017-01-27 19:10 Mark Oteiza
  2017-01-27 19:21 ` Lars Ingebrigtsen
                   ` (2 more replies)
  0 siblings, 3 replies; 15+ messages in thread
From: Mark Oteiza @ 2017-01-27 19:10 UTC (permalink / raw)
  To: emacs-devel; +Cc: Lars Ingebrigtsen


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
  welcome
- 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'."
   (interactive)
+  (access-file eww-download-directory "Download failed")
   (let ((url (get-text-property (point) 'shr-url)))
     (if (not url)
         (message "No URL under point")



^ permalink raw reply related	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2017-01-30 14:40 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-01-27 19:10 [PATCH] checking eww download directory Mark Oteiza
2017-01-27 19:21 ` Lars Ingebrigtsen
2017-01-27 19:48   ` Mark Oteiza
2017-01-27 20:10     ` Eli Zaretskii
2017-01-28  8:01       ` Yuri Khan
2017-01-28  8:54         ` Eli Zaretskii
2017-01-28 14:14     ` Lars Ingebrigtsen
2017-01-28 21:04       ` Mark Oteiza
2017-01-27 19:27 ` Lars Ingebrigtsen
2017-01-27 19:38 ` Clément Pit-Claudel
2017-01-27 20:17   ` Mark Oteiza
2017-01-27 22:21     ` Clément Pit-Claudel
2017-01-28  7:53     ` Eli Zaretskii
2017-01-29  1:01       ` Library for XDG things (was Re: [PATCH] checking eww download directory) Mark Oteiza
2017-01-30 14:40         ` Ted Zlatanov

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.