emacs-devel
[Top][All Lists]
Advanced

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

Re: master 5892b4db8de 2/3: Convert dictionary-mode to define-derived-mo


From: Basil L. Contovounesios
Subject: Re: master 5892b4db8de 2/3: Convert dictionary-mode to define-derived-mode
Date: Thu, 17 Aug 2023 11:15:57 +0200
User-agent: Gnus/5.13 (Gnus v5.13)

Visuwesh [2023-08-16 18:25 +0530] wrote:

> [சனி ஆகஸ்ட் 12, 2023] Stefan Kangas wrote:
>
>> branch: master
>> commit 5892b4db8de4694904f631dd86438926fb9d7ff1
>> Author: Stefan Kangas <stefankangas@gmail.com>
>> Commit: Stefan Kangas <stefankangas@gmail.com>
>>
>> +  (seq-reduce #'+
>> +              (mapcar
>> +               (lambda (buf)
>> +                 (with-current-buffer buf
>> +                   (if (derived-mode-p 'dictionary-mode) 1 0)))
>> +               (buffer-list))
>> +              0))
>> +
>
> I believe the following function should be faster
>
>     (defun dictionary--count-mode-buffers ()
>       "Return the number of buffers that "
>       (seq-reduce (lambda (count buf)
>                     (if (provided-mode-derived-p (buffer-local-value 
> 'major-mode buf)
>                                                  'dictionary-mode)
>                         (+ count 1)
>                       count))
>                   (buffer-list)
>                   0))

Yet faster and simpler would be to use seq-count in place of seq-reduce.

Thanks,
-- 
Basil



reply via email to

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