Created
March 30, 2010 20:33
-
-
Save peccu/349560 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; cf.http://d.hatena.ne.jp/grandVin/20080912/1221245359 | |
;; どうもこれでできてるらしいけど,自分のためにも自作してみた | |
;; だいたい下のような設定になっていれば | |
;; `bm-repository'にbookmarkのリストが入っている | |
;; これをanythingで選択して,jumpできるようにする | |
;; (setq-default bm-buffer-persistence t) | |
;; (add-hook' after-init-hook 'bm-repository-load) | |
;; (add-hook 'find-file-hooks 'bm-buffer-restore) | |
;; (add-hook 'kill-buffer-hook 'bm-buffer-save) | |
;; (add-hook 'auto-save-hook 'bm-buffer-save) | |
;; (add-hook 'after-save-hook 'bm-buffer-save) | |
;;; Visible Bookmarks(global) | |
;; (install-elisp "http://cvs.savannah.gnu.org/viewvc/*checkout*/bm/bm/bm.el") | |
(defvar anything-c-source-bm-global | |
'((name . "Global Bookmarks") | |
(init . anything-c-bm-global-init) | |
(candidates-in-buffer) | |
(type . file-line)) | |
"Needs bm.el. | |
http://www.nongnu.org/bm/") | |
(defun anything-c-bm-global-init () | |
"Init function for `anything-c-source-bm-global'." | |
(when (require 'bm nil t) | |
(with-no-warnings | |
(let ((files bm-repository) | |
(buf (anything-candidate-buffer 'global))) | |
(loop for (file . data) in files ;dataにカレントバッファのブックマーク情報を格納 | |
do | |
(let ((bookmarks (cdr (assoc 'bookmarks data)))) | |
;; (message (format "file:%s" file)) (sit-for 1) | |
(loop for bookmark in bookmarks | |
do | |
(let ((pos (cdr (assoc 'position bookmark))) ;bookmarkの場所をposに | |
(annotation (cdr (assoc 'annotation bookmark)))) | |
(let ((str (with-current-buffer (find-file-noselect file) | |
;; (message (format "annotation:%s" annotation)) (sit-for 2) | |
(goto-char pos) | |
(beginning-of-line) | |
(let (line) | |
(if (string= "" line) | |
(setq line "<EMPTY LINE>") | |
(setq line (car (split-string (thing-at-point 'line) "[\n\r]")))) | |
(format "%s: %7d: [%s]: %s\n" file (line-number-at-pos) annotation line))))) | |
(with-current-buffer buf (insert str))))))))))) | |
;; (anything 'anything-c-source-bm-global) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment