0
0
Fork 1
mirror of https://git.savannah.gnu.org/git/emacs/org-mode.git synced 2024-08-27 03:02:52 +00:00

Base org-iswitchb buffer selection on major-mode.

This was a request by Mike Newman.
This commit is contained in:
Carsten Dominik 2008-07-28 17:05:04 -07:00
parent d172a1ccc5
commit badb19e1c7
2 changed files with 38 additions and 23 deletions

View file

@ -1,3 +1,8 @@
2008-07-29 Carsten Dominik <dominik@science.uva.nl>
* org.el (org-buffer-list): Select buffers based on major mode,
not on file name.
2008-07-26 Carsten Dominik <dominik@science.uva.nl> 2008-07-26 Carsten Dominik <dominik@science.uva.nl>
* org-agenda.el (org-agenda-align-tags): Fix bug with malformed * org-agenda.el (org-agenda-align-tags): Fix bug with malformed

View file

@ -11880,7 +11880,7 @@ If there is already a time stamp at the cursor position, update it."
With a prefix argument, restrict available to files. With a prefix argument, restrict available to files.
With two prefix arguments, restrict available buffers to agenda files. With two prefix arguments, restrict available buffers to agenda files.
Due to some yet unresolved reason, global function Due to some yet unresolved reason, the global function
`iswitchb-mode' needs to be active for this function to work." `iswitchb-mode' needs to be active for this function to work."
(interactive "P") (interactive "P")
(require 'iswitchb) (require 'iswitchb)
@ -11899,33 +11899,43 @@ Due to some yet unresolved reason, global function
"Switch-to: " nil t)) "Switch-to: " nil t))
(or enabled (iswitchb-mode -1)))))) (or enabled (iswitchb-mode -1))))))
(defun org-buffer-list (&optional predicate tmp) (defun org-buffer-list (&optional predicate exclude-tmp)
"Return a list of Org buffers. "Return a list of Org buffers.
PREDICATE can be either 'export, 'files or 'agenda. PREDICATE can be `export', `files' or `agenda'.
'export restrict the list to Export buffers. export restrict the list to Export buffers.
'files restrict the list to buffers visiting Org files. files restrict the list to buffers visiting Org files.
'agenda restrict the list to buffers visiting agenda files. agenda restrict the list to buffers visiting agenda files.
If TMP is non-nil, don't include temporary buffers." If EXCLUDE-TMP is non-nil, ignore temporary buffers."
(let (filter blist) (let* ((bfn nil)
(setq filter (agenda-files (and (eq predicate 'agenda)
(cond ((eq predicate 'files) "\.org$") (mapcar 'file-truename (org-agenda-files t))))
((eq predicate 'export) "\*Org .*Export") (filter
(t "\*Org \\|\.org$"))) (cond
(setq blist ((eq predicate 'files)
(lambda (b) (with-current-buffer b (eq major-mode 'org-mode))))
((eq predicate 'export)
(lambda (b) (string-match "\*Org .*Export" (buffer-name b))))
((eq predicate 'agenda)
(lambda (b)
(with-current-buffer b
(and (eq major-mode 'org-mode)
(setq bfn (buffer-file-name b))
(member (file-truename bfn) agenda-files)))))
(t (lambda (b) (with-current-buffer b
(or (eq major-mode 'org-mode)
(string-match "\*Org .*Export"
(buffer-name b)))))))))
(delq nil
(mapcar (mapcar
(lambda(b) (lambda(b)
(let ((bname (buffer-name b)) (if (and (funcall filter b)
(bfile (buffer-file-name b))) (or (not exclude-tmp)
(if (and (string-match filter bname) (not (string-match "tmp" (buffer-name b)))))
(if (eq predicate 'agenda) b
(member bfile nil))
(mapcar (lambda(f) (file-truename f)) (buffer-list)))))
org-agenda-files)) t)
(if tmp (not (string-match "tmp" bname)) t)) b)))
(buffer-list)))
(delete nil blist)))
(defun org-agenda-files (&optional unrestricted archives) (defun org-agenda-files (&optional unrestricted archives)
"Get the list of agenda files. "Get the list of agenda files.