David S. Goldberg wrote:

> (defun dsg-bbdb-duplicate-and-edit-record (record newname)
>   "Duplicates the current record, prompting for a new value for name."
>   (interactive (list (bbdb-get-record "Record to start from: ")
>                    (read-string "New Name: ")))
>   (let ((omit-fields dsg-bbdb-omit-fields-on-duplicate)
>       (newnotes (bbdb-record-raw-notes (bbdb-current-record))))
>     (while omit-fields
>       (setq newnotes (remove (assoc (car omit-fields) newnotes) newnotes))
>       (setq omit-fields (cdr omit-fields)))
>     (bbdb-create-internal newname (bbdb-record-company record)
>                         (bbdb-record-net record)
>                         (bbdb-record-addresses record)
>                         (bbdb-record-phones record)
>                         newnotes)))

This is a very cool function, but you seem to be in the middle of
editing it.

In `interactive', you ask for a record, but you then get the new notes
from `bbdb-current-record'.

I am still on bbdb 2.00.06, so below is a slightly modified version of
your code that I am using.  I made three changes:

1. Use `bbdb-completing-read-record', the old name of `bbdb-get-record'.

2. Instead of `(bbdb-current-record)', use `record'.

3. Remove `net' field from duplicate, since my version doesn't allow
   duplicate net addresses.

(defun dsg-bbdb-duplicate-and-edit-record (record newname)
  "Duplicates the current record, prompting for a new value for name."
  (interactive (list (bbdb-completing-read-record "Record to start from: ")
                     (read-string "New Name: ")))
  (let ((omit-fields dsg-bbdb-omit-fields-on-duplicate)
        (newnotes (bbdb-record-raw-notes record)))
    (while omit-fields
      (setq newnotes (remove (assoc (car omit-fields) newnotes) newnotes))
      (setq omit-fields (cdr omit-fields)))
    (bbdb-display-records
     (list (bbdb-create-internal newname (bbdb-record-company record)
                                 nil
                                 (bbdb-record-addresses record)
                                 (bbdb-record-phones record)
                                 newnotes)))))

; Colin

_______________________________________________
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/bbdb-info
BBDB Home Page: http://bbdb.sourceforge.net/

Reply via email to