From: Maxim Nikulin <manikulin@gmail.com>
To: emacs-orgmode@gnu.org
Subject: Re: [PATCH] org-refile.el: Fix the case of emtpy buffer name
Date: Fri, 14 May 2021 22:09:30 +0700 [thread overview]
Message-ID: <s7m3rb$j3r$1@ciao.gmane.io> (raw)
In-Reply-To: <20210513182052.2798-2-doublequotation@gmail.com>
In my opinion, patch is the minimal change that fixes particular
workflow and can be committed in the current form. Commit message may be
improved a bit.
I have a question (mainly to maintainer) if another approach could lead
to undesired effects, see below.
I have noticed a couple of old issues that can be improved later since
they may require more changes than allowed for "TINYCHANGE".
On 14/05/2021 01:20, satotake wrote:
> [PATCH] org-refile.el: Fix the case of emtpy buffer name
Buffer not associated with a file may be more precise since "*scratch*"
has name.
> * lisp/org-refile.el (org-refile-get-targets): Ensure
> arg of `file-name-non' and `file-truename' is non-nil.
truncated function name
Comments below a loosely related to the suggested patch.
> --- a/lisp/org-refile.el
> +++ b/lisp/org-refile.el
> @@ -310,11 +310,13 @@ 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 (file-name-nondirectory f) 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 (file-truename (buffer-file-name (buffer-base-buffer))) f nil nil) tgs))
Notice `file-truename'
> + (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))
> (setq org-outline-path-cache nil)
> @@ -337,9 +339,10 @@ converted to a headline before refiling."
> #'identity
> (append
> (pcase org-refile-use-outline-path
> - (`file (list (file-name-nondirectory
> - (buffer-file-name
> - (buffer-base-buffer)))))
> + (`file (list
> + (and (buffer-file-name (buffer-base-buffer))
I hope, additional operation in the inner loop has minimal performance
penalty. Additional variable may be introduced and initialized before
the loop over headings. It may help to avoid discrepancy similar to
`file-truename'.
> + (file-name-nondirectory
> + (buffer-file-name (buffer-base-buffer))))))
> (`full-file-path
> (list (buffer-file-name
> (buffer-base-buffer))))
Earlier patch, that added `file-truename' above, missed this point. At
first I was surprised why this clause does not require modification.
To maintainers:
What are negative consequences of completely skipping of buffers that
have no associated files? I mean not to add them to the list for
iteration. I can anticipate some tests should be fixed but I do not
think it is a problem. Anyway `org-goto' and `org-refile' do not work in
such buffers (from my point of view, reaction to such issue should be
saving content of buffer to some file since critical size of notes is
achieved):
On 14/05/2021 01:20, satotake wrote:
> In addition to your point, I found that we cannot refile internally even with
>
> my patch. In other words, if we can cache and reuse it, error ("Please
> indicate a target file in the refile path") is raised
> when we select it as refile target.
> Probably, we need to some additional fixations.
> It may be good to filter `files' which does not have `buffer-file-name'.
>> Have you tried org-capture?
> Yes. Mostly I use org-capture, especially, for creating TODO tasks.
> I sometimes start with fundamental-mode new buffer.
> After writing some texts, I switch to org-mode and try to call refile.
> I do not know why I do it by myself clearly but I tend to do it when I
> do not have any clear goal for the file.
Thank you for details. I think, it is a kind of valid workflow.
Personally I would consider it unreliable however. I suppose,
`org-default-notes-file' (default capture target) better suited for
temporary notes since it minimizes risk of lost text in the case of
failure. It requires to change habits a bit to call org-capture with
simple template in advance.
next prev parent reply other threads:[~2021-05-14 15:11 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-09 14:47 org-refile.el: Fix the case of emtpy buffer name satotake
2021-05-09 14:47 ` [PATCH] " 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
2021-05-13 18:20 ` org-refile.el: Fix test case (Squashed) satotake
2021-05-13 18:20 ` [PATCH] org-refile.el: Fix the case of emtpy buffer name satotake
2021-05-14 15:09 ` Maxim Nikulin [this message]
2021-05-15 8:20 ` Bastien
2021-05-15 10:38 ` satotake
2021-05-15 10:38 ` [PATCH] org-refile.el: Fix the case of *scratch* buffer satotake
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='s7m3rb$j3r$1@ciao.gmane.io' \
--to=manikulin@gmail.com \
--cc=emacs-orgmode@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).