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: Philip Kaludercic
Subject: Re: master 5892b4db8de 2/3: Convert dictionary-mode to define-derived-mode
Date: Wed, 16 Aug 2023 22:33:23 +0000

Visuwesh <visuweshm@gmail.com> writes:

> [சனி ஆகஸ்ட் 12, 2023] Stefan Kangas wrote:
>
>> branch: master
>> commit 5892b4db8de4694904f631dd86438926fb9d7ff1
>> Author: Stefan Kangas <stefankangas@gmail.com>
>> Commit: Stefan Kangas <stefankangas@gmail.com>
>>
>>     Convert dictionary-mode to define-derived-mode
>>     
>>     * lisp/net/dictionary.el (dictionary-instances): Delete.
>>     (dictionary-mode): Use define-derived-mode.
>>     (dictionary--count-mode-buffers): New function.
>>     (dictionary-close): Use above new function.
>  
>> +(defun dictionary--count-mode-buffers ()
>> +  "Return the number of buffers that "
>
> The docstring is incomplete here.  :-(
>
>> +  (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))

Alternatively (length (match-buffers '(derived-mode . dictionary-mode)))



reply via email to

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