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 ms0.migadu.com with LMTPS id kP8sJTmln2AcaQEAgWs5BA (envelope-from ) for ; Sat, 15 May 2021 12:40:57 +0200 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 wNnMIDmln2CiXQAAB5/wlQ (envelope-from ) for ; Sat, 15 May 2021 10:40:57 +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 0D47D22169 for ; Sat, 15 May 2021 12:40:57 +0200 (CEST) Received: from localhost ([::1]:53012 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lhrj6-0006OG-8R for larch@yhetil.org; Sat, 15 May 2021 06:40:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38356) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lhrhu-0005Dg-R0 for emacs-orgmode@gnu.org; Sat, 15 May 2021 06:39:42 -0400 Received: from mail-pj1-x1033.google.com ([2607:f8b0:4864:20::1033]:36660) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lhrht-0002si-7C; Sat, 15 May 2021 06:39:42 -0400 Received: by mail-pj1-x1033.google.com with SMTP id n6-20020a17090ac686b029015d2f7aeea8so1895952pjt.1; Sat, 15 May 2021 03:39:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Y6asV0S1sWyCCWmFOG5FkIOBo9Xudtik2ES1ngnCecM=; b=qqu5vjWh+e0+NbuEtczPTRr1xgqCCDwk9BzRwPr5wcF9R1Keq7426LLCK+hTXUjOkh Y8KtYAEFM1ZpyRUpT2bklVEMVmmPDUiJt79sYky0V71gZzWGirKFl/CfZlhXlDhAOsis Synj38rlPXvUxUItZXBmUGzL6Kzp4YWaAJB/LkmyWaJkGy5zyRzR+72O+6Sur+qxDBt3 5qwLK9ZAVRI8VzQ98cvxlI0ME88ZQWwtXjYwxw8QE9hi9m9PIBPgYiNO6ZfBK32NHHgU AKkMzAHJxjtEkV4cpkYLf+F8OyeKmL8Vt3dSf5U5wpKrbK8sVGUA2KRFMITvldb9vAuz Q1Hg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Y6asV0S1sWyCCWmFOG5FkIOBo9Xudtik2ES1ngnCecM=; b=Ys0aAPbKK4cofce+AjoxqvAXOZb/mNo3c1dLv8CueAKIdzO2ML/3ZzK50HjSHWk4vD nDAu2yD6RJA5ahUUvB8SEkKnFagcpTEkwIRy1rpLVZhKZfc2ctH1IOZhnjFQ+EdXPZze cvwdCfYPmaka5HPSHKqNlbnVcSA8RmoLC4EKm6WQAORbRwXk4duB5lAAM7t4lr8oZbGP ZcjYqvTc9BKElojjY2dSGMUAe1F/yYrGFAAnx1ApESHvLP57G+lYp4/kazUapL8sa7CP jyZJ8KMlHOWSpPnYUEwb4BGlgTA2v0sa0LDQfI47f4EyTjWv/9SpznPlZNjTWGc8r/NN +Tow== X-Gm-Message-State: AOAM533opPcPvii91N2/jQNaq5+epWo1T3uAtRHLyqKiX6Fof9d7IBJG TJeNa/HHIyJjXCGO1AWmsDoEMChWgAQllw== X-Google-Smtp-Source: ABdhPJyeSepmTthKfc0tW89nIYcDBN5MeWsmlt43DNpj0QfcD222c4Ed0twdlbiR+QVSoBr8SeBCiQ== X-Received: by 2002:a17:90b:2397:: with SMTP id mr23mr23946906pjb.77.1621075179472; Sat, 15 May 2021 03:39:39 -0700 (PDT) Received: from localhost.localdomain (KD106154119051.au-net.ne.jp. [106.154.119.51]) by smtp.gmail.com with ESMTPSA id k38sm6033702pgi.73.2021.05.15.03.39.37 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 15 May 2021 03:39:39 -0700 (PDT) From: satotake To: bzg@gnu.org Subject: [PATCH] org-refile.el: Fix the case of *scratch* buffer Date: Sat, 15 May 2021 19:38:39 +0900 Message-Id: <20210515103839.8574-2-doublequotation@gmail.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210515103839.8574-1-doublequotation@gmail.com> References: <87im3kcssl.fsf@gnu.org> <20210515103839.8574-1-doublequotation@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=2607:f8b0:4864:20::1033; envelope-from=doublequotation@gmail.com; helo=mail-pj1-x1033.google.com 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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, 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: satotake , emacs-orgmode@gnu.org 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=1621075257; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: 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=Y6asV0S1sWyCCWmFOG5FkIOBo9Xudtik2ES1ngnCecM=; b=un2lI4fOWI7EiDxzaz6W1ArQMY1quYK7I+FE9LfSrUMrKUYh+qbzWn8Um5CfU7fIwn4j9B XMU/eAFitviEXS/b2D1/xZ0ZxWido16TD2G4HxbMye4BtlPScXIwjhcRbhKFVsgKRlPvjA d5BHBx/6Y7EVYjtXy8tbAUMW1z9PMV33ZsehJFoduLnZ7IuhLfc1Y6J8Ex9YxaYAA6qOgI eBv1IFrqA7ly4qQMr8AL+2cT17UHb7CqoTlD4zHmRTzAije2v8Rx2XlVAXADYjjAQvqZMo Fldwtjp+mggbdNM2ERkasAKXzIjwe8YgRVqbKVuAs48p4UlR0u/qE85CMcNelw== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1621075257; a=rsa-sha256; cv=none; b=SzjaVFa/7o+uW6dkBhB/qF4BOzrJ/kBLmPCUqdAQVixfkHewhwLKtWSUFKvsQLZP0+7f9R 72L4B5W1NU4RtYLeB3NXqZSvtc4Zklg39rY3S48ovyrXGw3MV2NAH9qf8t6+2KTgK1paT+ dFm1B3R/AE9tkiPQYVKnY6EYeIwhlagHCPZRzqF13psxaUuLuYEuokjcoLbmD1YcA6NOl4 YFXUmrSNBFPnb2xS6XPO3MhBiSlxREbw+GPvDzjsA/n/OCjNCMGpu8b6pOfwk+o3brc4Fu g4fAeouj6GreKbeP+05X9r3YUfGkIaLU8xCZb57Y1Ka73DWHkFI54nvtY+g5jg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20161025 header.b=qqu5vjWh; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=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-Migadu-Spam-Score: 3.65 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20161025 header.b=qqu5vjWh; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=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-Migadu-Queue-Id: 0D47D22169 X-Spam-Score: 3.65 X-Migadu-Scanner: scn0.migadu.com X-TUID: W/yxrEpd0tIw * lisp/org-refile.el (org-refile-get-targets): Ensure arg of `file-name-nondirectory' and `file-truename' is non-nil. If you set `org-refile-use-outline-path' `file' or `full-file-path', and call `org-refile' in the buffer before visiting file, errors are raised at these point. To fix them, check if they are nil or not. TINYCHANGE --- lisp/org-refile.el | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/lisp/org-refile.el b/lisp/org-refile.el index 24a1bde51..01a0a6f7f 100644 --- a/lisp/org-refile.el +++ b/lisp/org-refile.el @@ -267,7 +267,7 @@ converted to a headline before refiling." (let ((case-fold-search nil) ;; otherwise org confuses "TODO" as a kw and "Todo" as a word (entries (or org-refile-targets '((nil . (:level . 1))))) - targets tgs files desc descre) + targets tgs files desc descre tg-base) (message "Getting targets...") (with-current-buffer (or default-buffer (current-buffer)) (dolist (entry entries) @@ -309,12 +309,17 @@ converted to a headline before refiling." (when (bufferp f) (setq f (buffer-file-name (buffer-base-buffer f)))) (setq f (and f (expand-file-name f))) - (when (eq org-refile-use-outline-path 'file) - (push (list (file-name-nondirectory f) f nil nil) tgs)) - (when (eq org-refile-use-outline-path 'buffer-name) - (push (list (buffer-name (buffer-base-buffer)) f nil nil) tgs)) - (when (eq org-refile-use-outline-path 'full-file-path) - (push (list (file-truename (buffer-file-name (buffer-base-buffer))) f nil nil) tgs)) + (setq tg-base + (pcase org-refile-use-outline-path + (`file (and f (file-name-nondirectory f))) + (`full-file-path + (and (buffer-file-name (buffer-base-buffer)) + (file-truename (buffer-file-name (buffer-base-buffer))))) + (`buffer-name (buffer-name (buffer-base-buffer))) + (_ nil))) + (when (member org-refile-use-outline-path + '(file full-file-path buffer-name)) + (push (list tg-base f nil nil) tgs)) (org-with-wide-buffer (goto-char (point-min)) (setq org-outline-path-cache nil) @@ -336,17 +341,10 @@ converted to a headline before refiling." (mapconcat #'identity (append - (pcase org-refile-use-outline-path - (`file (list (file-name-nondirectory - (buffer-file-name - (buffer-base-buffer))))) - (`full-file-path - (list (buffer-file-name - (buffer-base-buffer)))) - (`buffer-name - (list (buffer-name - (buffer-base-buffer)))) - (_ nil)) + (if (member org-refile-use-outline-path + '(file full-file-path buffer-name)) + (list tg-base) + nil) (mapcar (lambda (s) (replace-regexp-in-string "/" "\\/" s nil t)) (org-get-outline-path t t))) -- 2.30.0