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)
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.
27 ;; Anything interface of in place annotations.
31 ;; Below are complete command list:
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
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)
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
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
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
))
89 ;;;; file-local source
90 (defvar anything-c-source-ipa
91 '((name .
"In Place Annotations (Current Buffer)")
92 (candidates . anything-ipa-candidates
)
93 (action ("Go To" . goto-char
)
94 ("Edit (empty string to delete)" .
95 (lambda (p) (save-excursion (goto-char p
) (ipa-edit t
))))
97 (lambda (p) (goto-char p
) (ipa-move t
))))
99 "`anything' source of ipa in current-buffer.")
101 (defun anything-ipa-candidates ()
103 (set-buffer anything-current-buffer
)
104 (loop for
(overlay . text
) in ipa-annotations-in-buffer
105 for pos
= (overlay-start overlay
)
106 for line
= (progn (goto-char pos
)
107 (buffer-substring (point-at-bol) (point-at-eol)))
108 for lineno
= (line-number-at-pos pos
)
110 (cons (format "%5d:[%s]%s"
111 lineno
(propertize text
'face ipa-annotation-face
) line
)
114 (defun anything-ipa ()
115 "`anything' interface of ipa."
117 (anything 'anything-c-source-ipa
))
120 (defvar anything-c-source-ipa-global
121 '((name .
"In Place Annotations (global)")
122 (init .
(lambda () (anything-candidate-buffer (ipa-find-storage-file))))
123 (get-line .
(lambda (s e
) (unless (= s e
) (cons (buffer-substring s e
) s
))))
124 (candidates-in-buffer)
126 (action ("Go To" . anything-ipa-go-to-annotation
)))
127 "`anything' source of all IPAs.")
129 (defun anything-ipa-go-to-annotation (pos)
130 (with-current-buffer (ipa-find-storage-file)
132 (ipa-go-to-annotation)))
134 (defun anything-ipa-global ()
135 "`anything' interface of ipa (global)."
137 (anything 'anything-c-source-ipa-global
))
139 (provide 'anything-ipa
)
141 ;; How to save (DO NOT REMOVE!!)
142 ;; (progn (magit-push) (emacswiki-post "anything-ipa.el"))
143 ;;; anything-ipa.el ends here