0

I'm trying to kill buffers after selecting them from buffer-list:

(kill-buffer
 (cl-remove-if-not (lambda (b)
                     (and
                      (string-match-p "ein" (buffer-name b))
                      (string-match-p "notebooklist" (buffer-name b))
                      )
                     )
                   (buffer-list))
 )

Sadly it yields an error: ERROR: (wrong-type-argument stringp (*ein:notebooklist http://127.0.0.1:8888*))

If anyone knew how to check what needs to be done to it before giving it to kill-buffer function that would be really helpful.

2

2 Answers 2

0

Kill-buffer expects a buffer or a buffer name (string) as argument. You're passing it a list with only one element: the buffer name.

Pass the car of that list (its only element) to kill-buffer:

(kill-buffer
 (car (cl-remove-if-not (lambda (b)
                          (and (string-match-p "ein" (buffer-name b))
                               (string-match-p "notebooklist" (buffer-name b))))
                        (buffer-list))))
0

mapc function seems to work - it applies kill-buffer function for every element in the list:

 (mapc 'kill-buffer
  (cl-remove-if-not (lambda (b)
                      (and
                       (string-match-p "ein" (buffer-name b))
                       (string-match-p "notebooklist" (buffer-name b))
                       )
                      )
                    (buffer-list))
  )

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.