Download
(eval-when-compile (require 'cl))
(require 'bm)
(defun bm-all ()
"Displays a buffer listing the bookmarks in all open buffers."
(interactive)
(let* ((bookmarks (bm-all-bookmarks))
(lines (mapconcat 'bm-format-line bookmarks "")))
(if (null bookmarks)
(message "No bookmarks.")
(with-output-to-temp-buffer "*bm-bookmarks*"
(set-buffer standard-output)
(insert lines)
(bm-show-mode)
(setq buffer-read-only t))
(let ((header (format " %-30s %5s %s" "Buffer" "Line" "Content")))
(put-text-property 0 (length header) 'face 'fixed-pitch header)
(with-current-buffer "*bm-bookmarks*"
(setq header-line-format header))))))
(defun bm-format-line (bm)
(let ((buf (overlay-buffer bm)))
(with-current-buffer buf
(let ((string
(format "%-30s %5s %s"
buf
(count-lines (point-min) (overlay-start bm))
(buffer-substring (overlay-start bm) (overlay-end bm)))))
(put-text-property 0 (length string) 'bm-buffer buf string)
(put-text-property 0 (length string) 'bm-bookmark bm string)
string))))
(defun bm-all-bookmarks ()
(let (bookmarks)
(mapcar #'(lambda (buf)
(mapcar #'(lambda (bm) (push bm bookmarks))
(bm-bookmarks-in-buffer buf)))
(buffer-list))
bookmarks))
(defun bm-bookmarks-in-buffer (buf)
"Gets a list of bookmarks in `buf', which can be a string or a buffer."
(flet ((mklist (x) (if (listp x) x (list x))))
(mklist
(with-current-buffer buf
(apply 'append
(mapcar 'mklist (remove nil (bm-lists))))))))
(provide 'bm-ext)