aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--emacs/.emacs.d/init/ycp-theme.el2
-rw-r--r--emacs/.emacs.d/init/ycp-time.el4
-rw-r--r--emacs/.emacs.d/lisp/my/belf.el62
-rw-r--r--emacs/.emacs.d/lisp/my/my-nov.el4
4 files changed, 66 insertions, 6 deletions
diff --git a/emacs/.emacs.d/init/ycp-theme.el b/emacs/.emacs.d/init/ycp-theme.el
index ee76311..2b58ba3 100644
--- a/emacs/.emacs.d/init/ycp-theme.el
+++ b/emacs/.emacs.d/init/ycp-theme.el
@@ -41,6 +41,8 @@
'normal :weight 'normal :height 150 :width 'normal)
(set-face-attribute 'fixed-pitch nil :family "Ubuntu Mono" :foundry "DAMA"
:slant 'normal :weight 'normal :height 150 :width 'normal)
+(set-face-attribute 'variable-pitch nil :family "Ubuntu" :foundry "DAMA"
+ :slant 'normal :weight 'normal :height 150 :width 'normal)
(provide 'ycp-theme)
;;; ycp-theme.el ends here
diff --git a/emacs/.emacs.d/init/ycp-time.el b/emacs/.emacs.d/init/ycp-time.el
index f98a9cd..f21061c 100644
--- a/emacs/.emacs.d/init/ycp-time.el
+++ b/emacs/.emacs.d/init/ycp-time.el
@@ -83,7 +83,7 @@
(holiday-fixed 1 26 "Australia Day (Vic holiday)")
(holiday-float 3 1 2 "Labour Day (Vic holiday)")
(holiday-fixed 4 25 "Anzac Day (Vic holiday)")
- (holiday-float 6 1 2 "Monarch's Birthday (Vic oliday)")
+ (holiday-float 6 1 2 "Monarch's Birthday (Vic holiday)")
(holiday-fixed 6 30 "End of financial year")
(holiday-float 9 5 -1 "(Possibly) Friday before the AFL Grand Final (Vic holiday)")
(holiday-float 10 5 1 "(Possibly) Friday before the AFL Grand Final (Vic holiday)")
@@ -123,7 +123,7 @@
(setq appt-display-interval 5)
;; dbus notification of appt
(require 'my-time)
- (setq appt-disp-window-function #'my-app-display-window)
+ (setq appt-disp-window-function #'my-appt-display-window)
;; with org-agenda-to-appt
(require 'org-clock)
(require 'my-utils)
diff --git a/emacs/.emacs.d/lisp/my/belf.el b/emacs/.emacs.d/lisp/my/belf.el
index 2811eb8..7eecf87 100644
--- a/emacs/.emacs.d/lisp/my/belf.el
+++ b/emacs/.emacs.d/lisp/my/belf.el
@@ -76,7 +76,7 @@
(defvar belf-dir "~/Documents" "Directory of books.")
-(defun belf-parse-all-file-names ()
+(defun belf-parse-file-names (file-names)
(seq-filter
#'identity
(seq-map
@@ -84,7 +84,10 @@
(when-let ((parsed (belf-parse-file-name f)))
(let-alist parsed
(list f (vector .authors .title .year)))))
- (directory-files belf-dir t "\\.\\(epub\\|pdf\\|cbr\\|djvu\\|mobi\\|azw3\\)$"))))
+ file-names)))
+
+(defun belf-parse-all-file-names ()
+ (belf-parse-file-names (directory-files belf-dir t "\\.\\(epub\\|pdf\\|cbr\\|djvu\\|mobi\\|azw3\\)$")))
(defun belf-file-name-desort (file-name new-dir)
"Rename a file.
@@ -352,12 +355,13 @@ For EPUB, looks for a cover image in the file."
(alist-get 'authors (belf-parse-file-name
(tabulated-list-get-id))))))
(let* ((file-name (tabulated-list-get-id))
+ (dir (file-name-directory file-name))
(parsed (belf-parse-file-name file-name))
new-base-name
new-file)
(setf (alist-get 'authors parsed) new-authors)
- (setq new-base-name (belf-format-base-name parsed))
- (dolist (file (directory-files belf-dir t
+ (setq new-base-name (belf-format-base-name parsed dir))
+ (dolist (file (directory-files dir t
(format "^%s\\.[a-zA-Z0-9]+$"
(regexp-quote
(file-name-base file-name)))))
@@ -448,4 +452,54 @@ Compare without leading \"The \"."
(interactive)
(find-file-other-window (tabulated-list-get-id)))
+(defvar belf-recent-file (locate-user-emacs-file "belf-list"))
+
+(defun belf-add-to-recent (file)
+ "Add FILE to `belf-recent-file'.
+
+Can be used as a `find-file-hook'."
+ (when (string-match-p "\\.\\(epub\\|pdf\\|cbr\\|djvu\\|mobi\\|azw3\\)$"
+ file)
+ (with-temp-buffer
+ (when (file-exists-p belf-recent-file)
+ (insert-file-contents belf-recent-file))
+ (goto-char (point-min))
+ (flush-lines (rx-to-string `(and bol "[" (= 23 anychar) "] " ,file eol)))
+ (insert
+ (format-time-string "[%Y-%m-%d %a %H:%M:%S]" (current-time))
+ " "
+ file
+ "\n")
+ (write-file belf-recent-file)
+ )))
+
+(defun belf-add-current-to-recent ()
+ (when buffer-file-name
+ (belf-add-to-recent buffer-file-name)))
+
+(define-derived-mode belf-recent-mode belf-mode "Bookshelf Recent"
+ "Major mode for browsing a list of books."
+ (setq revert-buffer-function #'belf-recent-list-refresh-contents))
+
+(defun belf-recent ()
+ (interactive)
+ (let ((buf (get-buffer-create "*Bookshelf Recent*")))
+ (with-current-buffer buf
+ (belf-recent-mode)
+ (belf-recent-list-refresh-contents))
+ (pop-to-buffer-same-window buf)))
+
+(defun belf-recent-list-refresh-contents (&rest _)
+ (setq-local tabulated-list-entries (belf-parse-recent-file-names))
+ (tabulated-list-print))
+
+(defun belf-parse-recent-file-names ()
+ (with-temp-buffer
+ (when (file-exists-p belf-recent-file)
+ (insert-file-contents belf-recent-file))
+ (goto-char (point-min))
+ (replace-regexp (rx bol (= 26 anychar)) "")
+ (belf-parse-file-names (string-lines (buffer-string))))
+ )
+
(provide 'belf)
diff --git a/emacs/.emacs.d/lisp/my/my-nov.el b/emacs/.emacs.d/lisp/my/my-nov.el
index 9a819c7..0246be2 100644
--- a/emacs/.emacs.d/lisp/my/my-nov.el
+++ b/emacs/.emacs.d/lisp/my/my-nov.el
@@ -45,6 +45,10 @@ chapter title."
(concat title ": " chapter-title))
))
+(defun my-nov-render-span (dom)
+ (unless (equal (dom-attr dom 'epub:type) "pagebreak")
+ (shr-generic dom)))
+
(defun my-nov-find-file-with-ipath (file-name ipath)
"Find epub file and goto IPATH.