emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* org-id: always add IDs
@ 2009-02-27  9:30 Sebastian Rose
  2009-03-01 16:11 ` Carsten Dominik
  0 siblings, 1 reply; 3+ messages in thread
From: Sebastian Rose @ 2009-02-27  9:30 UTC (permalink / raw)
  To: emacs-orgmode Org-Mode

Hi,


I have several questions concerning IDs.


Is there a prefered method to _always_ add an org-id to an entry? 

The IDs would become _realy_ usefull, if I could add them automatically
whenever a new entry is created (a headline) that is _not_ below
`org-export-headline-levels'.

Is it possible to have an ID added, even if the headline is added by
hand (i.e. typing `* headline')?
Can this be achieved using an advice? How to do that?


Is it possible to tell Org-mode to add IDs to all the entries that have
none yet?

How would I tell emacs to update Org-mode's ID database?


Could the org-id be added when publishing?
Like
    <h2 id="sec-2"> HEADLINE
     <span class="org-id" id="THE-ORG-ID-ITSELF">THE-ORG-ID-ITSELF</span>
    </h2>
or similar? 




Best Regards,

--
Sebastian Rose, EMMA STIL - mediendesign, Niemeyerstr.6, 30449 Hannover
Tel.:  +49 (0)511 - 36 58 472
Fax:   +49 (0)1805 - 233633 - 11044
mobil: +49 (0)173 - 83 93 417
Http:  www.emma-stil.de

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

* Re: org-id: always add IDs
  2009-02-27  9:30 org-id: always add IDs Sebastian Rose
@ 2009-03-01 16:11 ` Carsten Dominik
  2009-03-01 16:34   ` Sebastian Rose
  0 siblings, 1 reply; 3+ messages in thread
From: Carsten Dominik @ 2009-03-01 16:11 UTC (permalink / raw)
  To: Sebastian Rose; +Cc: emacs-orgmode Org-Mode


On Feb 27, 2009, at 10:30 AM, Sebastian Rose wrote:

> Hi,
>
>
> I have several questions concerning IDs.
>
>
> Is there a prefered method to _always_ add an org-id to an entry?

(add-hook 'org-insert-heading-hook
	(lambda () (org-id-get-create)))


> The IDs would become _realy_ usefull, if I could add them  
> automatically
> whenever a new entry is created (a headline) that is _not_ below
> `org-export-headline-levels'.

You need to do more work if you want to have id' only for the top
few levels, then you first need to find out what the level is.
You can look at the dynamically scoped variable `head' which will
contain the stars to be inserted (and, maybe, also a space,
careful there)

On the other hand, I don't see why it it would be a problem
to have ids in headlines below the limit.  But I do not yet know
how well my ID mechanism will scale.  Should be pretty good, actually.

> Is it possible to have an ID added, even if the headline is added by
> hand (i.e. typing `* headline')?

No easily.  The fastest way to get one added by hand is to store
a link to the heading with `C-c l'.  If `org-link-to-org-use-id' is t
or 'create-if-interactive', an id will be added.

> Can this be achieved using an advice? How to do that?

Since no special function is called when you type a headline,
it would have to be advice to org-self-insert-command.
Very likely that would significantly slow down typing, I strongly
advice against doing that.

> Is it possible to tell Org-mode to add IDs to all the entries that  
> have
> none yet?

(org-map-entries '(org-id-get-create) "LEVEL<5" 'agenda)

Make sure the scope (here `agenda') is so that you will reach the files
you want.

> How would I tell emacs to update Org-mode's ID database?

M-x org-id-update-id-locations RET

See the docstring to make sure it will reach the right files

> Could the org-id be added when publishing?

> Like
>    <h2 id="sec-2"> HEADLINE
>     <span class="org-id" id="THE-ORG-ID-ITSELF">THE-ORG-ID-ITSELF</ 
> span>
>    </h2>
> or similar?

They already are in the HTML, I am surprised you never noticed.

- Carsten

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

* Re: org-id: always add IDs
  2009-03-01 16:11 ` Carsten Dominik
@ 2009-03-01 16:34   ` Sebastian Rose
  0 siblings, 0 replies; 3+ messages in thread
From: Sebastian Rose @ 2009-03-01 16:34 UTC (permalink / raw)
  To: Carsten Dominik; +Cc: emacs-orgmode Org-Mode

Hi Carsten,


as always, your answer helped a lot. All questions and problems solved
so far. Thanks!


Carsten Dominik <dominik@science.uva.nl> writes:
> On Feb 27, 2009, at 10:30 AM, Sebastian Rose wrote:
>
>> Hi,
>>
>>
>> I have several questions concerning IDs.
>>
>>
>> Is there a prefered method to _always_ add an org-id to an entry?
>
> (add-hook 'org-insert-heading-hook
> 	(lambda () (org-id-get-create)))


Thanks a bunch!


>
>> The IDs would become _realy_ usefull, if I could add them automatically
>> whenever a new entry is created (a headline) that is _not_ below
>> `org-export-headline-levels'.
>
> You need to do more work if you want to have id' only for the top
> few levels, then you first need to find out what the level is.
> You can look at the dynamically scoped variable `head' which will
> contain the stars to be inserted (and, maybe, also a space,
> careful there)
>
> On the other hand, I don't see why it it would be a problem
> to have ids in headlines below the limit.  But I do not yet know
> how well my ID mechanism will scale.  Should be pretty good, actually.


Yes, you're right. Now as I think it over, I see that it is no feature I
need indeed. All tools using the exported XHTML will have to decide the
level on their own (e.g. for putting all the contents into a database
and split it by sections, subsections and paragraphs).



>> Is it possible to have an ID added, even if the headline is added by
>> hand (i.e. typing `* headline')?
>
> No easily.  The fastest way to get one added by hand is to store
> a link to the heading with `C-c l'.  If `org-link-to-org-use-id' is t
> or 'create-if-interactive', an id will be added.
>
>> Can this be achieved using an advice? How to do that?
>
> Since no special function is called when you type a headline,
> it would have to be advice to org-self-insert-command.
> Very likely that would significantly slow down typing, I strongly
> advice against doing that.
>
>> Is it possible to tell Org-mode to add IDs to all the entries that have
>> none yet?
>
> (org-map-entries '(org-id-get-create) "LEVEL<5" 'agenda)
>
> Make sure the scope (here `agenda') is so that you will reach the files
> you want.


Ahaaaa, fine. That solves the problem of automatically adding IDs when
creating headlines. I'll prefer fluid typing then, and postpone the
adding of missing IDs to some hook or interactive function call.

Is it possible to narrow the scope to files in a publishing project?
Hmmm - I think I should find the way to retrieve the list of files. It's
somewhere in org-exp.el I believe....



>> How would I tell emacs to update Org-mode's ID database?
>
> M-x org-id-update-id-locations RET
>
> See the docstring to make sure it will reach the right files
>
>> Could the org-id be added when publishing?
>
>> Like
>>    <h2 id="sec-2"> HEADLINE
>>     <span class="org-id" id="THE-ORG-ID-ITSELF">THE-ORG-ID-ITSELF</
>> span>
>>    </h2>
>> or similar?
>
> They already are in the HTML, I am surprised you never noticed.


... because I didn't use IDs in my publishing projects yet :-D



Best,
--
Sebastian Rose, EMMA STIL - mediendesign, Niemeyerstr.6, 30449 Hannover
Tel.:  +49 (0)511 - 36 58 472
Fax:   +49 (0)1805 - 233633 - 11044
mobil: +49 (0)173 - 83 93 417
Http:  www.emma-stil.de

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

end of thread, other threads:[~2009-03-01 16:31 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-02-27  9:30 org-id: always add IDs Sebastian Rose
2009-03-01 16:11 ` Carsten Dominik
2009-03-01 16:34   ` Sebastian Rose

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