如何在某个位置杀死缓冲区文件的所有缓冲区?

时间:2015-09-28 11:37:06

标签: emacs elisp

如何在某个位置使用缓冲区文件终止所有缓冲区?

例如,我希望使用c:... \ dev中的缓冲区文件和所有dired buffer subdir将所有缓冲区杀死到c:... \ dev

或者换句话说,如何浏览emacs中所有缓冲区的文件或目录?

谢谢@David @phils。我在ibuffer中结合了elisp代码和函数

(mapc (lambda (buffer)
    (let ((file-name
           (or (buffer-file-name buffer)
               (with-current-buffer buffer
                 (and
                  (boundp 'dired-directory)
                  (stringp dired-directory)
                  dired-directory))
               )))
      (when (and file-name
                 (string-match "^c:.*?\\\\dev" file-name))
        (kill-buffer buffer))))
  (buffer-list))

1 个答案:

答案 0 :(得分:3)

来自elisp使用:

(mapc (lambda (buffer)
        (let ((file-name
               (or (buffer-file-name buffer)
                   ;; In dired-mode we need `dired-directory' which
                   ;; might be a list and may not be fully expanded.
                   (with-current-buffer buffer
                     (and (eq major-mode 'dired-mode)
                          (expand-file-name
                           (if (consp dired-directory)
                               (car dired-directory)
                             dired-directory)))))))
          (when (and file-name
                     (string-match "^c:\\\\.*\\\\dev" file-name))
            (kill-buffer buffer))))
      (buffer-list))