[Ebib-users] searching across multiple real databases
Brought to you by:
joostkremers
From: Robbie M. <ro...@ac...> - 2012-08-18 13:13:41
|
Hello Joost and list This posting relates to searching across multiple databases. Unless I have misread the documentation badly (always a possibility), basic emacs-based searches and advanced searching (resulting in virtual databases) are only possible within the one database. Is this correct? I would like to work across six BibTeX files. It so, there are two possible fixes: concatenate the BibTeX files beforehand. Or offer users a 'super' database, a union of the existing real databases. Call it super, logical, or virtual, as you like. In fact, 'logical' has some merits. Anyway, I hacked a bit of 'ebib.el' to try and get something happening. The following patch FAILS to work, but did run. You should get the drift, anyhow. My questions are two-fold: * is this functionality needed ? * is this functionality possible ? It yes to both, I may go on hacking. Else, I will give up and simply run 'cat' on my BibTeX files to produce on single real (physical) database and leave it at that. many thanks in advance, Robbie CAUTION: patch is also hand-edited so may not take --- ebib.el.orig 2012-08-18 00:36:40.663700389 +0200 +++ ebib.el 2012-08-18 04:33:38.433636738 +0200 @@ -1518,6 +1518,7 @@ (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-virtual-db-union) (ebib-key index ";" ebib-prefix-map) (ebib-key index "a" ebib-add-entry) (ebib-key index "b" ebib-index-scroll-down) @@ -1746,13 +1747,16 @@ (message "%s found! Press `l' to check Ebib log buffer." (nth ebib-log-error '("Warnings" "Errors")))) (ebib-log 'log "")) -(defun ebib-merge-bibtex-file () +(defun ebib-merge-bibtex-file (bibfile) "Merges a BibTeX file into the database." (interactive) - (unless (edb-virtual ebib-cur-db) +; (unless (edb-virtual ebib-cur-db) + (unless nil ; robbie 18-Aug-2012 (if (not ebib-cur-db) (error "No database loaded. Use `o' to open a database") - (let ((file (read-file-name "File to merge: "))) + (let ((file bibfile)) ; could well be 'nil' + (unless file + (setq file (read-file-name "File to merge: "))) (setq ebib-log-error nil) ; we haven't found any errors (ebib-log 'log "%s: Merging file %s" (format-time-string "%d-%b-%Y: %H:%M:%S") (edb-filename ebib-cur-db)) (with-temp-buffer @@ -2889,6 +2893,51 @@ (ebib-log 'message "invoking: %s %s" "find-file" file-full-path) (find-file file-full-path)))))) +; robbie 18-Aug-2012 +; from 'ebib-virtual-db-and' +(defun ebib-virtual-db-union (arg) + "Combine open databased into a single virtual database. +If the current database is a virtual database already, +ignore the command." + (interactive "p") ; cannot think of a reason for this + (ebib-log 'message "creating virtual union database") + + (let* ((dbname "union" ) + (new-db (ebib-create-new-database nil) ) ; create new database, adds to census + (count 0 )) + + (setf (edb-virtual new-db) t) ; mark virtual, 't' also works + (setf (edb-filename new-db) nil) + (setf (edb-name new-db) (concat "V:" dbname)) + (setf (edb-modified new-db) nil) + (setf (edb-make-backup new-db) nil) + + ;; loop non-virtual databases + (dolist (db ebib-databases) + (ebib-execute-when + ((database) ; for some reason (real-db) did not seem to take + (setq ebib-cur-db db) ; change focus + (unless (edb-virtual db) ; skip virtual databases + (let ((ebib-merge-bibtex-filename (edb-filename ebib-cur-db) )) + (ebib-merge-bibtex-file ebib-merge-bibtex-filename) + (incf count) + (ebib-log 'message "current database %S" ebib-cur-db) + (ebib-log 'message "current filename %s\n" (prin1-to-string ebib-merge-bibtex-filename)) + ))))) + (ebib-log 'message "traversed %d databases\n" count) + + ;; file virtual database + (ebib-fill-entry-buffer) ; fill entry buffer + (ebib-fill-index-buffer) ; fill index buffer + )) + +; 'ebib-merge-bibtex-file' +; 'ebib-save-all-databases' uses 'mapc' + (defun ebib-virtual-db-and (not) "Filters entries into a virtual database. If the current database is a virtual database already, perform a --- Robbie Morrison PhD student -- policy-oriented energy system simulation Technical University of Berlin (TU-Berlin), Germany University email (redirected) : mor...@ie... Webmail (preferred) : ro...@ac... [from Webmail client] |