Skip to content

Instantly share code, notes, and snippets.

@peccu
Created March 30, 2010 20:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save peccu/349560 to your computer and use it in GitHub Desktop.
Save peccu/349560 to your computer and use it in GitHub Desktop.
;; 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