Added three new utility functions to 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.
This commit is contained in:
John Wiegley 2009-10-16 21:59:15 -04:00
parent c2719b7e06
commit 080babb885
2 changed files with 34 additions and 0 deletions

View File

@ -1,3 +1,16 @@
2009-10-17 John Wiegley <johnw@newartisans.com>
* 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 <carsten.dominik@gmail.com>
* org-agenda.el (org-agenda-list): Mark the all-todo items line as

View File

@ -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)