From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id IHCNLd0ulWFxNwAAgWs5BA (envelope-from ) for ; Wed, 17 Nov 2021 17:33:33 +0100 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id gFQqKd0ulWHdaQAA1q6Kng (envelope-from ) for ; Wed, 17 Nov 2021 16:33:33 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 6EDA929F2E for ; Wed, 17 Nov 2021 17:33:32 +0100 (CET) Received: from localhost ([::1]:51342 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mnNsI-00083H-Vm for larch@yhetil.org; Wed, 17 Nov 2021 11:33:31 -0500 Received: from eggs.gnu.org ([209.51.188.92]:59290) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mnNoW-0004AS-74 for emacs-orgmode@gnu.org; Wed, 17 Nov 2021 11:29:36 -0500 Received: from basilikum.nobis-admin.de ([89.238.71.130]:35522) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mnNoU-0007KE-1l for emacs-orgmode@gnu.org; Wed, 17 Nov 2021 11:29:35 -0500 From: Stefan Nobis DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=snobis.de; s=default; t=1637166570; bh=2AdJSzPWkkR6vVUJh7OGC55JLoUaDzMZEnB8NqN2HzQ=; h=From:To:Subject:References:Date:In-Reply-To:From; b=hVtQO5NFIaeEXb/2mVa8tZv5SZVQ/1ur3f+kE/6e9BMq10aVb+Qwl1ZtRyk+5qVv0 P420OoDcjk4DqSgj9CwJQofnOpzacAtubs6bg842pF+jYsyO7OSS2whn1xqweiWOFL stZS42uUuBmECQ1jxkFKg9fFEXl8z52b5PwyghAU= To: emacs-orgmode@gnu.org Subject: Re: insert automatically a reference to a section header and a link References: <877dd7mdx7.fsf@mat.ucm.es> <87r1bfnln2.fsf@ucl.ac.uk> <87o86ilw9a.fsf@mat.ucm.es> <87ilwqlvh5.fsf@mat.ucm.es> <87bl2ilqtr.fsf@mat.ucm.es> Mail-Followup-To: emacs-orgmode@gnu.org Date: Wed, 17 Nov 2021 17:29:29 +0100 In-Reply-To: <87bl2ilqtr.fsf@mat.ucm.es> (Uwe Brauer's message of "Wed, 17 Nov 2021 16:55:28 +0100") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (darwin) MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=89.238.71.130; envelope-from=stefan-ml@snobis.de; helo=basilikum.nobis-admin.de X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Migadu-Flow: FLOW_IN X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1637166812; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=2AdJSzPWkkR6vVUJh7OGC55JLoUaDzMZEnB8NqN2HzQ=; b=Qdz90bM20MAimCC9wqgtfcKc2K+/rSIvNOkBrkPtedGeFISKsm/FoYxFcYDjuFFBxYKWSd bQnEPMT1FdxEta+iHdTOGl+sK5C+Ca5makj5Tt2qONWPAcBrDAqJqB9CgT3EQsZO/jjAXl mbH71tq7Ahl9y4ZLHt2aJ5Jec55DwfHeX7FPYFdL3kc68pEUqgsv6lIf/sbEkgZnB9C8Oy SvL22EAV75WyEk0WVF2DHj9dCr8FVTe/RizQmXa8L6IkznvoVXKW+Lmt1g2XgtEUbV88qA auYPsaTNoLhy0NVsUXCZpqE+5nagmoHw5aGCy/VkkJGNcV6E7OEF6/wpIZEQvQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1637166812; a=rsa-sha256; cv=none; b=FxXfeQYJZVbUMxcUfNrdH10rlakUxCOUOiKclUm+Jo6k5VSGbqePXCR6BdiXupmgjWTQxa bseOFEzQU12j/7AwVOnCUUnxyuVIOo7aPjc3LyLEDStSvtPR2UrJN/EAFUKgY4fLnqyVTT TOveXkxyJS5iHtA8gKNOEXa4odia5LgLtBZPl7C0cALE9SH10E+rsW9c2l208sS3tCMwvB PS4quk5ua81j6wWdUmycUK6eBefO0yNiQx44Jmrz5HbIb7zD1d7AMV+wFY37zDJlaO6VHT thwKzImjAmeAdqmErhnX9MtebDvA2VbuRrocizkRf+3D1ZeSCAWutppCLtJFDQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=snobis.de header.s=default header.b=hVtQO5NF; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: -3.56 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=snobis.de header.s=default header.b=hVtQO5NF; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: 6EDA929F2E X-Spam-Score: -3.56 X-Migadu-Scanner: scn0.migadu.com X-TUID: odGF8aDFPLq4 Uwe Brauer writes: > I am not following you. You insert a header as in > * Intro > Now you want to refer to it with a link > As we have seen in section ... > So what precisely are you typing? I type "As we have seen in section [[*Intro]]" (literally, I tend to not use any keybindings or function to insert the link). This (the "*Intro" inside double square brackets) is called an internal link to headlines and they are a default feature of Org: https://orgmode.org/manual/Internal-Links.html#Internal-Links BTW: I mostly export to PDF via LaTeX and usually use the combination of cleveref with varioref. Therefore I prefer to type "As we have seen in [[*Intro]]" (leaving out "section") and let Org generate a "\vref{...}" reference. To achive this, I need little bit of extra setup (and do not forget to add the necessary usepackage commands either locally in the Org file or add it to org-latex-default-packages-alist): #+begin_src emacs-lisp (defun sn/ox-latex-filter-special-ref-vref (text backend info) (when (org-export-derived-backend-p backend 'latex) (replace-regexp-in-string "\\\\ref{" "\\\\vref{" text))) (add-to-list 'org-export-filter-link-functions #'sn/ox-latex-filter-special-ref-vref) #+end_src If you need internal links to headings more often and do not want to type the whole heading text manually, you can use functions like this (inspired by `worf-goto' and `counsel-outline'; if you do not use ivy/swiper/counsel, the code should at least give the basic idea): #+begin_src emacs-lisp (defun sn/org-insert-internal-link () "Use ivy to insert a link to a heading in the current `org-mode' document." (interactive) (let ((settings (cdr (assq major-mode counsel-outline-settings)))) (ivy-read "Heading: " (counsel-outline-candidates settings) :action 'sn/org-insert-internal-link-action))) (defun sn/org-insert-internal-link-action (x) "Insert link for `sn/worf-insert-internal-link'" (save-excursion (goto-char (cdr x)) (call-interactively 'org-store-link)) (org-insert-last-stored-link 1) (delete-char -1)) #+end_src -- Until the next mail..., Stefan.