@@ -321,67 +321,6 @@ function Section:get_repeater_dates()
321321 end , self .dates )
322322end
323323
324- --- @deprecated use treesitter.headline.set_property
325- --- @param properties table
326- --- @return table
327- function Section :add_properties (properties )
328- if self .properties .valid then
329- local start = vim .api .nvim_call_function (' getline' , { self .properties .range .start_line })
330- local indent = start :match (' ^%s*' )
331- for name , val in pairs (properties ) do
332- if self .properties .items [name :lower ()] then
333- local properties_content = self .root :get_node_text_list (self .properties .node )
334- for i , content in ipairs (properties_content ) do
335- if content :lower ():match (' ^%s*:' .. name :lower () .. ' :.*$' ) then
336- local new_line = content :gsub (vim .pesc (self .properties .items [name :lower ()]), val )
337- vim .api .nvim_call_function (' setline' , { self .properties .range .start_line + i - 1 , new_line })
338- break
339- end
340- end
341- else
342- vim .api .nvim_call_function (' append' , {
343- self .properties .range .start_line ,
344- string.format (' %s:%s: %s' , indent , name , val ),
345- })
346- end
347- end
348- return {
349- is_new = false ,
350- indent = indent ,
351- }
352- end
353-
354- local properties_line = self :get_content_start_line_number ()
355- local indent = config :get_indent (self .level + 1 )
356- local content = { string.format (' %s:PROPERTIES:' , indent ) }
357-
358- for name , val in pairs (properties ) do
359- table.insert (content , string.format (' %s:%s: %s' , indent , name , val ))
360- end
361-
362- table.insert (content , string.format (' %s:END:' , indent ))
363- vim .api .nvim_call_function (' append' , { properties_line , content })
364- return {
365- is_new = true ,
366- end_line = properties_line + # content ,
367- indent = indent ,
368- }
369- end
370-
371- function Section :get_content_start_line_number ()
372- if self :has_planning () then
373- return self .range .start_line + 1
374- end
375- return self .range .start_line
376- end
377-
378- function Section :get_todo_note_line_number ()
379- if self .properties .valid then
380- return self .properties .range .end_line
381- end
382- return self :get_content_start_line_number ()
383- end
384-
385324--- @return boolean
386325function Section :is_first_section ()
387326 if not self .parent then
@@ -494,46 +433,6 @@ function Section:promote(amount, promote_child_sections)
494433 end
495434end
496435
497- function Section :add_closed_date ()
498- local closed_date = self :get_closed_date ()
499- if closed_date then
500- return nil
501- end
502- return self :_add_planning_date (Date .now (), ' CLOSED' )
503- end
504-
505- --- @param date Date
506- function Section :add_scheduled_date (date )
507- local scheduled_date = self :get_scheduled_date ()
508- if scheduled_date then
509- return self :_update_date (scheduled_date , date )
510- end
511- return self :_add_planning_date (date , ' SCHEDULED' , true )
512- end
513-
514- --- @param date Date
515- function Section :add_deadline_date (date )
516- local deadline_date = self :get_deadline_date ()
517- if deadline_date then
518- return self :_update_date (deadline_date , date )
519- end
520- return self :_add_planning_date (date , ' DEADLINE' , true )
521- end
522-
523- function Section :remove_closed_date ()
524- local closed_date = self :get_closed_date ()
525- if not closed_date then
526- return nil
527- end
528- local planning_linenr = self .range .start_line + 1
529- local planning_line = vim .api .nvim_call_function (' getline' , { planning_linenr })
530- local new_line = planning_line :gsub (' %s*CLOSED:%s*[%[<]' .. vim .pesc (closed_date :to_string ()) .. ' [%]>]' , ' ' )
531- if vim .trim (new_line ) == ' ' then
532- return vim .api .nvim_call_function (' deletebufline' , { vim .api .nvim_get_current_buf (), planning_linenr })
533- end
534- return vim .api .nvim_call_function (' setline' , { planning_linenr , new_line })
535- end
536-
537436--- @return boolean
538437function Section :has_planning ()
539438 for _ , date in ipairs (self .dates ) do
@@ -619,43 +518,4 @@ function Section:get_title()
619518 return title
620519end
621520
622- function Section :_update_date (date , new_date )
623- date = date :set ({
624- year = new_date .year ,
625- month = new_date .month ,
626- day = new_date .day ,
627- })
628- local line = vim .api .nvim_call_function (' getline' , { date .range .start_line })
629- local view = vim .fn .winsaveview ()
630- local new_line =
631- string.format (' %s%s%s' , line :sub (1 , date .range .start_col ), date :to_string (), line :sub (date .range .end_col ))
632- vim .api .nvim_call_function (' setline' , {
633- date .range .start_line ,
634- new_line ,
635- })
636- vim .fn .winrestview (view )
637- return true
638- end
639-
640- --- @param date Date
641- --- @param type string
642- --- @param active ? boolean
643- --- @return string
644- function Section :_add_planning_date (date , type , active )
645- local date_string = date :to_wrapped_string (active )
646- if self :has_planning () then
647- local planning_linenr = self .range .start_line + 1
648- return vim .api .nvim_call_function (' setline' , {
649- planning_linenr ,
650- string.format (' %s %s: %s' , vim .api .nvim_call_function (' getline' , { planning_linenr }), type , date_string ),
651- })
652- end
653-
654- local indent = config :get_indent (self .level + 1 )
655- return vim .api .nvim_call_function (' append' , {
656- self .range .start_line ,
657- string.format (' %s%s: %s' , indent , type , date_string ),
658- })
659- end
660-
661521return Section
0 commit comments