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

How to disable org-super-agenda? #14

Closed
novoid opened this issue Aug 21, 2017 · 7 comments
Closed

How to disable org-super-agenda? #14

novoid opened this issue Aug 21, 2017 · 7 comments
Labels

Comments

@novoid
Copy link

novoid commented Aug 21, 2017

Hi!

The Error

Adding super-agenda to my setup broke a cronjob of mine which exports my agenda to a HTML file:
/usr/bin/emacs --batch --load /home/vk/.emacs.d/init.el --eval '(progn (setq org-agenda-files (append my-work-agenda-files my-nonwork-agenda-files)) (org-store-agenda-views))'

I now get: Wrong type argument: stringp, org-agenda

The stack trace for this error when I call it interactively in a running Emacs:

Debugger entered--Lisp error: (wrong-type-argument stringp org-agenda)
  expand-file-name(org-agenda "~/")
  (org-agenda-write (expand-file-name (pop files) dir) nil t bufname)
  (let ((ps-number-of-columns 2) (ps-landscape-mode t) (htmlize-output-type (quote css)) (org-super-agenda-groups my-super-agenda-groups)) (org-agenda-write (expand-file-name (pop files) dir) nil t bufname))
  eval((let ((ps-number-of-columns 2) (ps-landscape-mode t) (htmlize-output-type (quote css)) (org-super-agenda-groups my-super-agenda-groups)) (org-agenda-write (expand-file-name (pop files) dir) nil t bufname)))
  #[(&rest parameters) "\306�!\307	\310\n!\307\211\211\211\211\211\211\211������������������ �!\311 �\"\312\216�!\205\313

My current super agenda settings in case this is relevant to anybody.

Why I'm Not Interested In Fixing The Root Cause & What I Want To Achieve Instead

The error and its stack trace is not relevant to me, because I personally don't care to solve the root cause of it. Since I don't want the super-agenda output format in this HTML file anyway, I would like to disable the mode for this process (CLI invocation via cronjob to export my agenda file) only instead. With a running GUI Emacs, I'm file with the current situation and very grateful of having org-super-agenda.

Interactively, calling (org-super-agenda-mode) toggles the mode on/off. Therefore, without having deeper knowledge of Elisp I tried the following command:
/usr/bin/emacs --batch --load /home/vk/.emacs.d/init.el --eval '(progn (setq org-agenda-files (append my-work-agenda-files my-nonwork-agenda-files)) (org-super-agenda-mode) (org-store-agenda-views))'

This seems not to toggle the mode but to enable it twice: I do see "org-super-agenda-mode enabled." multiple times in the Messages buffer.

So: how am I able to disable the mode for this invocation?

Thanks!

@alphapapa
Copy link
Owner

Hi Karl,

It's defined using the standard define-minor-mode macro, so: With prefix argument ARG, turn on if positive, otherwise off. So just run (org-super-agenda-mode -1). :)

@novoid
Copy link
Author

novoid commented Aug 22, 2017

Thanks!

Unfortunately, it seems to be the case that (org-store-agenda-views) activates it by itself because of me having super-agenda placed in org-agenda-custom-commands. Therefore, using /usr/bin/emacs --batch --load /home/vk/.emacs.d/init.el --eval '(progn (setq org-agenda-files (append my-work-agenda-files my-nonwork-agenda-files)) (org-super-agenda-mode -1) (org-store-agenda-views))' disables the super-agenda right before it gets activated.

So maybe solving the root cause is is my interest as well? ;-)

Otherwise: is it possible to "catch" the prefix argument within org-agenda-custom-commands using when on invocation time? I do have my doubts...

Does anybody use org-store-agenda-views together with super-agenda?

@alphapapa
Copy link
Owner

org-store-agenda-views shouldn't be activating any modes, and setting org-super-agenda-groups in the custom commands variable list shouldn't do so either. The only way to activate the mode is to do it by running org-super-agenda-mode.

Do you use the customize system at all? If so, it might be activating the mode.

