Skip to content

Commit

Permalink
Rename library.el to bibliothek.el.
Browse files Browse the repository at this point in the history
  • Loading branch information
cadadr committed Jan 11, 2018
1 parent 28d7339 commit 188e6d4
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 51 deletions.
6 changes: 3 additions & 3 deletions Readme.org
Expand Up @@ -48,14 +48,14 @@ the moment. I'd be happy to accept changes or to hand it over if
anybody will be interested.
#+END_QUOTE

** =library.el=
«library.el» is a personal PDF library manager. Presently it only
** =bibliothek.el=
«bibliothek.el» is a personal PDF library manager. Presently it only
displays a concatenated tabular list of PDF files from many locations,
and allows to open the files or view metadata from that list. Find
below a screenshot of the default view. I intend to add some
functionality for moving PDF files around and editing the metadata.

[[./library.png]]
[[./bibliothek.png]]

** =gk-unilat.el=
«gk-unilat» is a unified input method for European variants of the
Expand Down
96 changes: 48 additions & 48 deletions library.el → bibliothek.el
@@ -1,11 +1,11 @@
;;; library.el --- Managing a digital library of PDFs -*- lexical-binding: t; -*-
;;; bibliothek.el --- Managing a digital library of PDFs -*- lexical-binding: t; -*-

;; Copyright (C) 2018 Göktuğ Kayaalp

;; Author: Göktuğ Kayaalp <self@gkayaalp.com>
;; Version: 0.1.0
;; Keywords: tools
;; URL: http://gkayaalp.com/emacs.html#library.el
;; URL: http://gkayaalp.com/emacs.html#bibliothek.el
;; Package-Requires: ((emacs "24.4") (pdf-tools "0.70"))

;; This program is free software; you can redistribute it and/or modify
Expand All @@ -23,34 +23,34 @@

;;; Commentary:

;; Library.el is a management tool for a library of PDFs. Or it
;; Bibliothek.el is a management tool for a library of PDFs. Or it
;; aspires to be so. It's quite fresh ATM, it'll grow as it gets
;; used more.

;; Presently, library.el displays PDF files from directories in
;; ‘library-path’ in a tabulated list [1], where the user can view the
;; Presently, bibliothek.el displays PDF files from directories in
;; ‘bibliothek-path’ in a tabulated list [1], where the user can view the
;; file related to row under point (RET on the button or ‘f’ anywhere
;; on the row by default) or bring up a buffer detailed with PDF
;; metadata of that file (bound to ‘i’ by default). Also,
;; ‘tabulated-list-mode’ provides an interactive buffer header, where
;; by clicking the column headers, the table can be sorted.

;; Some more documentation may be present in the docstring for the
;; ‘library’ command.
;; ‘bibliothek’ command.



;;;; Installation:

;; Library.el depends on ‘pdf-tools’.
;; Bibliothek.el depends on ‘pdf-tools’.

;; After putting a copy of library.el in a directory in the
;; ‘load-path’, library.el can be configured as such:
;; After putting a copy of bibliothek.el in a directory in the
;; ‘load-path’, bibliothek.el can be configured as such:

