Function: hmouse-choose-link-and-referent-windows

hmouse-choose-link-and-referent-windows is a byte-compiled function defined in hmouse-drv.el.

Signature

(hmouse-choose-link-and-referent-windows)

Documentation

Select and return a list of (link-button-window referent-window).

Source Code

;; Defined in ~/.emacs.d/elpa/hyperbole-20260414.325/hmouse-drv.el
(defun hmouse-choose-link-and-referent-windows ()
  "Select and return a list of (link-button-window referent-window)."
  (let ((link-but-window (or (and (window-live-p assist-key-depress-window)
				  assist-key-depress-window)
			     (selected-window)))
	(referent-window (and (window-live-p assist-key-release-window)
			      assist-key-release-window)))
    (unless (and link-but-window referent-window)
      (cond ((= (count-windows) 2)
	     (setq link-but-window (selected-window)
		   referent-window (next-window nil nil (selected-frame))))
	    ((= (hypb:count-visible-windows) 2)
	     (setq link-but-window (selected-window)
		   referent-window (next-window nil nil 'visible)))
	    ((= (hypb:count-visible-windows) 1)
	     ;; Fall through to error below
	     )
	    (t
	     ;; Either this frame has more than two windows or other
	     ;; frames exist that together have more than one window;
	     ;; choose which to use as the referent window.
	     (setq referent-window
		   (if (fboundp #'aw-select) ;; ace-window selection
		       (let ((aw-scope 'global))
			 (aw-select "Select link referent window"))
		     (message "Select link referent window with the mouse...")
		     (let (end-event)
		       (prog1 (cl-loop do (setq end-event (read-event))
				       until (and (mouse-event-p end-event)
						  (not (string-match "\\`down-" (symbol-name (car end-event)))))
				       finally return (posn-window (event-start end-event)))
			 (message "Done"))))))))
    (when (eq link-but-window referent-window)
      (error "(hmouse-choose-link-and-referent-windows): No other visible window with a link referent"))
    (unless (window-live-p link-but-window)
      (error "(hmouse-choose-link-and-referent-windows): Invalid link button window '%s'" link-but-window))
    (unless (window-live-p referent-window)
      (error "(hmouse-choose-link-and-referent-windows): Invalid link button window '%s'" referent-window))
    (list link-but-window referent-window)))