Giter Club home page Giter Club logo

Comments (7)

roccoblues avatar roccoblues commented on May 25, 2024 3

Quick update here: we have a, not to ugly, PR that fixes the issue that exec functions aren't triggered in the hook.

However the behavior is confusing because the command queue is only triggered after the complete hook is parsed. Fixing this would be a way bigger change.

I suggest something like alias nm='neomutt && sync-script.sh' as a temporary workaround for the original issue.

from neomutt.

roccoblues avatar roccoblues commented on May 25, 2024 2

I had a deeper look and the problem doesn't seem to be related to sync-mailbox. It looks like no exec command gets executed. With the following shutdown-hook

shutdown-hook "echo 'before'; exec sync-mailbox; echo 'after'"

and some additional logging I get:

[2024-03-18 08:44:11]<1> dlg_index() Got op OP_QUIT (198)
[2024-03-18 08:44:11]<5> mutt_startup_shutdown_hook() shutdown
[2024-03-18 08:44:11]<5> mutt_startup_shutdown_hook() hook: echo 'before'; exec sync-mailbox; echo 'after'
[2024-03-18 08:44:11]<5> parse_rc_buffer() buffer:
[2024-03-18 08:44:11]<1> parse_rc_buffer() NT_COMMAND: echo
[2024-03-18 08:44:11]<M> parse_echo() before
[2024-03-18 08:44:11]<5> msgwin_set_text() MW SET: 6, before
[2024-03-18 08:44:11]<5> msgwin_calc_rows() msgwin_calc_rows() => 1
[2024-03-18 08:44:11]<5> msgwin_recalc() recalc done, request WA_REPAINT
[2024-03-18 08:44:11]<5> msgwin_repaint() msgwin repaint done
[2024-03-18 08:44:11]<5> parse_rc_buffer() rc: 0
[2024-03-18 08:44:11]<N> notify_send() sending: NT_COMMAND/13
[2024-03-18 08:44:11]<N> send() send: 7, 0x12001f800
[2024-03-18 08:44:11]<1> parse_rc_buffer() NT_COMMAND: exec
[2024-03-18 08:44:11]<5> mutt_parse_exec() exec: echo 'before'; exec sync-mailbox; echo 'after'
[2024-03-18 08:44:11]<5> mutt_parse_exec() function: sync-mailbox
[2024-03-18 08:44:11]<5> mutt_push_macro_event() ch: 0 op: 174
[2024-03-18 08:44:11]<5> parse_rc_buffer() rc: 0
[2024-03-18 08:44:11]<N> notify_send() sending: NT_COMMAND/14
[2024-03-18 08:44:11]<N> send() send: 7, 0x12001f800
[2024-03-18 08:44:11]<1> parse_rc_buffer() NT_COMMAND: echo
[2024-03-18 08:44:11]<M> parse_echo() after
[2024-03-18 08:44:11]<5> msgwin_set_text() MW SET: 5, after

Notice how the exec sync-mailbox gets parsed correct but never executed. It's gets pushed as an "event" in mutt_push_macro_event() but that's it. I think that is because NeoMutt is no longer in the main loop and nothing is actually handling those events.

I'll see if I can find some changes related to that next.

from neomutt.

dorsiflexion avatar dorsiflexion commented on May 25, 2024 1

In fact it seems that shutdown-hook 'exec sync-mailbox' is doing exactly nothing.

I'm trying to do something very similar. It doesn't even seem to be a race condition, because when doing

shutdown-hook 'exec sync-mailbox; echo `sleep 5`; echo `script.sh`'

it is still not updated when the script runs.

Btw. neomutt updates mailboxes when it quits. So if you are closing, opening, closing and it works, that is no indication that the hook actually did something.

I'd also greatly appreciate some advice on what's wrong here.

from neomutt.

roccoblues avatar roccoblues commented on May 25, 2024 1

Hi,

to clarify: the shutdown-hook is executed right? The problem is that sync-mailbox doesn't work as expected in it?

My wild guess is that sync-mailbox works on the current mailbox and by the time the shutdown-hook is executed there's no "current mailbox" anymore. But we need @flatcap expertise here.

from neomutt.

rafaelrc7 avatar rafaelrc7 commented on May 25, 2024

Ok. I think I did manage to run both commands, by either doing:

shutdown-hook 'exec sync-mailbox `sync-script.sh`'

or

shutdown-hook 'exec sync-mailbox ; echo `sync-script.sh`'

However it still seems to not be working as expected... The sync-script (that is just a call to mbsync) detects no changes, so read emails are not updated, as if sync-mailbox had not been executed. However, if I run the hook two times, by closing, opening and closing it works, so the command is working but the mailbox is only being saved after the program exits.

How could I fix it?

from neomutt.

rafaelrc7 avatar rafaelrc7 commented on May 25, 2024

In fact it seems that shutdown-hook 'exec sync-mailbox' is doing exactly nothing.

I'm trying to do something very similar. It doesn't even seem to be a race condition, because when doing

shutdown-hook 'exec sync-mailbox; echo `sleep 5`; echo `script.sh`'

it is still not updated when the script runs.

Btw. neomutt updates mailboxes when it quits. So if you are closing, opening, closing and it works, that is no indication that the hook actually did something.

I'd also greatly appreciate some advice on what's wrong here.

Yes, I also tried using sleep in my hook to test if it was some race condition, and had the same results.

I ended up rebinding the exit key (q) to run the sync commands and then quit. It works. But it still seems to be something wrong with the shutdown-hook.

from neomutt.

dorsiflexion avatar dorsiflexion commented on May 25, 2024

to clarify: the shutdown-hook is executed right? The problem is that sync-mailbox doesn't work as expected in it?

Exactly. If I do something like:

shutdown-hook 'exec sync-mailbox; echo `notify-send test`'

I'm getting the notification. It's just that sync-mailbox doesn't seem to have an effect.

from neomutt.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.