emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* file level categories
@ 2008-03-06 15:55 Eddward DeVilla
  2008-03-06 19:23 ` Carsten Dominik
  0 siblings, 1 reply; 7+ messages in thread
From: Eddward DeVilla @ 2008-03-06 15:55 UTC (permalink / raw)
  To: org-mode mailing list

Hi,

    A while back I wrote a function that I call from org-mode-hook to
rename the buffer if it's file name is project.org.  It would rename
it to "Org - <category>" based on the category in the file.  I did
this because I tend to have different directories for the different
sorts of things I work on and I keep a consistently named file with
the state of the projects working from there.  The problem was that
all of my org buffers were call projects.org.

   Anyhow, I wrote that function using org-get-category and
org-get-category-table to determine the category for the file so I
could produce a more useful buffer name.  It looks like the category
table is gone now.  Would there be a good way to determine the
category of the the first #+CATEGORY entry in the file and get
something like default if there isn't one?  Or, does anyone have any
other interesting ideas for giving a unique buffer name to org files
with the same file name?

  If you're curious, the rename function I'm was using is:

(defun my-org-buffer-name ()
  (if (buffer-file-name)
      (when (string= (file-name-nondirectory buffer-file-name)
		     "projects.org")
	(let* ((org-category-table (org-get-category-table))  ; work around
some dynamic scope issue
	       (new-buffer-name (format "Org -- %s" (org-get-category)))
	       (buffer-name-re  (concat "^"
					new-buffer-name
					"\\(<[0-9]+>\\)?")))
	  (unless (string-match buffer-name-re (buffer-name))
	    (rename-buffer new-buffer-name t) )))))
(add-hook 'org-mode-hook 'my-org-buffer-name)


Thanks,
Edd

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

* Re: file level categories
  2008-03-06 15:55 file level categories Eddward DeVilla
@ 2008-03-06 19:23 ` Carsten Dominik
  2008-03-06 21:13   ` Joel J. Adamson
  0 siblings, 1 reply; 7+ messages in thread
From: Carsten Dominik @ 2008-03-06 19:23 UTC (permalink / raw)
  To: Eddward DeVilla; +Cc: org-mode mailing list

Hi Eddward,

After an Org-mode buffer is initialized, the variable `org-category'
contains the value of the *last* #+CATEGORY line in the buffer, as a  
symbol.

You really should have only of these lines in the buffer, if you need
multiple categories, use properties.

Anyway, you can get the value as a string with

  (symbol-name org-category)

HTH

- Carsten

On Mar 6, 2008, at 4:55 PM, Eddward DeVilla wrote:

> Hi,
>
>    A while back I wrote a function that I call from org-mode-hook to
> rename the buffer if it's file name is project.org.  It would rename
> it to "Org - <category>" based on the category in the file.  I did
> this because I tend to have different directories for the different
> sorts of things I work on and I keep a consistently named file with
> the state of the projects working from there.  The problem was that
> all of my org buffers were call projects.org.
>
>   Anyhow, I wrote that function using org-get-category and
> org-get-category-table to determine the category for the file so I
> could produce a more useful buffer name.  It looks like the category
> table is gone now.  Would there be a good way to determine the
> category of the the first #+CATEGORY entry in the file and get
> something like default if there isn't one?  Or, does anyone have any
> other interesting ideas for giving a unique buffer name to org files
> with the same file name?
>
>  If you're curious, the rename function I'm was using is:
>
> (defun my-org-buffer-name ()
>  (if (buffer-file-name)
>      (when (string= (file-name-nondirectory buffer-file-name)
> 		     "projects.org")
> 	(let* ((org-category-table (org-get-category-table))  ; work around
> some dynamic scope issue
> 	       (new-buffer-name (format "Org -- %s" (org-get-category)))
> 	       (buffer-name-re  (concat "^"
> 					new-buffer-name
> 					"\\(<[0-9]+>\\)?")))
> 	  (unless (string-match buffer-name-re (buffer-name))
> 	    (rename-buffer new-buffer-name t) )))))
> (add-hook 'org-mode-hook 'my-org-buffer-name)
>
>
> Thanks,
> Edd
>
>
> _______________________________________________
> Emacs-orgmode mailing list
> Remember: 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] 7+ messages in thread

