From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1.migadu.com ([2001:41d0:1008:1e59::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms8.migadu.com with LMTPS id aIZZEpeFkGWOagEAkFu2QA (envelope-from ) for ; Sat, 30 Dec 2023 22:03:19 +0100 Received: from aspmx1.migadu.com ([2001:41d0:403:4876::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1.migadu.com with LMTPS id uM+1DZeFkGXFmgAA62LTzQ (envelope-from ) for ; Sat, 30 Dec 2023 22:03:19 +0100 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=ushin.org header.s=key1 header.b=pLK3lRxW; 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=quarantine) header.from=ushin.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1703970199; 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:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=U0ZmJ8BL55L87cx7vzsifrjiIwPDKpBrUU9q9G+l36g=; b=Kn8UC0WI1H7BoHKuaYpct/QS5Jb/uwOqAH9bjNtwswy5+xqNqDGFhqLhqdZFeSotl+0P6Z //7JuIl3HQTrgwTP1YwtD3VY7xkqDAYycyTW++v7b0TOa6sPnwR3pvGgPeaKsAHzH3amJi 7si0ft4yCsAXPx3TeN3lqg582bExKuCm3DkgrzkUW1XhSsEZWxlZp7hnSfCWdV9bsu7HxZ ITUBbMjAjkBcxPSBqmd41raP+2UiY2V1YIF0oAT/6q6FzjpVEjylbIbLjD7iBn8wFH9sBR lW0LPUr5SS2UeNg8MC4tw5og6Epkei+ZYwXOsk85DOZpWrPKFNj26VkIVFehVA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=ushin.org header.s=key1 header.b=pLK3lRxW; 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=quarantine) header.from=ushin.org ARC-Seal: i=1; s=key1; d=yhetil.org; t=1703970199; a=rsa-sha256; cv=none; b=lA+33m8y6/I3VybhZWSjVtdp7grKkZX77UP+6+PnMw2VWe/I4HjXXuIjk6cnnZW4oVhFd9 GvkcesB8BuyL0v9nSErmLukCMf+WSwidZDZvbP4WBEED8mb4EigKphJlk+onyrzVPA7LnT K3sZBMhlMhcgX2HsCSMfTExUC+ZEsfNrp97BFHJsUkmJ8agQVtUnFrBLFmMQehpt5huUxa GoO9CQVgc/1IFI36n3BPycdyI0KjpxhemsBghKcgUBohlAga7ZSuGtYsUVQwCpepIL4uVd Spz7t4+BoISNNht4LHNkt6u6NLqHHP1HW9kRAlqvKeCrheWJ9L+8KFsGRuJ0tQ== 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 91B3E59B2A for ; Sat, 30 Dec 2023 22:03:18 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rJgTM-0005Ik-0O; Sat, 30 Dec 2023 16:02:20 -0500 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 1rJgTK-0005IL-RD for emacs-orgmode@gnu.org; Sat, 30 Dec 2023 16:02:18 -0500 Received: from out-176.mta1.migadu.com ([95.215.58.176]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rJgTH-0002Gv-Gv for emacs-orgmode@gnu.org; Sat, 30 Dec 2023 16:02:18 -0500 References: <87o7e9ei3p.fsf@ushin.org> <87wmsx3vyc.fsf@localhost> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ushin.org; s=key1; t=1703970128; 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: in-reply-to:in-reply-to:references:references; bh=U0ZmJ8BL55L87cx7vzsifrjiIwPDKpBrUU9q9G+l36g=; b=pLK3lRxWUUyNmtzQqNOsn6o+3iXjURKGzPF2qlivuYzYQfdkHwfbSeZ6sasmrux4gfOVt7 z31VBJWH5qVMvCesngUJQF5RMXikWMptZkMUE3+kCm63s4MPNB/RHQgP9g1PyKYYvwtJWC /YoH2rGZpHeQV5dVgl+sYGGoAzUlXtdVOUzZgafzICAdxbCJ5tUkOdOtQEutsofjeL4tzm hRH+TPA0r7luU0s1ULxadq/WhsTsBypu1jqfcpzGBRcGNq0tuD5+zcqJj66uExsELnizbx SHt3aCHQ6GzZ+nLdGKcCFzSP1mUaJwxJIvakYU1Dyi+2T6Axu3TwAPDmtTQbEg== X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Joseph Turner To: Ihor Radchenko Cc: emacs-orgmode@gnu.org, Adam Porter Subject: Re: Should org-link-parser add type "file" when link has no "file:" prefix? Date: Fri, 29 Dec 2023 14:05:13 -0800 In-reply-to: <87wmsx3vyc.fsf@localhost> Message-ID: <87a5pro14q.fsf@ushin.org> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=95.215.58.176; envelope-from=joseph@ushin.org; helo=out-176.mta1.migadu.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 5.0 requ) BAYES_00=-1.9, DATE_IN_PAST_12_24=1.049, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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-Country: US X-Migadu-Flow: FLOW_IN X-Migadu-Spam-Score: -6.47 X-Spam-Score: -6.47 X-Migadu-Queue-Id: 91B3E59B2A X-Migadu-Scanner: mx10.migadu.com X-TUID: o3FBdQdLFuyw --=-=-= Content-Type: text/plain Ihor Radchenko writes: > Joseph Turner writes: [...] > Thanks for reporting! > Fixed, on main. > https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=d15e52fef Thank you for the quick fix! >> In hyperdrive.el currently, "[[/foobar]]" and "[[file:/foobar]]" have >> different meanings: a link with no protocol prefix, like "[[/foobar]]", >> points to a file inside of the same hyperdrive (virtual p2p folder), >> whereas a link with the "file" protocol prefix, like "[[file:/foobar]]", >> points to a file on the local filesystem: > > I do not recommend such approach. From the point of view of most of the > Org mode code, it makes no difference whether file link has file: or > not. So, you may face unexpected issues. You are certainly right about unexpected issues ;) > It would be more reliable to provide a separate link type. > We might even extend the special file+application: link type syntax that > already allows special behavior for opening file links. Thank you! Would you explain about extending file+application syntax? hyperdrive.el does add a separate "hyper://" link type which is used to link to a hyperdrive file or directory by its "full" URL: hyper://aaj45d88g4eenu76rpmwzjiabsof1w8u6fufq6oogyhjk1ubygxy/hyperdrive/hyperdrive-manual.org Additionally, we want to make it possible for users to copy ("mirror") a directory of Org mode documents into a hyperdrive for other users to view and link to. Ideally, when users upload a set of files to a hyperdrive, the relative and absolute links between those files within the same hyperdrive work without modification. We also wanted users to be able to link to files on the local filesystem from within a hyperdrive. Firefox and Chrome treat prefix-less links as pointers to files on the same webserver and "file:" links as pointers to files on the filesystem. We thought that we could do the same thing in hyperdrive.el: [[/README.org]] could point to a file in the same hyperdrive while [[file:/README.org]] could point to a local file. Would you be open to changing Org mode so that prefix-less links could be handled in a special way by certain modes? Here's an idea: - Add a buffer-local variable `org-current-uri-scheme' which could be set to a string like "hyper". - When handling "file" type links, check if `org-current-uri-scheme' matches one of the keys in `org-link-parameters', and use the appropriate handler instead of the "file" handler. (see attached patch for an example usage in `org-link-open') What do you think? Thanks!! Joseph --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=org-current-uri-scheme-follow.patch diff --git a/lisp/ol.el b/lisp/ol.el index 20aab6bb8..3808b9215 100644 --- a/lisp/ol.el +++ b/lisp/ol.el @@ -1097,12 +1097,15 @@ (defun org-link-open (link &optional arg) ;; first need to integrate search option, if any. ("file" (let* ((option (org-element-property :search-option link)) - (path (if option (concat path "::" option) path))) - (org-link-open-as-file path - (pcase (org-element-property :application link) - ((guard arg) arg) - ("emacs" 'emacs) - ("sys" 'system))))) + (path (if option (concat path "::" option) path)) + (f (org-link-get-parameter org-current-uri-scheme :follow))) + (if (functionp f) + (funcall f path) + (org-link-open-as-file path + (pcase (org-element-property :application link) + ((guard arg) arg) + ("emacs" 'emacs) + ("sys" 'system)))))) ;; Internal links. ((or "coderef" "custom-id" "fuzzy" "radio") (unless (run-hook-with-args-until-success 'org-open-link-functions path) --=-=-=--