`anything-c-source-find-files': add `disable-shortcuts' attribute
[anything-config.git] / anything-ipa.el
blob107e53e7844c26041a141720c82c63f4752e3b99
1 ;;; anything-ipa.el --- Anything interface of In Place Annotation
2 ;; $Id: anything-ipa.el,v 1.6 2009-03-01 22:52:44 rubikitch Exp $
4 ;; Copyright (C) 2009 rubikitch
6 ;; Author: rubikitch <rubikitch@ruby-lang.org>
7 ;; Keywords: convenience, anything
8 ;; URL: http://www.emacswiki.org/cgi-bin/wiki/download/anything-ipa.el
10 ;; This file is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
13 ;; any later version.
15 ;; This file is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to
22 ;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
23 ;; Boston, MA 02110-1301, USA.
25 ;;; Commentary:
27 ;; Anything interface of in place annotations.
29 ;;; Commands:
31 ;; Below are complete command list:
33 ;; `anything-ipa'
34 ;; `anything' interface of ipa.
35 ;; `anything-ipa-global'
36 ;; `anything' interface of ipa (global).
38 ;;; Customizable Options:
40 ;; Below are customizable option list:
43 ;; Variable `anything-c-source-ipa' is source for in place annotations
44 ;; in current buffer. And command `anything-ipa' is anything menu of
45 ;; it. `anything-c-source-ipa-global' and `anything-ipa-global' are
46 ;; global ones.
49 ;;; Installation:
51 ;; Get ipa.el and anything.el from EmacsWiki
52 ;; http://www.emacswiki.org/cgi-bin/wiki/download/ipa.el
53 ;; http://www.emacswiki.org/cgi-bin/wiki/download/anything.el
55 ;; Then add the code below in your ~/.emacs.
56 ;; (require 'anything-ipa)
59 ;;; History:
61 ;; $Log: anything-ipa.el,v $
62 ;; Revision 1.6 2009-03-01 22:52:44 rubikitch
63 ;; Use `ipa-annotation-face' for annotation text
65 ;; Revision 1.5 2009/02/13 01:18:32 rubikitch
66 ;; migemize
68 ;; Revision 1.4 2009/02/13 00:49:36 rubikitch
69 ;; *** empty log message ***
71 ;; Revision 1.3 2009/02/13 00:48:08 rubikitch
72 ;; `anything-c-source-ipa': format change
74 ;; Revision 1.2 2009/02/13 00:46:16 rubikitch
75 ;; New variable: `anything-c-source-ipa-global'
76 ;; New command: `anything-ipa-global'
78 ;; Revision 1.1 2009/02/13 00:20:05 rubikitch
79 ;; Initial revision
82 ;;; Code:
84 (defvar anything-ipa-version "$Id: anything-ipa.el,v 1.6 2009-03-01 22:52:44 rubikitch Exp $")
85 (eval-when-compile (require 'cl))
86 (require 'anything)
87 (require 'ipa)
89 ;;;; file-local source
90 (defvar anything-c-source-ipa
91 '((name . "In Place Annotations (Current Buffer)")
92 (candidates . anything-ipa-candidates)
93 (action . goto-char)
94 (migemo))
95 "`anything' source of ipa in current-buffer.")
97 (defun anything-ipa-candidates ()
98 (save-excursion
99 (set-buffer anything-current-buffer)
100 (loop for (overlay . text) in ipa-annotations-in-buffer
101 for pos = (overlay-start overlay)
102 for line = (progn (goto-char pos)
103 (buffer-substring (point-at-bol) (point-at-eol)))
104 for lineno = (line-number-at-pos pos)
105 collect
106 (cons (format "%5d:[%s]%s"
107 lineno (propertize text 'face ipa-annotation-face) line)
108 pos))))
110 (defun anything-ipa ()
111 "`anything' interface of ipa."
112 (interactive)
113 (anything 'anything-c-source-ipa))
115 ;;;; global source
116 (defvar anything-c-source-ipa-global
117 '((name . "In Place Annotations (global)")
118 (init . (lambda () (anything-candidate-buffer (ipa-find-storage-file))))
119 (get-line . (lambda (s e) (unless (= s e) (cons (buffer-substring s e) s))))
120 (candidates-in-buffer)
121 (migemo)
122 (action ("Go To" . anything-ipa-go-to-annotation)))
123 "`anything' source of all IPAs.")
125 (defun anything-ipa-go-to-annotation (pos)
126 (with-current-buffer (ipa-find-storage-file)
127 (goto-char pos)
128 (ipa-go-to-annotation)))
130 (defun anything-ipa-global ()
131 "`anything' interface of ipa (global)."
132 (interactive)
133 (anything 'anything-c-source-ipa-global))
135 (provide 'anything-ipa)
137 ;; How to save (DO NOT REMOVE!!)
138 ;; (progn (magit-push) (emacswiki-post "anything-ipa.el"))
139 ;;; anything-ipa.el ends here