123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- (defun org-iswitchb (&optional arg)
- "Use `iswitchb-read-buffer' to prompt for an Org buffer to switch to.
- With a prefix argument, restrict available to files.
- With two prefix arguments, restrict available buffers to agenda files.
- Due to some yet unresolved reason, global function
- `iswitchb-mode' needs to be active for this function to work."
- (interactive "P")
- (eval-when-compile
- (require 'iswitchb))
- (let ((enabled iswitchb-mode) blist)
- (or enabled (iswitchb-mode 1))
- (setq blist (cond ((equal arg '(4)) (org-buffer-list 'files))
- ((equal arg '(16)) (org-buffer-list 'agenda))
- (t (org-buffer-list))))
- (unwind-protect
- (let ((iswitchb-make-buflist-hook
- (lambda ()
- (setq iswitchb-temp-buflist
- (mapcar 'buffer-name blist)))))
- (switch-to-buffer
- (iswitchb-read-buffer
- "Switch-to: " nil t))
- (or enabled (iswitchb-mode -1))))))
- (defun org-buffer-list (&optional predicate tmp)
- "Return a list of Org buffers.
- PREDICATE can be either 'export, 'files or 'agenda.
- 'export restrict the list to Export buffers.
- 'files restrict the list to buffers visiting Org files.
- 'agenda restrict the list to buffers visiting agenda files.
- If TMP is non-nil, don't include temporary buffers."
- (let (filter blist)
- (setq filter
- (cond ((eq predicate 'files) "\.org$")
- ((eq predicate 'export) "\*Org .*Export")
- (t "\*Org \\|\.org$")))
- (setq blist
- (mapcar
- (lambda(b)
- (let ((bname (buffer-name b))
- (bfile (buffer-file-name b)))
- (if (and (string-match filter bname)
- (if (eq predicate 'agenda)
- (member bfile
- (mapcar (lambda(f) (file-truename f))
- org-agenda-files)) t)
- (if tmp (not (string-match "tmp" bname)) t)) b)))
- (buffer-list)))
- (delete nil blist)))
- (provide 'org-iswitchb)
|