aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--emacs/.emacs.d/init/ycp-markup.el1
-rw-r--r--emacs/.emacs.d/init/ycp-reading.el4
-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.el64
-rw-r--r--emacs/.emacs.d/lisp/my/my-libgen.el20
-rw-r--r--emacs/.emacs.d/lisp/my/my-nov.el4
7 files changed, 92 insertions, 7 deletions
diff --git a/emacs/.emacs.d/init/ycp-markup.el b/emacs/.emacs.d/init/ycp-markup.el
index 6a6e8b8..c90dc6a 100644
--- a/emacs/.emacs.d/init/ycp-markup.el
+++ b/emacs/.emacs.d/init/ycp-markup.el
@@ -115,6 +115,7 @@
(my-keybind nov-mode-map
"Q" #'my-nov-copy-buffer-file-with-staging
"i" #'imenu)
+ (add-to-list 'nov-shr-rendering-functions '(span . my-nov-render-span))
)
;;; json-mode
diff --git a/emacs/.emacs.d/init/ycp-reading.el b/emacs/.emacs.d/init/ycp-reading.el
index 24c47d0..477aa5d 100644
--- a/emacs/.emacs.d/init/ycp-reading.el
+++ b/emacs/.emacs.d/init/ycp-reading.el
@@ -27,6 +27,8 @@
;;; Code:
(my-package belf
- (my-setq-from-local belf-dir))
+ (my-setq-from-local belf-dir)
+ (add-hook 'find-file-hook 'belf-recent-add-current)
+ (blink-cursor-mode 0))
(provide 'ycp-reading)
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..8a4a9f0 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,56 @@ Compare without leading \"The \"."
(interactive)
(find-file-other-window (tabulated-list-get-id)))
+;;; belf-recent
+
+(defvar belf-recent-file (locate-user-emacs-file "belf-list"))
+
+(defun belf-recent-add (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-recent-add-current ()
+ (when buffer-file-name
+ (belf-recent-add 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-recent-parse-file-names))
+ (tabulated-list-print))
+
+(defun belf-recent-parse-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-libgen.el b/emacs/.emacs.d/lisp/my/my-libgen.el
index fac7cb0..d4efb30 100644
--- a/emacs/.emacs.d/lisp/my/my-libgen.el
+++ b/emacs/.emacs.d/lisp/my/my-libgen.el
@@ -186,6 +186,25 @@
nil
(lambda () (my-libgen-check-md5 filename md5)))))
+(defun my-libgen-plus-edition-infobox (edition-id)
+ (let ((dom (my-url-fetch-dom
+ (format "%s/edition.php?id=%s" my-libgen-plus-host edition-id))))
+ (infobox-render-string
+ (with-temp-buffer
+ (insert (mapconcat (lambda (p) (dom-texts p ""))
+ (dom-by-tag (dom-by-class dom "order-2") 'p) "\n"))
+ (shr-insert-document (dom-by-class dom "order-5"))
+ (buffer-string))
+ `(my-libgen-plus-edition-infobox ,edition-id)
+ (called-interactively-p 'interactive)
+ )
+ ))
+
+(defun my-libgen-plus-infobox-action ()
+ (interactive)
+ (my-libgen-plus-edition-infobox
+ (alist-get 'edition-id (get-text-property (point) 'button-data))))
+
(defun my-libgen-check-md5 (file md5)
(let ((actual (substring (my-call-process-out "md5sum" file) 0 32)))
(unless (equal actual md5)
@@ -224,6 +243,7 @@
(let ((kmap (make-sparse-keymap)))
(set-keymap-parent kmap button-map)
(define-key kmap "d" 'my-libgen-plus-download-action)
+ (define-key kmap "i" 'my-libgen-plus-infobox-action)
;; (define-key kmap "t" 'my-libgen-download-onion-action)
;; (define-key kmap "p" 'my-libgen-show-more-info)
kmap))
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.