[Ebib-users] eight patches: UI, keywords, help, DOI open
Brought to you by:
joostkremers
From: Robbie M. <ro...@ac...> - 2012-08-27 12:22:46
|
Hello Joost Eight patches follow, youngest first. It might be easiest if I was able to push my local 'git' branch onto the sourceforge repository?? 7783f3d Open DOI functionality. bde7600 Improved info quit behavior. bca334b Dedicated INFOPATH envar setting. e6210c3 Ebib help mapped to '?' key. ead611b Add user-specified default keywords text file. 7c477a2 Add user-specified default keywords. 45d03fb Fewer blank lines in log buffer. 2554f4e Cleaner index buffer display. Note also the TOFIX comments. Robbie --- commit 7783f3d3096f315e7a6d7113bddf2a3834e545fa Author: Robbie Morrison <ro...@ac...> Date: Mon Aug 27 13:55:13 2012 +0200 Open DOI functionality. DOI = digital object identifier. This commit allows users to browse DOI's directly. Add variables 'ebib-standard-doi-field' and 'ebib-doi-url'. Add function 'ebib-browse-doi'. Add menu entry and index buffer key map to "i". Much of the code mirrors 'ebib-browse-url'. diff --git a/ebib.el b/ebib.el index f251be0..9cfb7eb 100644 --- a/ebib.el +++ b/ebib.el @@ -211,8 +211,16 @@ send a url to a browser. This option sets the field from which this command extracts the url." :group 'ebib :type 'symbol) +(defcustom ebib-standard-doi-field 'doi + "*Standard field to store doi (digital object identifier) in. +In the index buffer, the command ebib-browse-doi can be used to +send a suitable url to a browser. This option sets the field from +which this command extracts the doi." + :group 'ebib + :type 'symbol) + (defcustom ebib-url-regexp "\\\\url{\\(.*\\)}\\|https?://[^ '<>\"\n\t\f]+" "*Regular expression to extract urls from a field." :group 'ebib :type 'string) @@ -371,8 +379,9 @@ Each string is added to the preamble on a separate line." ;; constants and variables that are set only once (defconst ebib-bibtex-identifier "[^\"#%'(),={} \t\n\f]*" "Regexp describing a licit BibTeX identifier.") (defconst ebib-version "==VERSION==") +(defconst ebib-doi-url "http://dx.doi.org/" "Prepend to turn doi field value into a web address.") (defvar ebib-initialized nil "T if Ebib has been initialized.") ;; buffers and highlights (defvar ebib-index-buffer nil "The index buffer.") @@ -1539,8 +1548,9 @@ killed and the database has been modified." (ebib-key index "F" ebib-follow-crossref) (ebib-key index "g" ebib-goto-first-entry) (ebib-key index "G" ebib-goto-last-entry) (ebib-key index "h" ebib-index-help) +(ebib-key index "i" ebib-browse-doi) (ebib-key index "j" ebib-next-entry) (ebib-key index "J" ebib-switch-to-database) (ebib-key index "k" ebib-prev-entry) (ebib-key index "K" ebib-generate-autokey) @@ -1607,8 +1617,9 @@ killed and the database has been modified." ["Edit Strings" ebib-edit-strings (and ebib-cur-db (not (edb-virtual ebib-cur-db)))] ["Edit Preamble" ebib-edit-preamble (and ebib-cur-db (not (edb-virtual ebib-cur-db)))] "--" ["Open URL" ebib-browse-url (gethash ebib-standard-url-field ebib-cur-entry-hash)] + ["Open DOI" ebib-browse-doi (gethash ebib-standard-doi-field ebib-cur-entry-hash)] ["View File" ebib-view-file (gethash ebib-standard-file-field ebib-cur-entry-hash)] ("Print Entries" ["As Bibliography" ebib-latex-entries (and ebib-cur-db (not (edb-virtual ebib-cur-db)))] ["As Index Cards" ebib-print-entries ebib-cur-db] @@ -2807,8 +2818,26 @@ which URL to choose." (error "Field `%s' is empty" ebib-standard-url-field)))) ((default) (beep)))) +(defun ebib-browse-doi () + "Asks a browser to load a modified URL in the standard DOI field. +The standard DOI field may not contain more than one DOI. + +By \"standard DOI field\" is meant the field defined in the +customization variable EBIB-STANDARD-DOI-FIELD. Its default value +is `doi'." + (interactive) + (ebib-execute-when + ((entries) + (let ((doi (to-raw (gethash ebib-standard-doi-field + (ebib-retrieve-entry (ebib-cur-entry-key) ebib-cur-db))))) + (when (not (and doi + (ebib-call-browser (concat ebib-doi-url doi) 1))) ; '1' was 'num' + (error "No doi found in field `%s'" ebib-standard-doi-field)))) + ((default) + (beep)))) + (defun ebib-call-browser (urls n) "Passes the Nth URL in URLS to a browser. URLS must be a string of whitespace-separated URLs." ;; first we extract all valid urls and then pick the nth one commit bde7600eeaf85ca30721d67504544e7d5838fc9c Author: Robbie Morrison <ro...@ac...> Date: Mon Aug 27 13:22:43 2012 +0200 Improved info quit behavior. This is the last of three commits to improve ebib help. The "q" key is now bound to 'Info-exit' and then 'ebib'. This gives more intuitive behavior than before, but the solution is not ideal and could be developed further. diff --git a/ebib.el b/ebib.el index c1a938e..f251be0 100644 --- a/ebib.el +++ b/ebib.el @@ -1379,8 +1379,15 @@ buffers and reads the rc file." (info-initialize) ;load 'Info-directory-list' (ebib-log 'message "local path : %S" localpath) (ebib-log 'message "INFOPATH : %s" (getenv "INFOPATH")) (ebib-log 'message "Info-directory-list : %S\n" Info-directory-list)) + (add-hook 'Info-mode-hook + '(lambda () + (local-set-key (kbd "q") '(lambda () + (interactive) + (Info-exit) + (ebib))))) + (ebib-log 'message "Info-mode 'q' key now bound to 'Info-quit' and 'ebib'\n") ;; as before (setq ebib-index-highlight (ebib-make-highlight 1 1 ebib-index-buffer)) (setq ebib-fields-highlight (ebib-make-highlight 1 1 ebib-entry-buffer)) (setq ebib-strings-highlight (ebib-make-highlight 1 1 ebib-strings-buffer)) commit bca334b64dd1ac80dff3594c63ef5d872d500123 Author: Robbie Morrison <ro...@ac...> Date: Mon Aug 27 13:16:26 2012 +0200 Dedicated INFOPATH envar setting. The 'INFOPATH' environmental variable is now explicitly set in 'ebib-init'. The current implementation is hardcoded to suit the author, but improving on this should not present a problem. It should map to the location of 'ebib' instead. diff --git a/ebib.el b/ebib.el index 7b8fb70..c1a938e 100644 --- a/ebib.el +++ b/ebib.el @@ -1369,8 +1369,19 @@ buffers and reads the rc file." (load "~/.ebibrc" t) (ebib-create-buffers) (setq ebib-keywords-list (read-file-to-list ebib-keywords-file)) ; *Ebib-log* buffer must already exist (ebib-log 'message "keywords list: %S\n" ebib-keywords-list) + ;; 'info' functionality + (require 'info) + ;; TOFIX: 27-Aug-2012: robbie: the following 'localnode' is hardcoded for me, it needs fixing + (let* ((localnode "~/synk/elisp/ebib-1.9.1/info/") ; trailing slash optional + (localpath (expand-file-name localnode))) ; local elisp directory + (setenv "INFOPATH" (concat localpath ":" (getenv "INFOPATH"))) + (info-initialize) ;load 'Info-directory-list' + (ebib-log 'message "local path : %S" localpath) + (ebib-log 'message "INFOPATH : %s" (getenv "INFOPATH")) + (ebib-log 'message "Info-directory-list : %S\n" Info-directory-list)) + ;; as before (setq ebib-index-highlight (ebib-make-highlight 1 1 ebib-index-buffer)) (setq ebib-fields-highlight (ebib-make-highlight 1 1 ebib-entry-buffer)) (setq ebib-strings-highlight (ebib-make-highlight 1 1 ebib-strings-buffer)) (setq ebib-initialized t)) commit e6210c3fcd7a75a9fefad8f7ff992c647c54f50a Author: Robbie Morrison <ro...@ac...> Date: Mon Aug 27 13:11:52 2012 +0200 Ebib help mapped to '?' key. This is one of three commits to improve ebib help. The index buffer '?' key is now mapped to 'ebib-info' diff --git a/ebib.el b/ebib.el index 7ced6bc..7b8fb70 100644 --- a/ebib.el +++ b/ebib.el @@ -1509,8 +1509,9 @@ killed and the database has been modified." (ebib-key index "&" ebib-virtual-db-and) (ebib-key index "|" ebib-virtual-db-or) (ebib-key index "~" ebib-virtual-db-not) (ebib-key index ";" ebib-prefix-map) +(ebib-key index "?" ebib-info) (ebib-key index "a" ebib-add-entry) (ebib-key index "b" ebib-index-scroll-down) (ebib-key index "c" ebib-close-database) (ebib-key index "d" ebib-delete-entry) commit ead611b4ac993cd352484318d30cff8265ec51d3 Author: Robbie Morrison <ro...@ac...> Date: Mon Aug 27 12:53:34 2012 +0200 Add user-specified default keywords text file. Add user-specified variable 'ebib-keywords-file' This is currently set to "~/.ebib-keywords" for test purposes. Add function 'read-file-to-list'. Add suitable calls to function 'ebib-init'. See also the TOFIX comments in the code. diff --git a/ebib.el b/ebib.el index 2ac3376..7ced6bc 100644 --- a/ebib.el +++ b/ebib.el @@ -78,8 +78,15 @@ "*List of keywords to load automatically when Ebib starts." :group 'ebib :type 'list) +; TOFIX: 21-Aug-2012: robbie: 'type' = 'string' needs confirmation +(defcustom ebib-keywords-file + (expand-file-name "~/.ebib-keywords") + "Name of text file containing newline separated keywords." + :group 'ebib + :type 'string) + (defcustom ebib-preload-bib-files nil "*List of .bib files to load automatically when Ebib starts." :group 'ebib :type '(repeat (file :must-match t))) @@ -1282,8 +1289,18 @@ is a list of fields that are considered in order for the sort value." (ebib-retrieve-entry entry-key ebib-cur-db))))) (setq sortkey-list (cdr sortkey-list))) sort-string)) +(defun read-file-to-list (filename) + "Return a list of lines from a file FILENAME." + (if (file-readable-p filename) + (with-temp-buffer + (insert-file-contents filename) + (ebib-log 'message "read file: %s\n" filename) + (split-string (buffer-string) "\n" t)) ; 't' is omit nulls, blank lines in this case + (ebib-log 'warning "cannot read file: %s" filename) + ebib-keywords-list)) ; use hardcoded list instead + ;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; main program execution ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -1350,8 +1367,10 @@ buffers and reads the rc file." ebib-saved-window-config nil) (put 'timestamp 'ebib-hidden t) (load "~/.ebibrc" t) (ebib-create-buffers) + (setq ebib-keywords-list (read-file-to-list ebib-keywords-file)) ; *Ebib-log* buffer must already exist + (ebib-log 'message "keywords list: %S\n" ebib-keywords-list) (setq ebib-index-highlight (ebib-make-highlight 1 1 ebib-index-buffer)) (setq ebib-fields-highlight (ebib-make-highlight 1 1 ebib-entry-buffer)) (setq ebib-strings-highlight (ebib-make-highlight 1 1 ebib-strings-buffer)) (setq ebib-initialized t)) commit 7c477a201a2fde2c9d672e112f6bd4d5db67a3e0 Author: Robbie Morrison <ro...@ac...> Date: Mon Aug 27 12:20:11 2012 +0200 Add user-specified default keywords. Add user-specified variable 'ebib-keywords-list'. This variable is currently set to (list "keyword-1" "keyword-2") for test purposes. The next commit will read this list from a text file instead. See also the TOFIX comments in the code for some minor issues to fix. diff --git a/ebib.el b/ebib.el index 9adf6bd..2ac3376 100644 --- a/ebib.el +++ b/ebib.el @@ -69,8 +69,17 @@ "*The default type for a newly created BibTeX entry." :group 'ebib :type 'symbol) +; this variable can grow during a session but any changes are +; lost on exit. could also sort the list in function 'ebib-init'. +; TOFIX: 21-Aug-2012: robbie: empty the list after testing +; TOFIX: 21-Aug-2012: robbie: 'type' = 'list' needs confirmation +(defcustom ebib-keywords-list (list "keyword-1" "keyword-2") + "*List of keywords to load automatically when Ebib starts." + :group 'ebib + :type 'list) + (defcustom ebib-preload-bib-files nil "*List of .bib files to load automatically when Ebib starts." :group 'ebib :type '(repeat (file :must-match t))) @@ -3278,9 +3287,12 @@ NIL. If EBIB-HIDE-HIDDEN-FIELDS is NIL, return FIELD." (if-str (new-contents (read-string (format "%s: " (symbol-name ebib-current-field)) (if init-contents (cons init-contents 0) nil) - ebib-minibuf-hist)) + (if (and ebib-keywords-list + (equal ebib-current-field 'keywords)) + 'ebib-keywords-list + ebib-minibuf-hist))) (puthash ebib-current-field (if raw new-contents (concat "{" new-contents "}")) ebib-cur-entry-hash) commit 45d03fb8892f74da883b9e6ca1021fed7660f3d8 Author: Robbie Morrison <ro...@ac...> Date: Mon Aug 27 11:45:53 2012 +0200 Fewer blank lines in log buffer. Modify one 'insert' and two 'ebib-log' calls in order to remove unnecessary blank lines and/or form-feed chars (\f or ASCII 12) from the output to the ebib log buffer. diff --git a/ebib.el b/ebib.el index 83ef8ef..9adf6bd 100644 --- a/ebib.el +++ b/ebib.el @@ -1367,9 +1367,9 @@ buffers and reads the rc file." ;; the log buffer (setq ebib-log-buffer (get-buffer-create " *Ebib-log*")) (set-buffer ebib-log-buffer) (erase-buffer) - (insert "Ebib log messages\n\n(Press C-v or SPACE to scroll down, M-v or `b' to scroll up, `q' to quit.)\n\n\n") + (insert "Ebib log messages\n\n(Press C-v or SPACE to scroll down, M-v or `b' to scroll up, `q' to quit.)\n\n") (ebib-log-mode) ;; and lastly we create a buffer for the entry keys. (setq ebib-index-buffer (get-buffer-create " none")) (set-buffer ebib-index-buffer) @@ -1702,9 +1702,9 @@ signal the user to check the log for warnings or errors." ;; user opened a new file or if no BibTeX entries were found. (ebib-fill-index-buffer) (when ebib-log-error (message "%s found! Press `l' to check Ebib log buffer." (nth ebib-log-error '("Warnings" "Errors")))) - (ebib-log 'log "\n\f\n")) + (ebib-log 'log "")) (defun ebib-merge-bibtex-file () "Merges a BibTeX file into the database." (interactive) @@ -1733,9 +1733,9 @@ signal the user to check the log for warnings or errors." "a" "no")) (when ebib-log-error (message "%s found! Press `l' to check Ebib log buffer." (nth ebib-log-error '("Warnings" "Errors")))) - (ebib-log 'log "\n\f\n")))))))) + (ebib-log 'log "")))))))) (defun ebib-find-bibtex-entries (timestamp) "Finds the BibTeX entries in the current buffer. The search is started at the beginnig of the buffer. All entries commit 2554f4e1ae038b78d0bd7fc88ec20130822515a3 Author: Robbie Morrison <ro...@ac...> Date: Mon Aug 27 11:11:41 2012 +0200 Cleaner index buffer display. Modify function 'ebib-display-entry' to remove the semicolon trailing the year in the index window -- cosmetic but a little cleaner in my view. diff --git a/ebib.el b/ebib.el index 4abd4ee..83ef8ef 100644 --- a/ebib.el +++ b/ebib.el @@ -907,9 +907,9 @@ matching entry is returned." (or (to-raw (gethash field cur-entry-hash)) "")) ebib-index-display-fields - "; ")) + " ")) "")))) (defun ebib-redisplay-current-field () "Redisplays the contents of the current field in the entry buffer." --- Robbie Morrison PhD student -- policy-oriented energy system simulation Institute for Energy Engineering (IET) Technical University of Berlin (TU-Berlin), Germany University email (redirected) : mor...@ie... Webmail (preferred) : ro...@ac... [from Webmail client] |