girzel / ebdb

An EIEIO port of BBDB, Emacs' contact-management package
67 stars 12 forks source link

Cannot send email because of anniversary issue #91

Closed brabalan closed 4 years ago

brabalan commented 4 years ago

I'm trying to send an email, and I keep getting this error:

Debugger entered--Lisp error: (wrong-number-of-arguments #<subr encode-time> 1)
  encode-time((0 0 0 4 7 2001 nil nil nil))
  #f(compiled-function (ann) #<bytecode 0x2e01ff1>)(#<ebdb-field-anniversary ebdb-field-anniversary>)

The root of the call is:

  ebdb-fmt-record(#<ebdb-formatter-ebdb-multiline ebdb-formatter-ebdb-multiline> #<ebdb-record-person **********>)
  ebdb-display-records((#<ebdb-record-person Augustin Schmitt>) #<ebdb-formatter-ebdb-multiline ebdb-formatter-ebdb-multiline> nil nil (#<window 3 on *unsent mail*> 0.1 below))

Is there a way to deactivate populating the ebdb window in this case? To get around the issue, I have to deactivate ebdb altogether and restart emacs.

girzel commented 4 years ago

On 05/25/20 12:02 PM, Alan Schmitt wrote:

I'm trying to send an email, and I keep getting this error:


Debugger entered--Lisp error: (wrong-number-of-arguments #<subr encode-time> 1)
  encode-time((0 0 0 4 7 2001 nil nil nil))
  #f(compiled-function (ann) #<bytecode
0x2e01ff1>)(#<ebdb-field-anniversary ebdb-field-anniversary>)

Whoa, that's weird. What version of Emacs are you using? As far as I know, encode-time takes a single argument and always has done.

In the meantime you can get a working system with:

(setq ebdb-mua-auto-update-p nil)
brabalan commented 4 years ago

I'm using GNU Emacs 26.3 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.10) of 2019-08-29.

Calling help on encode-time return this:

encode-time is a function defined in C source code.

(encode-time SECOND MINUTE HOUR DAY MONTH YEAR &optional ZONE)

So it seems to take multiple arguments. (I also tried it on emacs -Q to make sure.)

Thanks a lot for the workaround.

girzel commented 4 years ago

On 05/26/20 00:20 AM, Alan Schmitt wrote:

I'm using GNU Emacs 26.3 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.10) of 2019-08-29.

Calling help on encode-time return this:

encode-time is a function defined in C source code.

(encode-time SECOND MINUTE HOUR DAY MONTH YEAR &optional ZONE)

So it seems to take multiple arguments. (I also tried it on emacs -Q to make sure.)

Ah! They changed the calling convention in Emacs 27. A fix should be very simple, I'll try to get that released today.

Thanks for the report.

girzel commented 4 years ago

If you have a moment would you evaluate this and make sure it works okay?

(cl-defmethod ebdb-string ((ann ebdb-field-anniversary))
  (let* ((date (slot-value ann 'date))
     encoded)
    (setq encoded
      (condition-case nil
          (encode-time
           ;; Why did I reverse the day month order?!
           `(0 0 0
           ,(nth 1 date)
           ,(car date)
           ,(or (nth 2 date) 0)
           nil nil nil))
        (wrong-number-of-arguments
         ;; Emacs <=26
         (apply #'encode-time
            `(0 0 0
            ,(nth 1 date)
            ,(car date)
            ,(or (nth 2 date) 0))))))
    (format-time-string
     (if (nth 2 date)
     ebdb-anniversary-ymd-format
       ebdb-anniversary-md-format)
     encoded)))

Thanks!

brabalan commented 4 years ago

It works great, thanks!