]> git.eshelyaron.com Git - emacs.git/commitdiff
Simplify dictionary-close even more
authorStefan Kangas <stefankangas@gmail.com>
Sat, 19 Aug 2023 11:03:46 +0000 (13:03 +0200)
committerStefan Kangas <stefankangas@gmail.com>
Sat, 19 Aug 2023 11:09:08 +0000 (13:09 +0200)
* lisp/net/dictionary.el (dictionary-close): Simplify.
Suggested by Philip Kaludercic <philipk@posteo.net>.

lisp/net/dictionary.el

index 58f36db252369d4345548a470a6e0d77fda5157e..ca706c3c6e93be9921476e1adb610f8c4cc5dfd8 100644 (file)
@@ -573,22 +573,12 @@ The connection takes the proxy setting in customization group
 ;; Dealing with closing the buffer
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
-(defun dictionary--count-mode-buffers ()
-  (seq-reduce (lambda (count buf)
-                (if (provided-mode-derived-p
-                     (buffer-local-value 'major-mode buf)
-                     'dictionary-mode)
-                    (+ count 1)
-                  count))
-              (buffer-list)
-              0))
-
 (defun dictionary-close (&rest _ignored)
   "Close the current dictionary buffer and its connection."
   (interactive)
   (when (derived-mode-p 'dictionary-mode)
     (setq major-mode nil)
-    (if (<= (dictionary--count-mode-buffers) 0)
+    (if (<= (length (match-buffers '(derived-mode . dictionary-mode))) 0)
         (dictionary-connection-close dictionary-connection))
     (let ((configuration dictionary-window-configuration)
           (selected-window dictionary-selected-window))