- (unless (push-button pos)
- ;; check if the symbol under point is a function or variable
- (let ((sym
- (intern
- (save-excursion
- (goto-char pos) (skip-syntax-backward "w_")
- (buffer-substring (point)
- (progn (skip-syntax-forward "w_")
- (point)))))))
- (when (or (boundp sym) (fboundp sym) (facep sym))
- (help-do-xref pos #'help-xref-interned (list sym))))))
-
+ ;; check if the symbol under point is a function, variable or face
+ (let ((sym
+ (intern
+ (save-excursion
+ (goto-char pos) (skip-syntax-backward "w_")
+ (buffer-substring (point)
+ (progn (skip-syntax-forward "w_")
+ (point)))))))
+ (when (or (boundp sym)
+ (get sym 'variable-documentation)
+ (fboundp sym) (facep sym))
+ (help-do-xref pos #'help-xref-interned (list sym)))))
+
+(defun help-insert-string (string)
+ "Insert STRING to the help buffer and install xref info for it.
+This function can be used to restore the old contents of the help buffer
+when going back to the previous topic in the xref stack. It is needed
+in case when it is impossible to recompute the old contents of the
+help buffer by other means."
+ (setq help-xref-stack-item (list #'help-insert-string string))
+ (with-output-to-temp-buffer (help-buffer)
+ (insert string)))