From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2.migadu.com ([2001:41d0:303:e16b::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms13.migadu.com with LMTPS id OLmjAQSHImcvMAAAe85BDQ:P1 (envelope-from ) for ; Wed, 30 Oct 2024 19:20:36 +0000 Received: from aspmx1.migadu.com ([2001:41d0:303:e16b::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2.migadu.com with LMTPS id OLmjAQSHImcvMAAAe85BDQ (envelope-from ) for ; Wed, 30 Oct 2024 20:20:36 +0100 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=eauchat.org header.s=mail header.b=samfamXr; 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"; dmarc=pass (policy=none) header.from=eauchat.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1730316035; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=wfYR7R5WDLmjZSxpfE5MuKeW0ij+A0vsTa4OF9Ty0lQ=; b=tEAgGrfoJJf99qtuqKvfbWtTCr5J3vLKwS0UX+aatZ15RPyRPR+LaFv+FgEcAs+EHX0yXD 0jxdrPstSunAVCZNVpxBHKl7p8ksKUpb7YcOQb4/AAlNUnfz5FgDgKJo07AlAPe+svpGPG UYCjDVm6E4z2oPMUohBKimbjwcGG6O0fS/5j4U52qHbvE3ukVw5KZ1/9RfQ+x/FImQ/3oP aE9aNIr0r+RbHst59wd7x2/PFhKZCafbZ1Xzxf4qtgHoLmb35aS5TUf/L7oDbCCrNsvuhJ O9y0p8Z0l0m3xHsoPbVjdMxAI1HrX7e6eRxmpOdXd+XEoujMbcB8Szy0FkF50A== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1730316035; a=rsa-sha256; cv=none; b=F4YHnShLfmfUu0xgvgFbmEfWDaSYa+LTNS9Zo2rHDYkcoi88rua58ehUtOctzDqY6E+MKg g5qGiYlmGxlvnHoK/d21T33Jra4SPEYWGQyNbW84W8tLPDqKaiVq+5ShEnB8Sn4x1rWsM/ 991CHIkVeU/SinXxem9BuNY8KnZH5i7MK0jAtlohYbdRMOeesmGrLBikEnOgGwG56iOsu4 qXJrNlebLJLDteAz7qOAK/SlmSzORwMKumtHU5659XtJYkK5YVwpETlFbsApdeF2GNXf7s 8njuUv6TsBNatkXi+NabJQWd+TtoaNDBrDC/UqUMHAXLqPpHNYd+2z+WBVj4KQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=eauchat.org header.s=mail header.b=samfamXr; 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"; dmarc=pass (policy=none) header.from=eauchat.org 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 9BCBE558B3 for ; Wed, 30 Oct 2024 20:20:35 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t6EER-0006Ce-SY; Wed, 30 Oct 2024 15:19:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t6EEP-0006Bn-FJ for emacs-orgmode@gnu.org; Wed, 30 Oct 2024 15:19:49 -0400 Received: from elegua.eauchat.org ([91.224.149.118] helo=eauchat.org) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1t6EEM-0000tg-Gl for emacs-orgmode@gnu.org; Wed, 30 Oct 2024 15:19:48 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=eauchat.org; s=mail; t=1730315977; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=wfYR7R5WDLmjZSxpfE5MuKeW0ij+A0vsTa4OF9Ty0lQ=; b=samfamXrxIWaBhMSaNViAUmnN/rCg0aWeP8vgAzvT+pQcHmqcE16az7VNmVsZ8lOge2xjO kuen+s9wB9r/KWjcAaDPKXcJPpevGeG14lzDtO2ENVI6k1ma7MYk/mr5fBG4xOsbgaJGU5 lMk+G0KjwQDVeT22mLoIgOcBUaMQ47o= From: =?utf-8?Q?S=C3=A9bastien_Lerique?= To: Ihor Radchenko Cc: emacs-orgmode@gnu.org Subject: Re: An org-follow-mode following org/org-roam links In-Reply-To: <87a5eqvj7p.fsf@localhost> (Ihor Radchenko's message of "Sat, 26 Oct 2024 17:59:22 +0000") References: <87a5ex1p3z.fsf@eauchat.org> <87a5eqvj7p.fsf@localhost> Date: Wed, 30 Oct 2024 20:19:35 +0100 Message-ID: <87ldy5o0u0.fsf@eauchat.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Received-SPF: pass client-ip=91.224.149.118; envelope-from=sl@eauchat.org; helo=eauchat.org 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, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, 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-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US X-Migadu-Spam-Score: -2.70 X-Spam-Score: -2.70 X-Migadu-Queue-Id: 9BCBE558B3 X-Migadu-Scanner: mx13.migadu.com X-TUID: e74szHroRcGZ On 26 Oct 2024 at 17:59, Ihor Radchenko wrote: > You can do something like (save-excursion (org-back-to-heading t) (point-= marker)) > This will move point back to the beginning of current heading, return > marker corresponding to that point, and move back. > Indeed, thanks to the final setup is the following, and works grand: --8<---------------cut here---------------start------------->8--- (defvar sl/org-follow-preview-buffer nil) (defun sl/org-follow-link () "Automatically open the first link in the current line. When it is a file to open, the buffer will open in \"other\" window." (interactive) (when (and (member this-command '(previous-line next-line forward-char backward-char left-char right-char org-previous-link org-next-link)) ;; This second condition may be part of the minor-mode function (derived-mode-p 'org-mode)) (save-excursion ;; `cl-letf' is meant to ensure `file-file-other-window' to be used f= or ;; opening a file by temporarily changing the value of ;; `org-link-frame-setup' during evaluating the body. (cl-letf (((alist-get 'file org-link-frame-setup) #'find-file-other-window)) (let ((buffers-before-follow) (win (selected-window)) (link (when (or (org-in-regexp org-link-any-re) (re-search-forward org-link-any-re (line-end-position) :t)) ;; It seems `org-element-link-parser' must be located at ;; the beginning of the link at point. (goto-char (match-beginning 0)) (org-element-link-parser)))) (when link (when sl/org-follow-preview-buffer (kill-buffer sl/org-follow-preview-buffer) (setq sl/org-follow-preview-buffer nil)) (setq buffers-before-follow (buffer-list)) (org-link-open link) ;; Current buffer is the link target (unless (member (current-buffer) buffers-before-follow) (rename-buffer (concat "preview: " (buffer-name))) (setq sl/org-follow-preview-buffer (current-buffer)))) (select-window win)))))) (define-minor-mode sl/org-follow-link-minor-mode "Automatically open the first link in the current line. When it is a file to open, the buffer will open in \"other\" window." :lighter " sfl" ;; The indicator for the mode line. (if sl/org-follow-link-minor-mode (add-hook 'post-command-hook #'sl/org-follow-link nil :local) (remove-hook 'post-command-hook #'sl/org-follow-link :local))) --8<---------------cut here---------------end--------------->8--- Best --=20 S=C3=A9bastien Lerique https://slvh.fr/