1

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."
  (interactive)
  (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
`help-xref-interned'.

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))
                  (with-temp-buffer
                    (let ((help-xref-following t))
                      (help-mode)
                      (help-xref-interned ,sym)
                      (buffer-string))))))
    (if (fboundp #'popwin-mode)
        `(let ((old-popwin popwin-mode))
           (popwin-mode -1)
           (unwind-protect
               ,form
             (popwin-mode (or old-popwin -1))))
      ,form)))

Can I make this more idiomatic/less verbose?

3
  • Did you consider just disabling popwin for help windows?
    – wasamasa
    Commented Jan 4, 2016 at 7:18
  • For all help windows? No, I want to be able to use popwin to dismiss windows normally. Commented Jan 4, 2016 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
    Commented Jan 4, 2016 at 7:32

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.