【问题标题】:emacs shell could not process % characteremacs shell 无法处理 % 字符
【发布时间】:2020-04-21 03:30:19
【问题描述】:

在 emacs shell 中,当我输入命令“echo %”时,emacs 将死机,当我取消命令时,消息 显示如下错误:

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)

【问题讨论】:

  • M-x eshellM-x shell ?无论哪种情况,我都无法复制该问题。请告诉我们M-x emacs-version 所说的内容,并提供从emacs -Q 开始的配方以重现问题。
  • @Drew,感谢您的回复,我使用的是 shell,而不是 eshell。版本:“2017-09-13 的 GNU Emacs 25.3.2(x86_64-pc-linux-gnu,GTK+ 版本 3.18.9)”这很奇怪,emacs -Q 工作正常。什么时候开始没有“-Q”选项,消息是“comint-simple-send-around:格式字符串在格式说明符中间结束”,我更新问题中的定义和设置。

标签: shell emacs


【解决方案1】:

错误在您的自定义代码中,您正在执行此操作:

(message string)

string 显然是在评估 invalid 格式字符串。

(message FORMAT-STRING &rest ARGS)
...
第一个参数是格式控制字符串,其余是数据 在字符串的控制下进行格式化。百分号 (%),严重 重音(`)和撇号(')在格式上是特殊的;看 `format-message' 了解详情。 显示没有特殊的STRING 治疗,使用(message "%s" STRING)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-03-04
    • 2011-07-02
    • 2015-10-21
    • 1970-01-01
    • 1970-01-01
    • 2021-04-27
    • 2023-03-30
    • 2012-07-03
    相关资源
    最近更新 更多