Skip to content

Commit 0f4d28c

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 4f99b37 commit 0f4d28c

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
@@ -1184,6 +1184,31 @@ Additional files to search from agenda search prompt. Currently it accepts only
11841184
a single value: `agenda-archives`. Example value: `{'agenda-archives'}`
11851185

11861186

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

11891214
Adjust behavior of the calendar modal (ex:

docs/configuration.org

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

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