Thread: [Refdb-cvs] CVS: elisp refdb-mode.el,1.6,1.7
Status: Beta
Brought to you by:
mhoenicka
|
From: Michael S. <xm...@us...> - 2003-12-28 12:02:11
|
Update of /cvsroot/refdb/elisp In directory sc8-pr-cvs1:/tmp/cvs-serv5864 Modified Files: refdb-mode.el Log Message: RFE #866615 (listb query only at startup), RFE #865893 (deleteref) http://sourceforge.net/tracker/index.php?func=detail&aid=866615&group_id=26091&atid=385994 http://sourceforge.net/tracker/index.php?func=detail&aid=865893&group_id=26091&atid=385994 RFE #866615 - do listdb query only at startup Enhancement: refdb-mode now does a listdb query only once per session, instead of doing it each time refdb-mode-hook runs RFE #865893 - Add deletref support to refdb-mode Enhancement: Added refdb-deleteref-on-region command and corresponding menu item. Index: refdb-mode.el =================================================================== RCS file: /cvsroot/refdb/elisp/refdb-mode.el,v retrieving revision 1.6 retrieving revision 1.7 diff -u -U2 -r1.6 -r1.7 --- refdb-mode.el 26 Dec 2003 09:48:49 -0000 1.6 +++ refdb-mode.el 28 Dec 2003 12:02:07 -0000 1.7 @@ -295,4 +295,6 @@ (defvar refdb-input-type "ris") +(defvar refdb-database-list-initilized-flag nil) +(defvar refdb-default-database-set-flag nil) ;; ******************************************************************* @@ -340,4 +342,9 @@ :group 'refdb) +(defcustom refdb-deleteref-options "-f stdin" + "Options included when running the 'refdbc -c deleteref' command." + :type 'string + :group 'refdb) + (defcustom refdb-getref-options "" "Options included when running the 'refdbc -c addref' command." @@ -437,13 +444,18 @@ (defun refdb-initialize-database-list () "Initialize list of RefDB databases." - (message "Initializing RefDB database list...") - (setq refdb-current-database-list (refdb-list-databases)) - (message - "Building list of databases using '%s %s -C listdb %s'...done" - refdb-refdbc-program - refdb-refdbc-options - refdb-listdb-sql-regexp - ) - (message "Initializing RefDB database list...done") + (if (eq refdb-database-list-initilized-flag nil) + (progn + (message "Initializing RefDB database list...") + (setq refdb-current-database-list (refdb-list-databases)) + (message + "Building list of databases using '%s %s -C listdb %s'...done" + refdb-refdbc-program + refdb-refdbc-options + refdb-listdb-sql-regexp + ) + (message "Initializing RefDB database list...done") + (setq refdb-database-list-initilized-flag t) + ) + ) ) @@ -454,31 +466,36 @@ file or in his or her ~/.refdbcrc file. If so, that value is used as the database value in all RefDB commands." - (message "Setting default database...") - (setq refdb-database-default - (car - (last - (split-string - (with-output-to-string - (with-current-buffer - standard-output - (call-process shell-file-name nil '(t t) nil shell-command-switch - (format "%s %s -C set defaultdb" - refdb-refdbc-program - refdb-refdbc-options - ) - ) + (if (eq refdb-default-database-set-flag nil) + (progn + (message "Setting default database...") + (setq refdb-database-default + (car + (last + (split-string + (with-output-to-string + (with-current-buffer + standard-output + (call-process shell-file-name nil '(t t) nil shell-command-switch + (format "%s %s -C set defaultdb" + refdb-refdbc-program + refdb-refdbc-options + ) + ) + ) + ) + ) + ) ) + ) + (if (and + (equal refdb-database "") + (not (equal refdb-database-default "defaultdb")) ) - ) + (setq refdb-database refdb-database-default) ) - ) + (message "Setting default database...done") + (setq refdb-default-database-set-flag t) ) - (if (and - (equal refdb-database "") - (not (equal refdb-database-default "defaultdb")) - ) - (setq refdb-database refdb-database-default) ) - (message "Setting default database...done") ) @@ -546,4 +563,9 @@ ) +(defvar refdb-deleteref-menu-item + ["Delete References" (refdb-deleteref-on-region) t] + "RefDB menu item for deleting references." + ) + (defvar refdb-getref-by-author-menu-item ["Author..." @@ -732,5 +754,5 @@ (defun refdb-addref-on-region () - "Add references in the current region to the current RefDB database." + "Add all references in region to current database." (interactive) ;; temporarily set resize-mini-windows to nil to force Emacs to show @@ -753,6 +775,6 @@ ) "*refdb-output*" nil "*refdb-messages*") - (message - "Displaying output for '%s %s -C addref %s -d %s -t %s'" + (message + "Displaying output for '%s %s -C addref %s -d %s -t %s'...done" refdb-refdbc-program refdb-refdbc-options @@ -763,5 +785,5 @@ (display-buffer "*refdb-output*") ) - (message "Error: No region marked.") + (error "No region marked") ) ;; else if no databases specified, prompt to select from available @@ -775,4 +797,53 @@ ) +(defun refdb-deleteref-on-region () + "Delete all references in region from current database." + (interactive) + (if (yes-or-no-p + "Really delete all references in the current region? " + ) + ;; temporarily set resize-mini-windows to nil to force Emacs to show + ;; addref output in separate buffer instead of minibuffer + (progn + (setq resize-mini-windows nil) + (if (not (eq (length refdb-database) 0)) + (if (mark) + (progn + (refdb-determine-input-type) + (message "Deleting references in selected region from %s database..." refdb-database) + (shell-command-on-region + (point) (mark) + (format + "%s %s -C deleteref %s -d %s" + refdb-refdbc-program + refdb-refdbc-options + refdb-deleteref-options + refdb-database + ) + "*refdb-output*" nil "*refdb-messages*") + (message + "Displaying output for '%s %s -C deleteref %s -d %s'...done" + refdb-refdbc-program + refdb-refdbc-options + refdb-deleteref-options + refdb-database + ) + (display-buffer "*refdb-output*") + ) + (error "No region marked") + ) + ;; else if no databases specified, prompt to select from available + ;; databases, then re-call command + (call-interactively 'refdb-select-database) + (refdb-deleteref-on-region) + ) + (message "Deleting references in selected region from %s database...done" refdb-database) + ;; set resize-mini-windows back to default value + (setq resize-mini-windows (get 'resize-mini-windows 'standard-value)) + ) + (error "Deletion aborted") + ) + ) + (defun refdb-message-getting-refs (field value) "Emit appropriate status message for FIELD and VALUE. @@ -785,4 +856,14 @@ ) +(defun refdb-message-getting-refs-done (field value) + "Emit appropriate status message for FIELD and VALUE. +This function is called by the various refdb-getref-by commands." + (message + "Getting datasets for %s %s...done" + field + value + ) + ) + (defun refdb-getref-by-field (field value) "Display all RefDB datasets that match the specified FIELD and VALUE. @@ -829,5 +910,5 @@ (message (format - "Displaying output for '%s %s -C getref :%s:=%s %s -d %s -t %s -s %s'" + "Displaying output for '%s %s -C getref :%s:=%s %s -d %s -t %s -s %s'...done" refdb-refdbc-program refdb-refdbc-options @@ -891,4 +972,5 @@ (refdb-message-getting-refs 'author author) (refdb-getref-by-field "AU" author) + (refdb-message-getting-refs-done 'author author) ) @@ -898,4 +980,5 @@ (refdb-message-getting-refs 'title title) (refdb-getref-by-field "TI" title) + (refdb-message-getting-refs-done 'title title) ) @@ -905,4 +988,5 @@ (refdb-message-getting-refs 'keyword keyword) (refdb-getref-by-field "KW" keyword) + (refdb-message-getting-refs-done 'keyword keyword) ) @@ -912,4 +996,5 @@ (refdb-message-getting-refs 'id id) (refdb-getref-by-field "ID" id) + (refdb-message-getting-refs-done 'id id) ) @@ -919,4 +1004,5 @@ (refdb-message-getting-refs 'citekey citekey) (refdb-getref-by-field "CK" citekey) + (refdb-message-getting-refs-done 'citekey citekey) ) @@ -965,5 +1051,5 @@ (message (format - "Displaying output for '%s %s -C getref %s %s -d %s -t %s -s %s'" + "Displaying output for '%s %s -C getref %s %s -d %s -t %s -s %s'...done" refdb-refdbc-program refdb-refdbc-options @@ -983,4 +1069,5 @@ (setq resize-mini-windows resize-mini-windows-default) ) + (message (format "Getting datasets for search string %s...done" searchstring)) ) @@ -1209,4 +1296,5 @@ '( refdb-addref-menu-item + refdb-deleteref-menu-item refdb-getref-submenu-definition refdb-data-output-submenu-definition |