alphapapa / org-ql

A searching tool for Org-mode, including custom query languages, commands, saved searches and agenda-like views, etc.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cannot run org-agenda-kill after introducing derived mode

AloisJanicek opened this issue · comments

Since org-agenda-kill explicitly requires org-agenda-mode by this line

(or (eq major-mode 'org-agenda-mode) (user-error "Not in agenda"))

at the beginning of its definition, after introducing org-ql-view-mode in ba7d4a2, user can no longer delete org headings from inside Org-QL buffer.

This is loosely related to #35 in a sense that it shows that Org-mode sometimes tests and restricts execution of its org-agenda functions.

Temporary work-around for users until this is solved would be advising org-agenda-kill with :around advice and overriding value of major-mode - which is not pretty.

  (advice-add #'org-agenda-kill :around (lambda (orig-fun &rest args)
                                          (let ((major-mode 'org-agenda-mode))
                                            (apply orig-fun args))))

after searching org-agenda.el, more commands are using this equality test:

  • org-agenda-capture
  • org-agenda-archive-with
  • org-agenda-kill-all-agenda-buffers (but this fn is probably not relevant to org-ql)
  • org-agenda-save-markers-for-cut-and-paste (also not sure if relevant)

Hi Alois,

Thanks for catching this.

I wasn't aware of the org-agenda-kill command. I'm surprised that it even exists, because it sounds somewhat dangerous, to kill an entry remotely while in an Agenda buffer. I guess it isn't bound by default?

Anyway, as you noticed, other commands are broken by this as well. I guess I should revert the change that added the derived mode, at least for 0.4, because I didn't intend to break those commands. Instead, I can do another kind of check in the org-ql-view-refresh command.

In the long term, the org-ql-view buffers will probably have their own mode (I intend it to be based on magit-section, similar to Bufler), and remote-editing commands like these will need to be either reimplemented or wrapped by org-ql-view.

I'll push a fix for this in a little while. Thanks.

I think that should do it. Please let me know if that fixes it for you. Thanks.

Works well now, you fixed it, thanks for your quick response.

When it comes to destructive remote editing from agenda buffers, I use org-agenda-kill a lot in my inbox search. I have a habit of capturing almost anything which comes up to my mind and sometimes those things are so low quality that it is best to delete them :-) and the most easier way to do it is to press d d (or default C-k if I was not using evil-collection)

As for your long term plans with org-ql-view and its architecture I am entirely trusting your instincts and expertise on this.