File: eproject-anything.el

package info (click to toggle)
eproject-el 1.5+git20180312.068218d-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 204 kB
  • sloc: lisp: 1,092; sh: 10; makefile: 2
file content (83 lines) | stat: -rw-r--r-- 3,188 bytes parent folder | download
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
77
78
79
80
81
82
83
;;; eproject-anything.el --- anything.el integration for eproject
;; Copyright (C) 2011 Antono Vasiljev

;; Author: Antono Vasiljev <self@antono.info>
;; Keywords: convenience, search, navigation

;; This program 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 of the License, or
;; (at your option) any later version.

;; This program 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 this program.  If not, see <http://www.gnu.org/licenses/>.
;;
;;; Commentary:

;; (require 'anything)
;; (require 'eproject)
;; (require 'eproject-anything)
;; (global-set-key (kbd "s-L") 'anything-eproject-files)
;; (global-set-key (kbd "s-b") 'anything-eproject-buffers)

;;; Code:
;;

(declare-function anything "anything")

;;;###autoload
(defvar anything-c-source-eproject-files
  '((name . "Files in eProject")
    (init . (lambda () (if (buffer-file-name)
                           (setq anything-eproject-root-dir
                                 (eproject-maybe-turn-on))
                         (setq anything-eproject-root-dir 'nil))))
    (candidates . (lambda () (if anything-eproject-root-dir
                                 (eproject-list-project-files
                                  anything-eproject-root-dir))))
    (type . file))
  "Search for files in the current eProject.")

;;;###autoload
(defvar anything-c-source-eproject-buffers
  '((name . "Buffers in this eProject")
    (init . (lambda () (if (buffer-file-name)
                           (setq anything-eproject-root-dir
                                 (eproject-maybe-turn-on))
                         (setq anything-eproject-root-dir 'nil))))
    (candidates . (lambda () (if anything-eproject-root-dir
                                 (mapcar 'buffer-name
                                         (cdr (assoc
                                               anything-eproject-root-dir
                                               (eproject--project-buffers)))))))
    (volatile)
    (type . buffer))
  "Search for buffers in this project.")

;;;###autoload
(defun anything-eproject-files ()
  "Preconfigured `anything' for searching files inside current eproject."
  (interactive)
  (let ((anything-sources
         '(anything-c-source-eproject-files))
        anything-samewindow)
    (anything nil nil nil nil nil "eproject")))

;;;###autoload
(defun anything-eproject-buffers ()
  "Preconfigured `anything' for opening buffers. Searches for
buffers in the current project, then other buffers, also gives
option of recentf. Replaces switch-to-buffer."
  (interactive)
  (anything '(anything-c-source-eproject-buffers
              anything-c-source-buffers+
              anything-c-source-buffer-not-found
              anything-c-source-recentf)))

(provide 'eproject-anything)
;;; eproject-anything.el ends here