Function: hui:ebut-link-directly

hui:ebut-link-directly is an interactive and byte-compiled function defined in hui.el.

Signature

(hui:ebut-link-directly &optional DEPRESS-WINDOW RELEASE-WINDOW)

Documentation

Create a link ebutton at Assist Key depress point, linked to release point.

If an explicit button already exists at point, replace it with the new link button and return t; otherwise, return nil.

With optional DEPRESS-WINDOW and RELEASE-WINDOW, use the points from those instead. See also documentation for hui:link-possible-types.

An Assist Mouse Key drag between windows (when not on an item) runs this command.

Key Bindings

Source Code

;; Defined in ~/.emacs.d/elpa/hyperbole-20260414.325/hui.el
(defun hui:ebut-link-directly (&optional depress-window release-window)
  "Create a link ebutton at Assist Key depress point, linked to release point.
If an explicit button already exists at point, replace it with the new
link button and return t; otherwise, return nil.

With optional DEPRESS-WINDOW and RELEASE-WINDOW, use the points
from those instead.  See also documentation for `hui:link-possible-types'.

An Assist Mouse Key drag between windows (when not on an item)
runs this command."
  (interactive (progn
		 ;; Clear smart key variables so this does not
		 ;; improperly reference values left over from a prior
		 ;; drag or click.
		 (action-key-clear-variables)
		 (assist-key-clear-variables)
		 (hmouse-choose-link-and-referent-windows)))

  (hattr:clear 'hbut:current)
  (unless (called-interactively-p 'any)
    ;; Clear smart key variables so this does not improperly reference
    ;; values left over from a prior drag or click.
    (action-key-clear-variables)
    (assist-key-clear-variables))
  (let (but-lbl edit-flag link-types num-types type-and-args lbl-key but-loc but-dir)
    (cl-multiple-value-bind (link-but-window referent-window)
	(if (and depress-window release-window)
	    (list depress-window release-window)
	  (hmouse-choose-link-and-referent-windows))

      (select-window referent-window)
      ;; This sets hbut:current to link-to button attributes.
      (setq link-types (hui:link-possible-types)
	    num-types (length link-types))

      (select-window link-but-window)
      ;; It is rarely possible that a *Warnings* buffer popup might have
      ;; displaced the button src buffer in the depress window, so switch
      ;; to it to be safe.
      (when (and assist-key-depress-buffer
		 (not (eq (current-buffer) assist-key-depress-buffer))
		 (buffer-live-p assist-key-depress-buffer))
	(switch-to-buffer assist-key-depress-buffer))
      (hui:buf-writable-err (current-buffer) "ebut-link-directly")
      (if (ebut:at-p)
	  (setq edit-flag t
		but-loc (hattr:get 'hbut:current 'loc)
		but-dir (hattr:get 'hbut:current 'dir)
		lbl-key (hattr:get 'hbut:current 'lbl-key))
	(setq but-loc (hui:key-src (current-buffer))
	      but-dir (hui:key-dir (current-buffer)))
	(unless lbl-key
	  (setq but-lbl (hui:hbut-label
			 (cond ((hmouse-prior-active-region)
				hkey-region)
			       ((use-region-p)
				(hui:hbut-label-default
				 (region-beginning) (region-end))))
			 "ebut-link-directly"
			 "Create ebutton named: ")
		lbl-key (hbut:label-to-key but-lbl))))

      ;; num-types is the number of possible link types to choose among
      (cond ((= num-types 0)
	     (error "(ebut-link-directly): No possible link type to create"))
	    ((= num-types 1)
	     (setq type-and-args (hui:list-remove-text-properties (car link-types)))
	     (hui:ebut-link-create edit-flag link-but-window lbl-key but-loc but-dir type-and-args))
	    (t ;; more than 1
	     (let ((item)
		   type)
	       (setq type-and-args
		     (hui:menu-choose
		      (cons '("Link to>")
			    (mapcar
			     (lambda (type-and-args)
			       (setq type (car type-and-args))
			       (list
				(capitalize
				 (if (string-match
				      "^\\(link-to\\|eval\\)-"
				      (setq item (symbol-name type)))
				     (setq item (substring
						 item (match-end 0)))
				   item))
				type-and-args
				(documentation (symtable:actype-p type))))
			     link-types)))
		     type-and-args (hui:list-remove-text-properties type-and-args))
	       (hui:ebut-link-create
		edit-flag link-but-window
		lbl-key but-loc but-dir type-and-args))))
      (with-selected-window referent-window
	(hmouse-pulse-line))
      (when (called-interactively-p 'interactive)
	(hui:ebut-message edit-flag))
      edit-flag)))