Function: ghostel--start

ghostel--start is a natively compiled function defined in ghostel.el.

Signature

(ghostel--start CONTEXT NAME &optional ARG)

Documentation

Find or create the ghostel slot for CONTEXT and pop to it.

CONTEXT is an identity alist without its instance pair; NAME is the buffer name for a new instance-1 buffer. ARG follows ghostel's prefix conventions: a number selects that instance, any other non-nil value creates the next free instance. Returns the buffer.

Source Code

;; Defined in /nix/store/1252krff0gb2kisjcpp45m50cpdskfrl-emacs-packages-deps/share/emacs/site-lisp/ghostel.el
(defun ghostel--start (context name &optional arg)
  "Find or create the ghostel slot for CONTEXT and pop to it.
CONTEXT is an identity alist without its `instance' pair; NAME is
the buffer name for a new instance-1 buffer.  ARG follows
`ghostel''s prefix conventions: a number selects that instance, any
other non-nil value creates the next free instance.  Returns the
buffer."
  (let* ((fresh (and arg (not (numberp arg))))
         (instance (cond ((numberp arg) arg)
                         (fresh (ghostel--next-instance context))
                         (t 1)))
         (identity (append context `((instance . ,instance))))
         (buf-name (if (> instance 1) (format "%s<%d>" name instance) name))
         (display-action (append display-buffer--same-window-action
                                 '((category . comint))))
         (existing (and (not fresh)
                        (ghostel--find-buffer-by-identity identity))))
    (if existing
        (progn
          (unless (buffer-local-value 'ghostel--term existing)
            (user-error "Ghostel buffer %s has no terminal"
                        (buffer-name existing)))
          (pop-to-buffer existing display-action)
          existing)
      (ghostel-create buf-name display-action identity))))