From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nicolas Goaziou Subject: Re: Include heading title in HTML section-number cross-reference, like LaTex \nameref? Date: Sun, 09 Feb 2014 09:29:33 +0100 Message-ID: <87fvnsofiq.fsf@gmail.com> References: <87k3d5nuiw.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:34177) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WCPlO-00009p-N5 for emacs-orgmode@gnu.org; Sun, 09 Feb 2014 03:29:24 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WCPlH-0004wB-SP for emacs-orgmode@gnu.org; Sun, 09 Feb 2014 03:29:18 -0500 Received: from mail-wg0-x22b.google.com ([2a00:1450:400c:c00::22b]:41999) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WCPlH-0004w7-KY for emacs-orgmode@gnu.org; Sun, 09 Feb 2014 03:29:11 -0500 Received: by mail-wg0-f43.google.com with SMTP id y10so3303743wgg.34 for ; Sun, 09 Feb 2014 00:29:10 -0800 (PST) In-Reply-To: (D. C. Toedt's message of "Sat, 8 Feb 2014 18:04:49 -0600") 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: "D. C. Toedt" Cc: emacs-orgmode@gnu.org "D. C. Toedt" writes: > I found a problem when trying this on a bigger file (my book file): If $1 > (actually, #$1) is for a link target that doesn't exist, then org-mode goes > into its "No match - create this as a new heading? (y or n)" routine. That > causes the rest of the export to fail. It'd be better if get-title could > do the same thing org-mode does natively, that is, including the text of $1 > as italics to indicate a non-existent link. > > Example file below: > > > #+MACRO: get-title (eval (save-excursion (org-open-link-from-string > "[[#$1]]") (org-get-heading nil nil))) > #+MACRO: SECREF [[#$1][{{{get-title($1)}}}]] > #+OPTIONS: H:7 toc:nil num:1 email:t author:t > > * Introduction to Technology Contracts > :PROPERTIES: > :CUSTOM_ID: IntroTechContracts > :END: > > Lorem ipsum etc. etc. > > * Dangerous Clauses > :PROPERTIES: > :CUSTOM_ID: DangerousClauses > :END: > > Lorem ipsum etc. etc. -- see Section {{{SECREF( > BogusLinkTarget > )}}} The following should work. #+MACRO: get-title (eval (or (save-excursion (ignore-errors (let ((org-link-search-inhibit-query t)) (org-open-link-from-string "[[#$1]]") (org-get-heading nil nil)))) "/$1/")) Regards, -- Nicolas Goaziou