Skip to content

Commit

Permalink
feature: support org_toggle_timestamp_type (#651)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
3 people authored May 21, 2024
1 parent 2c82236 commit 82af22f
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 0 deletions.
3 changes: 3 additions & 0 deletions DOCS.md
Original file line number Diff line number Diff line change
Expand Up @@ -1031,6 +1031,9 @@ Decrease date under cursor by 1 or "count" day(s) (Example count: `5<S-UP>`).
#### **org_change_date**
*mapped to*: `cid`<br />
Change date under cursor. Opens calendar to select new date
#### **org_toggle_timestamp_type**
*mapped to*: `<Leader>od!`<br />
Switches the timestamp under the cursor between inactive and active.
#### **org_priority**
*mapped to*: `<Leader>o,`<br />
Choose the priority of a headline item.
Expand Down
1 change: 1 addition & 0 deletions lua/orgmode/config/defaults.lua
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ local DefaultConfig = {
org_schedule = '<prefix>is',
org_time_stamp = '<prefix>i.',
org_time_stamp_inactive = '<prefix>i!',
org_toggle_timestamp_type = '<prefix>d!',
org_insert_link = '<prefix>li',
org_store_link = '<prefix>ls',
org_clock_in = '<prefix>xi',
Expand Down
4 changes: 4 additions & 0 deletions lua/orgmode/config/mappings/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,10 @@ return {
'org_mappings.org_babel_tangle',
{ opts = { desc = 'org tangle', help_desc = 'Tangle current file' } }
),
org_toggle_timestamp_type = m.action(
'org_mappings.org_toggle_timestamp_type',
{ opts = { desc = 'org toggle timestamp type', help_desc = 'Toggle timestamp active/inactive type' } }
),
},
edit_src = {
org_edit_src_abort = m.custom(
Expand Down
10 changes: 10 additions & 0 deletions lua/orgmode/org/mappings.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1020,6 +1020,16 @@ function OrgMappings:org_time_stamp(inactive)
end)
end

function OrgMappings:org_toggle_timestamp_type()
local date = self:_get_date_under_cursor()
if not date then
return
end

date.active = not date.active
self:_replace_date(date)
end

---@param direction string
---@param use_fast_access? boolean
---@return boolean
Expand Down

0 comments on commit 82af22f

Please sign in to comment.