Function: hui:gbut-create

hui:gbut-create is an interactive and byte-compiled function defined in hui.el.

Signature

(hui:gbut-create LBL IBUT-FLAG)

Documentation

Create a Hyperbole global button with LBL.

By default, create an explicit button.

With prefix arg IBUT-FLAG non-nil, create a global implicit button with LBL as its name instead. See hui:gibut-create for details.

Key Bindings

Source Code

;; Defined in ~/.emacs.d/elpa/hyperbole-20260414.325/hui.el
(defun hui:gbut-create (lbl ibut-flag)
  "Create a Hyperbole global button with LBL.
By default, create an explicit button.

With prefix arg IBUT-FLAG non-nil, create a global implicit
button with LBL as its name instead.  See `hui:gibut-create' for
details."
  (interactive (list nil current-prefix-arg))
  (unless lbl
    (setq lbl (hui:hbut-label nil "gbut-create"
			      (if current-prefix-arg
				  "Create global implicit button named: "
				"Create global explicit button labeled: "))))
  (hypb:assert-same-start-and-end-buffer
    (if ibut-flag
	(hui:gibut-create lbl (hui:hbut-label nil "gbut-create"
					      "Implicit button text (with any delimiters): "))
      (let (actype
            but-buf
            src-dir)
	(save-excursion
	  (setq src-dir default-directory
		actype (hui:actype)
		but-buf (find-file-noselect (gbut:file)))
	  (set-buffer but-buf)
          (hui:buf-writable-err (current-buffer) "gbut-create")
          ;; This prevents movement of point which might be useful to user.
          (save-excursion
	    (goto-char (point-max))
            (unless (bolp)
	      (insert "\n"))
	    ;; loc = Directory of the global button file
	    (hattr:set 'hbut:current 'loc (hui:key-src but-buf))
	    ;; dir = default-directory of current buffer at the start of
	    ;; this `hui:gbut-create' function call (when button is created)
	    (hattr:set 'hbut:current 'dir src-dir)
	    (hattr:set 'hbut:current 'actype actype)
	    (hattr:set 'hbut:current 'args (hargs:actype-get actype))
	    (hattr:set 'hbut:current 'action (when hui:ebut-prompt-for-action
					       (hui:action actype)))
	    ;; Ensure ebut:operate is given but-buf as the current buffer
	    (set-buffer but-buf)
	    (setq lbl (concat lbl (ebut:operate lbl nil)))
	    (goto-char (point-max))
	    (insert "\n")
	    (save-buffer))
          (message "`%s' global explicit button created." lbl))))))