cofi / evil-numbers

Increment and decrement numbers in Emacs
GNU General Public License v3.0
119 stars 23 forks source link

Implement 2 pairs of inc/dec commands: one shall pad with zeros, another shall not #6

Open maximbaz opened 9 years ago

maximbaz commented 9 years ago

searches for number up to eol and then increments or decrements and keep zero padding up (unlike in vim)

@cofi, out of curiosity, what was the rationale behind this decision?

I'm sure there are pros and cons in both approaches, and padding doesn't always suit as well (see @mlf176f2's PR for just one of many examples).

I think it makes sense to have 2 pairs of commands, one shall pad with zeros, another shall not. And no need to implement fancy rules to determine, when to use padding.


P.S. This may be better discussed in a separate thread, but currently padding works only for positive numbers, e.g. decrement from 10 gives 09, while increment from -10 gives -9.

dieggsy commented 7 years ago

I think I've implemented this in the padding-tests branch of my fork. It has evil-numbers/inc-at-pt-pad and evil-numbers/dec-at-pt-pad that preserve padding (consistently for negatives too, I think), where the original functions do not preserve it.

I'm pretty sure it still has some kinks to work out, though.

Edit: pulled into master of my fork, for now. I think most if not all of the "kinks" were present even before my changes.

juliapath commented 6 years ago

My fork has this. There is a variable evil-numbers/padDefault (off by default), which enables or disables padding globally and in addition every command takes an optional padded argument, so you could easily make a commands inc-at-pt-pad and inc-at-pt-nopad.