I'm attending a conference, and I have downloaded all abstracts so I can read them offline. They are all html files with the same structure.
The files are numbered according to abstract submission number, so 0001.html, 0002.html, 0003.html etc.
If I run a find-file
, it doesn't help me much in finding abstracts by name.
What I would like to do is for find-file
to not prompt me for filenames, but for the title that is within the html file. When I select a title, Emacs opens the html file with eww-browse-url
.
Here's what I have so far:
I can extract the titles with:
(defun read-html-into-dom (html)
(with-temp-buffer
(insert-file-contents html)
(libxml-parse-html-region (point-min) (point-max))))
(defun abstract-extract-title (html)
(let ((title (car (dom-by-class (read-html-into-dom html) "submissionTitle"))))
(if title
(dom-text title)
"No title")))
and I can open the abstracts by filename with:
(defun conference--find-abstract-file ()
(interactive)
(let ((default-directory conference-dir))
(concat "file://"
(expand-file-name (read-file-name "Choose abstract:")))))
(defun conference-find-abstract ()
(interactive)
(eww-browse-url (call-interactively #'conference--find-abstract-file)))
How could I combine these two, such that when I call conference-find-abstract
it runs over all filenames and shows me the titles?
I know I have to change conference--find-abstract-file
, but I'm lost at how to do this transformation, since eww-browse-url
needs filenames.
Any examples of similar problems and solutions, or names of functions that could help me would be welcome. I suppose I'm looking for a common pattern, but don't know what it is called.