* Re: file level categories
  2008-03-06 19:23 ` Carsten Dominik
@ 2008-03-06 21:13   ` Joel J. Adamson
  2008-03-06 22:14     ` Bastien
  2008-03-06 22:47     ` Eddward DeVilla
  0 siblings, 2 replies; 7+ messages in thread
From: Joel J. Adamson @ 2008-03-06 21:13 UTC (permalink / raw)
  To: Carsten Dominik; +Cc: Eddward DeVilla, org-mode mailing list

Carsten Dominik <dominik@science.uva.nl> writes:

> You really should have only of these lines in the buffer, if you need
> multiple categories, use properties.

Carsten,

I'm a little confused.  Forgetting for the moment what the OP wants to
accomplish, if I have multiple

#+CATEGORY

lines in a buffer, each one shows up in my agenda indexed by the
category immediately preceding it.  Is there some other way *I should*
do this?

Thanks,
Joel
-- 
Joel J. Adamson
Biostatistician
Pediatric Psychopharmacology Research Unit
Massachusetts General Hospital
Boston, MA  02114
(617) 643-1432
(303) 880-3109

The information transmitted in this electronic communication is intended only
for the person or entity to whom it is addressed and may contain confidential
and/or privileged material. Any review, retransmission, dissemination or other
use of or taking of any action in reliance upon this information by persons or
entities other than the intended recipient is prohibited. If you received this
information in error, please contact the Compliance HelpLine at 800-856-1983 and
properly dispose of this information.

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

* Re: file level categories
  2008-03-06 21:13   ` Joel J. Adamson
@ 2008-03-06 22:14     ` Bastien
  2008-03-06 22:47     ` Eddward DeVilla
  1 sibling, 0 replies; 7+ messages in thread
From: Bastien @ 2008-03-06 22:14 UTC (permalink / raw)
  To: Joel J. Adamson; +Cc: Eddward DeVilla, org-mode mailing list

jadamson@partners.org (Joel J. Adamson) writes:

> I'm a little confused.  Forgetting for the moment what the OP wants to
> accomplish, if I have multiple
>
> #+CATEGORY
>
> lines in a buffer, each one shows up in my agenda indexed by the
> category immediately preceding it.  Is there some other way *I should*
> do this?

Yes.  The manual explicitely discourages having multiple #+ARCHIVE in
the same buffer:

  (info  "(org)Moving subtrees")

This has been preserved for backward compatibility, but is not the right
way to set several archive locations.  Better use properties.  

HTH,

-- 
Bastien

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

* Re: file level categories
  2008-03-06 21:13   ` Joel J. Adamson
  2008-03-06 22:14     ` Bastien
@ 2008-03-06 22:47     ` Eddward DeVilla
  2008-03-07  8:29       ` Rainer Stengele
  1 sibling, 1 reply; 7+ messages in thread
From: Eddward DeVilla @ 2008-03-06 22:47 UTC (permalink / raw)
  To: Joel J. Adamson; +Cc: org-mode mailing list

On Thu, Mar 6, 2008 at 3:13 PM, Joel J. Adamson <jadamson@partners.org> wrote:

>  I'm a little confused.  Forgetting for the moment what the OP wants to
>  accomplish, if I have multiple
>
>  #+CATEGORY
>
>  lines in a buffer, each one shows up in my agenda indexed by the
>  category immediately preceding it.  Is there some other way *I should*
>  do this?

The #+CATEGORY is more of a legacy thing now.  Unless you are like me
and try to have one category per file, you should use the category
property in the property drawer for an item.

Edd

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

* Re: file level categories
  2008-03-06 22:47     ` Eddward DeVilla
@ 2008-03-07  8:29       ` Rainer Stengele
  2008-03-07  9:45         ` Carsten Dominik
  0 siblings, 1 reply; 7+ messages in thread
From: Rainer Stengele @ 2008-03-07  8:29 UTC (permalink / raw)
  To: Eddward DeVilla; +Cc: org-mode mailing list

