emacs - Killing buffers whose names start with a particular string -


here's problem: use emacs , lots of buffers pretty useless time, *messages* or *completions*.

i want bind \c-y close buffers start * except *shell* (and *shell* < k >) buffers.

to that, i'd add emacs-lisp in .emacs file:

(defun string-prefix s1 s2   (if (> (string-length s1) (string-length s2)) nil     (string=? s1 (substring s2 0 (string-length s1))) ))  (defun curry2   (lambda (f)     (lambda (x)       (lambda (y)     (f x y) ))))  (defun filter   (lambda (f l)     (if (null? l) '()       (let ((rest (cdr l)))     (if (f (car l)) (cons (car l) rest)       rest) ))))   (defun kill-useless (arg)   (interactive "p")   (map 'kill-buffer        (filter     (not ((curry2 string-prefix) "*shell*"))     (list-buffers)     ) ))  (global-set-key "\c-y" 'kill-useless) 

i've tested string-prefix , curry2 using scheme , filter seems pretty straightforward. sadly can't kill-useless work properly.

it says filter: invalid function: (curry2 string-prefix).

now, thing kind of suck @ emacs-lisp, don't use lisp except scheme, , in scheme (mit), works:

(filter ((curry2 string-prefix?) "*shell") '("*shell*" "*sh22" "eel")) ;value 5: ("*shell*") 

i'd like:

  1. a way fix code
  2. suggestions on how in different way

thanks!

an alternate approach:

(require 'cl)  (defun is-useless-buffer (buffer)   (let ((name (buffer-name buffer)))     (and (= ?* (aref name 0))          (not (string-match "^\\*shell\\*" name)))))  (defun kill-useless-buffers ()   (interactive)   (loop buffer being buffers         (and (is-useless-buffer buffer) (kill-buffer buffer)))) 

Comments

Popular posts from this blog

linux - Mailx and Gmail nss config dir -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -