From: Stefan Kangas Date: Sat, 19 Aug 2023 11:03:46 +0000 (+0200) Subject: Simplify dictionary-close even more X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=dc8f09b3b0a3144e0117932736f59f79ff2a381b;p=emacs.git Simplify dictionary-close even more * lisp/net/dictionary.el (dictionary-close): Simplify. Suggested by Philip Kaludercic . --- diff --git a/lisp/net/dictionary.el b/lisp/net/dictionary.el index 58f36db2523..ca706c3c6e9 100644 --- a/lisp/net/dictionary.el +++ b/lisp/net/dictionary.el @@ -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))