Eddward DeVilla schrieb:
> On Thu, Mar 6, 2008 at 3:13 PM, Joel J. Adamson <jadamson@partners.org> wrote:
> 
>>  I'm a little confused.  Forgetting for the moment what the OP wants to
>>  accomplish, if I have multiple
>>
>>  #+CATEGORY
>>
>>  lines in a buffer, each one shows up in my agenda indexed by the
>>  category immediately preceding it.  Is there some other way *I should*
>>  do this?
> 
> The #+CATEGORY is more of a legacy thing now.  Unless you are like me
> and try to have one category per file, you should use the category
> property in the property drawer for an item.
> 
> Edd
> 
> 
> _______________________________________________
> Emacs-orgmode mailing list
> Remember: use `Reply All' to send replies to the list.
> Emacs-orgmode@gnu.org
> http://lists.gnu.org/mailman/listinfo/emacs-orgmode
> 

you mean if I have 5 blocks of items, each belonging to another CATEGORY
I have to add a CATEGORY drawer to each and every item?

I am now working ok with #+CATEGORY at the beginning of each big section.

rainer

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

* Re: Re: file level categories
  2008-03-07  8:29       ` Rainer Stengele
@ 2008-03-07  9:45         ` Carsten Dominik
  0 siblings, 0 replies; 7+ messages in thread
From: Carsten Dominik @ 2008-03-07  9:45 UTC (permalink / raw)
  To: Rainer Stengele; +Cc: emacs-orgmode


On Mar 7, 2008, at 9:29 AM, Rainer Stengele wrote:

> Eddward DeVilla schrieb:
>> On Thu, Mar 6, 2008 at 3:13 PM, Joel J. Adamson <jadamson@partners.org 
>> > wrote:
>>
>>> I'm a little confused.  Forgetting for the moment what the OP  
>>> wants to
>>> accomplish, if I have multiple
>>>
>>> #+CATEGORY
>>>
>>> lines in a buffer, each one shows up in my agenda indexed by the
>>> category immediately preceding it.  Is there some other way *I  
>>> should*
>>> do this?
>>
>> The #+CATEGORY is more of a legacy thing now.  Unless you are like me
>> and try to have one category per file, you should use the category
>> property in the property drawer for an item.
>>
>> Edd
>>
>>
>> _______________________________________________
>> Emacs-orgmode mailing list
>> Remember: use `Reply All' to send replies to the list.
>> Emacs-orgmode@gnu.org
>> http://lists.gnu.org/mailman/listinfo/emacs-orgmode
>>
>
> you mean if I have 5 blocks of items, each belonging to another  
> CATEGORY
> I have to add a CATEGORY drawer to each and every item?

You dont have to.  However, the Use of #+CATEGORY has its problems.   
In particular,
in an outline, there is no such place as "between entries or trees".   
Therefore,
from the logical structure of the file, #+CATEGORY is always part of  
the previous
entry.  It is therefore confusing to have it set the category for the  
following
stuff.

If you only have top-level entries, putting category properties can be  
annoying.
However, CATEGORY is trated as a property with in inheritance.  So in

* HOME tasks
   :PROPERTIES:
     :CATEGORY: home
   :END:

** task 1
** task 2

both task 1 and task 2 have category "home".

Anyway, use of multiple #+CATEGORY lines will stay in org-mode for the  
foreseeable
future, but I will never use it.

HTH

- Carsten


>
>
> I am now working ok with #+CATEGORY at the beginning of each big  
> section.
>
> rainer
>
>
>
> _______________________________________________
> Emacs-orgmode mailing list
> Remember: 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] 7+ messages in thread

end of thread, other threads:[~2008-03-07  9:45 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-03-06 15:55 file level categories Eddward DeVilla
2008-03-06 19:23 ` Carsten Dominik
2008-03-06 21:13   ` Joel J. Adamson
2008-03-06 22:14     ` Bastien
2008-03-06 22:47     ` Eddward DeVilla
2008-03-07  8:29       ` Rainer Stengele
2008-03-07  9:45         ` Carsten Dominik

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