Following this question about automatically displaying documentation in a pop-up window, I decided to give it a try based on existing work on Popup Help in Emacs Lisp and clippy.

However, I've run into an issue whereby help-xref-interned doesn't play nice with popwin. When I try to create a temp buffer for help-xref-interned, there is a brief flash as popwin brings the window up, then quickly dismisses it.

Therefore, it seems necessary to disable popwin temporarily, then restore it to its original state. I'm wondering what the idiomatic way to do this is. What I have is below:

(defun *-describe-symbol-popup ()
  "Display full documentation of symbol in a pop-up window."
  (let ((doc (*-symbol-full-doc (symbol-at-point)))
        (x-gtk-use-system-tooltips nil))
    (if (string-empty-p doc)
        (message "Unknown symbol, or no documentation available.")
      (pos-tip-show doc 'tooltip nil nil -1))))

(defmacro *-symbol-full-doc (symbol)
  "Return a string of the full documentation of SYMBOL, as given by

If `popwin-mode' is active, disable it temporarily. The value of
`popwin-mode' is thus always nil, even when the mode is active.'"
  (let* ((sym (make-symbol " sym "))
         (form `(let ((,sym ,symbol))
                    (let ((help-xref-following t))
                      (help-xref-interned ,sym)
    (if (fboundp #'popwin-mode)
        `(let ((old-popwin popwin-mode))
           (popwin-mode -1)
             (popwin-mode (or old-popwin -1))))

Can I make this more idiomatic/less verbose?

  • Did you consider just disabling popwin for help windows? – wasamasa Jan 4 '16 at 7:18
  • For all help windows? No, I want to be able to use popwin to dismiss windows normally. – Tianxiang Xiong Jan 4 '16 at 7:29
  • Well, ok, in this case I'm not sure what there is to be gained over just hitting q to dismiss the window. – wasamasa Jan 4 '16 at 7:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.