Skip to content

Commit 82af22f

Browse files
feature: support org_toggle_timestamp_type (#651)
* feature: support org_toggle_timestamp_type Allows to make active timestamp inactive and vice versa with one keybinding. * docs: add documentation for org_toggle_timestamp_type * Update DOCS.md Co-authored-by: Kristijan Husak <husakkristijan@gmail.com> * Update lua/orgmode/config/mappings/init.lua Co-authored-by: Kristijan Husak <husakkristijan@gmail.com> --------- Co-authored-by: Sebastian Flügge <seflue@users.noreply.github.com> Co-authored-by: Kristijan Husak <husakkristijan@gmail.com>
1 parent 2c82236 commit 82af22f

File tree

4 files changed

+18
-0
lines changed

4 files changed

+18
-0
lines changed

DOCS.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1031,6 +1031,9 @@ Decrease date under cursor by 1 or "count" day(s) (Example count: `5<S-UP>`).
10311031
#### **org_change_date**
10321032
*mapped to*: `cid`<br />
10331033
Change date under cursor. Opens calendar to select new date
1034+
#### **org_toggle_timestamp_type**
1035+
*mapped to*: `<Leader>od!`<br />
1036+
Switches the timestamp under the cursor between inactive and active.
10341037
#### **org_priority**
10351038
*mapped to*: `<Leader>o,`<br />
10361039
Choose the priority of a headline item.

lua/orgmode/config/defaults.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ local DefaultConfig = {
161161
org_schedule = '<prefix>is',
162162
org_time_stamp = '<prefix>i.',
163163
org_time_stamp_inactive = '<prefix>i!',
164+
org_toggle_timestamp_type = '<prefix>d!',
164165
org_insert_link = '<prefix>li',
165166
org_store_link = '<prefix>ls',
166167
org_clock_in = '<prefix>xi',

lua/orgmode/config/mappings/init.lua

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,10 @@ return {
351351
'org_mappings.org_babel_tangle',
352352
{ opts = { desc = 'org tangle', help_desc = 'Tangle current file' } }
353353
),
354+
org_toggle_timestamp_type = m.action(
355+
'org_mappings.org_toggle_timestamp_type',
356+
{ opts = { desc = 'org toggle timestamp type', help_desc = 'Toggle timestamp active/inactive type' } }
357+
),
354358
},
355359
edit_src = {
356360
org_edit_src_abort = m.custom(

lua/orgmode/org/mappings.lua

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1020,6 +1020,16 @@ function OrgMappings:org_time_stamp(inactive)
10201020
end)
10211021
end
10221022

1023+
function OrgMappings:org_toggle_timestamp_type()
1024+
local date = self:_get_date_under_cursor()
1025+
if not date then
1026+
return
1027+
end
1028+
1029+
date.active = not date.active
1030+
self:_replace_date(date)
1031+
end
1032+
10231033
---@param direction string
10241034
---@param use_fast_access? boolean
10251035
---@return boolean

0 commit comments

Comments
 (0)