summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Guerry <bzg@altern.org>2012-09-18 08:40:11 +0200
committerBastien Guerry <bzg@altern.org>2012-09-18 08:40:11 +0200
commit6cc7ff10929a0a76e022442bd4f98fd6ab873be6 (patch)
tree9ebabe159750c36c53c30cd29f85e33ee212c276
parenta67676809c042805dfeeb9d677d4dafc0df7c369 (diff)
downloadorg-mode-6cc7ff10929a0a76e022442bd4f98fd6ab873be6.tar.gz
org-agenda.el: Allow `org-agenda-finalize-hook' to modify the buffer
* org-agenda.el (org-agenda-before-write-hook) (org-agenda-add-entry-text-maxlines): Enhance phrasing. (org-agenda-finalize-hook, org-agenda-mode-hook): Tell that the buffer is writable when the hook is called. (org-agenda-finalize): Allow org-agenda-finalize-hook to modify the buffer. Thanks to Moritz Ulrich and to Aaron Ecay for triggering this fix.
-rw-r--r--lisp/org-agenda.el22
1 files changed, 14 insertions, 8 deletions
diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
index b24fd7b..7088315 100644
--- a/lisp/org-agenda.el
+++ b/lisp/org-agenda.el
@@ -160,8 +160,8 @@ before assigned to the variables. So make sure to quote values you do
(sexp :tag "Value"))))
(defcustom org-agenda-before-write-hook '(org-agenda-add-entry-text)
- "Hook run in temporary buffer before writing it to an export file.
-A useful function is `org-agenda-add-entry-text'."
+ "Hook run in a temporary buffer before writing the agenda to an export file.
+A useful function for this hook is `org-agenda-add-entry-text'."
:group 'org-agenda-export
:type 'hook
:options '(org-agenda-add-entry-text))
@@ -169,7 +169,7 @@ A useful function is `org-agenda-add-entry-text'."
(defcustom org-agenda-add-entry-text-maxlines 0
"Maximum number of entry text lines to be added to agenda.
This is only relevant when `org-agenda-add-entry-text' is part of
-`org-agenda-before-write-hook', which it is by default.
+`org-agenda-before-write-hook', which is the default.
When this is 0, nothing will happen. When it is greater than 0, it
specifies the maximum number of lines that will be added for each entry
that is listed in the agenda view.
@@ -902,7 +902,12 @@ to nil."
(make-obsolete-variable 'org-finalize-agenda-hook 'org-agenda-finalize-hook "24.3")
(defcustom org-agenda-finalize-hook nil
- "Hook run just before displaying an agenda buffer."
+ "Hook run just before displaying an agenda buffer.
+The buffer is still writable when the hook is called.
+
+You can modify some of the buffer substrings but you should be
+extra careful not to modify the text properties of the agenda
+headlines as the agenda display heavily relies on them."
:group 'org-agenda-startup
:type 'hook)
@@ -1850,7 +1855,8 @@ works you probably want to add it to `org-agenda-custom-commands' for good."
(defvar org-agenda-redo-command nil)
(defvar org-agenda-query-string nil)
(defvar org-agenda-mode-hook nil
- "Hook for `org-agenda-mode', run after the mode is turned on.")
+ "Hook run after `org-agenda-mode' is turned on.
+The buffer is still writable when this hook is called.")
(defvar org-agenda-type nil)
(defvar org-agenda-force-single-file nil)
(defvar org-agenda-bulk-marked-entries nil
@@ -3437,14 +3443,14 @@ generating a new one."
(org-agenda-entry-text-show))
(if (functionp 'org-habit-insert-consistency-graphs)
(org-habit-insert-consistency-graphs))
- (run-hooks 'org-agenda-finalize-hook)
+ (let ((inhibit-read-only t))
+ (run-hooks 'org-agenda-finalize-hook))
(setq org-agenda-type (org-get-at-bol 'org-agenda-type))
(when (or org-agenda-tag-filter (get 'org-agenda-tag-filter :preset-filter))
(org-agenda-filter-apply org-agenda-tag-filter 'tag))
(when (or org-agenda-category-filter (get 'org-agenda-category-filter :preset-filter))
(org-agenda-filter-apply org-agenda-category-filter 'category))
- (org-add-hook 'kill-buffer-hook 'org-agenda-reset-markers 'append 'local)
- )))
+ (org-add-hook 'kill-buffer-hook 'org-agenda-reset-markers 'append 'local))))
(defun org-agenda-mark-clocking-task ()
"Mark the current clock entry in the agenda if it is present."