Skip to content

Commit 068180b

Browse files
committed
feat(agenda): customizable scheduled/deadline prefix
Adds org_agenda_scheduled_leaders and org_agenda_deadline_leaders for configuring the texts preceding scheduled and deadline items in the agenda.
1 parent 3fb33c6 commit 068180b

5 files changed

Lines changed: 63 additions & 4 deletions

File tree

doc/orgmode.txt

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1183,6 +1183,31 @@ Additional files to search from agenda search prompt. Currently it accepts only
11831183
a single value: `agenda-archives`. Example value: `{'agenda-archives'}`
11841184

11851185

1186+
org_agenda_scheduled_leaders *orgmode-org_agenda_scheduled_leaders*
1187+
1188+
- Type: `string[]`
1189+
- Default: `{'Scheduled:', 'Sched. %dx:'}`
1190+
1191+
Text preceding scheduled items in the agenda view. This is a list with two
1192+
strings. The first applies when the item is scheduled on the current day. The
1193+
second applies when it has been scheduled previously, it may contain a %d
1194+
indicating that this is the nth time that this item is scheduled, due to
1195+
automatic rescheduling of unfinished items for the following day. So this
1196+
number is one larger than the number of days that passed since this item was
1197+
scheduled first.
1198+
1199+
1200+
org_agenda_deadline_leaders *orgmode-org_agenda_deadline_leaders*
1201+
1202+
- Type: `string[]`
1203+
- Default: `{'Deadline:', 'In %d d.:', "%d d. ago"},`
1204+
1205+
Text preceding deadline items in the agenda view. This is a list with three
1206+
strings. The first applies when the item has its deadline on the current day.
1207+
The second applies when the deadline is in the future, the third one when it is
1208+
in the past. The strings may contain %d to capture the number of days.
1209+
1210+
11861211
CALENDAR SETTINGS *orgmode-configuration-calendar-settings*
11871212

11881213
Adjust behavior of the calendar modal (ex:

docs/configuration.org

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1120,6 +1120,31 @@ Additional files to search from agenda search prompt.
11201120
Currently it accepts only a single value: =agenda-archives=.
11211121
Example value: ={'agenda-archives'}=
11221122

1123+
*** org_agenda_scheduled_leaders
1124+
:PROPERTIES:
1125+
:CUSTOM_ID: org_agenda_scheduled_leaders
1126+
:END:
1127+
- Type: =string[]=
1128+
- Default: ={'Scheduled:', 'Sched. %dx:'}=
1129+
Text preceding scheduled items in the agenda view. This is a list with two
1130+
strings. The first applies when the item is scheduled on the current day. The
1131+
second applies when it has been scheduled previously, it may contain a %d
1132+
indicating that this is the nth time that this item is scheduled, due to
1133+
automatic rescheduling of unfinished items for the following day. So this
1134+
number is one larger than the number of days that passed since this item was
1135+
scheduled first.
1136+
1137+
*** org_agenda_deadline_leaders
1138+
:PROPERTIES:
1139+
:CUSTOM_ID: org_agenda_deadline_leaders
1140+
:END:
1141+
- Type: =string[]=
1142+
- Default: ={'Deadline:', 'In %d d.:', "%d d. ago"},=
1143+
Text preceding deadline items in the agenda view. This is a list with three
1144+
strings. The first applies when the item has its deadline on the current day.
1145+
The second applies when the deadline is in the future, the third one when it is
1146+
in the past. The strings may contain %d to capture the number of days.
1147+
11231148
** Calendar settings
11241149
:PROPERTIES:
11251150
:CUSTOM_ID: calendar-settings

lua/orgmode/agenda/agenda_item.lua

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -157,19 +157,24 @@ function AgendaItem:_generate_label()
157157
local time = self.headline_date:has_time() and add_padding(self:_format_time(self.headline_date)) or ''
158158
if self.headline_date:is_deadline() then
159159
if self.is_same_day then
160-
return time .. 'Deadline:'
160+
return time .. config.org_agenda_deadline_leaders[1]
161+
end
162+
local diff = self.date:diff(self.headline_date)
163+
if diff < 0 then
164+
return config.org_agenda_deadline_leaders[2]:gsub('%%d', math.abs(diff))
165+
else
166+
return config.org_agenda_deadline_leaders[3]:gsub('%%d', math.abs(diff))
161167
end
162-
return self.headline_date:humanize(self.date) .. ':'
163168
end
164169

165170
if self.headline_date:is_scheduled() then
166171
if self.is_same_day then
167-
return time .. 'Scheduled:'
172+
return time .. config.org_agenda_scheduled_leaders[1]
168173
end
169174

170175
local diff = math.abs(self.date:diff(self.headline_date))
171176

172-
return 'Sched. ' .. diff .. 'x:'
177+
return config.org_agenda_scheduled_leaders[2]:gsub('%%d', diff)
173178
end
174179

175180
if self.headline_date.is_date_range_start then

lua/orgmode/config/_meta.lua

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,8 @@
220220
---@field org_agenda_remove_tags? boolean If true, tags will be removed from the all agenda views. Default: false
221221
---@field org_agenda_use_time_grid? boolean If true, Render time grid in agenda as set by org_agenda_time_grid. Default: true
222222
---@field org_agenda_show_future_repeats? boolean | 'next' If true, show all future repeats. If `next`, show only next repeat. If false, do hnot show any repeats. Default: true
223+
---@field org_agenda_scheduled_leaders? string[] Text preceding scheduled items in the agenda view. This is a list with two strings: the first applies when the item is scheduled on the current day, the second applies when it has been scheduled previously. Default: { 'Scheduled:', 'Sched. %dx:' }
224+
---@field org_agenda_deadline_leaders? string[] Text preceding deadline items in the agenda view. This is a list with three strings. The first applies when the item has its deadline on the current day. The second applies when the deadline is in the future, the third one when it is in the past. Default: {'Deadline:', 'In %d d.:', "%d d. ago"}
223225
---@field org_agenda_time_grid? OrgAgendaTimeGridOpts Agenda time grid configuration. Default: { type = { 'daily', 'today', 'require-timed' }, times = { 800, 1000, 1200, 1400, 1600, 1800, 2000 }, time_separator = '┄┄┄┄┄', time_label = '┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄' }
224226
---@field org_agenda_current_time_string? string String to indicate current time on the time grid. Default: '<- now -----------------------------------------------'
225227
---@field org_priority_highest? string | number Highest priority level. Default: 'A'

lua/orgmode/config/defaults.lua

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ local DefaultConfig = {
4343
org_agenda_current_time_string = '<- now -----------------------------------------------',
4444
org_agenda_use_time_grid = true,
4545
org_agenda_show_future_repeats = true,
46+
org_agenda_scheduled_leaders = { 'Scheduled:', 'Sched. %dx:' },
47+
org_agenda_deadline_leaders = { 'Deadline:', 'In %d d.:', '%d d. ago:' },
4648
org_priority_highest = 'A',
4749
org_priority_default = 'B',
4850
org_priority_lowest = 'C',

0 commit comments

Comments
 (0)