emacs-erc
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Add compat to ERC


From: Philip Kaludercic
Subject: Re: Add compat to ERC
Date: Fri, 08 Jul 2022 14:35:18 +0000

"J.P." <jp@neverwas.me> writes:

> Hi Philip,
>
> Thanks for making compat! Although most of it's way over my head, the
> parts I did manage to grasp look really well done. It seems to work
> great with ERC on Emacs 27 and 28, so much so that I'd like to make us
> the first :core package to require it, if that's acceptable to everyone.

Would be great to see!  Thank you for starting the initiative.

> I've attempted a patch but had no real clue what I was doing. Please
> tell us what needs changing, assuming it's salvageable; otherwise, feel
> free to take over or, if you'd be willing, provide a replacement
> whenever time allows.

I'd be glad to help, I just don't use ERC so I'd need a basic
configuration to contribute materially.

> diff --git a/lisp/erc/erc-compat.el b/lisp/erc/erc-compat.el
> index 16cfb15a5a..899522f186 100644
> --- a/lisp/erc/erc-compat.el
> +++ b/lisp/erc/erc-compat.el
> @@ -26,6 +26,7 @@
>  ;; This mostly defines stuff that cannot be worked around easily.
>  
>  ;;; Code:
> +(require 'compat nil 'noerror)

I guess this is the main part.  Have you tested it to see if it works?

>  ;;;###autoload(autoload 'erc-define-minor-mode "erc-compat")
>  (define-obsolete-function-alias 'erc-define-minor-mode
> @@ -150,6 +151,40 @@ erc-subseq
>                (setq i (1+ i) start (1+ start)))
>              res))))))
>  
> +;;;; lisp/calendar/time-date.el
> +
> +(defun erc-compat--28-decoded-time-period (time)
> +  "Interpret DECODED as a period and return its length in seconds.
> +For computational purposes, years are 365 days long and months
> +are 30 days long."
> +  (+ (if (consp (decoded-time-second time))
> +         ;; Fractional second.
> +         (/ (float (car (decoded-time-second time)))
> +            (cdr (decoded-time-second time)))
> +       (or (decoded-time-second time) 0))
> +     (* (or (decoded-time-minute time) 0) 60)
> +     (* (or (decoded-time-hour time) 0) 60 60)
> +     (* (or (decoded-time-day time) 0) 60 60 24)
> +     (* (or (decoded-time-month time) 0) 60 60 24 30)
> +     (* (or (decoded-time-year time) 0) 60 60 24 365)))
> +
> +(defmacro erc-compat--decoded-time-period (time)
> +  (declare (indent defun))
> +  (list (if (< emacs-major-version 28)
> +            'erc-compat--28-decoded-time-period
> +          'decoded-time-period)
> +        time))

If you want, we can upstream these definitions into compat.  I would
guess others are interested in them too.

My wish would be to one day replace all custom *-compat.el files in the
core with compat.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]