emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH] Always return refreshed category
@ 2010-12-22 14:06 Julien Danjou
  2010-12-23  7:43 ` [Accepted] " Carsten Dominik
  2010-12-23  7:43 ` [PATCH] " Carsten Dominik
  0 siblings, 2 replies; 13+ messages in thread
From: Julien Danjou @ 2010-12-22 14:06 UTC (permalink / raw)
  To: emacs-orgmode; +Cc: Julien Danjou

* org-icalendar.el (org-print-icalendar-entries): Do not manually
  refresh categories.

* org-clock.el (org-clock-insert-selection-line): Do not manually
  refresh categories.

* org.el (org-get-category): Refresh categories if no category found.
(org-entry-properties): Do not manually refresh categories.
(org-prepare-agenda-buffers): Do not manually refresh categories.

It seems a very bad thing to call manually for a category refresh. It
seems better to try to refresh if we do not have a category.

Signed-off-by: Julien Danjou <julien@danjou.info>
---
 lisp/org-archive.el   |    1 -
 lisp/org-clock.el     |    4 +---
 lisp/org-icalendar.el |    1 -
 lisp/org.el           |   11 +++++------
 4 files changed, 6 insertions(+), 11 deletions(-)

diff --git a/lisp/org-archive.el b/lisp/org-archive.el
index e56b01f..c32ee23 100644
--- a/lisp/org-archive.el
+++ b/lisp/org-archive.el
@@ -226,7 +226,6 @@ this heading."
       (save-excursion
 	(org-back-to-heading t)
 	;; Get context information that will be lost by moving the tree
-	(org-refresh-category-properties)
 	(setq category (org-get-category)
 	      todo (and (looking-at org-todo-line-regexp)
 			(match-string 2))
diff --git a/lisp/org-clock.el b/lisp/org-clock.el
index 93b0b52..17fccae 100644
--- a/lisp/org-clock.el
+++ b/lisp/org-clock.el
@@ -442,9 +442,7 @@ pointing to it."
 	    (ignore-errors
 	      (goto-char marker)
 	      (setq file (buffer-file-name (marker-buffer marker))
-		    cat (or (org-get-category)
-			    (progn (org-refresh-category-properties)
-				   (org-get-category)))
+		    cat (org-get-category)
 		    heading (org-get-heading 'notags)
 		    prefix (save-excursion
 			     (org-back-to-heading t)
diff --git a/lisp/org-icalendar.el b/lisp/org-icalendar.el
index d4034fe..a1bc5ad 100644
--- a/lisp/org-icalendar.el
+++ b/lisp/org-icalendar.el
@@ -302,7 +302,6 @@ When COMBINE is non nil, add the category to each line."
 	scheduledp deadlinep todo prefix due start
 	tmp pri categories location summary desc uid alarm
 	(sexp-buffer (get-buffer-create "*ical-tmp*")))
-    (org-refresh-category-properties)
     (save-excursion
       (goto-char (point-min))
       (while (re-search-forward re1 nil t)
diff --git a/lisp/org.el b/lisp/org.el
index 3cecca7..e80d2fc 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -8141,7 +8141,10 @@ call CMD."
 
 (defun org-get-category (&optional pos)
   "Get the category applying to position POS."
-  (get-text-property (or pos (point)) 'org-category))
+  (let ((pos (or pos (point))))
+    (or (get-text-property pos 'org-category)
+	(org-refresh-category-properties)
+	(get-text-property pos 'org-category))))
 
 (defun org-refresh-category-properties ()
   "Refresh category text properties in the buffer."
@@ -13481,10 +13484,7 @@ things up because then unnecessary parsing is avoided."
 						       'add_times))
 		    props))
 	  (unless (assoc "CATEGORY" props)
-	    (setq value (or (org-get-category)
-			    (progn (org-refresh-category-properties)
-				   (org-get-category))))
-	    (push (cons "CATEGORY" value) props))
+	    (push (cons "CATEGORY" (org-get-category)) props))
 	  (append sum-props (nreverse props)))))))
 
 (defun org-entry-get (pom property &optional inherit literal-nil)
@@ -15701,7 +15701,6 @@ When a buffer is unmodified, it is just killed.  When modified, it is saved
 	      (set-buffer (org-get-agenda-file-buffer file)))
 	    (widen)
 	    (setq bmp (buffer-modified-p))
-	    (org-refresh-category-properties)
 	    (setq org-todo-keywords-for-agenda
 		  (append org-todo-keywords-for-agenda org-todo-keywords-1))
 	    (setq org-done-keywords-for-agenda
-- 
1.7.2.3

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [Accepted] Always return refreshed category
  2010-12-22 14:06 [PATCH] Always return refreshed category Julien Danjou
@ 2010-12-23  7:43 ` Carsten Dominik
  2010-12-23  7:43 ` [PATCH] " Carsten Dominik
  1 sibling, 0 replies; 13+ messages in thread
From: Carsten Dominik @ 2010-12-23  7:43 UTC (permalink / raw)
  To: emacs-orgmode

Patch 505 (http://patchwork.newartisans.com/patch/505/) is now "Accepted".

Maintainer comment: No comment

This relates to the following submission:

http://mid.gmane.org/%3C1293026785-12467-1-git-send-email-julien%40danjou.info%3E

Here is the original message containing the patch:

> Content-Type: text/plain; charset="utf-8"
> MIME-Version: 1.0
> Content-Transfer-Encoding: 7bit
> Subject: [Orgmode] Always return refreshed category
> Date: Wed, 22 Dec 2010 19:06:25 -0000
> From: Julien Danjou <julien@danjou.info>
> X-Patchwork-Id: 505
> Message-Id: <1293026785-12467-1-git-send-email-julien@danjou.info>
> To: emacs-orgmode@gnu.org
> Cc: Julien Danjou <julien@danjou.info>
> 
> * org-icalendar.el (org-print-icalendar-entries): Do not manually
>   refresh categories.
> 
> * org-clock.el (org-clock-insert-selection-line): Do not manually
>   refresh categories.
> 
> * org.el (org-get-category): Refresh categories if no category found.
> (org-entry-properties): Do not manually refresh categories.
> (org-prepare-agenda-buffers): Do not manually refresh categories.
> 
> It seems a very bad thing to call manually for a category refresh. It
> seems better to try to refresh if we do not have a category.
> 
> Signed-off-by: Julien Danjou <julien@danjou.info>
> 
> ---
> lisp/org-archive.el   |    1 -
>  lisp/org-clock.el     |    4 +---
>  lisp/org-icalendar.el |    1 -
>  lisp/org.el           |   11 +++++------
>  4 files changed, 6 insertions(+), 11 deletions(-)
> 
> diff --git a/lisp/org-archive.el b/lisp/org-archive.el
> index e56b01f..c32ee23 100644
> --- a/lisp/org-archive.el
> +++ b/lisp/org-archive.el
> @@ -226,7 +226,6 @@ this heading."
>        (save-excursion
>  	(org-back-to-heading t)
>  	;; Get context information that will be lost by moving the tree
> -	(org-refresh-category-properties)
>  	(setq category (org-get-category)
>  	      todo (and (looking-at org-todo-line-regexp)
>  			(match-string 2))
> diff --git a/lisp/org-clock.el b/lisp/org-clock.el
> index 93b0b52..17fccae 100644
> --- a/lisp/org-clock.el
> +++ b/lisp/org-clock.el
> @@ -442,9 +442,7 @@ pointing to it."
>  	    (ignore-errors
>  	      (goto-char marker)
>  	      (setq file (buffer-file-name (marker-buffer marker))
> -		    cat (or (org-get-category)
> -			    (progn (org-refresh-category-properties)
> -				   (org-get-category)))
> +		    cat (org-get-category)
>  		    heading (org-get-heading 'notags)
>  		    prefix (save-excursion
>  			     (org-back-to-heading t)
> diff --git a/lisp/org-icalendar.el b/lisp/org-icalendar.el
> index d4034fe..a1bc5ad 100644
> --- a/lisp/org-icalendar.el
> +++ b/lisp/org-icalendar.el
> @@ -302,7 +302,6 @@ When COMBINE is non nil, add the category to each line."
>  	scheduledp deadlinep todo prefix due start
>  	tmp pri categories location summary desc uid alarm
>  	(sexp-buffer (get-buffer-create "*ical-tmp*")))
> -    (org-refresh-category-properties)
>      (save-excursion
>        (goto-char (point-min))
>        (while (re-search-forward re1 nil t)
> diff --git a/lisp/org.el b/lisp/org.el
> index 3cecca7..e80d2fc 100644
> --- a/lisp/org.el
> +++ b/lisp/org.el
> @@ -8141,7 +8141,10 @@ call CMD."
>  
>  (defun org-get-category (&optional pos)
>    "Get the category applying to position POS."
> -  (get-text-property (or pos (point)) 'org-category))
> +  (let ((pos (or pos (point))))
> +    (or (get-text-property pos 'org-category)
> +	(org-refresh-category-properties)
> +	(get-text-property pos 'org-category))))
>  
>  (defun org-refresh-category-properties ()
>    "Refresh category text properties in the buffer."
> @@ -13481,10 +13484,7 @@ things up because then unnecessary parsing is avoided."
>  						       'add_times))
>  		    props))
>  	  (unless (assoc "CATEGORY" props)
> -	    (setq value (or (org-get-category)
> -			    (progn (org-refresh-category-properties)
> -				   (org-get-category))))
> -	    (push (cons "CATEGORY" value) props))
> +	    (push (cons "CATEGORY" (org-get-category)) props))
>  	  (append sum-props (nreverse props)))))))
>  
>  (defun org-entry-get (pom property &optional inherit literal-nil)
> @@ -15701,7 +15701,6 @@ When a buffer is unmodified, it is just killed.  When modified, it is saved
>  	      (set-buffer (org-get-agenda-file-buffer file)))
>  	    (widen)
>  	    (setq bmp (buffer-modified-p))
> -	    (org-refresh-category-properties)
>  	    (setq org-todo-keywords-for-agenda
>  		  (append org-todo-keywords-for-agenda org-todo-keywords-1))
>  	    (setq org-done-keywords-for-agenda
> 

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] Always return refreshed category
  2010-12-22 14:06 [PATCH] Always return refreshed category Julien Danjou
  2010-12-23  7:43 ` [Accepted] " Carsten Dominik
@ 2010-12-23  7:43 ` Carsten Dominik
  2010-12-23 15:42   ` Matt Lundin
  1 sibling, 1 reply; 13+ messages in thread
From: Carsten Dominik @ 2010-12-23  7:43 UTC (permalink / raw)
  To: Julien Danjou; +Cc: emacs-orgmode

Applied, thanks.

- Carsten

On Dec 22, 2010, at 3:06 PM, Julien Danjou wrote:

> * org-icalendar.el (org-print-icalendar-entries): Do not manually
>  refresh categories.
>
> * org-clock.el (org-clock-insert-selection-line): Do not manually
>  refresh categories.
>
> * org.el (org-get-category): Refresh categories if no category found.
> (org-entry-properties): Do not manually refresh categories.
> (org-prepare-agenda-buffers): Do not manually refresh categories.
>
> It seems a very bad thing to call manually for a category refresh. It
> seems better to try to refresh if we do not have a category.
>
> Signed-off-by: Julien Danjou <julien@danjou.info>
> ---
> lisp/org-archive.el   |    1 -
> lisp/org-clock.el     |    4 +---
> lisp/org-icalendar.el |    1 -
> lisp/org.el           |   11 +++++------
> 4 files changed, 6 insertions(+), 11 deletions(-)
>
> diff --git a/lisp/org-archive.el b/lisp/org-archive.el
> index e56b01f..c32ee23 100644
> --- a/lisp/org-archive.el
> +++ b/lisp/org-archive.el
> @@ -226,7 +226,6 @@ this heading."
>       (save-excursion
> 	(org-back-to-heading t)
> 	;; Get context information that will be lost by moving the tree
> -	(org-refresh-category-properties)
> 	(setq category (org-get-category)
> 	      todo (and (looking-at org-todo-line-regexp)
> 			(match-string 2))
> diff --git a/lisp/org-clock.el b/lisp/org-clock.el
> index 93b0b52..17fccae 100644
> --- a/lisp/org-clock.el
> +++ b/lisp/org-clock.el
> @@ -442,9 +442,7 @@ pointing to it."
> 	    (ignore-errors
> 	      (goto-char marker)
> 	      (setq file (buffer-file-name (marker-buffer marker))
> -		    cat (or (org-get-category)
> -			    (progn (org-refresh-category-properties)
> -				   (org-get-category)))
> +		    cat (org-get-category)
> 		    heading (org-get-heading 'notags)
> 		    prefix (save-excursion
> 			     (org-back-to-heading t)
> diff --git a/lisp/org-icalendar.el b/lisp/org-icalendar.el
> index d4034fe..a1bc5ad 100644
> --- a/lisp/org-icalendar.el
> +++ b/lisp/org-icalendar.el
> @@ -302,7 +302,6 @@ When COMBINE is non nil, add the category to  
> each line."
> 	scheduledp deadlinep todo prefix due start
> 	tmp pri categories location summary desc uid alarm
> 	(sexp-buffer (get-buffer-create "*ical-tmp*")))
> -    (org-refresh-category-properties)
>     (save-excursion
>       (goto-char (point-min))
>       (while (re-search-forward re1 nil t)
> diff --git a/lisp/org.el b/lisp/org.el
> index 3cecca7..e80d2fc 100644
> --- a/lisp/org.el
> +++ b/lisp/org.el
> @@ -8141,7 +8141,10 @@ call CMD."
>
> (defun org-get-category (&optional pos)
>   "Get the category applying to position POS."
> -  (get-text-property (or pos (point)) 'org-category))
> +  (let ((pos (or pos (point))))
> +    (or (get-text-property pos 'org-category)
> +	(org-refresh-category-properties)
> +	(get-text-property pos 'org-category))))
>
> (defun org-refresh-category-properties ()
>   "Refresh category text properties in the buffer."
> @@ -13481,10 +13484,7 @@ things up because then unnecessary parsing  
> is avoided."
> 						       'add_times))
> 		    props))
> 	  (unless (assoc "CATEGORY" props)
> -	    (setq value (or (org-get-category)
> -			    (progn (org-refresh-category-properties)
> -				   (org-get-category))))
> -	    (push (cons "CATEGORY" value) props))
> +	    (push (cons "CATEGORY" (org-get-category)) props))
> 	  (append sum-props (nreverse props)))))))
>
> (defun org-entry-get (pom property &optional inherit literal-nil)
> @@ -15701,7 +15701,6 @@ When a buffer is unmodified, it is just  
> killed.  When modified, it is saved
> 	      (set-buffer (org-get-agenda-file-buffer file)))
> 	    (widen)
> 	    (setq bmp (buffer-modified-p))
> -	    (org-refresh-category-properties)
> 	    (setq org-todo-keywords-for-agenda
> 		  (append org-todo-keywords-for-agenda org-todo-keywords-1))
> 	    (setq org-done-keywords-for-agenda
> -- 
> 1.7.2.3
>
>
> _______________________________________________
> Emacs-orgmode mailing list
> Please use `Reply All' to send replies to the list.
> Emacs-orgmode@gnu.org
> http://lists.gnu.org/mailman/listinfo/emacs-orgmode

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] Always return refreshed category
  2010-12-23  7:43 ` [PATCH] " Carsten Dominik
@ 2010-12-23 15:42   ` Matt Lundin
  2010-12-23 16:03     ` Julien Danjou
  0 siblings, 1 reply; 13+ messages in thread
From: Matt Lundin @ 2010-12-23 15:42 UTC (permalink / raw)
  To: Carsten Dominik; +Cc: Julien Danjou, emacs-orgmode

Carsten Dominik <carsten.dominik@gmail.com> writes:

> Applied, thanks.
>

This patch produces some unexpected category strings. Here's a sample
file:

--8<---------------cut here---------------start------------->8---
* TODO A todo
  SCHEDULED: <2010-12-23 Thu>
  [2010-12-23 Thu 10:22]
* TODO Another todo
  SCHEDULED: <2010-12-23 Thu>
  [2010-12-23 Thu 10:25]
--8<---------------cut here---------------end--------------->8---

When I run the agenda on it, I get the following:

--8<---------------cut here---------------start------------->8---
Day-agenda (W51):
Thursday   23 December 2010
  test:       Scheduled:  TODO A todo
  t:          Scheduled:  TODO Another todo
--8<---------------cut here---------------end--------------->8---

This resolves itself the second time I call the agenda. But I also
periodically find that "???" is added as a category string when there is
no #+CATEGORY line or :CATEGORY: property.

> On Dec 22, 2010, at 3:06 PM, Julien Danjou wrote:
>
>> diff --git a/lisp/org.el b/lisp/org.el
>> index 3cecca7..e80d2fc 100644
>> --- a/lisp/org.el
>> +++ b/lisp/org.el
>> @@ -8141,7 +8141,10 @@ call CMD."
>>
>> (defun org-get-category (&optional pos)
>>   "Get the category applying to position POS."
>> -  (get-text-property (or pos (point)) 'org-category))
>> +  (let ((pos (or pos (point))))
>> +    (or (get-text-property pos 'org-category)
>> +	(org-refresh-category-properties)
>> +	(get-text-property pos 'org-category))))


Another observation: org-refresh-category-properties returns t and thus
short-circuits the "or" here. Is the following perhaps the intended
behavior?

--8<---------------cut here---------------start------------->8---
diff --git a/lisp/org.el b/lisp/org.el
index e80d2fc..55f1bf1 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -8143,8 +8143,8 @@ call CMD."
   "Get the category applying to position POS."
   (let ((pos (or pos (point))))
     (or (get-text-property pos 'org-category)
-	(org-refresh-category-properties)
-	(get-text-property pos 'org-category))))
+	(progn (org-refresh-category-properties)
+	       (get-text-property pos 'org-category)))))
 
 (defun org-refresh-category-properties ()
   "Refresh category text properties in the buffer."
--8<---------------cut here---------------end--------------->8---

Best,
Matt

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* Re: [PATCH] Always return refreshed category
  2010-12-23 15:42   ` Matt Lundin
@ 2010-12-23 16:03     ` Julien Danjou
  2010-12-24 15:46       ` Matt Lundin
  0 siblings, 1 reply; 13+ messages in thread
From: Julien Danjou @ 2010-12-23 16:03 UTC (permalink / raw)
  To: Matt Lundin; +Cc: emacs-orgmode, Carsten Dominik


[-- Attachment #1.1: Type: text/plain, Size: 924 bytes --]

On Thu, Dec 23 2010, Matt Lundin wrote:

> Another observation: org-refresh-category-properties returns t

That's the 't' you see as category.

> and thus
> short-circuits the "or" here. Is the following perhaps the intended
> behavior?
>
> diff --git a/lisp/org.el b/lisp/org.el
> index e80d2fc..55f1bf1 100644
> --- a/lisp/org.el
> +++ b/lisp/org.el
> @@ -8143,8 +8143,8 @@ call CMD."
>    "Get the category applying to position POS."
>    (let ((pos (or pos (point))))
>      (or (get-text-property pos 'org-category)
> -	(org-refresh-category-properties)
> -	(get-text-property pos 'org-category))))
> +	(progn (org-refresh-category-properties)
> +	       (get-text-property pos 'org-category)))))
>  
>  (defun org-refresh-category-properties ()
>    "Refresh category text properties in the buffer."

Good catch indeed, I missed a progn.

-- 
Julien Danjou
❱ http://julien.danjou.info

[-- Attachment #1.2: Type: application/pgp-signature, Size: 197 bytes --]

[-- Attachment #2: Type: text/plain, Size: 201 bytes --]

_______________________________________________
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] Always return refreshed category
  2010-12-23 16:03     ` Julien Danjou
@ 2010-12-24 15:46       ` Matt Lundin
  2010-12-24 16:33         ` Carsten Dominik
  2010-12-24 16:33         ` Julien Danjou
  0 siblings, 2 replies; 13+ messages in thread
From: Matt Lundin @ 2010-12-24 15:46 UTC (permalink / raw)
  To: Julien Danjou; +Cc: emacs-orgmode, Carsten Dominik

Hi Julien,

Julien Danjou <julien@danjou.info> writes:

> On Thu, Dec 23 2010, Matt Lundin wrote:
>
>> Another observation: org-refresh-category-properties returns t
>
> That's the 't' you see as category.
>
>> and thus
>> short-circuits the "or" here. Is the following perhaps the intended
>> behavior?
>>
>> diff --git a/lisp/org.el b/lisp/org.el
>> index e80d2fc..55f1bf1 100644
>> --- a/lisp/org.el
>> +++ b/lisp/org.el
>> @@ -8143,8 +8143,8 @@ call CMD."
>>    "Get the category applying to position POS."
>>    (let ((pos (or pos (point))))
>>      (or (get-text-property pos 'org-category)
>> -	(org-refresh-category-properties)
>> -	(get-text-property pos 'org-category))))
>> +	(progn (org-refresh-category-properties)
>> +	       (get-text-property pos 'org-category)))))
>>  
>>  (defun org-refresh-category-properties ()
>>    "Refresh category text properties in the buffer."
>
> Good catch indeed, I missed a progn.

With your original patch, I am also frequently seeing "???" as a
category in the agenda buffer. E.g.,

???:        In  -1 d.:  TODO Christmas gifts wrapped                    :home:

This occurs with files/entries that do not have an in-buffer category
statement (e.g, #+CATEGORY: or :CATEGORY:).

Thanks,
Matt

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] Always return refreshed category
  2010-12-24 15:46       ` Matt Lundin
@ 2010-12-24 16:33         ` Carsten Dominik
  2010-12-27 10:56           ` Julien Danjou
  2010-12-24 16:33         ` Julien Danjou
  1 sibling, 1 reply; 13+ messages in thread
From: Carsten Dominik @ 2010-12-24 16:33 UTC (permalink / raw)
  To: Matt Lundin; +Cc: Julien Danjou, emacs-orgmode

Hi Matt, hi Julien,

I have reverted the patch for now.  It would be great if the two of
you could continue to try to fix it before we make another attempt.

Thanks

- Carsten

On Dec 24, 2010, at 4:46 PM, Matt Lundin wrote:

> Hi Julien,
>
> Julien Danjou <julien@danjou.info> writes:
>
>> On Thu, Dec 23 2010, Matt Lundin wrote:
>>
>>> Another observation: org-refresh-category-properties returns t
>>
>> That's the 't' you see as category.
>>
>>> and thus
>>> short-circuits the "or" here. Is the following perhaps the intended
>>> behavior?
>>>
>>> diff --git a/lisp/org.el b/lisp/org.el
>>> index e80d2fc..55f1bf1 100644
>>> --- a/lisp/org.el
>>> +++ b/lisp/org.el
>>> @@ -8143,8 +8143,8 @@ call CMD."
>>>   "Get the category applying to position POS."
>>>   (let ((pos (or pos (point))))
>>>     (or (get-text-property pos 'org-category)
>>> -	(org-refresh-category-properties)
>>> -	(get-text-property pos 'org-category))))
>>> +	(progn (org-refresh-category-properties)
>>> +	       (get-text-property pos 'org-category)))))
>>>
>>> (defun org-refresh-category-properties ()
>>>   "Refresh category text properties in the buffer."
>>
>> Good catch indeed, I missed a progn.
>
> With your original patch, I am also frequently seeing "???" as a
> category in the agenda buffer. E.g.,
>
> ???:        In  -1 d.:  TODO Christmas gifts  
> wrapped                    :home:
>
> This occurs with files/entries that do not have an in-buffer category
> statement (e.g, #+CATEGORY: or :CATEGORY:).
>
> Thanks,
> Matt

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] Always return refreshed category
  2010-12-24 15:46       ` Matt Lundin
  2010-12-24 16:33         ` Carsten Dominik
@ 2010-12-24 16:33         ` Julien Danjou
  1 sibling, 0 replies; 13+ messages in thread
From: Julien Danjou @ 2010-12-24 16:33 UTC (permalink / raw)
  To: Matt Lundin; +Cc: emacs-orgmode, Carsten Dominik


[-- Attachment #1.1.1: Type: text/plain, Size: 516 bytes --]

On Fri, Dec 24 2010, Matt Lundin wrote:

> With your original patch, I am also frequently seeing "???" as a
> category in the agenda buffer. E.g.,
>
> ???:        In  -1 d.:  TODO Christmas gifts wrapped                    :home:
>
> This occurs with files/entries that do not have an in-buffer category
> statement (e.g, #+CATEGORY: or :CATEGORY:).

Seems like the refresh function set this by default if no category is
found. That looks stupid, I wonder why there's that line.

Here's a patch that should fix it.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.1.2: 0001-Fix-in-category.patch --]
[-- Type: text/x-diff, Size: 904 bytes --]

From 89464e137f66cfeb144938692479bf95e9187a4d Mon Sep 17 00:00:00 2001
From: Julien Danjou <julien@danjou.info>
Date: Fri, 24 Dec 2010 17:32:45 +0100
Subject: [PATCH] Fix ??? in category

* org.el (org-refresh-category-properties): Do not set ??? as default
  category if no default.

Signed-off-by: Julien Danjou <julien@danjou.info>
---
 lisp/org.el |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/lisp/org.el b/lisp/org.el
index 863a80b..5fb2ba4 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -8154,8 +8154,7 @@ call CMD."
 		  ((null org-category)
 		   (if buffer-file-name
 		       (file-name-sans-extension
-			(file-name-nondirectory buffer-file-name))
-		     "???"))
+			(file-name-nondirectory buffer-file-name))))
 		  ((symbolp org-category) (symbol-name org-category))
 		  (t org-category)))
 	beg end cat pos optionp)
-- 
1.7.2.3


[-- Attachment #1.1.3: Type: text/plain, Size: 53 bytes --]


-- 
Julien Danjou
❱ http://julien.danjou.info

[-- Attachment #1.2: Type: application/pgp-signature, Size: 197 bytes --]

[-- Attachment #2: Type: text/plain, Size: 201 bytes --]

_______________________________________________
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* Re: Re: [PATCH] Always return refreshed category
  2010-12-24 16:33         ` Carsten Dominik
@ 2010-12-27 10:56           ` Julien Danjou
  2010-12-27 14:23             ` Julien Danjou
  0 siblings, 1 reply; 13+ messages in thread
From: Julien Danjou @ 2010-12-27 10:56 UTC (permalink / raw)
  To: Carsten Dominik; +Cc: Matt Lundin, emacs-orgmode


[-- Attachment #1.1.1: Type: text/plain, Size: 236 bytes --]

On Fri, Dec 24 2010, Carsten Dominik wrote:

> I have reverted the patch for now.  It would be great if the two of
> you could continue to try to fix it before we make another attempt.

Here's an updated patch with all the fixes above.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.1.2: 0001-Always-return-refreshed-category.patch --]
[-- Type: text/x-diff, Size: 4331 bytes --]

From 3821f60475b20df92ad21afc7604b4c7f0c3d9bb Mon Sep 17 00:00:00 2001
From: Julien Danjou <julien@danjou.info>
Date: Wed, 22 Dec 2010 15:00:27 +0100
Subject: [PATCH] Always return refreshed category

* org-icalendar.el (org-print-icalendar-entries): Do not manually
  refresh categories.

* org-clock.el (org-clock-insert-selection-line): Do not manually
  refresh categories.

* org.el (org-get-category): Refresh categories if no category found.
(org-entry-properties): Do not manually refresh categories.
(org-prepare-agenda-buffers): Do not manually refresh categories.

It seems a very bad thing to call manually for a category refresh. It
seems better to try to refresh if we do not have a category.

Signed-off-by: Julien Danjou <julien@danjou.info>
---
 lisp/org-archive.el   |    1 -
 lisp/org-clock.el     |    4 +---
 lisp/org-icalendar.el |    1 -
 lisp/org.el           |   14 ++++++--------
 4 files changed, 7 insertions(+), 13 deletions(-)

diff --git a/lisp/org-archive.el b/lisp/org-archive.el
index e56b01f..c32ee23 100644
--- a/lisp/org-archive.el
+++ b/lisp/org-archive.el
@@ -226,7 +226,6 @@ this heading."
       (save-excursion
 	(org-back-to-heading t)
 	;; Get context information that will be lost by moving the tree
-	(org-refresh-category-properties)
 	(setq category (org-get-category)
 	      todo (and (looking-at org-todo-line-regexp)
 			(match-string 2))
diff --git a/lisp/org-clock.el b/lisp/org-clock.el
index 93b0b52..17fccae 100644
--- a/lisp/org-clock.el
+++ b/lisp/org-clock.el
@@ -442,9 +442,7 @@ pointing to it."
 	    (ignore-errors
 	      (goto-char marker)
 	      (setq file (buffer-file-name (marker-buffer marker))
-		    cat (or (org-get-category)
-			    (progn (org-refresh-category-properties)
-				   (org-get-category)))
+		    cat (org-get-category)
 		    heading (org-get-heading 'notags)
 		    prefix (save-excursion
 			     (org-back-to-heading t)
diff --git a/lisp/org-icalendar.el b/lisp/org-icalendar.el
index d4034fe..a1bc5ad 100644
--- a/lisp/org-icalendar.el
+++ b/lisp/org-icalendar.el
@@ -302,7 +302,6 @@ When COMBINE is non nil, add the category to each line."
 	scheduledp deadlinep todo prefix due start
 	tmp pri categories location summary desc uid alarm
 	(sexp-buffer (get-buffer-create "*ical-tmp*")))
-    (org-refresh-category-properties)
     (save-excursion
       (goto-char (point-min))
       (while (re-search-forward re1 nil t)
diff --git a/lisp/org.el b/lisp/org.el
index e190b84..125fbef 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -8142,7 +8142,10 @@ call CMD."
 
 (defun org-get-category (&optional pos)
   "Get the category applying to position POS."
-  (get-text-property (or pos (point)) 'org-category))
+  (let ((pos (or pos (point))))
+    (or (get-text-property pos 'org-category)
+	(progn (org-refresh-category-properties)
+	       (get-text-property pos 'org-category)))))
 
 (defun org-refresh-category-properties ()
   "Refresh category text properties in the buffer."
@@ -8150,8 +8153,7 @@ call CMD."
 		  ((null org-category)
 		   (if buffer-file-name
 		       (file-name-sans-extension
-			(file-name-nondirectory buffer-file-name))
-		     "???"))
+			(file-name-nondirectory buffer-file-name))))
 		  ((symbolp org-category) (symbol-name org-category))
 		  (t org-category)))
 	beg end cat pos optionp)
@@ -13482,10 +13484,7 @@ things up because then unnecessary parsing is avoided."
 						       'add_times))
 		    props))
 	  (unless (assoc "CATEGORY" props)
-	    (setq value (or (org-get-category)
-			    (progn (org-refresh-category-properties)
-				   (org-get-category))))
-	    (push (cons "CATEGORY" value) props))
+	    (push (cons "CATEGORY" (org-get-category)) props))
 	  (append sum-props (nreverse props)))))))
 
 (defun org-entry-get (pom property &optional inherit literal-nil)
@@ -15702,7 +15701,6 @@ When a buffer is unmodified, it is just killed.  When modified, it is saved
 	      (set-buffer (org-get-agenda-file-buffer file)))
 	    (widen)
 	    (setq bmp (buffer-modified-p))
-	    (org-refresh-category-properties)
 	    (setq org-todo-keywords-for-agenda
 		  (append org-todo-keywords-for-agenda org-todo-keywords-1))
 	    (setq org-done-keywords-for-agenda
-- 
1.7.2.3


[-- Attachment #1.1.3: Type: text/plain, Size: 79 bytes --]


Sorry for the mess. :)

-- 
Julien Danjou
❱ http://julien.danjou.info

[-- Attachment #1.2: Type: application/pgp-signature, Size: 197 bytes --]

[-- Attachment #2: Type: text/plain, Size: 201 bytes --]

_______________________________________________
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* Re: Re: [PATCH] Always return refreshed category
  2010-12-27 10:56           ` Julien Danjou
@ 2010-12-27 14:23             ` Julien Danjou
  2011-01-03  8:39               ` Carsten Dominik
  0 siblings, 1 reply; 13+ messages in thread
From: Julien Danjou @ 2010-12-27 14:23 UTC (permalink / raw)
  To: Carsten Dominik; +Cc: Matt Lundin, emacs-orgmode


[-- Attachment #1.1.1: Type: text/plain, Size: 396 bytes --]

On Mon, Dec 27 2010, Julien Danjou wrote:

> On Fri, Dec 24 2010, Carsten Dominik wrote:
>
>> I have reverted the patch for now.  It would be great if the two of
>> you could continue to try to fix it before we make another attempt.
>
> Here's an updated patch with all the fixes above.

I've re-added a refresh in the prepare, otherwise the categories are not
being updated in the agenda views.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.1.2: 0001-Always-return-refreshed-category.patch --]
[-- Type: text/x-diff, Size: 3862 bytes --]

From f84b0aaa50854ebfcd70008646411e9809874346 Mon Sep 17 00:00:00 2001
From: Julien Danjou <julien@danjou.info>
Date: Wed, 22 Dec 2010 15:00:27 +0100
Subject: [PATCH] Always return refreshed category

* org-icalendar.el (org-print-icalendar-entries): Do not manually
  refresh categories.

* org-clock.el (org-clock-insert-selection-line): Do not manually
  refresh categories.

* org.el (org-get-category): Refresh categories if no category found.
(org-entry-properties): Do not manually refresh categories.

It seems a very bad thing to call manually for a category refresh. It
seems better to try to refresh if we do not have a category.

Signed-off-by: Julien Danjou <julien@danjou.info>
---
 lisp/org-archive.el   |    1 -
 lisp/org-clock.el     |    4 +---
 lisp/org-icalendar.el |    1 -
 lisp/org.el           |   13 ++++++-------
 4 files changed, 7 insertions(+), 12 deletions(-)

diff --git a/lisp/org-archive.el b/lisp/org-archive.el
index e56b01f..c32ee23 100644
--- a/lisp/org-archive.el
+++ b/lisp/org-archive.el
@@ -226,7 +226,6 @@ this heading."
       (save-excursion
 	(org-back-to-heading t)
 	;; Get context information that will be lost by moving the tree
-	(org-refresh-category-properties)
 	(setq category (org-get-category)
 	      todo (and (looking-at org-todo-line-regexp)
 			(match-string 2))
diff --git a/lisp/org-clock.el b/lisp/org-clock.el
index 93b0b52..17fccae 100644
--- a/lisp/org-clock.el
+++ b/lisp/org-clock.el
@@ -442,9 +442,7 @@ pointing to it."
 	    (ignore-errors
 	      (goto-char marker)
 	      (setq file (buffer-file-name (marker-buffer marker))
-		    cat (or (org-get-category)
-			    (progn (org-refresh-category-properties)
-				   (org-get-category)))
+		    cat (org-get-category)
 		    heading (org-get-heading 'notags)
 		    prefix (save-excursion
 			     (org-back-to-heading t)
diff --git a/lisp/org-icalendar.el b/lisp/org-icalendar.el
index d4034fe..a1bc5ad 100644
--- a/lisp/org-icalendar.el
+++ b/lisp/org-icalendar.el
@@ -302,7 +302,6 @@ When COMBINE is non nil, add the category to each line."
 	scheduledp deadlinep todo prefix due start
 	tmp pri categories location summary desc uid alarm
 	(sexp-buffer (get-buffer-create "*ical-tmp*")))
-    (org-refresh-category-properties)
     (save-excursion
       (goto-char (point-min))
       (while (re-search-forward re1 nil t)
diff --git a/lisp/org.el b/lisp/org.el
index e190b84..61180ca 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -8142,7 +8142,10 @@ call CMD."
 
 (defun org-get-category (&optional pos)
   "Get the category applying to position POS."
-  (get-text-property (or pos (point)) 'org-category))
+  (let ((pos (or pos (point))))
+    (or (get-text-property pos 'org-category)
+	(progn (org-refresh-category-properties)
+	       (get-text-property pos 'org-category)))))
 
 (defun org-refresh-category-properties ()
   "Refresh category text properties in the buffer."
@@ -8150,8 +8153,7 @@ call CMD."
 		  ((null org-category)
 		   (if buffer-file-name
 		       (file-name-sans-extension
-			(file-name-nondirectory buffer-file-name))
-		     "???"))
+			(file-name-nondirectory buffer-file-name))))
 		  ((symbolp org-category) (symbol-name org-category))
 		  (t org-category)))
 	beg end cat pos optionp)
@@ -13482,10 +13484,7 @@ things up because then unnecessary parsing is avoided."
 						       'add_times))
 		    props))
 	  (unless (assoc "CATEGORY" props)
-	    (setq value (or (org-get-category)
-			    (progn (org-refresh-category-properties)
-				   (org-get-category))))
-	    (push (cons "CATEGORY" value) props))
+	    (push (cons "CATEGORY" (org-get-category)) props))
 	  (append sum-props (nreverse props)))))))
 
 (defun org-entry-get (pom property &optional inherit literal-nil)
-- 
1.7.2.3


[-- Attachment #1.1.3: Type: text/plain, Size: 53 bytes --]


-- 
Julien Danjou
❱ http://julien.danjou.info

[-- Attachment #1.2: Type: application/pgp-signature, Size: 197 bytes --]

[-- Attachment #2: Type: text/plain, Size: 201 bytes --]

_______________________________________________
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* Re: Re: [PATCH] Always return refreshed category
  2010-12-27 14:23             ` Julien Danjou
@ 2011-01-03  8:39               ` Carsten Dominik
  2011-01-03 10:57                 ` Julien Danjou
  0 siblings, 1 reply; 13+ messages in thread
From: Carsten Dominik @ 2011-01-03  8:39 UTC (permalink / raw)
  To: Julien Danjou; +Cc: Matt Lundin, emacs-orgmode

Hi Julien,

neither in the patch nor in the ChangeLog entry I am
able to find the refresh for categories in agenda
buffer preparation - even though your message states that you
have changed this.

Can you please take a fresh look and write a fresh patch?
Matt, will you be able to test that patch when it comes in?

Thanks

- Carsten

On Dec 27, 2010, at 3:23 PM, Julien Danjou wrote:

> On Mon, Dec 27 2010, Julien Danjou wrote:
>
>> On Fri, Dec 24 2010, Carsten Dominik wrote:
>>
>>> I have reverted the patch for now.  It would be great if the two of
>>> you could continue to try to fix it before we make another attempt.
>>
>> Here's an updated patch with all the fixes above.
>
> I've re-added a refresh in the prepare, otherwise the categories are  
> not
> being updated in the agenda views.
> From f84b0aaa50854ebfcd70008646411e9809874346 Mon Sep 17 00:00:00 2001
> From: Julien Danjou <julien@danjou.info>
> Date: Wed, 22 Dec 2010 15:00:27 +0100
> Subject: [PATCH] Always return refreshed category
>
> * org-icalendar.el (org-print-icalendar-entries): Do not manually
>  refresh categories.
>
> * org-clock.el (org-clock-insert-selection-line): Do not manually
>  refresh categories.
>
> * org.el (org-get-category): Refresh categories if no category found.
> (org-entry-properties): Do not manually refresh categories.
>
> It seems a very bad thing to call manually for a category refresh. It
> seems better to try to refresh if we do not have a category.
>
> Signed-off-by: Julien Danjou <julien@danjou.info>
> ---
> lisp/org-archive.el   |    1 -
> lisp/org-clock.el     |    4 +---
> lisp/org-icalendar.el |    1 -
> lisp/org.el           |   13 ++++++-------
> 4 files changed, 7 insertions(+), 12 deletions(-)
>
> diff --git a/lisp/org-archive.el b/lisp/org-archive.el
> index e56b01f..c32ee23 100644
> --- a/lisp/org-archive.el
> +++ b/lisp/org-archive.el
> @@ -226,7 +226,6 @@ this heading."
>       (save-excursion
> 	(org-back-to-heading t)
> 	;; Get context information that will be lost by moving the tree
> -	(org-refresh-category-properties)
> 	(setq category (org-get-category)
> 	      todo (and (looking-at org-todo-line-regexp)
> 			(match-string 2))
> diff --git a/lisp/org-clock.el b/lisp/org-clock.el
> index 93b0b52..17fccae 100644
> --- a/lisp/org-clock.el
> +++ b/lisp/org-clock.el
> @@ -442,9 +442,7 @@ pointing to it."
> 	    (ignore-errors
> 	      (goto-char marker)
> 	      (setq file (buffer-file-name (marker-buffer marker))
> -		    cat (or (org-get-category)
> -			    (progn (org-refresh-category-properties)
> -				   (org-get-category)))
> +		    cat (org-get-category)
> 		    heading (org-get-heading 'notags)
> 		    prefix (save-excursion
> 			     (org-back-to-heading t)
> diff --git a/lisp/org-icalendar.el b/lisp/org-icalendar.el
> index d4034fe..a1bc5ad 100644
> --- a/lisp/org-icalendar.el
> +++ b/lisp/org-icalendar.el
> @@ -302,7 +302,6 @@ When COMBINE is non nil, add the category to  
> each line."
> 	scheduledp deadlinep todo prefix due start
> 	tmp pri categories location summary desc uid alarm
> 	(sexp-buffer (get-buffer-create "*ical-tmp*")))
> -    (org-refresh-category-properties)
>     (save-excursion
>       (goto-char (point-min))
>       (while (re-search-forward re1 nil t)
> diff --git a/lisp/org.el b/lisp/org.el
> index e190b84..61180ca 100644
> --- a/lisp/org.el
> +++ b/lisp/org.el
> @@ -8142,7 +8142,10 @@ call CMD."
>
> (defun org-get-category (&optional pos)
>   "Get the category applying to position POS."
> -  (get-text-property (or pos (point)) 'org-category))
> +  (let ((pos (or pos (point))))
> +    (or (get-text-property pos 'org-category)
> +	(progn (org-refresh-category-properties)
> +	       (get-text-property pos 'org-category)))))
>
> (defun org-refresh-category-properties ()
>   "Refresh category text properties in the buffer."
> @@ -8150,8 +8153,7 @@ call CMD."
> 		  ((null org-category)
> 		   (if buffer-file-name
> 		       (file-name-sans-extension
> -			(file-name-nondirectory buffer-file-name))
> -		     "???"))
> +			(file-name-nondirectory buffer-file-name))))
> 		  ((symbolp org-category) (symbol-name org-category))
> 		  (t org-category)))
> 	beg end cat pos optionp)
> @@ -13482,10 +13484,7 @@ things up because then unnecessary parsing  
> is avoided."
> 						       'add_times))
> 		    props))
> 	  (unless (assoc "CATEGORY" props)
> -	    (setq value (or (org-get-category)
> -			    (progn (org-refresh-category-properties)
> -				   (org-get-category))))
> -	    (push (cons "CATEGORY" value) props))
> +	    (push (cons "CATEGORY" (org-get-category)) props))
> 	  (append sum-props (nreverse props)))))))
>
> (defun org-entry-get (pom property &optional inherit literal-nil)
> -- 
> 1.7.2.3
>
>
> -- 
> Julien Danjou
> ❱ http://julien.danjou.info

- Carsten

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Re: [PATCH] Always return refreshed category
  2011-01-03  8:39               ` Carsten Dominik
@ 2011-01-03 10:57                 ` Julien Danjou
  2011-01-03 12:14                   ` Carsten Dominik
  0 siblings, 1 reply; 13+ messages in thread
From: Julien Danjou @ 2011-01-03 10:57 UTC (permalink / raw)
  To: Carsten Dominik; +Cc: Matt Lundin, emacs-orgmode


[-- Attachment #1.1: Type: text/plain, Size: 386 bytes --]

On Mon, Jan 03 2011, Carsten Dominik wrote:

> neither in the patch nor in the ChangeLog entry I am
> able to find the refresh for categories in agenda
> buffer preparation - even though your message states that you
> have changed this.

Of course since it was a line I removed, and I removed the removal from
the patch. :)

-- 
Julien Danjou
❱ http://julien.danjou.info

[-- Attachment #1.2: Type: application/pgp-signature, Size: 197 bytes --]

[-- Attachment #2: Type: text/plain, Size: 201 bytes --]

_______________________________________________
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Re: [PATCH] Always return refreshed category
  2011-01-03 10:57                 ` Julien Danjou
@ 2011-01-03 12:14                   ` Carsten Dominik
  0 siblings, 0 replies; 13+ messages in thread
From: Carsten Dominik @ 2011-01-03 12:14 UTC (permalink / raw)
  To: Julien Danjou; +Cc: Matt Lundin, emacs-orgmode


On Jan 3, 2011, at 11:57 AM, Julien Danjou wrote:

> On Mon, Jan 03 2011, Carsten Dominik wrote:
>
>> neither in the patch nor in the ChangeLog entry I am
>> able to find the refresh for categories in agenda
>> buffer preparation - even though your message states that you
>> have changed this.
>
> Of course since it was a line I removed, and I removed the removal  
> from
> the patch. :)

Indeed.  Thanks.

Still, I have only taken part of the patch.  Calling the property update
explicitly is important in some cases, as you have noticed.

Best wishes

- Carsten

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2011-01-03 12:14 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-12-22 14:06 [PATCH] Always return refreshed category Julien Danjou
2010-12-23  7:43 ` [Accepted] " Carsten Dominik
2010-12-23  7:43 ` [PATCH] " Carsten Dominik
2010-12-23 15:42   ` Matt Lundin
2010-12-23 16:03     ` Julien Danjou
2010-12-24 15:46       ` Matt Lundin
2010-12-24 16:33         ` Carsten Dominik
2010-12-27 10:56           ` Julien Danjou
2010-12-27 14:23             ` Julien Danjou
2011-01-03  8:39               ` Carsten Dominik
2011-01-03 10:57                 ` Julien Danjou
2011-01-03 12:14                   ` Carsten Dominik
2010-12-24 16:33         ` Julien Danjou

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).