branch: externals/ebdb
commit 9ce8e30784aca2f02dad9af300a1b1fe5a3f3a98
Author: Eric Abrahamsen <[email protected]>
Commit: Eric Abrahamsen <[email protected]>

    Check db editable before reading new record
    
    * ebdb-com.el (ebdb-create-record): Move the ebdb-db-editable check
      before record reading, don't make the user enter a whole record and
      then find out afterwards it isn't going to work.
---
 ebdb-com.el | 32 ++++++++++++++++----------------
 1 file changed, 16 insertions(+), 16 deletions(-)

diff --git a/ebdb-com.el b/ebdb-com.el
index f651368..da54005 100644
--- a/ebdb-com.el
+++ b/ebdb-com.el
@@ -1573,24 +1573,24 @@ in `ebdb-db-list', using its default record class.  Use
    (list (car ebdb-db-list)))
   (unless record-class
     (setq record-class (slot-value db 'record-class)))
-  (let ((record (ebdb-read record-class)))
-   (condition-case nil
-       (progn
-        (ebdb-db-editable db nil t)
-        (run-hook-with-args 'ebdb-create-hook record)
-        (run-hook-with-args 'ebdb-change-hook record)
-        (ebdb-db-add-record db record)
-        (ebdb-init-record record)
-        (run-hook-with-args 'ebdb-after-change-hook record)
-        (ebdb-display-records (list record) ebdb-default-multiline-formatter t)
-        (dolist (b (buffer-list))
-          (with-current-buffer b
+  (condition-case nil
+      (let (record)
+       (ebdb-db-editable db nil t)
+       (setq record (ebdb-read record-class))
+       (run-hook-with-args 'ebdb-create-hook record)
+       (run-hook-with-args 'ebdb-change-hook record)
+       (ebdb-db-add-record db record)
+       (ebdb-init-record record)
+       (run-hook-with-args 'ebdb-after-change-hook record)
+       (ebdb-display-records (list record) ebdb-default-multiline-formatter t)
+       (dolist (b (buffer-list))
+         (with-current-buffer b
            (when (derived-mode-p 'ebdb-mode)
              (set-buffer-modified-p t)))))
-     (ebdb-readonly-db
-      (message "%s is read-only" (ebdb-string db)))
-     (ebdb-unsynced-db
-      (message "%s is out of sync" (ebdb-string db))))))
+    (ebdb-readonly-db
+     (message "%s is read-only" (ebdb-string db)))
+    (ebdb-unsynced-db
+     (message "%s is out of sync" (ebdb-string db)))))
 
 ;;;###autoload
 (defun ebdb-create-record-extended ()

Reply via email to