emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH 2/2] org-refile.el: Fix test case
  2021-05-09 15:55 ` satotake
@ 2021-05-09 15:55   ` satotake
  2021-05-09 16:05   ` satotake
  1 sibling, 0 replies; 4+ messages in thread
From: satotake @ 2021-05-09 15:55 UTC (permalink / raw)
  To: emacs-orgmode; +Cc: satotake

* lisp/org-refile.el (org-refile-get-targets): Check
`buffer-file-name' return value instead of `buffer-base-buffer'.

To pass the related tests, we need to check `buffer-file-name'.

TINYCHANGE
---
 lisp/org-refile.el | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/lisp/org-refile.el b/lisp/org-refile.el
index 6f5b8acee..2900be27e 100644
--- a/lisp/org-refile.el
+++ b/lisp/org-refile.el
@@ -310,13 +310,12 @@ converted to a headline before refiling."
 		 (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 (if f (file-name-nondirectory f) nil) f nil nil) tgs))
+		 (push (list (and f (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 (if (buffer-base-buffer)
-                                 (file-truename (buffer-file-name (buffer-base-buffer)))
-                               nil)
+		 (push (list (and (buffer-file-name (buffer-base-buffer))
+                                  (file-truename (buffer-file-name (buffer-base-buffer))))
                              f nil nil) tgs))
 	       (org-with-wide-buffer
 		(goto-char (point-min))
@@ -341,10 +340,9 @@ converted to a headline before refiling."
 				(append
 				 (pcase org-refile-use-outline-path
 				   (`file (list
-                                           (if (buffer-base-buffer)
-                                               (file-name-nondirectory
-                                                (buffer-file-name (buffer-base-buffer)))
-                                                  nil)))
+                                           (and (buffer-file-name (buffer-base-buffer))
+                                                (file-name-nondirectory
+                                                 (buffer-file-name (buffer-base-buffer))))))
 				   (`full-file-path
 				    (list (buffer-file-name
 					   (buffer-base-buffer))))
-- 
2.30.0



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] org-refile.el: Fix test case
@ 2021-05-09 16:02 satotake
  0 siblings, 0 replies; 4+ messages in thread
From: satotake @ 2021-05-09 16:02 UTC (permalink / raw)
  To: emacs-orgmode; +Cc: satotake

* lisp/org-refile.el (org-refile-get-targets): Check
`buffer-file-name' return value instead of `buffer-base-buffer'.

To pass the related tests, we need to check `buffer-file-name'.

TINYCHANGE
---
 lisp/org-refile.el | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/lisp/org-refile.el b/lisp/org-refile.el
index 6f5b8acee..2900be27e 100644
--- a/lisp/org-refile.el
+++ b/lisp/org-refile.el
@@ -310,13 +310,12 @@ converted to a headline before refiling."
 		 (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 (if f (file-name-nondirectory f) nil) f nil nil) tgs))
+		 (push (list (and f (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 (if (buffer-base-buffer)
-                                 (file-truename (buffer-file-name (buffer-base-buffer)))
-                               nil)
+		 (push (list (and (buffer-file-name (buffer-base-buffer))
+                                  (file-truename (buffer-file-name (buffer-base-buffer))))
                              f nil nil) tgs))
 	       (org-with-wide-buffer
 		(goto-char (point-min))
@@ -341,10 +340,9 @@ converted to a headline before refiling."
 				(append
 				 (pcase org-refile-use-outline-path
 				   (`file (list
-                                           (if (buffer-base-buffer)
-                                               (file-name-nondirectory
-                                                (buffer-file-name (buffer-base-buffer)))
-                                                  nil)))
+                                           (and (buffer-file-name (buffer-base-buffer))
+                                                (file-name-nondirectory
+                                                 (buffer-file-name (buffer-base-buffer))))))
 				   (`full-file-path
 				    (list (buffer-file-name
 					   (buffer-base-buffer))))
-- 
2.30.0



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] org-refile.el: Fix test case
  2021-05-09 15:55 ` satotake
  2021-05-09 15:55   ` [PATCH 2/2] org-refile.el: Fix test case satotake
@ 2021-05-09 16:05   ` satotake
  2021-05-11 11:45     ` Maxim Nikulin
  1 sibling, 1 reply; 4+ messages in thread
From: satotake @ 2021-05-09 16:05 UTC (permalink / raw)
  To: emacs-orgmode; +Cc: satotake

* lisp/org-refile.el (org-refile-get-targets): Check
`buffer-file-name' return value instead of `buffer-base-buffer'.

To pass the related tests, we need to check `buffer-file-name'.

TINYCHANGE
---
 lisp/org-refile.el | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/lisp/org-refile.el b/lisp/org-refile.el
index 6f5b8acee..2900be27e 100644
--- a/lisp/org-refile.el
+++ b/lisp/org-refile.el
@@ -310,13 +310,12 @@ converted to a headline before refiling."
 		 (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 (if f (file-name-nondirectory f) nil) f nil nil) tgs))
+		 (push (list (and f (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 (if (buffer-base-buffer)
-                                 (file-truename (buffer-file-name (buffer-base-buffer)))
-                               nil)
+		 (push (list (and (buffer-file-name (buffer-base-buffer))
+                                  (file-truename (buffer-file-name (buffer-base-buffer))))
                              f nil nil) tgs))
 	       (org-with-wide-buffer
 		(goto-char (point-min))
@@ -341,10 +340,9 @@ converted to a headline before refiling."
 				(append
 				 (pcase org-refile-use-outline-path
 				   (`file (list
-                                           (if (buffer-base-buffer)
-                                               (file-name-nondirectory
-                                                (buffer-file-name (buffer-base-buffer)))
-                                                  nil)))
+                                           (and (buffer-file-name (buffer-base-buffer))
+                                                (file-name-nondirectory
+                                                 (buffer-file-name (buffer-base-buffer))))))
 				   (`full-file-path
 				    (list (buffer-file-name
 					   (buffer-base-buffer))))
-- 
2.30.0



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 2/2] org-refile.el: Fix test case
  2021-05-09 16:05   ` satotake
@ 2021-05-11 11:45     ` Maxim Nikulin
  0 siblings, 0 replies; 4+ messages in thread
From: Maxim Nikulin @ 2021-05-11 11:45 UTC (permalink / raw)
  To: emacs-orgmode

On 09/05/2021 23:05, satotake wrote:
> * lisp/org-refile.el (org-refile-get-targets): Check
> `buffer-file-name' return value instead of `buffer-base-buffer'.
> 
> To pass the related tests, we need to check `buffer-file-name'.

Thank you for the patches. Maybe I have missed something, but it seems 2 
patches are not logically independent, second one touches the same code 
to fix regression in tests. If so, could you, please, squash both 
patches into a single one (e.g. using git rebase --interactive)? I hope, 
it will help to review the change and to avoid confusion with several 
versions of second patch in 2 threads.

Code around has at least one more problem: questionable behavior in the 
case of indirect buffers (e.g. C-x 4 c). Refile targets cache, when 
enabled, is not reused for indirect buffer.

On 09/05/2021 21:47, satotake wrote:
> I often use org-mode for note-taking and so on.
> Sometimes, I would like to refile the headings in the scratch to other
> org files while I am writing.

Have you tried org-capture? https://orgmode.org/manual/Capture.html
https://sachachua.com/blog/2015/02/learn-take-notes-efficiently-org-mode/#unnumbered-3
I think, existence of this feature is the reason why this bug was 
remaining unnoticed.




^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-05-11 11:47 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-05-09 16:02 [PATCH 2/2] org-refile.el: Fix test case satotake
  -- strict thread matches above, loose matches on Subject: below --
2021-05-09 14:47 [PATCH] org-refile.el: Fix the case of emtpy buffer name satotake
2021-05-09 15:55 ` satotake
2021-05-09 15:55   ` [PATCH 2/2] org-refile.el: Fix test case satotake
2021-05-09 16:05   ` satotake
2021-05-11 11:45     ` Maxim Nikulin

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).