alphapapa / alphapapa/pocket-reader.el

Example of storing/loading individual articles with personal edits

Aperta
#47 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub
discussion
Lingua principale
Emacs Lisp
Stelle
224
Fork
11
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

Hey just to share a very hacky code, didn't write much emacs-lisp before.
I'd like to keep notes on articles I read or optionally save articles for offline reading.

Without building some fancy sync system I made reader open an article in a buffer that has a specific file assigned to it on disk, so while reading one can choose to edit, comment etc and/or save. If file is found next time you try to read the article, it will be read from the disk directly. Maybe this is interesting to someone or as an idea for some better implemented feature.

This hooks it only to "TAB" pocket-reader-pop-to-url

(Would be nice if pocket-reader-pop-to-url-default-function had an optional argument of title, pocket id etc provided to it, so I could name the file better)

```emacs-lisp
(defun pop-to-buffer-with-file (buffer file)
(with-current-buffer (get-buffer-create buffer)
(setq buffer-file-name file))
(pop-to-buffer buffer))

(defun encode-url-to-filename (url)
(let ((filename (replace-regexp-in-string "https?://" "" url)))
(setq filename (replace-regexp-in-string "www." "" filename))
(setq filename (replace-regexp-in-string "/" "-" filename))
filename))

(defun get-pocket-filename (url)
(concat "~/txt/pocket/" (encode-url-to-filename url) ".org"))

(defun my-pocket-reader-pop-to-url (url)
(let ((filename (get-pocket-filename url)))
(if (file-exists-p filename)
(pop-to-buffer (find-file-noselect filename))
(org-web-tools-read-url-as-org
url
:show-buffer-fn
(lambda (url)
(pop-to-buffer-with-file url filename))))))

(customize-set-variable 'pocket-reader-pop-to-url-default-function
#'my-pocket-reader-pop-to-url)

```

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.