From 6cc7ff10929a0a76e022442bd4f98fd6ab873be6 Mon Sep 17 00:00:00 2001 From: Bastien Guerry Date: Tue, 18 Sep 2012 08:40:11 +0200 Subject: [PATCH 1/4] 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. --- lisp/org-agenda.el | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el index b24fd7bed..708831599 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." From a82797356c8c4e85fa0541479d70719c9f2bb09d Mon Sep 17 00:00:00 2001 From: Bastien Guerry Date: Tue, 18 Sep 2012 09:09:41 +0200 Subject: [PATCH 2/4] org-agenda.el: Fix the display of the number of commands for block agendas MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * org-agenda.el (org-agenda-get-restriction-and-command): Fix the display of the number of commands for block agendas. Thanks to Sébastien Vauban for reporting this. --- lisp/org-agenda.el | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el index 708831599..9d7d2fa3b 100644 --- a/lisp/org-agenda.el +++ b/lisp/org-agenda.el @@ -2675,13 +2675,12 @@ L Timeline for current buffer # List stuck projects (!=configure) ((stringp match) (setq match (copy-sequence match)) (org-add-props match nil 'face 'org-warning)) - (match - (format "set of %d commands" (length match))) - (t "")))) + ((listp type) + (format "set of %d commands" (length type)))))) (if (org-string-nw-p match) (add-text-properties 0 (length line) (list 'help-echo - (concat "Matcher: "match)) line))) + (concat "Matcher: " match)) line))) (push line lines))) (setq lines (nreverse lines)) (when prefixes From 0ca661415469b2434248f96a5fda66f0816f8728 Mon Sep 17 00:00:00 2001 From: Bastien Guerry Date: Tue, 18 Sep 2012 11:09:25 +0200 Subject: [PATCH 3/4] org-exp.el (org-export): Set the mark correctly when exporting a subtree * org-exp.el (org-export): Set the mark correctly when exporting a subtree. Thanks to Tyler Smith for reporting this problem. --- lisp/org-exp.el | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lisp/org-exp.el b/lisp/org-exp.el index d76a2952a..6b506cd12 100644 --- a/lisp/org-exp.el +++ b/lisp/org-exp.el @@ -974,6 +974,8 @@ Pressing `1' will switch between these two options." (let* ((bg (org-xor (equal arg '(16)) org-export-run-in-background)) (subtree-p (or (org-region-active-p) (eq org-export-initial-scope 'subtree))) + (regb (and (org-region-active-p) (region-beginning))) + (rege (and (org-region-active-p) (region-end))) (help "[t] insert the export option template \[v] limit export to visible part of outline tree \[1] switch buffer/subtree export @@ -1054,6 +1056,10 @@ Pressing `1' will switch between these two options." ((not subtree-p) (setq subtree-p t) (setq bpos (point)) + (org-mark-subtree) + (org-activate-mark) + (setq regb (and (org-region-active-p) (region-beginning))) + (setq rege (and (org-region-active-p) (region-end))) (message "Export subtree: ")))) (when (eq r1 ?\ ) (let ((case-fold-search t) @@ -1091,8 +1097,9 @@ Pressing `1' will switch between these two options." "-f" (symbol-name (nth 1 ass))))) (set-process-sentinel p 'org-export-process-sentinel) (message "Background process \"%s\": started" p)) - ;; background processing not requested, or not possible - (if subtree-p (progn (org-mark-subtree) (org-activate-mark))) + ;; set the mark correctly when exporting a subtree + (if subtree-p (let (deactivate-mark) (push-mark rege t t) (goto-char regb))) + (call-interactively (nth 1 ass)) (when (and bpos (get-buffer-window cbuf)) (let ((cw (selected-window))) From 90565f2eded81a4a3f908ccce2993274a2618650 Mon Sep 17 00:00:00 2001 From: Bastien Guerry Date: Tue, 18 Sep 2012 12:24:05 +0200 Subject: [PATCH 4/4] org.el (org-mode): Try to set the org-hide face correctly * org.el (org-mode): Try to set the org-hide face correctly. Thanks to Arne Babenhauserheide for reporting a related problem. --- lisp/org.el | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lisp/org.el b/lisp/org.el index bbb8c4ddd..79eddeb5a 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -5166,7 +5166,16 @@ The following commands are available: (require 'org-indent) (org-indent-mode 1)) (unless org-inhibit-startup-visibility-stuff - (org-set-startup-visibility)))) + (org-set-startup-visibility))) + ;; Try to set org-hide correctly + (set-face-foreground + 'org-hide + (or (face-background 'default) + (face-background 'org-default) + (cdr (assoc 'background-color default-frame-alist)) + (cdr (assoc 'background-color initial-frame-alist)) + (cdr (assoc 'background-color window-system-default-frame-alist)) + (face-foreground 'org-hide)))) (when (fboundp 'abbrev-table-put) (abbrev-table-put org-mode-abbrev-table