Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

org-ql-find does not take you to the search result you select #380

Closed
oantolin opened this issue Oct 23, 2023 · 14 comments
Closed

org-ql-find does not take you to the search result you select #380

oantolin opened this issue Oct 23, 2023 · 14 comments
Assignees
Labels
Milestone

Comments

@oantolin
Copy link
Contributor

Or rather it does, but it does so inside a org-with-point-at which expands to a form including save-excursion so the jumping gets undone right away! (There's an easy work around: just use embark-dwim, but I would much rather just press RET.) This is with org-ql version 0.8-pre from MELPA, build 20231020.244.

oantolin added a commit to oantolin/emacs-config that referenced this issue Oct 23, 2023
alphapapa added a commit that referenced this issue Oct 23, 2023
Fixes #380.

Reported-by: Omar Antolín Camarena <[email protected]>
@alphapapa
Copy link
Owner

Hi Omar,

Thanks for reporting that. I hadn't noticed since I use org-tree-to-indirect-buffer in the org-ql-find-goto-hook.

I think this commit should fix it: 631cd80 Please let me know if it does for you.

@alphapapa alphapapa self-assigned this Oct 23, 2023
@alphapapa alphapapa added the bug label Oct 23, 2023
@alphapapa alphapapa added this to the 0.7.3 milestone Oct 23, 2023
@oantolin
Copy link
Contributor Author

Yes, that works perfectly. Thank you!

@telenieko
Copy link

THANK YOU, @oantolin !!! This has been driving me crazy for weeks now, and I had no idea where, even on which package, the problem was!!

@alphapapa
Copy link
Owner

@telenieko Glad that it's fixed for you. Could you tell me a bit more about how you're using org-ql? I'm surprised it wasn't more obvious where the problem was.

@oantolin
Copy link
Contributor Author

Yeah, I'm curious about that too, @telenieko.

@telenieko
Copy link

telenieko commented Oct 25, 2023

@telenieko Glad that it's fixed for you. Could you tell me a bit more about how you're using org-ql? I'm surprised it wasn't more obvious where the problem was.

There are two places that were broken in my system,

In a notmuch-show buffer I can call mf-email-get-links-to-current-thread and, using org-ql I will find any Org entries that contain links to any e-mails of the e-mail thread being visited. (#279 has some background on the org-backlinks predicate):

(defun mf-email-get-links-to-current-thread()
  "Find org items linking to this email thread."
  (interactive)
  (let* ((message-ids (notmuch-show-get-messages-ids))
         (targets (mapconcat (lambda (tgt) (format "\"notmuch:%s\"" tgt))
			     message-ids))
         (query (format "org-backlinks:%s" targets))
         (title (format "Tasks linked to: %s"
                        (notmuch-show-get-subject)))
         )
    (org-ql-find (org-agenda-files t t)
		 :query-prefix query
		 :prompt "Tareas relacionadas: ")))

I also have a very simple search function bound to a key for "full text" searching:

(defun mf-pkm-todo-search (arg)
  "Search for TODO. If ARG search archives too."
  (interactive "P")
  (let ((include-archives (not (eq nil arg))))
    (org-ql-find (org-agenda-files nil include-archives))))

You see both functions use org-ql-find to allow me to refine the search in the minibuffer (specially on the e-mail searching function).

Back to the obviousness: Now that @oantolin mentioned it... I feel ashamed of missing this behaviour of org-with-point-at (well, not ashamed, I'm a newbie still!). But before then my brain just did not make the connection.

@alphapapa
Copy link
Owner

In a notmuch-show buffer I can call mf-email-get-links-to-current-thread and, using org-ql I will find any Org entries that contain links to any e-mails of the e-mail thread being visited. (#279 has some background on the org-backlinks predicate):

Cool, thanks. Quick thing I noticed that you might want to be aware of: you seem to be concatting targets without commas between tokens, i.e. IIUC it will turn into something like org-backlinks:"notmuch:FOO""notmuch:BAR". Instead the query should look something like org-backlinks:notmuch:FOO,notmuch:BAR (assuming that the org-backlinks predicate handles multiple arguments correctly).

Back to the obviousness: Now that @oantolin mentioned it... I feel ashamed of missing this behaviour of org-with-point-at (well, not ashamed, I'm a newbie still!). But before then my brain just did not make the connection.

Well, you shouldn't feel bad, after all, I misused it myself. :)

Also, friendly tip: Instead of (not (eq nil arg)) you can use the classic trick to "booleanize" it, (not (not arg)).

@telenieko
Copy link

telenieko commented Oct 31, 2023

Thanks for the tips @alphapapa! will polish my code a little bit! :D

For anyone coming here in the future: I fixed the targets concatenation by passing a SEPARATOR parameter to mapconcat.

@bram85
Copy link
Contributor

bram85 commented Jan 8, 2024

Commit 8e9a8fe reintroduces org-with-point-at, essentially reintroducing this bug again in release 0.8.1.

@alphapapa
Copy link
Owner

Commit 8e9a8fe reintroduces org-with-point-at, essentially reintroducing this bug again in release 0.8.1.

Argh. Thanks for reporting.

@alphapapa alphapapa reopened this Jan 9, 2024
@alphapapa alphapapa modified the milestones: 0.7.3, 0.8.2 Jan 9, 2024
alphapapa added a commit that referenced this issue Jan 9, 2024
@alphapapa
Copy link
Owner

alphapapa commented Jan 9, 2024

This should be fixed now, on master and in v0.8.2. Thanks, @bram85.

@oantolin
Copy link
Contributor Author

I'm still seeing the bug after that commit. You did replace org-with-point-at with without-restriction, but you forgot to actually move point. The code in commit 631cd80 included a (goto-char marker) which you don't have anymore.

alphapapa added a commit that referenced this issue Jan 10, 2024
@alphapapa
Copy link
Owner

@oantolin Thanks. I've just pushed fixes as v0.8.3 and to master. I've tested it more carefully, and it seems to work correctly in various circumstances. Please let me know if you find any more problems.

@oantolin
Copy link
Contributor Author

Thank you! I can confirm that fix works for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants