diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 2775042ed..f69045f03 100755 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,16 @@ +2009-10-17 John Wiegley + + * org.el (org-files-list): New utility function for returning a + list of all open org-mode buffers, plus all files used to build + the agenda buffer. Note that not all the files will necessarily + be visited by a buffer at time of call. + (org-entry-beginning-position): Like the function + `line-beginning-position', this inline function returns the + beginning position of the current heading/entry. + (org-entry-end-position): Like the function `line-end-position', + this inline function returns the end position of the current + heading/entry. + 2009-10-16 Carsten Dominik * org-agenda.el (org-agenda-list): Mark the all-todo items line as diff --git a/lisp/org.el b/lisp/org.el index d3d886ff0..f4635b9b5 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -5335,6 +5335,27 @@ are at least `org-cycle-separator-lines' empty lines before the headline." (let ((context (if (org-up-heading-safe) 'children 'overview))) (org-cycle-show-empty-lines context)))) +(defun org-files-list () + "Return `org-agenda-files' list, plus all open org-mode files. +This is useful for operations that need to scan all of a user's +open and agenda-wise Org files." + (let ((files (mapcar 'expand-file-name org-agenda-files))) + (dolist (buf (buffer-list)) + (with-current-buffer buf + (if (eq major-mode 'org-mode) + (let ((file (expand-file-name (buffer-file-name)))) + (unless (member file files) + (push file files)))))) + files)) + +(defsubst org-entry-beginning-position () + "Return the beginning position of the current entry." + (save-excursion (outline-back-to-heading t) (point))) + +(defsubst org-entry-end-position () + "Return the end position of the current entry." + (save-excursion (outline-next-heading) (point))) + (defun org-cycle-hide-drawers (state) "Re-hide all drawers after a visibility state change." (when (and (org-mode-p)