如何找出当前缓冲区中使用的语法表?
Ch s 显示语法表本身,但在那里没有提到它的名字......或者至少我无法在那里找到它。
答案 0 :(得分:3)
我认为你混淆了一个Lisp变量及其语法表值。语法表没有名称。
听起来你想要一个当前值为当前语法表的变量的名称。如果是这样,这通常是错误的。
语法表根本不需要与变量相关联。
然而,您可以做的是查看当前主模式是否具有名为MODENAME-mode-syntax-table
的变量,其中MODENAME
是主模式名称。这是一种惯例,只要主模式有自己的语法表,就会遵循这种惯例。请参阅Elisp手册,节点Major Mode Conventions
。
如果是这种情况,那么只需检查MODENAME-mode-syntax-table
的值。如果没有这样的变量那么至少你会发现它。您还可以检查当前语法表是否等于该变量的值。如果没有这样的变量,您至少可以检查当前语法表是否等于变量standard-syntax-table
的值。
这就是你可以做的所有事情,以获得类似于“当前语法表的名称”的内容。
但这听起来像XY question。 IOW,也许您应该说为什么要寻找表“名称”。说明你想要解决的真正问题(作为一个单独的问题)。
更新:命令以人类可读的形式显示给定语法变量的语法表。
(defun describe-syntax-variable (variable)
"Describe the syntax specifications for the given syntax VARIABLE.
The descriptions are inserted in a help buffer, which is then displayed."
(interactive
(let ((v (variable-at-point))
(enable-recursive-minibuffers t)
val)
(setq val (completing-read (if (symbolp v)
(format
"Describe syntax variable (default %s): " v)
"Describe syntax variable: ")
obarray
(lambda (vv)
(or (get vv 'variable-documentation)
(and (boundp vv) (not (keywordp vv)))))
t nil nil
(and (symbolp v) (symbol-name v))))
(list (if (equal val "") v (intern val)))))
(help-setup-xref (list #'describe-syntax-variable variable)
(called-interactively-p 'interactive))
(with-help-window (help-buffer)
(with-current-buffer standard-output
(setq variable (symbol-value variable))
(describe-vector variable 'internal-describe-syntax-value)
(while (setq variable (char-table-parent variable))
(insert "\nThe parent syntax table is:")
(describe-vector variable 'internal-describe-syntax-value)))))