Subject: bug#38294: [PATCH] Handle killing of virtual buffers in Ido

From: Dario Gjorgjevski <[email-masked]>
Date: Wed, 20 Nov 2019 09:56:43 +0100

Currently, ‘ido-kill-buffer’ does essentially nothing to virtual
buffers.  (They are visited and then immediately killed.)  The attached
patch changes that so that they are instead removed from ‘recentf-list’,
akin to ‘ido-kill-buffer-at-head’.

>From 4295cac14ea280d43c0aa493520543aa403a4c2e Mon Sep 17 00:00:00 2001
From: Dario Gjorgjevski <[email-masked]>
Date: Wed, 20 Nov 2019 09:34:58 +0100
Subject: [PATCH] Handle killing of virtual buffers in Ido
To: [email-masked]

* lisp/ido.el (ido-buffer-internal): Handle killing of virtual buffers
as a special case.
(ido-visit-buffer): Document the special case.
---
 lisp/ido.el | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/lisp/ido.el b/lisp/ido.el
index 79f259b819..bf3f57883d 100644
--- a/lisp/ido.el
+++ b/lisp/ido.el
@@ -2286,7 +2286,10 @@ ido-buffer-internal
        ((and ido-enable-virtual-buffers
 	     ido-virtual-buffers
 	     (setq filename (assoc buf ido-virtual-buffers)))
-	(ido-visit-buffer (find-file-noselect (cdr filename)) method t))
+        (if (eq method 'kill)
+            (setq recentf-list
+	          (delete (cdr filename) recentf-list))
+	  (ido-visit-buffer (find-file-noselect (cdr filename)) method t)))
 
        ((and (eq ido-create-new-buffer 'prompt)
 	     (null require-match)
@@ -4128,6 +4131,8 @@ ido-visit-buffer
       (setq buffer (buffer-name buffer)))
   (let (win newframe)
     (cond
+     ;; "killing" of virtual buffers is handled in
+     ;; `ido-buffer-internal'
      ((eq method 'kill)
       (if record
 	  (ido-record-command 'kill-buffer buffer))
-- 
2.17.1