emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Max Nikulin <manikulin@gmail.com>
To: Yuchen Pei <id@ypei.org>,
	emacs-orgmode mailing list <emacs-orgmode@gnu.org>
Subject: Re: [PATCH] Fixing refile cache use for org-goto in indirect buffers.
Date: Mon, 19 Sep 2022 22:48:34 +0700	[thread overview]
Message-ID: <7b2b5134-46c4-2db2-1322-a2d1257cbf30@gmail.com> (raw)
In-Reply-To: <87zgevvs6e.fsf@ypei.org>

On 19/09/2022 12:16, Yuchen Pei wrote:
> To reprod:
> - make sure the org-refile-targets generates a big enough list where
>    the refile cache makes a difference
> - visit an org file in org-refile-targets
> - M-x clone-indirect-buffer-other-window
> - C-0 C-c C-w to clear cache
> - M-: (org-refile-get-targets)

Have you tried to execute this command in the indirect buffer?

> - org-goto in the original buffer takes no effort
> - but, org-goto in the indirect buffer takes time, which is unexpected.

> diff --git a/lisp/org-refile.el b/lisp/org-refile.el
> index 16cff25bd..7189ef595 100644
> --- a/lisp/org-refile.el
> +++ b/lisp/org-refile.el
> @@ -306,7 +306,10 @@ converted to a headline before refiling."
>   	(dolist (f files)
>   	  (with-current-buffer (if (bufferp f) f (org-get-agenda-file-buffer f))
>   	    (or
> -	     (setq tgs (org-refile-cache-get (buffer-file-name) descre))
> +	     (setq tgs (org-refile-cache-get
> +                        (buffer-file-name (when (bufferp f)
> +                                            (buffer-base-buffer f)))
> +                        descre))

Thank you for the attempt to improve handling of indirect buffers.

I am afraid, more serious refactoring is required to reuse result of 
`buffer-base-buffer', for the previous attempt to avoid issues with 
`buffer-file-name' see
satotake to emacs-orgmode… [PATCH] org-refile.el: Fix the case of 
*scratch* buffer. Sat, 15 May 2021 19:38:39 +0900. 

There are several corner cases with `org-refile-cache', `org-goto', and 
- Perhaps buffer name, not file name should be used as the cache key if 
some buffer is not associated with any file. Alternatively cache should 
not be used at all.
- When an indirect buffer is narrowed down to some region (e.g. created 
using `org-tree-to-indirect-buffer') jump targets should be filtered to 
the displayed range.

So the change is an improvement (I would prefer `and' instead of `when' 
in such expression, but it does not really matter). Leaving aside other 
issues and more serious refactoring, it seems, storing results to the 
cache requires a similar fix, so perhaps it is possible to move "(setq f 
...)" code above of "(or ...)" and reuse f as the cache key.

Please, send patches produced by "git format-patch" command.

  reply	other threads:[~2022-09-19 16:07 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-19  5:16 [PATCH] Fixing refile cache use for org-goto in indirect buffers Yuchen Pei
2022-09-19 15:48 ` Max Nikulin [this message]
2022-09-20 12:44   ` Yuchen Pei
2022-09-20 17:33     ` Max Nikulin
  -- strict thread matches above, loose matches on Subject: below --
2022-09-19  5:16 Yuchen Pei

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:

  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=7b2b5134-46c4-2db2-1322-a2d1257cbf30@gmail.com \
    --to=manikulin@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=id@ypei.org \


* 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


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).