File tree Expand file tree Collapse file tree 4 files changed +42
-13
lines changed Expand file tree Collapse file tree 4 files changed +42
-13
lines changed Original file line number Diff line number Diff line change @@ -304,7 +304,8 @@ function Headline:get_todo()
304
304
local keywords_info = todo_keywords .KEYS
305
305
306
306
-- A valid keyword can only be the first child
307
- local todo_node = self :_get_child_node (' item' ):named_child (0 )
307
+ local first_item_node = self :_get_child_node (' item' )
308
+ local todo_node = first_item_node and first_item_node :named_child (0 )
308
309
if not todo_node then
309
310
return nil , nil , nil
310
311
end
Original file line number Diff line number Diff line change @@ -208,18 +208,23 @@ function Org.action(cmd, opts)
208
208
end
209
209
210
210
function Org .cron (opts )
211
- local config = require ( ' orgmode.config ' ): extend ( opts or {} )
212
- if not config . notifications . cron_enabled then
213
- return vim . cmd ( [[ qa! ]] )
214
- end
215
- Org . files : load (): next ( vim . schedule_wrap ( function ()
216
- --- @diagnostic disable-next-line : inject-field
211
+ local ok , result = pcall ( function ( )
212
+ local config = require ( ' orgmode.config ' ): extend ( opts or {})
213
+ if not config . notifications . cron_enabled then
214
+ return vim . cmd ( [[ qa! ]] )
215
+ end
216
+ Org . files : load_sync ( true , 20000 )
217
217
instance .notifications = require (' orgmode.notifications' )
218
218
:new ({
219
219
files = Org .files ,
220
220
})
221
221
:cron ()
222
- end ))
222
+ end )
223
+
224
+ if not ok then
225
+ require (' orgmode.utils' ).system_notification (' Orgmode failed to run cron: ' .. tostring (result ))
226
+ return vim .cmd ([[ qa!]] )
227
+ end
223
228
end
224
229
225
230
function Org .instance ()
Original file line number Diff line number Diff line change @@ -79,6 +79,16 @@ function utils.writefile(file, data)
79
79
end )
80
80
end
81
81
82
+ function utils .system_notification (message )
83
+ if vim .fn .executable (' notify-send' ) == 1 then
84
+ vim .loop .spawn (' notify-send' , { args = { message } })
85
+ end
86
+
87
+ if vim .fn .executable (' terminal-notifier' ) == 1 then
88
+ vim .loop .spawn (' terminal-notifier' , { args = { ' -message' , message } })
89
+ end
90
+ end
91
+
82
92
function utils .open (target )
83
93
if vim .fn .executable (' xdg-open' ) == 1 then
84
94
return vim .fn .system (string.format (' xdg-open %s' , target ))
Original file line number Diff line number Diff line change @@ -264,18 +264,31 @@ end
264
264
--- @return any
265
265
function Promise .wait (self , timeout )
266
266
local is_done = false
267
+ local has_error = false
267
268
local result = nil
268
269
269
- self :next (function (...)
270
- result = PackedValue .new (... )
271
- is_done = true
272
- end )
270
+ self
271
+ :next (function (...)
272
+ result = PackedValue .new (... )
273
+ is_done = true
274
+ end )
275
+ :catch (function (...)
276
+ has_error = true
277
+ result = PackedValue .new (... )
278
+ is_done = true
279
+ end )
273
280
274
281
vim .wait (timeout or 5000 , function ()
275
282
return is_done
276
283
end , 1 )
277
284
278
- return result and result :unpack ()
285
+ local value = result and result :unpack ()
286
+
287
+ if has_error then
288
+ return error (value )
289
+ end
290
+
291
+ return value
279
292
end
280
293
281
294
--- Equivalents to JavaScript's Promise.all.
You can’t perform that action at this time.
0 commit comments