From: Xavier Capaldi <xcapaldi@scribo.biz>
To: 53638@debbugs.gnu.org
Subject: bug#53638: [PATCH] newsticker better path handling and data
Date: Sun, 15 May 2022 23:50:22 -0400 [thread overview]
Message-ID: <87y1z287b5.fsf@corydoras.i-did-not-set--mail-host-address--so-tickle-me> (raw)
In-Reply-To: <87h79lgg5n.fsf@protonmail.com>
[-- Attachment #1: Type: text/plain, Size: 283 bytes --]
Not sure if this bug report/patch is blocked but I faced the
`prin1-to-string` issue which is fixed by the patch here. I've attached
an updated patch that uses chained calls to `expand-file-name` instead
of `file-name-concat` since that was the last issue mentioned with the
patch.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: newsticker-patch-3.diff --]
[-- Type: text/x-patch, Size: 5474 bytes --]
diff --git a/lisp/net/newst-backend.el b/lisp/net/newst-backend.el
index a62a7bd8b7..d3610a2130 100644
--- a/lisp/net/newst-backend.el
+++ b/lisp/net/newst-backend.el
@@ -1697,11 +1697,13 @@ newsticker--update-process-ids
;; ======================================================================
(defun newsticker--images-dir ()
"Return directory where feed images are saved."
- (concat newsticker-dir "/images/"))
+ (file-name-as-directory
+ (expand-file-name "images" newsticker-dir)))
(defun newsticker--icons-dir ()
"Return directory where feed icons are saved."
- (concat newsticker-dir "/icons/"))
+ (file-name-as-directory
+ (expand-file-name "icons" newsticker-dir)))
(defun newsticker--image-get (feed-name filename directory url)
"Get image for FEED-NAME by returning FILENAME from DIRECTORY.
@@ -2114,7 +2116,8 @@ newsticker--cache-get-feed
(defun newsticker--cache-dir ()
"Return directory for saving cache data."
- (concat newsticker-dir "/feeds"))
+ (file-name-as-directory
+ (expand-file-name "feeds" newsticker-dir)))
(defun newsticker--cache-save ()
"Save cache data for all feeds."
@@ -2125,11 +2128,15 @@ newsticker--cache-save
(defun newsticker--cache-save-feed (feed)
"Save cache data for FEED."
- (let ((dir (concat (newsticker--cache-dir) "/" (symbol-name (car feed)))))
+ (let ((dir (file-name-as-directory
+ (expand-file-name (symbol-name (car feed))
+ (newsticker--cache-dir))))
+ (print-level nil)
+ (print-length nil))
(unless (file-directory-p dir)
(make-directory dir t))
(let ((coding-system-for-write 'utf-8))
- (with-temp-file (concat dir "/data")
+ (with-temp-file (expand-file-name "data" dir)
(insert ";; -*- coding: utf-8 -*-\n")
(insert (prin1-to-string (cdr feed)))))))
@@ -2141,7 +2148,7 @@ newsticker--cache-read
(defun newsticker--cache-read-feed (feed-name)
"Read cache data for feed named FEED-NAME."
- (let ((file-name (concat (newsticker--cache-dir) "/" feed-name "/data"))
+ (let ((file-name (expand-file-name "data" (expand-file-name feed-name (newsticker--cache-dir)))
(coding-system-for-read 'utf-8))
(when (file-exists-p file-name)
(with-temp-buffer
@@ -2334,14 +2343,15 @@ newsticker-download-images
"Download the first image.
If FEEDNAME equals \"imagefeed\" download the first image URL
found in the description=contents of ITEM to the directory
-\"~/tmp/newsticker/FEEDNAME/TITLE\" where TITLE is the title of
+`temporary-file-directory'/newsticker/FEEDNAME/TITLE where TITLE is the title of
the item."
(when (string= feedname "imagefeed")
(let ((title (newsticker--title item))
(desc (newsticker--desc item)))
(when (string-match "<img src=\"\\(http://[^ \"]+\\)\"" desc)
(let ((url (substring desc (match-beginning 1) (match-end 1)))
- (temp-dir (concat "~/tmp/newsticker/" feedname "/" title))
+ (temp-dir (file-name-as-directory
+ (expand-file-name title (expand-file-name feedname (expand-file-name "newsticker" temporary-file-directory)))))
(org-dir default-directory))
(unless (file-directory-p temp-dir)
(make-directory temp-dir t))
@@ -2355,7 +2368,8 @@ newsticker-download-images
(defun newsticker-download-enclosures (feedname item)
"In all feeds download the enclosed object of the news ITEM.
-The object is saved to the directory \"~/tmp/newsticker/FEEDNAME/TITLE\", which
+The object is saved to the directory
+`temporary-file-directory'/newsticker/FEEDNAME/TITLE, which
is created if it does not exist. TITLE is the title of the news
item. Argument FEEDNAME is ignored.
This function is suited for adding it to `newsticker-new-item-functions'."
@@ -2363,7 +2377,8 @@ newsticker-download-enclosures
(enclosure (newsticker--enclosure item)))
(when enclosure
(let ((url (cdr (assoc 'url enclosure)))
- (temp-dir (concat "~/tmp/newsticker/" feedname "/" title))
+ (temp-dir (file-name-as-directory
+ (expand-file-name title (expand-file-name feedname (expand-file-name "newsticker" temporary-file-directory)))))
(org-dir default-directory))
(unless (file-directory-p temp-dir)
(make-directory temp-dir t))
diff --git a/lisp/net/newst-treeview.el b/lisp/net/newst-treeview.el
index 80d9fd1cef..f90a03873f 100644
--- a/lisp/net/newst-treeview.el
+++ b/lisp/net/newst-treeview.el
@@ -1257,7 +1257,10 @@ newsticker-treeview-save
"Save treeview group settings."
(interactive)
(let ((coding-system-for-write 'utf-8)
- (buf (find-file-noselect (concat newsticker-dir "/groups"))))
+ (buf (find-file-noselect (expand-file-name "groups"
+ newsticker-dir)))
+ (print-length nil)
+ (print-level nil))
(when buf
(with-current-buffer buf
(setq buffer-undo-list t)
@@ -1270,7 +1273,8 @@ newsticker-treeview-save
(defun newsticker--treeview-load ()
"Load treeview settings."
(let* ((coding-system-for-read 'utf-8)
- (filename (concat newsticker-dir "/groups"))
+ (filename (concat (file-name-as-directory newsticker-dir)
+ "groups"))
(buf (and (file-exists-p filename)
(find-file-noselect filename))))
(when buf
next prev parent reply other threads:[~2022-05-16 3:50 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-30 19:47 bug#53638: [PATCH] newsticker better path handling and data storage mailj2--- via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-01-31 10:23 ` Robert Pluim
2022-01-31 12:19 ` Eli Zaretskii
2022-01-31 15:47 ` Lars Ingebrigtsen
2022-01-31 20:09 ` mailj2--- via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-02-01 3:25 ` Eli Zaretskii
2022-05-16 3:50 ` Xavier Capaldi [this message]
2022-05-16 12:04 ` bug#53638: [PATCH] newsticker better path handling and data Lars Ingebrigtsen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87y1z287b5.fsf@corydoras.i-did-not-set--mail-host-address--so-tickle-me \
--to=xcapaldi@scribo.biz \
--cc=53638@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).