(defun radix-number-at-point ()
"Return the radix number at point, or nil if none is found."
(when (thing-at-point-looking-at "-?#[0-9][0-9]*r[a-zA-Z0-9]+\\.?[a-zA-Z0-9]*" 500)
(read (buffer-substring-no-properties (match-beginning 0) (match-end 0)))))
1 回答
我没有完整,直接的答案给您,但这里有几个库,您可以查看有关自己实现这一点的想法 . 一些问题取决于您希望如何显示/返回数字 .
modeline-char.el - 次模式
mlc-char-in-mode-line-mode
在模式行打火机中显示点后的字符,后跟=
,后跟字符的十六进制Unicode代码点 . 见Show Char In Mode Line .thingatpt+.el -
number-at-point-decimal
和number-at-point-hex
等功能 . 见Thing At Point Plus .如果要识别的文本使用标准Emacs表单作为基数和该基数中的数字,那么您可以定义
radix-number-at-point
. 该表格记录在Elisp手册中,节点Integer Basics . 例如,#13r90B3
与十进制整数19919
的编号相同 .这是一个快速的定义 . 你可能想调整一下 .
您还可以定义一个不需要显式
#rRADIX
部分的函数,例如,按顺序自动尝试不同的基数,例如,使用返回数字的最小基数 .