From 402cadf8ee35a54e1f9493f6cf20189d30a5b004 Mon Sep 17 00:00:00 2001 From: JSDurand Date: Thu, 20 May 2021 22:21:38 +0800 Subject: Fix a bug of switch-to-buffer-same-mode. * ibuffer.el (switch-to-buffer-same-mode): Fix a bug. --- ibuffer.el | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/ibuffer.el b/ibuffer.el index 7f172ac..8d77296 100644 --- a/ibuffer.el +++ b/ibuffer.el @@ -39,19 +39,20 @@ If the optional ARG is non-nil, then produce an IBUFFER buffer (interactive "P") (cond ((null arg) - (let ((def (buffer-name - (car - (delete nil - (mapcar - (lambda (buf) - (and - (provided-mode-derived-p - (buffer-local-value 'major-mode buf) - (buffer-local-value 'major-mode (current-buffer))) - (not (= (aref (buffer-name buf) 0) 32)) - (not (eq buf (current-buffer))) - buf)) - (buffer-list))))))) + (let* ((mode (buffer-local-value 'major-mode (current-buffer))) + (def (buffer-name + (car + (delete nil + (mapcar + (lambda (buf) + (and + (provided-mode-derived-p + (buffer-local-value 'major-mode buf) + mode) + (not (= (aref (buffer-name buf) 0) 32)) + (not (eq buf (current-buffer))) + buf)) + (buffer-list))))))) (switch-to-buffer (read-buffer (format "Switch to buffer with major mode %S:" @@ -62,11 +63,9 @@ If the optional ARG is non-nil, then produce an IBUFFER buffer (buffer-local-value 'major-mode (cond ((consp name-or-cons) - (car name-or-cons)) + (cdr name-or-cons)) ((get-buffer name-or-cons)))) - (buffer-local-value - 'major-mode - (current-buffer)))))))) + mode)))))) ((ibuffer nil (format "*Buffers for %S*" -- cgit v1.2.3-18-g5258