orgmode icon indicating copy to clipboard operation
orgmode copied to clipboard

More intuitive priority cycling

Open gerazov opened this issue 2 years ago • 7 comments

I'm not sure if it's bound by emacs orgmode behavior, but current priority increase and decrease is a bit counterintuitive.

  • increase cycle
    • none (default priority) -> [#C] (low priority) -> [#B] (default priority) -> [#A] (high priority) -> none.
  • decrease cycle
    • none (default priority) -> [#A] (high priority) -> [#B] (default priority) -> [#C] (low priority) -> none.

Thus, the first press actually decreases priority, and then sets it to the initial state, and only then actually increases priority. The reverse is true for decrease - one needs to press 3 times to actually reduce priority.

In other words to give [#A] priority to a task with no priority, the fastest way to do it is by pressing decrease priority.

This PR modifies the cycle as follows:

  • increase cycle
    • none (default priority) -> [#A] (high priority) -> none
    • [#C] (low priority) -> [#B] (default priority) -> [#A] (high priority) -> none
  • decrease cycle
    • none (default priority) -> [#C] (low priority) -> none
    • [#A] (high priority) -> [#B] (default priority) -> [#C] (low priority) -> none

While it breaks the cycle starting with none, the increase and decrease reflect the change in priority.

gerazov avatar Mar 27 '22 21:03 gerazov

This code seems to completely break the cycle. priority-pr-bug

kristijanhusak avatar Apr 03 '22 17:04 kristijanhusak

Yes it does ... but it does consistently increase (decrease) priority. We could have it loop, i.e. none -> A -> C -> none -> A, but then the B is missing.

Maybe it would make sense to have a separate cycle up/down command that would do what increase and decrease do atm. But it all ties back to how it's done in emacs.

btw - great work on the Clocking summary table :sunglasses:

gerazov avatar Apr 04 '22 06:04 gerazov

In other words to give [#A] priority to a task with no priority, the fastest way to do it is by pressing decrease priority. There is a binding for changing the priority to any state (iirc it's <leader>o, by default). I would say that's the fastest way to get to the highest priority.

TravonteD avatar Apr 20 '22 14:04 TravonteD

Good tip! but you still need to write in the priority, so that's 4 keys. Currently I use reduce priority to mark tasks as important - it's one key in the agenda - and 3 in the org file cir :slightly_smiling_face:

gerazov avatar Apr 21 '22 06:04 gerazov

A possible solution to this (for the sake of convenience) could be to have a set_to_priority(<num>) function that can be used in custom mappings, so that one could make a keymap for priority A,B,etc.

TravonteD avatar Apr 22 '22 15:04 TravonteD

Hmm :thinking: maybe a toggle function would be convenient? e.g. toggle_high_priority() for [#A] and toggle_low_priority() for [#C], imo [#B] is not that useful.

gerazov avatar Apr 26 '22 10:04 gerazov

My previous suggestion is now possible by using the new treesitter functions. Here's an example.

local Headline = require('orgmode.treesitter.headline')
local tree_utils = require('orgmode.utils.treesitter')

vim.keymap.set('n', '<some-keymap>', function()
  local headline = Headline:new(tree_utils.closest_headline())
  headline:set_priority('A')
end)

TravonteD avatar May 10 '22 10:05 TravonteD