Skip to content

Conversation

@wynro
Copy link
Contributor

@wynro wynro commented Oct 18, 2021

Mainly, moved a lot of the functionality that was previously inside he the ipcalc function to a bunch of separated functions, to allow independent usage, and (I think) cleaner code.

Also added the functionality to insert the report in the current buffer using the universal argument (Now, by doing C-u M-x ipcalc RET 192.168.25.0/24 RET the full report is inserted on the current point).

I have also added a bunch of tests to ensure that I didn't break anything during the refactoring.

There are still a couple of rough edges (for example, if you try to calculate the min/max host of a very small network, like a /31 or /32, it gives nonsensical answer), but I think this is good enough

You commented about bumping up the version. If you don't mind, I would prefer you to review this and then bump the version once we agree this is prepared to be merged.

wynro added 14 commits October 18, 2021 22:43
- Also added a macro to simplify writing functions that interact with
the user
- Reverse function not added, ass the ip/cidr cannot be calculate from
the network alone (for example, 10.1.1.1/8 would produce 10.0.0.0, but
from the 10.0.0.0 we can't obtain the initial value)
- We have to include a couple of special cases for /31 and /32
networks. Technically speaking, both of those networks have 0 hosts,
so there is no concept of first or last host in those. We have to
settle to a couple of default values that look consistent with the old
functions, and with a couple of IPv4 calculators I found on the
Internet.
- When a function that used ipcalc-insert-or-return-value was called
inside another function that did the same, both would receive the same
current-prefix-arg, meaning that when called with universal argument
both would write its output. Now, the outer most function captures the
value of current-prefix-arg, and does not pass it to the internal
function, preventing that behavior
…list

- Now the full report can be generated and consumed programmatically
- With this, we can separate the logic of generating the information
from the logic of formatting the information to present to the user.
- We could (should) write extra tests for ipcalc-alist, but we are
testing ipcalc, that uses it, so I'll consider it enough
- Instead of manually managing the value of current-prefix-arg, we can
simply use `interactive-p' to check if the function was called
interactively
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant