[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] org-refile.el: Fix the case of *scratch* buffer
From: |
satotake |
Subject: |
[PATCH] org-refile.el: Fix the case of *scratch* buffer |
Date: |
Sat, 15 May 2021 19:38:39 +0900 |
* 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
- [PATCH] org-refile.el: Fix the case of emtpy buffer name, (continued)
- [PATCH] org-refile.el: Fix the case of emtpy buffer name, satotake, 2021/05/09
- Re: org-refile.el: Fix the case of emtpy buffer name, satotake, 2021/05/09
- [PATCH 2/2] org-refile.el: Fix test case, satotake, 2021/05/09
- [PATCH 2/2] org-refile.el: Fix test case, satotake, 2021/05/09
- Re: [PATCH 2/2] org-refile.el: Fix test case, Maxim Nikulin, 2021/05/11
- Re: org-refile.el: Fix test case (Squashed), satotake, 2021/05/13
- [PATCH] org-refile.el: Fix the case of emtpy buffer name, satotake, 2021/05/13
- Re: [PATCH] org-refile.el: Fix the case of emtpy buffer name, Maxim Nikulin, 2021/05/14
- Re: [PATCH] org-refile.el: Fix the case of emtpy buffer name, Bastien, 2021/05/15
- Re: [PATCH] org-refile.el: Fix the case of emtpy buffer name, satotake, 2021/05/15
- [PATCH] org-refile.el: Fix the case of *scratch* buffer,
satotake <=