adamniederer / 0xc Goto Github PK
View Code? Open in Web Editor NEWEasy base conversion in emacs
Easy base conversion in emacs
Do you think if it's useful to provide a function that converts all the hex numbers in the buffer to decimal numbers?
For example, something like 0xc-convert-buffer
that converts
<tag1>0x4</tag1>
<tag2>0x3</tag2>
<tag3>0x1 0x2 0x3<tag3>
to
<tag1>4</tag1>
<tag2>3</tag2>
<tag3>1 2 3<tag3>
I imagine this can be done by re-search-forward
for 0x[0-9a-f]+
and call 0xc-convert-point
?
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?
Hi,
I tried using 0xc
after installing it from MELPA. I tried to do a simple conversion of the number 10 to hexadecimal, just to get a feel for how this works. However, everything I try seems to end up with this error:
0xc-string-to-number: Wrong type argument: stringp, nil
This error occurs when I try 0xc-convert-point
as well. I'm not sure whether I'm just using this package incorrectly or if this is a bug. In either case, there's not enough documentation here for me to tell. FYI, I'm using Emacs 25.1.1 on OS X 10.11.6.
In the package listing (M-x list-packages
) this package is missing it's description.
You should add something like this into the comments at top of the file:
;;; 0xc.el --- Base 10 number conversion utility.
I think it would be great to have an example section in the README file. So people can get to know this great package easier! Thanks!
as title. Thanks!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.