gpt4 book ai didi

emacs - 如何让 C-x C-e 只显示十进制和十六进制?

转载 作者:太空宇宙 更新时间:2023-11-03 18:48:21 25 4
gpt4 key购买 nike

这是 How to get C-x C-e to display the result in octal and hexadecimal by default? 的后续行动

有没有办法让 C-x C-e 只显示十进制和十六进制的结果?

例如

(+ 40 2)

应该产生

42 (#x2a)

代替

42 (#o52, #x2a, ?*)

最佳答案

您只需要重写/调整为此创建打印格式的例程。将以下内容添加到您的 .emacs 中,您就可以开始了。

(require 'simple)
(defun eval-expression-print-format (value)
"Format VALUE as a result of evaluated expression.
Return a formatted string which is displayed in the echo area
in addition to the value printed by prin1 in functions which
display the result of expression evaluation."
(if (and (integerp value)
(or (not (memq this-command '(eval-last-sexp eval-print-last-sexp)))
(eq this-command last-command)
(if (boundp 'edebug-active) edebug-active)))
(let ((char-string
(if (or (if (boundp 'edebug-active) edebug-active)
(memq this-command '(eval-last-sexp eval-print-last-sexp)))
(prin1-char value))))
(format " (#x%x)" value value))))

关于emacs - 如何让 C-x C-e 只显示十进制和十六进制?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6752305/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com