为何有些符号(symbol)无法比较?

创建一个 help 缓冲,把 [back] 按钮的属性读出来,发现其中 category 的值 help-back-button(是一个符号),然而直接把它跟 help-back-button 比较的时候返回 nil:

(let ((curr-buf (current-buffer))
      (help-buf "*Help2*")
      (shouldeq (lambda (testfn sym1 sym2)
                   (format "(testfn %S %S) => %s\n" sym1 sym2 (funcall testfn sym1 sym2)))))
  (with-current-buffer (get-buffer-create help-buf)
    (read-only-mode -1)
    (erase-buffer)
    (help-insert-xref-button help-back-label 'help-back curr-buf)
    (help-mode)
    (backward-char)
    (concat (format "properties: %S\n" (text-properties-at (point)))
            (funcall shouldeq 'equal (get-text-property (point) 'help-args)          (list curr-buf))
            (funcall shouldeq 'eq    (get-text-property (point) 'type)               'help-back)
            (funcall shouldeq 'eq    (get-text-property (point) 'category)           'help-back-button)
            (funcall shouldeq 'equal (symbolp (get-text-property (point) 'category)) t)
            )))
;; =>
;; "properties: (help-args (#<buffer *scratch*>) category help-back-button button (t) fontified nil)
;; (testfn (#<buffer *scratch*>) (#<buffer *scratch*>)) => t
;; (testfn help-back help-back) => t
;; (testfn help-back-button help-back-button) => nil
;; (testfn t t) => t
;; "

另一个比较疑惑的地方是:(text-properties-at ...) 取出来的 properties 并不包含 type,而它其实是存在的,(help-insert-xref-button ...) 第二个参数就是 type,通过 (get-text-property ...) 也可以取到,为何要这样设计?


APPEND 2018-09-16 00.53.09

(button-category-symbol 'help-back)                           ;; => help-back-button
(symbolp (button-category-symbol 'help-back))                 ;; => t
(eq (button-category-symbol 'help-back) 'help-back-button)    ;; => nil
(equal (button-category-symbol 'help-back) 'help-back-button) ;; => nil

C-h f define-button-type

(info “elisp”) C-s get-text-property

其实是个旧问题:请教一个(并不)低级的plist问题 - #14,来自 twlz0ne

我还参与讨论过,怎么给忘了。

Ni not hou dao