The week of sick leave was quite productive :). I wrote my first Elisp app. Comments, advices and free Elisp lessons are appeciated :) Bread and Bread-library: Book-reader for Emacs ============================================== Author: Dmitri Minaev Date: 2008/05/04 07:57:32 AM Table of Contents ================= 1 Intro 2 What ebook reading software should do 2.1 Catalog 2.2 Book reader 3 Bread-mode: mode for reading Fictionbook2 books 4 Bread-library: cataloging ebooks 5 Installation 5.1 Supporting packages 5.1.1 Required 5.1.2 Recommended 6 Todo 1 Intro ~~~~~~~ I miss good Linux software for keeping a catalog of ebooks and for reading ebooks. It's strange that such software hasn't yet been written. Or has it? There are some general cataloging applications, like Alexandria and Tellico. They miss some necessary features, though. Anyway, I would prefer an Emacs-based ebook reader to any other GUI or console tool. Almost all parts of such book-reading software are already written: Org-mode for the catalogue, standard bookmarks to remember positions, view-mode for comfortable scrolling, etc. Why not put them all together? 2 What ebook reading software should do ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2.1 Catalog =========== 1. Various views of the collection: - by title; - by author; - by genre. 2. Tagging and search by tags. 3. Rating books and sorting by rating. 4. Annotations. 5. Track state: books to read, read books, unfinished books. 6. Automatic cataloging: add new files from a library directory. 2.2 Book reader =============== This part is less important for me, because I prefer my Hanlin Ereader v3 to reading from LCD screen. 1. Support multiple file formats: txt, html, pdf and fb2 (Fictionbook2, xml-based format developed specifically for fiction texts, see [Fictionbook.org] for specification and [Fictionbook.ru] for books in fb2). For graphics-enabled formats, images should be displayed. 2. Support footnotes and hyperlinks. 3. Save and restore positions in books. 4. Include a bookmark manager. 3 Bread-mode: mode for reading Fictionbook2 books ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Currently, it's just a tiny hack. Bread-mode doesn't support footnotes, hyperlinks, images and text formatting. Bread-mode turns on sgml-mode, calls `sgml-tags-invible' to hide all tags, enables longlines-mode for better readability and switches to view-mode. The result is more or less acceptable for most Fictionbook2 files Bookmarks are standard Emacs bookmarks. Current positions may be memorized with `session.el', for example. 4 Bread-library: cataloging ebooks ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Bread-library keeps a list of ebooks on your hard disk and provides a way to sort, search, categorize, rate and annotate them. The first idea was to clone the Emms-browser. I began copying and pasting, but then I found what seems to be a better alternative. For more than 1 year I used to keep my reading journal in Emacs Org-mode. I have developed a file structure that I find very useful. 1. Categories are used to rate books from 0 to 9. 2. Every book may be in one of the following states: TOREAD, READING, POSTPONED, THROWNAWAY and DONE. 3. Books are tagged to classify them by genres. The most used tags are: `autobiographical', `fiction', `nonfiction', `modernclassics', `crypto', `math', `science', `scifi', `philosophy', `history', `geography', `politics', `fairytale', `kids'. I wanted to keep this setup in Bread mode. It meant that the book manager should use Org-mode. However, processing information stored in a weakly formalized text may be a non-trivial task. Of course, the most straight-forward way to solve the task would be to use sexps as back-end for the information storage and processing. Sexps could be easily manipulated to sort and group the books in whatever way we want. Sexps are not the most efficient storage speedwise, but I wanted to see how many books may be stored in such sexp-database before efficiency problems make me re-write Bread-library with hashes. Now, I know that Bread-library copes, at least, with 400 books. I've got a feeling, though, that the reply will slow down noticeably with 600-800 books. After installation, Bread-library is launched with `bread-library-browse' command. It loads the data from `~/.bread-library' file and renders its contents into Org-mode. Bread-library defines a minor mode, `bread-library-mode', which provides the following additional keybindings: - `C-x g g': group books by genre and by author; - `C-x g a': group books by author (the default view); - `C-x g t': sort books by title; - `C-x x': quit Bread library, saving the database. The rendered Org file is an (almost) fully functional Org file. Clicking on the hyperlink will open the file. You can use `S-Left' and `S-Right' to switch states of the books, or use `S-Up' and `S-Down' to set rating. You can set and modify tags with `C-c C-c'. `C-c \' will search by tags. You can edit the entries and the changes will be saved. The only trick is that the name of the author, the title, genre and file path are stored in the properties of the entry, not in its header. The changes made in the header and in the hyperlink will not be saved. You can even add new entries in this buffer, as long as you stick to the format of the entries. However, a more comfortable way to add books to the catalog is using a tiny function from Dired (see below, under Installation. When a book is added through Dired, Bread-library attempts to extract metadata from the file. Currently, Bread-library can do it for Fictionbook2 files only (and imperfectly). 5 Installation ~~~~~~~~~~~~~~ 1. Put bread.el and bread-library.el into a directory in your load-path. 2. Set up Org-mode. 3. Add to the init file the following code: (eval-after-load "dired" '(define-key dired-mode-map "\C-xl" 'dired-bread-add-book)) (defun dired-bread-add-book () (interactive) (bread-library-add-book (dired-get-filename))) (autoload 'bread-mode "bread" "Fictionbook2 mode" t) (add-to-list 'auto-mode-alist '("\\.fb2$" . bread-mode)) 5.1 Supporting packages ======================= 5.1.1 Required -------------- 1. Org-mode 2. Sgml-mode 3. Dired 5.1.2 Recommended ----------------- 1. session.el 6 Todo ~~~~~~ 1. Enhance metadata extraction for fb2 files. 2. Extract metadata from other files. 3. Learn more on Emacs regexps :). 4. Modify Org-mode hyperlinks to use only certain modes: doc-view for PDF, w3m for html, etc. 5. Images for fb2. 6. Mass addition of books by traversing the given directory. 7. Add support of zipped files. 8. Add Org-mode tags selection to bread-library-add-book. 9. Offer a list of already used genres when adding new books. 10. Lots more :) -- With best regards, Dmitri Minaev Russian history blog: http://minaev.blogspot.com