Function: ghostel-beginning-of-input-or-line
ghostel-beginning-of-input-or-line is an interactive and natively
compiled function defined in ghostel.el.
Signature
(ghostel-beginning-of-input-or-line)
Documentation
Move point to the start of input on a prompt row, else beginning-of-line.
On prompt rows, point moves to the first input character after the prompt prefix. On other rows, point moves to the line beginning.
Key Bindings
ghostel-line-mode-map C-a ghostel-readonly-mode-map C-a
Source Code
;; Defined in /nix/store/1252krff0gb2kisjcpp45m50cpdskfrl-emacs-packages-deps/share/emacs/site-lisp/ghostel.el
(defun ghostel-beginning-of-input-or-line ()
"Move point to the start of input on a prompt row, else `beginning-of-line'.
On prompt rows, point moves to the first input character after the
prompt prefix. On other rows, point moves to the line beginning."
(interactive "^")
(let* ((bol (line-beginning-position))
(eol (line-end-position))
;; Line-mode marker target — only meaningful when the
;; marker is on the current line.
(line-mode-target
(and (eq ghostel--input-mode 'line)
(markerp ghostel--line-input-start)
(let ((m (marker-position ghostel--line-input-start)))
(and m (>= m bol) (<= m eol) m))))
;; Text-property fallback: walk forward from BOL while
;; chars carry `ghostel-prompt'. Only treat as input-start
;; when there is real content past the prefix; an
;; all-prompt line (multi-line prompt continuation) goes to
;; BOL instead of jumping to EOL.
(prop-target
(unless line-mode-target
(save-excursion
(goto-char bol)
(let ((pos bol))
(while (and (< pos eol)
(get-text-property pos 'ghostel-prompt))
(setq pos (1+ pos)))
(and (> pos bol) (< pos eol) pos)))))
;; Regex fallback for shells/REPLs without OSC 133. Suppressed
;; when OSC 133 is active and a real prompt sits below point:
;; this property-less line is then command output, not a prompt, so
;; prefer BOL over a stray mid-line %/>/#. During a live REPL/tmux
;; session, the bottom line has no prompt and the regex still fires.
(regex-target
(unless (or line-mode-target prop-target
(and ghostel--prompt-positions
(text-property-not-all (point) (point-max)
'ghostel-prompt nil)))
(ghostel--regex-prompt-end bol))))
(cond
(line-mode-target (goto-char line-mode-target))
(prop-target (goto-char prop-target))
(regex-target (goto-char regex-target))
(t (move-beginning-of-line 1)))))