AdamNiederer / AdamNiederer/0xc

Mode-sensitive number base cycling?

Offen
#8 1 Kommentar 1 Reaktion 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
Emacs Lisp
Sterne
44
Forks
8
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

I was looking for a command like `M-x number-base-at-point-cycle`. If I'm in `c-mode` and I have `0123` (octal) at point, it would convert it to `83` (decimal). If I then used the command a second time, it would convert the number to `0x53` (hex). A third time, back to `0123` (octal). If I'm in `nasm-mode` it would know that NASM also has `0b1010` syntax for binary literals so it would cycle through that as well. If I used the command in `lisp-mode` it would know that Lisp spells numbers like `#x-123` (hex) and would do the same thing in a mode-sensitive fashion. This command could then be used in keyboard macros to convert many numbers at once. Actually we could have:

* `number-base-at-point-to-binary`
* `number-base-at-point-to-octal`
* `number-base-at-point-to-decimal`
* `number-base-at-point-to-hex`
* `number-base-at-point-cycle`

Each of them could take an optional prefix argument to specify the number of digits in the resulting number, so the result would be padded with leading zeros where needed.

Do you think such a command would be a good fit for this package, or too different?

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.