Skip to content

Commit 260a366

Browse files
authored
feat(agenda): highlight upcoming deadlines as @org.agenda.deadline.upcoming (#1138)
* feat(agenda): highlight upcoming deadlines as `@org.agenda.deadline.upcoming` AI-assisted: Claude Sonnet 4.6 from GitHub Copilot * docs: document newly added `@org.agenda.deadline.upcoming`
1 parent 8c22d44 commit 260a366

7 files changed

Lines changed: 14 additions & 5 deletions

File tree

doc/orgmode.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2986,6 +2986,7 @@ The following highlight groups are used:
29862986
- `@org.table.heading` - Table headings - linked to `@markup.heading`,
29872987
- `@org.edit_src` - The highlight for the source content in an _Org_ buffer while it is being edited in an edit special buffer - linked to `Visual`,
29882988
- `@org.agenda.deadline`: A item deadline in the agenda view - Parsed from `Error` (see note below)
2989+
- `@org.agenda.deadline.upcoming`: A item upcoming deadline in the agenda view - Parsed from `WarningMsg` (see note below)
29892990
- `@org.agenda.scheduled`: A scheduled item in the agenda view - Parsed from `DiffAdd` (see note below)
29902991
- `@org.agenda.scheduled_past`: A item past its scheduled date in the agenda view - Parsed from `WarningMsg` (see note below)
29912992
- `@org.agenda.time_grid`: Time grid line - Parsed from `WarningMsg` (see note below)

docs/configuration.org

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2961,6 +2961,7 @@ The following highlight groups are used:
29612961
- =@org.table.heading= - Table headings - linked to =@markup.heading=,
29622962
- =@org.edit_src= - The highlight for the source content in an /Org/ buffer while it is being edited in an edit special buffer - linked to =Visual=,
29632963
- =@org.agenda.deadline=: A item deadline in the agenda view - Parsed from =Error= (see note below)
2964+
- =@org.agenda.deadline.upcoming=: A item upcoming deadline in the agenda view - Parsed from =WarningMsg= (see note below)
29642965
- =@org.agenda.scheduled=: A scheduled item in the agenda view - Parsed from =DiffAdd= (see note below)
29652966
- =@org.agenda.scheduled_past=: A item past its scheduled date in the agenda view - Parsed from =WarningMsg= (see note below)
29662967
- =@org.agenda.time_grid=: Time grid line - Parsed from =WarningMsg= (see note below)

lua/orgmode/agenda/agenda_item.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ function AgendaItem:get_hlgroup()
223223
if self.is_today and self.headline_date:is_after(self.date, 'day') then
224224
local diff = math.abs(self.date:diff(self.headline_date))
225225
if diff <= FUTURE_DEADLINE_AS_WARNING_DAYS then
226-
return hl_map.warning
226+
return hl_map.upcoming_deadline
227227
end
228228
return nil
229229
end

lua/orgmode/colors/highlights.lua

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ function M.define_agenda_colors()
8787
local keyword_colors = colors.get_todo_keywords_colors()
8888
local c = {
8989
deadline = '@org.agenda.deadline',
90+
upcoming_deadline = '@org.agenda.deadline.upcoming',
9091
ok = '@org.agenda.scheduled',
9192
warning = '@org.agenda.scheduled_past',
9293
}
@@ -205,6 +206,7 @@ function M.get_agenda_hl_map()
205206
TODO = '@org.keyword.todo',
206207
DONE = '@org.keyword.done',
207208
deadline = '@org.agenda.deadline',
209+
upcoming_deadline = '@org.agenda.deadline.upcoming',
208210
ok = '@org.agenda.scheduled',
209211
warning = '@org.agenda.scheduled_past',
210212
priority = config:get_priorities(),

lua/orgmode/colors/init.lua

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ M.get_todo_keywords_colors = function()
5959
gui = M.from_hex(error):lighten_by(0.1):to_rgb(),
6060
cterm = 9,
6161
},
62+
upcoming_deadline = {
63+
gui = M.from_hex(warning):lighten_by(0.1):to_rgb(),
64+
cterm = 11,
65+
},
6266
ok = {
6367
gui = M.from_hex(ok):lighten_by(0.1):to_rgb(),
6468
cterm = 10,

tests/plenary/agenda/agenda_item_spec.lua

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,12 @@ describe('Agenda item', function()
9292
assert.is.Nil(agenda_item:get_priority_hlgroup())
9393
assert.are.same('In 9 d.:', agenda_item.label)
9494

95-
-- future without warning within the default warning days and less than 6 days (highlights as warning)
95+
-- future without warning within the default warning days and less than 6 days (highlights as upcoming warning)
9696
headline = generate(string.format('DEADLINE: <%s>', today:add({ day = 6 }):to_string()))
9797
agenda_item = AgendaItem:new(headline:get_all_dates()[1], headline, today)
9898
assert.is.True(agenda_item.is_valid)
9999
assert.is.same(hl_map.TODO, agenda_item:get_todo_hlgroup())
100-
assert.is.same(hl_map.warning, agenda_item:get_hlgroup())
100+
assert.is.same(hl_map.upcoming_deadline, agenda_item:get_hlgroup())
101101
assert.is.Nil(agenda_item:get_priority_hlgroup())
102102
assert.are.same('In 6 d.:', agenda_item.label)
103103

@@ -108,12 +108,12 @@ describe('Agenda item', function()
108108
assert.is.same(hl_map.TODO, agenda_item:get_todo_hlgroup())
109109
assert.are.same('In 9 d.:', agenda_item.label)
110110

111-
-- future with warning within the defined warning period and less than 6 days (highlights as warning)
111+
-- future with warning within the defined warning period and less than 6 days (highlights as upcoming deadline)
112112
headline = generate(string.format('DEADLINE: <%s -10d>', today:add({ day = 6 }):to_string()))
113113
agenda_item = AgendaItem:new(headline:get_all_dates()[1], headline, today)
114114
assert.is.True(agenda_item.is_valid)
115115
assert.is.same(hl_map.TODO, agenda_item:get_todo_hlgroup())
116-
assert.is.same(hl_map.warning, agenda_item:get_hlgroup())
116+
assert.is.same(hl_map.upcoming_deadline, agenda_item:get_hlgroup())
117117
assert.is.Nil(agenda_item:get_priority_hlgroup())
118118
assert.are.same('In 6 d.:', agenda_item.label)
119119

tests/plenary/colors/colors_spec.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ describe('Colors', function()
4545
DONE = { gui = '#00FF00', cterm = 2 },
4646
TODO = { gui = '#FF0000', cterm = 1 },
4747
deadline = { gui = '#ff1a1a', cterm = 9 },
48+
upcoming_deadline = { gui = '#ff981a', cterm = 11 },
4849
ok = { gui = '#1aff1a', cterm = 10 },
4950
warning = { gui = '#ff981a', cterm = 11 },
5051
}, todo_keywords_colors)

0 commit comments

Comments
 (0)