From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id kOvjDjjIpF8eewAA0tVLHw (envelope-from ) for ; Fri, 06 Nov 2020 03:51:20 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id yLaoCjjIpF9+LgAAB5/wlQ (envelope-from ) for ; Fri, 06 Nov 2020 03:51:20 +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 7B73E9404C8 for ; Fri, 6 Nov 2020 03:51:19 +0000 (UTC) Received: from localhost ([::1]:36888 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kasmS-00025T-N9 for larch@yhetil.org; Thu, 05 Nov 2020 22:51:16 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:47860) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kasV6-00018i-AN for emacs-orgmode@gnu.org; Thu, 05 Nov 2020 22:33:24 -0500 Received: from pb-smtp1.pobox.com ([64.147.108.70]:59427) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kasV2-0007gG-2L for emacs-orgmode@gnu.org; Thu, 05 Nov 2020 22:33:19 -0500 Received: from pb-smtp1.pobox.com (unknown [127.0.0.1]) by pb-smtp1.pobox.com (Postfix) with ESMTP id 7645793A5E; Thu, 5 Nov 2020 22:33:12 -0500 (EST) (envelope-from kyle@kyleam.com) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=pobox.com; h=from:to:cc :subject:in-reply-to:references:date:message-id:mime-version :content-type; s=sasl; bh=cAYoJLjGSIOwMOzouru2clfPmc4=; b=aJRZaq +ztR++5KACmRvzx5Ysq8ILGor/LpJj1OCY8Kfn5/fH8sSXoc9ZO0T+0SWSh6noZ0 xifiroZmNFsxQziubyDobx7lRmVkN0XhWS/NdyC8vTxcm59JRb/7wkMoEHClshep BUlao7h580t5VtqLkJR6MX84195KjGj/mbnJo= Received: from pb-smtp1.nyi.icgroup.com (unknown [127.0.0.1]) by pb-smtp1.pobox.com (Postfix) with ESMTP id 6CB4C93A5D; Thu, 5 Nov 2020 22:33:12 -0500 (EST) (envelope-from kyle@kyleam.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=kyleam.com; h=from:to:cc:subject:in-reply-to:references:date:message-id:mime-version:content-type; s=mesmtp; bh=pTdPoJztJdMf8u5PwhqePyTcR7P+YP15ZXSZFg1K0QA=; b=2lsszhlS5rfFtnp8VenRVOcpdsyIU7EMGXnCn0PN9V+CuZ8mPyu2YmmJbi1UONPKDlXiLtOx5e6SY3XPwbQ6WR+VAwhA8wT8gqePhjlpSnECKWdHSLn8XW5pLU05Cc22fSsI6t0BnsS3RGrE58qdcEOm8ZWlR64uC0Ny1fdisIs= Received: from localhost (unknown [45.33.91.115]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by pb-smtp1.pobox.com (Postfix) with ESMTPSA id D1FF393A5C; Thu, 5 Nov 2020 22:33:11 -0500 (EST) (envelope-from kyle@kyleam.com) From: Kyle Meyer To: Jack Kamm Subject: Re: [PATCH] New "project" option for org-link-file-path-type In-Reply-To: <87blgd6lgw.fsf@gmail.com> References: <87v9etq2pg.fsf@gmail.com> <874km89uxu.fsf@kyleam.com> <87blgd6lgw.fsf@gmail.com> Date: Thu, 05 Nov 2020 22:33:10 -0500 Message-ID: <87pn4rnoqx.fsf@kyleam.com> MIME-Version: 1.0 Content-Type: text/plain X-Pobox-Relay-ID: CBE360B2-1FE0-11EB-9421-D152C8D8090B-24757444!pb-smtp1.pobox.com Received-SPF: pass client-ip=64.147.108.70; envelope-from=kyle@kyleam.com; helo=pb-smtp1.pobox.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/05 22:33:12 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, 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: , Cc: emacs-orgmode@gnu.org Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Scanner: ns3122888.ip-94-23-21.eu Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=pobox.com header.s=sasl header.b=aJRZaq +; dkim=pass header.d=kyleam.com header.s=mesmtp header.b=2lsszhlS; dmarc=none; 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-Spam-Score: -1.21 X-TUID: WUct8ti+AdZI Jack Kamm writes: > I like the idea of letting org-link-file-path-type be a function. > > However, it struck me that it might be too limiting to just have the > function return the project root. There's a lot more potential for > customization here -- for example, a user might want to combine the > noabbrev option with the adaptive option. If we could instead pass a > function that takes the filename as an argument and returns the path to > insert, that would allow for greater flexibility. > > Other benefits are that the implementation is much simpler, and > subjectively I think it's more intuitive to explain the meaning of this > option (as opposed to an option where the user passes a function that > returns the project root). > > The downside of this is that the user has to do a bit more work and > write some elisp to take advantage of the option. > > I've attached an updated patch in this direction. What do you think? I > think the simplicity and flexibility outweighs the downside, but I'm not > sure. I think that's a good direction to go (for the reasons you laid out, not just because it lets me use this with projectile :). > +++ b/etc/ORG-NEWS > @@ -35,6 +35,25 @@ omit a file description was to omit the header argument entirely, > which made it difficult/impossible to provide a default value for > =file-desc=. > > +*** New option to set ~org-link-file-path-type~ to a function > + > +If ~org-link-file-path-type~ can now be set to a function that takes > +the full filename as an argument and returns the path to link to. Drop "If"? > +For example, if you use ~project.el~, you can set this function to use > +relative links within a project as follows: > + > +#+begin_src emacs-lisp > +(setq (org-link-file-path-type > + (lambda (path) > + (let* ((proj (project-current)) > + (root (if proj (project-root proj) default-directory))) > + (if (string-prefix-p (expand-file-name root) path) > + (progn > + (file-relative-name path)) > + (abbreviate-file-name path)))))) > +#+end_src superfluous progn