From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id OGDYDOKtbGIi3AAAbAwnHQ (envelope-from ) for ; Sat, 30 Apr 2022 05:32:50 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id OLYdDeKtbGIKdQEAauVa8A (envelope-from ) for ; Sat, 30 Apr 2022 05:32:50 +0200 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 AC83692E6 for ; Sat, 30 Apr 2022 05:32:49 +0200 (CEST) Received: from localhost ([::1]:38030 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nkdqh-0007Ph-V1 for larch@yhetil.org; Fri, 29 Apr 2022 23:32:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50064) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nkdqC-0007OH-Nm for emacs-orgmode@gnu.org; Fri, 29 Apr 2022 23:32:16 -0400 Received: from mail-pl1-x62a.google.com ([2607:f8b0:4864:20::62a]:46028) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nkdqA-0000E0-TH for emacs-orgmode@gnu.org; Fri, 29 Apr 2022 23:32:16 -0400 Received: by mail-pl1-x62a.google.com with SMTP id h12so8629133plf.12 for ; Fri, 29 Apr 2022 20:32:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:in-reply-to:references:date:message-id :mime-version; bh=TQScNwqYiiCYAADdDP+nIkJnG+XtfZagpIn085ktUqQ=; b=MOT7VxoCsAoCQjfRR+B6KsPK4qoMGgynIYUP+5lsTXgFh0yx0OylIDNvn66HpxRcBM h/AZ4bJKrEeKIALpGt02aCXA1C4SFtw+LuVOg9cbQ2WIXTnffGLnVzaN1pUeWqnr/dJh swwOdkyJahqTUK27jYayVzI+oaTq6y2RsLmQ7voTKTyTLTKJ1kavd10qwraOgJD7ZD2j fCMAny13sms+pBBUHGQCElZbMH+FtfB8dLbu35rnCrd0wDPYG+NviTqpnnOJj4PjHF5+ u7ZMuK4Os/xn1TsU9doqyfzcbCzjJmRsCMkGJBKqtCQyJyN7BIIStsLYbk+h0uA9eheY lXVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:in-reply-to:references:date :message-id:mime-version; bh=TQScNwqYiiCYAADdDP+nIkJnG+XtfZagpIn085ktUqQ=; b=4shzk31HxOdcSLMQOvBtOeMwrCFetFNJwJHmXloGxgkSkjkUzRJUQOzoXfQmsXrOOQ +mU+7b+wi4GdCvfej2yrifsAttdVpaq/ltaW2Z2MPydGY812CZzpS7DQd8vk9hSAAI2n JtmnQOkPP8Ieb9Cypq+sym3CHOli2uI2gnivY7BVcGP33vbIXNbvEQQJYJ5WK81FZ1b6 veaFSWZYCkDfBg07tEBGE+CA7ZL047MnAaJjs/Pvho1fNqOPBU2Z1+Hhj25RPy3VGQAU Y78m62wMXGF99Qgk4GWRFnqGSdj0PZhkhO/HbCrJw/Gmo6MSbXndhrvkA2X+9nczOwzf 7kWg== X-Gm-Message-State: AOAM532bfH6ic0qeBW/Ujq6648LxmlLmu63kba3itt6NksZS+4BynKg2 vtgkPawaTDempgbjez3Gosg= X-Google-Smtp-Source: ABdhPJxKuSxnWPS4Vq2cRGpoC3xsa4ts4nT5hg9Y2RX5kvz5ZILhOvIHVdN0tg/eq3+i24+FV8/yXA== X-Received: by 2002:a17:903:2352:b0:15d:5c2f:85ab with SMTP id c18-20020a170903235200b0015d5c2f85abmr2295354plh.47.1651289533314; Fri, 29 Apr 2022 20:32:13 -0700 (PDT) Received: from localhost ([45.83.130.130]) by smtp.gmail.com with ESMTPSA id bd4-20020a170902830400b0015e8d4eb1c2sm333872plb.12.2022.04.29.20.32.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Apr 2022 20:32:12 -0700 (PDT) From: Ihor Radchenko To: Matt Price Subject: Re: [PATCH] org-attach-attach: fix symlinks In-Reply-To: References: Date: Sat, 30 Apr 2022 11:32:58 +0800 Message-ID: <87pmkzutxx.fsf@localhost> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=2607:f8b0:4864:20::62a; envelope-from=yantar92@gmail.com; helo=mail-pl1-x62a.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 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, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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: , Cc: Org Mode Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Migadu-Flow: FLOW_IN X-Migadu-To: larch@yhetil.org X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1651289569; 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=TQScNwqYiiCYAADdDP+nIkJnG+XtfZagpIn085ktUqQ=; b=o1034QmDDEgnDZFYyuoutq3v241UATmlRksY/BhifvBbjAmjZotzZ6fLIGqmy2XzGng/I/ bUMLoxFsZTct1Jwl+oG4lTirXnFZ04+Ruu4m+VDRaXaTt3jvK6nDyi5WIWTgJI4P/zNrbs Qe+5FNV3LCHbM3SFcRmrcolScJdapu26WloLDZEcZtbwHmCqfGBpV9X9upDhNXYAmlNmJI 0xMcm+aFffNeuYbqQe4Y7epUTxl9Z0wEd0gi+ITnm9A+1RXtprUrARegTyeDI/V1PdxiUA 3NY7GLVNPsUZyNudJerxMbreVYfA29z4MtmFDnjh+KVwQN/fvWuLTZgGbe2dOQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1651289569; a=rsa-sha256; cv=none; b=anQjV4VMvArXzXtOfl7fwDvSkchtK5iFJGoy9YWUgv7Pi0GqODqPopzCPPX65yv42ogfkQ e/kXhiQzKkBWwHHGcfgBnpbU7Y/RKt1lWGZULNaB5mDi3tusqf+uEcaXEqD3hRFFsWiYje QGcMz166XWgnhoSAFl3rdZnmE83srWo0aqZ5kEqnIYEhIhjuhe8O6w9Gl3PIgQp6WkwBYu ZvS+PnpumvvK+ZqeTumZ54IGzTOE1EIqELBF2ly+QNrt3DLy5sCY5WwnMIW9lKVbx9H3UR tHz6r1lDhQZLerD/wr7YHwHc6au4ctk4DQ4lmO/ape0lq36QHEko96INeMDVqg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=MOT7VxoC; dmarc=pass (policy=none) header.from=gmail.com; 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: -8.79 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=MOT7VxoC; dmarc=pass (policy=none) header.from=gmail.com; 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: AC83692E6 X-Spam-Score: -8.79 X-Migadu-Scanner: scn0.migadu.com X-TUID: 6EpLgF11NjO3 --=-=-= Content-Type: text/plain Matt Price writes: > I'm having trouble with org-attach-attach if my current buffer is visiting > a filepath starting with "~/". This trivial patch fixes the problem for me > by running (expand-file-name) on the file before attaching. I always use > the 'lns method, so I don't know whether it might be better to > expand-file-name before running any of the methods. > > Alternatively, it might actually be better to use a *relative* file path > where possible (e.g. to ensure that project directories are fully > portable), but I'm not sure how best to do that. I do not like explicit expansion of the FILE path. It may break relative vs. absolute path handling. Attaching an alternative patch. It makes use of make-symbolic-link arguments. Best, Ihor --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-org-attach-attach-Avoid-linking-to-path-starting-wit.patch >From ff9ccae51ce1b02fc5d95cbc60de7a44c42f28a1 Mon Sep 17 00:00:00 2001 Message-Id: From: Ihor Radchenko Date: Sat, 30 Apr 2022 11:27:30 +0800 Subject: [PATCH] org-attach-attach: Avoid linking to path starting with ~ * lisp/org-attach.el (org-attach-attach): Auto-expand ~ in the file patch when using symlink (`lns') attach method. Fixes https://orgmode.org/list/CAN_Dec_LyTKgSN_kiftee9GULM7FPER5frQFant3n_2C3cwM-g@mail.gmail.com --- lisp/org-attach.el | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lisp/org-attach.el b/lisp/org-attach.el index 5ee2b84b2..760592507 100644 --- a/lisp/org-attach.el +++ b/lisp/org-attach.el @@ -524,7 +524,8 @@ (defun org-attach-attach (file &optional visit-dir method) ((eq method 'mv) (rename-file file attach-file)) ((eq method 'cp) (copy-file file attach-file)) ((eq method 'ln) (add-name-to-file file attach-file)) - ((eq method 'lns) (make-symbolic-link file attach-file)) + ;; We pass integer third argument to auto-expand "~" in FILE. + ((eq method 'lns) (make-symbolic-link file attach-file 1)) ((eq method 'url) (url-copy-file file attach-file))) (run-hook-with-args 'org-attach-after-change-hook attach-dir) (org-attach-tag) -- 2.35.1 --=-=-=--