From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id aID1DTgLX2GFLgAAgWs5BA (envelope-from ) for ; Thu, 07 Oct 2021 16:59:04 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id +DzBCTgLX2H4UQAA1q6Kng (envelope-from ) for ; Thu, 07 Oct 2021 14:59:04 +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 7E0C6C482 for ; Thu, 7 Oct 2021 16:59:03 +0200 (CEST) Received: from localhost ([::1]:41310 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mYUrO-0006wK-Kx for larch@yhetil.org; Thu, 07 Oct 2021 10:59:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55316) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mYUpp-0006uO-S9 for emacs-orgmode@gnu.org; Thu, 07 Oct 2021 10:57:26 -0400 Received: from mout02.posteo.de ([185.67.36.66]:42421) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mYUpn-0003aB-OV for emacs-orgmode@gnu.org; Thu, 07 Oct 2021 10:57:25 -0400 Received: from submission (posteo.de [89.146.220.130]) by mout02.posteo.de (Postfix) with ESMTPS id EC7CC240101 for ; Thu, 7 Oct 2021 16:57:19 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1633618640; bh=VALpc06+xB6kPTxFeWQy4Cbmx9HXXgyGHrpNFXjtfKQ=; h=From:To:Subject:Date:From; b=aAXleyb2dmhKgqQUhIUJ3ylao67l1wamVfmfblKdba0RKlI+JBuJMZT+KRe5ImbcK XiR74X2zFVLUa91jzN3zC8hhYnIreawkAq0wmGCGAx3FXF8+aeO2ieFM8iJ6fq/5wC EQJaqKDDuwh5av1xOuUOuyb6x9N7zZnBEqYGheuAmPVhZrIPY3Gu7fkPu0YVBpHxIm K3IETZYRYa5nE/TbHzysqkQleUGrIml9kK3d8dpL2xlvOI+2ZkKj6zcRKrtv3D4Ll4 A+aSkyIupUN9aiwmRVXsuffM0mYbnupWaKoZ7yS0xkn+dCyEGlVBjnv1qr/0Da3ohY XgtDXbmKIvspg== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4HQDv32Phsz9rxB for ; Thu, 7 Oct 2021 16:57:19 +0200 (CEST) From: =?utf-8?Q?Juan_Manuel_Mac=C3=ADas?= To: orgmode Subject: [tip] Go to the org node from the attached directory Date: Thu, 07 Oct 2021 14:57:18 +0000 Message-ID: <87tuhsnar5.fsf@posteo.net> MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=185.67.36.66; envelope-from=maciaschain@posteo.net; helo=mout02.posteo.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=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.23 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 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1633618743; 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:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=mD155bPhtFmgAGG1u50EOn16qYExoJiAHrvFspVigLE=; b=nWyVMJ8+2D6nWke39iVI6xp1q/jRc2vprIBDtlwC1YCHjV4YNtIYDEWkZpkgZfusemrhXe ez9v5o7/n8oFQNfxxGwzHCorQiDzhHzIpj9ZqsQhMfVAMolM7xn0qCwa3664Wgeo0uGPJ9 qMkwc2N1lCLGNS7e8l7KkIZzLjH4OWO03eN4M8T0LMcw9l15PcU8rZSqPleTq++iwCNn9M KzHE0sBMnsUS2FsQvYg8IkZ5K5jrC1PC/hh70x1xsiA/12HfL+xDr3GYZQhwGWTIQIGISp RD2DRB4Ef7K+fXpS/ublsEht4ZeO1O9ER+i2vg3HZ3pPd5/KXDV8a+RsfvSVJA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1633618743; a=rsa-sha256; cv=none; b=cWVti3hFnUemw8tLwCE9ykFDso1zTi21RXiesTog8FBncM4GZNkYBUsHU+otbeOafSKVuG CB7l+D7PA5FEoVSQLqUMwz1MiFRQbrwcmJuXMlprfIhtlfFHBWQbBeLHcV81AG1D8nPpV0 yOGtdE/ZVUo3OKNh8xbPjqmUap3/8rde62gHAakWFHs2KBcqtDPjNl6K4Mt/PRG4P1vAPe GHJNr5bHLYi1LUe1LQWr0UftYsEW8i7FnuVDMjsP7N9SUN+qfRUFq5OSYsiaeV6av9GtbY mE+F216bNaD8BplcoXyZNRxkKkaSezPVbJ9Mt1GRn1ioOXYhlPF1tsWwcOpZBQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=aAXleyb2; spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Migadu-Spam-Score: -1.62 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=aAXleyb2; dmarc=pass (policy=none) header.from=posteo.net; spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Migadu-Queue-Id: 7E0C6C482 X-Spam-Score: -1.62 X-Migadu-Scanner: scn0.migadu.com X-TUID: wPeGT1BGQpLO Hi, I often come across the following use case: helm-locate leads me to a file named (for example) document.pdf, which is in an attached folder of an Org node. I open the document and then I would like to jump from there to the Org node. I don't know if anyone has found any solutions for this or if there is any specific package. I have come up with this poor man's solution: add a local variable to the attached directory, which should contain the org node ID. The function that adds the variable after I run org-attach: #+begin_src emacs-lisp (defun my-org-attach/add-dir-variable (&rest _ignore) (let* ((dir (org-attach-dir)) (id (org-id-get-create)) (default-directory dir)) (unless (file-exists-p (concat dir "/" ".dir-locals.el")) (save-window-excursion (add-dir-local-variable nil 'node-id id) (save-buffer) (read (current-buffer)) (kill-buffer))))) #+end_src and then: #+begin_src emacs-lisp (advice-add 'org-attach :after #'my-org-attach/add-dir-variable) #+end_src and the function to jump from the attached folder to the org node: #+begin_src emacs-lisp (defun my-org-attach/goto-node () (interactive) (org-id-goto node-id)) #+end_src (of course this only works if there is only one attached directory per node). Best regards, Juan Manuel