Skip to main content

Module image

Module image 

Source
Expand description

image-mode — the major mode for a buffer whose file is a picture.

:e diagram.png used to fail on the UTF-8 read: Document::open is read_to_string, and a PNG is not text. This mode is the other answer — the file becomes an ordinary buffer with an ordinary major, listed by :ls, reached by :bn, named in the modeline — and what it shows is the image, through the same inline-media substrate an org [[file:…]] block uses.

§It presents, it does not edit

Mode::presents_extensions is what tells the open path not to read the bytes. The buffer holds a single empty line and the picture hangs below it as a media block, so nothing about the file’s contents is in the rope.

That makes read-only load-bearing rather than tidy: the buffer’s text is not the file, so writing it back would replace the image with nothing. Both declarations are present and both are needed — ReadOnly gates insert-mode typing, and the implied read-only-mode carries the invocation runner that refuses dd, x, cw and p. The option alone would let an operator through.

The third gate is not here: :w is refused host-side, because a save does not go through either of the above.

Structs§

ImageFileMediaSource
The media producer that draws an image-mode buffer’s own file.
ImageMode
Major mode for a buffer backed by an image file.

Constants§

IMAGE_EXTENSIONS
Extensions image-mode claims.
IMAGE_FILE_SOURCE_ID
This producer’s teardown key.

Functions§

is_image_path
True when path is a file image-mode presents.
register_image_media_source
Register ImageFileMediaSource against the boot-time media registry.