File tree 5 files changed +31
-0
lines changed
5 files changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ local fs = require('orgmode.utils.fs')
3
3
local config = require (' orgmode.config' )
4
4
local Templates = require (' orgmode.capture.templates' )
5
5
local Template = require (' orgmode.capture.template' )
6
+ local EventManager = require (' orgmode.events' )
6
7
local Menu = require (' orgmode.ui.menu' )
7
8
local Range = require (' orgmode.files.elements.range' )
8
9
local CaptureWindow = require (' orgmode.capture.window' )
@@ -300,6 +301,7 @@ function Capture:refile_file_headline_to_archive(headline)
300
301
local headline_category = headline :get_category ()
301
302
local outline_path = headline :get_outline_path ()
302
303
304
+ EventManager .dispatch (EventManager .event .HeadlineArchived :new (headline , destination_file ))
303
305
return self
304
306
:_refile_from_org_file ({
305
307
source_headline = headline ,
Original file line number Diff line number Diff line change
1
+ --- @param event OrgHeadlineArchivedEvent
2
+ return function (event )
3
+ require (' orgmode.attach' ):maybe_delete_archived (event .headline )
4
+ end
Original file line number Diff line number Diff line change 1
1
local Events = require (' orgmode.events.types' )
2
2
local AlignTags = require (' orgmode.events.listeners.align_tags' )
3
+ local AttachMaybeDeleteArchived = require (' orgmode.events.listeners.attach_maybe_delete_archived' )
3
4
4
5
return {
5
6
[Events .TodoChanged ] = {
@@ -11,4 +12,7 @@ return {
11
12
[Events .HeadlinePromoted ] = {
12
13
AlignTags ,
13
14
},
15
+ [Events .HeadlineArchived ] = {
16
+ AttachMaybeDeleteArchived ,
17
+ },
14
18
}
Original file line number Diff line number Diff line change
1
+ --- @class OrgHeadlineArchivedEvent : OrgEvent
2
+ --- @field type string
3
+ --- @field headline OrgHeadline
4
+ --- @field destination_file OrgFile
5
+ local HeadlineArchivedEvent = {
6
+ type = ' orgmode.headline_archived' ,
7
+ }
8
+
9
+ --- @param headline OrgHeadline
10
+ --- @param destination_file OrgFile
11
+ --- @return OrgHeadlineArchivedEvent
12
+ function HeadlineArchivedEvent :new (headline , destination_file )
13
+ local obj = setmetatable ({}, self )
14
+ self .__index = self
15
+ obj .headline = headline
16
+ obj .destination_file = destination_file
17
+ return obj
18
+ end
19
+
20
+ return HeadlineArchivedEvent
Original file line number Diff line number Diff line change 8
8
HeadingToggled = require (' orgmode.events.types.heading_toggled' ),
9
9
AttachChanged = require (' orgmode.events.types.attach_changed_event' ),
10
10
AttachOpened = require (' orgmode.events.types.attach_opened_event' ),
11
+ HeadlineArchived = require (' orgmode.events.types.headline_archived_event' ),
11
12
}
You can’t perform that action at this time.
0 commit comments