-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathsimp-project-ibuffer.el
76 lines (60 loc) · 2.68 KB
/
simp-project-ibuffer.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
;;; simp-project-ibuffer.el --- Find files in a simp project
;; Copyright (C) 2011-2015 @re5et
;; Author: atom smith
;; URL: https://github.com/re5et/simp
;; Created: 16 Jan 2013
;; Version: 0.4.0
;; Keywords: project grep find
;; This file is NOT part of GNU Emacs.
;; This is free software; you can redistribute it and/or modify it under
;; the terms of the GNU General Public License as published by the Free
;; Software Foundation; either version 3, or (at your option) any later
;; version.
;; This file is distributed in the hope that it will be useful, but
;; WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;; General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with Emacs; see the file COPYING, or type `C-h C-c'. If not,
;; write to the Free Software Foundation at this address:
;; Free Software Foundation
;; 51 Franklin Street, Fifth Floor
;; Boston, MA 02110-1301
;; USA
;;; Commentary
(require 'ibuf-ext)
(define-ibuffer-filter simp-project-buffers
"Ibuffer filtered by buffers associated with current-buffer simp-project"
(:description "simp project"
:reader (read-from-minibuffer "simp project directory: "))
(ibuffer-awhen (simp-project-ibuffer-buffer-root buf)
(string-match qualifier it)))
(define-ibuffer-filter simp-project-file-buffers
"Ibuffer filtered by file buffers associated with current-buffer simp-project"
(:description "simp project"
:reader (read-from-minibuffer "simp project directory: "))
(ibuffer-awhen (and (buffer-local-value 'buffer-file-name buf)
(simp-project-ibuffer-buffer-root buf))
(string-match qualifier it)))
(defun simp-project-ibuffer (&optional files-only)
"Start Ibuffer filtered to buffers associated with your
current buffers simp project. If FILES-ONLY is non-nil, only
show buffers associated with files"
(interactive)
(let ((default-directory (simp-project-root))
(simp-project-filter (if files-only
'simp-project-file-buffers
'simp-project-buffers)))
(ibuffer t "*simp Ibuffer*" `((,simp-project-filter . ,(simp-project-root))))))
(defun simp-project-ibuffer-files-only ()
"Convenience method to start simp-project-ibuffer
with files only flag set."
(interactive)
(simp-project-ibuffer t))
(defun simp-project-ibuffer-buffer-root (buffer)
(condition-case nil
(with-current-buffer buffer (simp-project-root))
(error nil)))
(simp-project-ibuffer-buffer-root (current-buffer))
(provide 'simp-project-ibuffer)
;;; simp-project-ibuffer.el ends here