emacs shell 无法处理 % 字符
emacs shell could not process % character
在 emacs shell 中,当我键入命令 "echo %" 时,emacs 将死机,当我取消命令时,Message 显示错误如下:
comint-simple-send-around: Format string ends in middle of format specifier
我调试错误,因为 Emacs 使用 format
函数,%%
可以用于 %
,但仍然发送 shell 和 %%
字符。
下面是定义:
(defun comint-simple-send-around (simle-function proc string)
(dolist (item name-variable-map)
(let ((name (car item))
(value (symbol-value (cdr item))))
(setq string (replace-regexp-in-string name value string))
))
(message string)
(funcall simle-function proc string)
)
(advice-add #'comint-simple-send :around #'comint-simple-send-around)
错误在您的自定义代码中,您正在执行此操作的地方:
(message string)
其中 string
显然评估为 无效 格式字符串。
(message FORMAT-STRING &rest ARGS)
...
The first argument is a format control string, and the rest are data
to be formatted under control of the string. Percent sign (%), grave
accent (`) and apostrophe (') are special in the format; see
`format-message' for details. To display STRING without special
treatment, use (message "%s" STRING)
.
在 emacs shell 中,当我键入命令 "echo %" 时,emacs 将死机,当我取消命令时,Message 显示错误如下:
comint-simple-send-around: Format string ends in middle of format specifier
我调试错误,因为 Emacs 使用 format
函数,%%
可以用于 %
,但仍然发送 shell 和 %%
字符。
下面是定义:
(defun comint-simple-send-around (simle-function proc string)
(dolist (item name-variable-map)
(let ((name (car item))
(value (symbol-value (cdr item))))
(setq string (replace-regexp-in-string name value string))
))
(message string)
(funcall simle-function proc string)
)
(advice-add #'comint-simple-send :around #'comint-simple-send-around)
错误在您的自定义代码中,您正在执行此操作的地方:
(message string)
其中 string
显然评估为 无效 格式字符串。
(message FORMAT-STRING &rest ARGS)
...
The first argument is a format control string, and the rest are data to be formatted under control of the string. Percent sign (%), grave accent (`) and apostrophe (') are special in the format; see `format-message' for details. To display STRING without special treatment, use(message "%s" STRING)
.