File tree Expand file tree Collapse file tree 5 files changed +31
-0
lines changed Expand file tree Collapse file tree 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')
33local config = require (' orgmode.config' )
44local Templates = require (' orgmode.capture.templates' )
55local Template = require (' orgmode.capture.template' )
6+ local EventManager = require (' orgmode.events' )
67local Menu = require (' orgmode.ui.menu' )
78local Range = require (' orgmode.files.elements.range' )
89local CaptureWindow = require (' orgmode.capture.window' )
@@ -300,6 +301,7 @@ function Capture:refile_file_headline_to_archive(headline)
300301 local headline_category = headline :get_category ()
301302 local outline_path = headline :get_outline_path ()
302303
304+ EventManager .dispatch (EventManager .event .HeadlineArchived :new (headline , destination_file ))
303305 return self
304306 :_refile_from_org_file ({
305307 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 11local Events = require (' orgmode.events.types' )
22local AlignTags = require (' orgmode.events.listeners.align_tags' )
3+ local AttachMaybeDeleteArchived = require (' orgmode.events.listeners.attach_maybe_delete_archived' )
34
45return {
56 [Events .TodoChanged ] = {
@@ -11,4 +12,7 @@ return {
1112 [Events .HeadlinePromoted ] = {
1213 AlignTags ,
1314 },
15+ [Events .HeadlineArchived ] = {
16+ AttachMaybeDeleteArchived ,
17+ },
1418}
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 88 HeadingToggled = require (' orgmode.events.types.heading_toggled' ),
99 AttachChanged = require (' orgmode.events.types.attach_changed_event' ),
1010 AttachOpened = require (' orgmode.events.types.attach_opened_event' ),
11+ HeadlineArchived = require (' orgmode.events.types.headline_archived_event' ),
1112}
You can’t perform that action at this time.
0 commit comments