From mboxrd@z Thu Jan 1 00:00:00 1970 From: =?UTF-8?Q?Cl=c3=a9ment_Pit--Claudel?= Subject: Exporting fuzzy links using LaTeX's autoref Date: Mon, 8 Aug 2016 22:03:11 -0400 Message-ID: <89a1be0e-011a-8875-0886-28a18ab13b87@gmail.com> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="ioqVaCU9AoJsxa1DKC77LCNPGoFX30w8J" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:46015) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bWwO5-0001e5-3M for emacs-orgmode@gnu.org; Mon, 08 Aug 2016 22:03:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bWwO0-0003gi-S6 for emacs-orgmode@gnu.org; Mon, 08 Aug 2016 22:03:24 -0400 Received: from mout.kundenserver.de ([217.72.192.73]:57050) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bWwO0-0003ga-Hp for emacs-orgmode@gnu.org; Mon, 08 Aug 2016 22:03:20 -0400 Received: from [18.189.127.88] ([18.189.127.88]) by mrelayeu.kundenserver.de (mreue102) with ESMTPSA (Nemesis) id 0M09s4-1bERX118Zw-00uH2d for ; Tue, 09 Aug 2016 04:03:19 +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" To: emacs-orgmode@gnu.org This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --ioqVaCU9AoJsxa1DKC77LCNPGoFX30w8J Content-Type: multipart/mixed; boundary="0LoK9AvQknrC2Pu28NLnPfVuu2bc1n1u8" From: =?UTF-8?Q?Cl=c3=a9ment_Pit--Claudel?= To: emacs-orgmode@gnu.org Message-ID: <89a1be0e-011a-8875-0886-28a18ab13b87@gmail.com> Subject: Exporting fuzzy links using LaTeX's autoref --0LoK9AvQknrC2Pu28NLnPfVuu2bc1n1u8 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hi all, The LaTeX command \autoref{} produces a hyperlink that covers both the ta= rget type and its number; for example, \autoref{chap:org} produces someth= ing like _Chapter 3_. It's very similar to Chapter \ref{chap:org}, but: * "Chapter" is clickable * I can demote this chapter to a section, or change a figure into a tale,= and the word "Chapter" or "Figure" will appropriately change. I'd like to use this facility in my org-mode documents. I started definin= g a new link type [[autoref:(1)][(2)]]; (1) is the actual link, and (2) i= s the text to use in HTML export (Figure, Section, ...); LaTeX export ign= ores it (this isn't ideal, because in the buffer it only shows Figure, se= ction, etc.; bu since the follow function of custom links only gets the p= ath, I didn't find another way). This mostly worked: (org-add-link-type "autoref" #'org-autoref-follow #'org-autoref-export) (defun org-autoref-follow (path) "Follow fuzzy link PATH." (unless (run-hook-with-args-until-success 'org-open-link-functions path) (let ((destination (org-with-wide-buffer (org-link-search path (point)) ;; should be +2 of= beginning (point)))) (unless (and (<=3D (point-min) destination) (>=3D (point-max) destination)) (widen)) (goto-char destination)))) but then I started looking at org-autoref-export, and things got hairy. o= rg-latex-link gets three arguments (link desc info), which it uses in the= fuzzy link case to call (org-export-resolve-fuzzy-link link info). But c= ustom links don't get quite as much info: they just get the path, and not= the `info' parameter. I wasn't sure how to proceed at that point, so I w= rote my function as :around advice on org-latex-link; which is not too sa= tisfactory. Did I miss something? Thanks! Cl=C3=A9ment. --0LoK9AvQknrC2Pu28NLnPfVuu2bc1n1u8-- --ioqVaCU9AoJsxa1DKC77LCNPGoFX30w8J Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAEBCAAGBQJXqTnfAAoJEPqg+cTm90wjzAMP/i1EPnUIv+Sf9Nai1DNlERZE 91AvxQIH1Njh90jtQ5cuhTvxHU+5R7wtIiaCalyDcAiGRGimBtfTRCiidDoikVeY MvaKGeBST4fNbfUdGD8yeQb36q/c0q3pS47lKhnh/JKwGkB0+A910DiaY4DARahM iBJYQFD6IKis/acUDy0sBzTcMFOUo900O4STS6MS38Sqc5gKW9RgI6iTlDRjYp8F 7vWYfj1RgdCuGTJGm4NrogM4HtskW3G7G/uYPxhFZLY/BXo/F9kTxy+3rGrCxEcc DEaCzPIag2dwexO2HbO1sjHGC6D1nEPkv8Gw5BEKfVB5mABVeMF11yqFk0jvV2Zg sLKeVM3EWXwYIUcobSX7PZXUpBfxQ524uLnLTSw44Qml+a3fSadxeETn53XXiZ5o EhaV1pnQ7JRVkVo1Pukj5IQgN2VWE5Jx1UaZRk+KLi4afJNLYPO2gAKbamDUi6VL ZLI2eEL3WTGdXYpgM5a15G9OmFZOxWE8Z4AwbubhbRUGVYmPbRG1PQvHfGvoRgze wCCMVxqWLNjvkvWqItW1ptTni256dlFz/NpaDEPFR2vR5Za0uI41y72N5KGcvxu6 ZSOSBbRcLOt2cBwfoACAldIU9azIE9n5kMF/fljlq5k1yYLbPD3DCE0blUmE8ojJ CVbiBsFdFvnv+DtRdYny =V/0Y -----END PGP SIGNATURE----- --ioqVaCU9AoJsxa1DKC77LCNPGoFX30w8J--