;; (require 'library)
;; (setq library-path (list "~/Documents"))
;; (require 'bibliothek)
;; (setq bibliothek-path (list "~/Documents"))

;; Then, the Library interface can be brought up via M-x library RET.
;; Then, the Bibliothek interface can be brought up via M-x bibliothek RET.

;; [1] (see (info "(elisp) Tabulated List Mode"))

Expand All @@ -66,35 +66,35 @@

;;;; Customisables:

(defgroup library
(defgroup bibliothek
nil
"Customisations for library.el, digital PDF library manager."
"Customisations for bibliothek.el, digital PDF library manager."
:group 'emacs
:prefix "library-")
:prefix "bibliothek-")

(defvar library-path nil "A list of paths to look for PDF files.")
(defvar bibliothek-path nil "A list of paths to look for PDF files.")



;;;; Helper functions:

(defun library--assoca (keyseq list)
(defun bibliothek--assoca (keyseq list)
"Arbitrary depth multi-level alist query."
(let ((ks (if (listp keyseq) keyseq (list keyseq)))
(ret list))
(dolist (k ks ret)
(setq ret (cdr (assoc k ret))))))

(defun library--items ()
"Extract all the PDF files from each directory in ‘library-path’."
(defun bibliothek--items ()
"Extract all the PDF files from each directory in ‘bibliothek-path’."
(let (items)
(dolist (directory library-path items)
(dolist (directory bibliothek-path items)
(dolist (file (directory-files directory t "\\.pdf$" t))
(cl-pushnew (cons (cons 'library--filename file)
(cl-pushnew (cons (cons 'bibliothek--filename file)
(pdf-info-metadata file))
items)))))

(defun library--find (&optional marker)
(defun bibliothek--find (&optional marker)
"Open the PDF file for the row under point.
Optional argument MARKER is passed in when this function is
called from a button."
Expand All @@ -110,12 +110,12 @@ called from a button."
(tabulated-list-get-id))))

;; Adapted from ‘pdf-misc-display-metadata’.
(defun library--display-metadata (path)
(defun bibliothek--display-metadata (path)
"Display PDF metadata for file at PATH."
(interactive)
(let* ((md (pdf-info-metadata path)))
(switch-to-buffer
(with-current-buffer (get-buffer-create "*Library Item Metadata*")
(with-current-buffer (get-buffer-create "*Bibliothek Item Metadata*")
(let* ((inhibit-read-only t)
(pad (apply'
max (mapcar (lambda (d) (length (symbol-name (car d)))) md)))
Expand All @@ -141,64 +141,64 @@ called from a button."
(current-buffer)))
nil))

(defun library--info ()
(defun bibliothek--info ()
"Show the metadata buffer for current row."
(interactive)
(library--display-metadata (tabulated-list-get-id)))
(bibliothek--display-metadata (tabulated-list-get-id)))



;;;; The major mode:

(define-derived-mode library-mode tabulated-list-mode
"Library"
"Library listing."
(define-derived-mode bibliothek-mode tabulated-list-mode
"Bibliothek"
"Bibliothek listing."
(tabulated-list-init-header)
(tabulated-list-print t)
(hl-line-mode))

(defvar library-mode-map (make-sparse-keymap))
(defvar bibliothek-mode-map (make-sparse-keymap))

(let ((map library-mode-map))
(define-key map "f" 'library--find)
(define-key map "g" 'library)
(define-key map "i" 'library--info))
(let ((map bibliothek-mode-map))
(define-key map "f" 'bibliothek--find)
(define-key map "g" 'bibliothek)
(define-key map "i" 'bibliothek--info))

;;;###autoload
(defun library ()
(defun bibliothek ()
"Show the library contents.
This is the main entry point to the Library package. It shows a
This is the main entry point to the Bibliothek package. It shows a
tabulated list of metadata for all the PDF files found in the
directories under ‘library-path’.
directories under ‘bibliothek-path’.
The keybindings are as follows:
\\{library-mode-map}"
\\{bibliothek-mode-map}"
(interactive)
(switch-to-buffer
(with-current-buffer (get-buffer-create "*Library*")
(let ((items (library--items))
(with-current-buffer (get-buffer-create "*Bibliothek*")
(let ((items (bibliothek--items))
(f (lambda (item)
(list (library--assoca 'library--filename item)
(let ((title (library--assoca 'title item))
(path (library--assoca 'library--filename item)))
(list (bibliothek--assoca 'bibliothek--filename item)
(let ((title (bibliothek--assoca 'title item))
(path (bibliothek--assoca 'bibliothek--filename item)))
(vector
(cons title
`(action library--find file ,path))
(library--assoca 'author item)
`(action bibliothek--find file ,path))
(bibliothek--assoca 'author item)
path))))))
(setf tabulated-list-entries
(mapcar f items)
tabulated-list-format [("Title" 40 t)
("Author" 20 t)
("Path" 20 t)])
(library-mode)
(bibliothek-mode)
(setq-local truncate-lines t)
(current-buffer)))))



;;; Footer:
(provide 'library)
;;; library.el ends here
(provide 'bibliothek)
;;; bibliothek.el ends here
File renamed without changes

0 comments on commit 188e6d4

Please sign in to comment.