Here s my problem: I use Emacs and get lots of buffers that are pretty useless all the time, like *Messages* or *Completions*.
除了*shell*(和*shell* <k >)缓冲外,我想把C-y捆绑起来,关闭从*起的所有缓冲地带。
为此,我要在我的ema子档案中增加一些Emacs-Lisp:
(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 already tested string-prefix
and curry2
using Scheme and filter
seems pretty straightforward.
Sadly I just can t get kill-useless
to work properly.
它说<代码>过滤器:无效功能:(curry2 string-prefix)。
现在,在Emacs-Lisp,我确实不使用任何许可证,但计划(麻省理工学院)则这样做:
(filter ((curry2 string-prefix?) "*shell") ("*shell*" "*sh22" "eel"))
;Value 5: ("*shell*")
我这样说:
- a way to fix my code
- suggestions on how to do this in a different way
感谢!