As for the root cause, I don't see how org-super-agenda-mode could be causing the backtrace you gave. And it seems that the backtrace is interrupted with some byte-compiled code. And I don't know what that org-agenda variable is supposed to be or where it's coming from.

Otherwise: is it possible to "catch" the prefix argument within org-agenda-custom-commands using when on invocation time? I do have my doubts...

Sorry, I don't understand what you mean.

I'm afraid I'm kind of lost now. If all you want is to disable the super-groups from being written to your stored views files, all you should have to do is what you said in your last message:

/usr/bin/emacs --batch --load /home/vk/.emacs.d/init.el \
--eval "(progn 
(setq org-agenda-files (append my-work-agenda-files my-nonwork-agenda-files)) 
(org-super-agenda-mode -1)
(org-store-agenda-views))"

If that doesn't work, I'm guessing that something else in your init file is activating org-super-agenda-mode.

Then again, I've never used the stored views, so... :)

@novoid
Copy link
Author

novoid commented Aug 22, 2017

My guess is that my own invocation of org-super-agenda-mode is the culprit here: (as linked above)

(setq org-agenda-custom-commands
      (quote (

              ("a" "Super Agenda" agenda
               (org-super-agenda-mode)  ;;; <--- I activate super-agenda for this specific agenda only; not the others
               ((org-super-agenda-groups my-super-agenda-groups))
               (org-agenda nil "a"))
[...]

Definition of my-super-agenda-groups

The comment where I unfortunately lost you was something in this direction:

(setq org-agenda-custom-commands
      (quote (

              ("a" "Super Agenda" agenda
               (when $INTERACTIVEMODEANDNOTSTOREAGENDAVIEWS
                   (org-super-agenda-mode))  ;; <- activating only for interactive use
               ((org-super-agenda-groups my-super-agenda-groups))
               (org-agenda nil "a"))
[...]

As far as I know is this not possible because when the agenda is generated, this status check is not executed. But I am really wild guessing here and I don't have an idea how to replace $INTERACTIVEMODEANDNOTSTOREAGENDAVIEWS with working code.

@alphapapa
Copy link
Owner

alphapapa commented Aug 22, 2017

Maybe another approach will work. You see, if org-super-agenda-groups is nil, no groups are created, even when org-super-agenda-mode is on. So you shouldn't need to toggle the mode on and off. Just set the groups to nil when you're storing the views. Maybe wrap the call to org-store-agenda-views, like:

(let ((org-super-agenda-groups nil))
  (org-store-agenda-views))

By the way, I don't think this is valid:

(setq org-agenda-custom-commands
      (quote (

              ("a" "Super Agenda" agenda
               (org-super-agenda-mode)  ;;; <--- I activate super-agenda for this specific agenda only; not the others
               ((org-super-agenda-groups my-super-agenda-groups))
               (org-agenda nil "a"))

Looking at the docs for org-agenda-custom-commands, you're putting (org-super-agenda-mode) in the place of the MATCH argument. It might work as a coincidence, but it's not following the spec.

Anyway, try this:

/usr/bin/emacs --batch --load /home/vk/.emacs.d/init.el \
--eval "
(let ((org-agenda-files (append my-work-agenda-files my-nonwork-agenda-files))
      (org-super-agenda-groups nil))
  (org-store-agenda-views))"

@alphapapa
Copy link
Owner

alphapapa commented Aug 22, 2017

Oh, I think I see the problem now: you want to use org-store-agenda-views but you only want the grouping on some of the agenda commands.

So, yeah, just set the groups to nil for the commands you don't want to be grouped. You can't call a function for each agenda "subcommand" within the custom command, but you can bind variables for each subcommand, so you can disable the grouping that way.

...Okay, so I guess now I really get it: you want to have groups or not depending on whether you're storing the agenda views or viewing them in Emacs.

I think the best thing to do is just use a copy of the agenda commands that doesn't do grouping. If you don't change the commands very often, it won't be much trouble to update them. If you do change them a lot, you could easily write a function to set org-agenda-custom-commands with two copies of them, one with grouping and one without.

@alphapapa
Copy link
Owner

Let me know if you have any other issues or ideas. :)

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

2 participants