From mboxrd@z Thu Jan 1 00:00:00 1970 From: Rasmus Subject: Re: [patch, ox] Unnumbered headlines Date: Sun, 21 Sep 2014 16:37:50 +0200 Message-ID: <87k34xghtt.fsf@gmx.us> References: <87lhqzyubg.fsf@gmx.us> <87bnrrp0tb.fsf@nicolasgoaziou.fr> <87r40n6nrg.fsf@gmx.us> <87egwmaxte.fsf@nicolasgoaziou.fr> <87k34y701i.fsf@gmx.us> <87fvfl86ct.fsf@nicolasgoaziou.fr> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:50262) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XViHP-00044a-P6 for emacs-orgmode@gnu.org; Sun, 21 Sep 2014 10:38:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XViHI-0004hB-Ap for emacs-orgmode@gnu.org; Sun, 21 Sep 2014 10:38:23 -0400 Received: from mout.gmx.net ([212.227.15.18]:56546) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XViHI-0004gm-15 for emacs-orgmode@gnu.org; Sun, 21 Sep 2014 10:38:16 -0400 In-Reply-To: <87fvfl86ct.fsf@nicolasgoaziou.fr> (Nicolas Goaziou's message of "Sun, 21 Sep 2014 15:12:50 +0200") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: mail@nicolasgoaziou.fr, emacs-orgmode@gnu.org Cc: alantyree@gmail.com, tsd@tsdye.com Hi, Thanks for the comments. Let's give it another try, shand't we. Nicolas Goaziou writes: >> I introduce a new function `org-export-get-headline-id` which returns >> the first non-nil from the following list. There's a caveat: >> CUSTOM_ID is ensured to be unique! Did I open the famous can of worm? >> >> 1. The CUSTOM_ID property. >> 2. A relative level number if the headline is numbered. >> 3. The ID property >> 4. A new generated unique ID. > > I think we should keep separated CUSTOM_ID and ID on the one hand, and > internal reference on the other hand. > > There's no guarantee that CUSTOM_ID will be unique, and, even if you > check it out, there's no guarantee either that its value can be used > as-is in the generated docstring (think about ":CUSTOM_ID: 100%" in > LaTeX export). > > CUSTOM_ID is a human readable reference to an Org headline. This > headline should be referred to internally with a more specific id. To > a lesser extent, I think this also applied to org-id. > > Also `org-export-headline-internal-id' (or some such, to avoid confusion > with other IDs) may return a value simpler than what `org-id-new' > returns (e.g. a dumb counter). If it is possible, the output will be > easier to read. Okay, I returned to my first hack (which never made it to this list). Basically, I ID everything. Unnumbered sections get the id "unnumbered-sec-COUNTER" and numbered sections get the id "sec-COUNTER". Perhaps you will find it too much of a hack. The other easy alternative, which I find less pleasing, would have on incremental counter, but it makes it harder to read. A third alternative is give the numbers like in this patch, but store the numbers for unnumbered section somewhere else than :headline-numbering. >> Anyhow, `org-export-get-headline-id' ensures that we can refer to >> unnumbered headlines, which was not possible before. > > This is untrue. > >> Of course, in LaTeX such ref to a \section* will be nonsense, so we >> could introduce a \pageref here. > > At the moment, referring to an unnumbered section displays its name. In some modes, yes. In LaTeX it produces a \ref{=C2=B7} that LaTeX will laugh at. If you have a better idea than using the title I'm all ears! >> + (when (equal 'headline (org-element-type destination)) > > Comparing symbols with `equal' is a sin beyond redemption. Use `eq'. Shiiit. . . Why, out of curiosity? I though equal was like the meaner, tougher eq, that gets shit right, but is a bit more expensive. >> + (format "[%s]" (org-export-data (org-export-get-alt-title >> destination info) info))))))))) > > alt title is for table of contents only. Yeah, but I though, conditional on using title for ref when nothing better exists, it would be nicer to have something shorter. Anyway, I changed it to plain title now. > Nitpick: I suggest `and' instead of `when' since there's no side-effect. OK, I think I got 'em all.=20 >> + (unless (org-export-get-node-property :UNNUMBERED headline t) > > Actually, this test is fragile. In the following example > > * H1 > :PROPERTIES: > :UNNUMBERED: t > :END: > ** H2 > :PROPERTIES: > :UNNUMBERED: nil > :END: > *** H3 Fixed. Thanks, Rasmus --=20 Don't panic!!!