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: Visuwesh
Subject: Re: master 5892b4db8de 2/3: Convert dictionary-mode to define-derived-mode
Date: Wed, 16 Aug 2023 18:25:42 +0530
User-agent: Gnus/5.13 (Gnus v5.13)

[சனி ஆகஸ்ட் 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))



reply via email to

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