Buffers

Buffer management functions

Function: get-buffer (name)
Find and return a buffer with NAME, return nil if not found.
Function: make-buffer (name &rest args)
Create a buffer with NAME.
ARGS is passed as initialization arguments besides some extra keyword arguments:
:mode MODE-OR-MODES: Enable MODE-OR-MODES in the new buffer. MODE-OR-MODES can either be a list or a single symbol.
:disambiguate SUFFIX: When provided, try appending <SUFFIX> to NAME in case of name collision before trying <number>.
:revert REVERT-P: If REVERT-P is t, call revert-buffer on the new buffer.
Function: get-buffer-create (name &rest args)
Returning a buffer with NAME if found, or create one.
When creating a new buffer, NAME and ARGS has the same meaning as in make-buffer.
If an existing buffer is found, it is reinitialized with ARGS.
Progn generic function: on-delete-buffer (buffer)
Run when BUFFER is about to be deleted.

Buffer focus

Neomacs keep track of the current position being edited using a focus marker.

Function: focus (&optional (buffer (current-buffer)))

Customize how buffer focus is rendered:

Standard generic function: render-focus-aux (buffer pos)
Render focus at POS for BUFFER

Buffer selection

Neomacs tracks selection with a selection marker. The range between the selection marker and focus marker is considered selected when selection-active is t. Certain commands (for example, some clipboard commands) that normally act on focused element will act on the selected range instead if selection is active.

Standard generic function, setf-able: selection-marker (object)
Standard generic function, setf-able: selection-active (object)

Buffer management commands

Command (C-x b): switch-to-buffer (buffer &optional (victim (focused-buffer)))
Command: bury-buffer (&optional (buffer (current-buffer)))
Stop displaying BUFFER.
Command (C-x k): delete-buffer (buffer)
Command (s-k): delete-this-buffer ()

There is also a dedicated list mode for managing buffers:

Command: list-buffers ()

Loading URLs

Function: load-url (buffer url)
Load URL in BUFFER.
This set up a promise handler so that on-buffer-loaded is triggered when URL finishes loading. We use this instead of Electron's did-finish-load event because the latter doesn't carry url information, and getting url with webContents.getURL() isn't reliable because it may get the URL of a later issued unfinished load operation.
Standard generic function, setf-able: load-status (object)
Progn generic function: on-buffer-dom-ready (buffer)
Progn generic function: on-buffer-loaded (buffer url err)
Run when BUFFER finishes loading URL.
This is invoked both when load succeeded or failed. When load succeeded, ERR is nil.
Progn generic function: on-buffer-did-start-navigation (buffer details)