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§
- Image
File Media Source - The media producer that draws an
image-modebuffer’s own file. - Image
Mode - Major mode for a buffer backed by an image file.
Constants§
- IMAGE_
EXTENSIONS - Extensions
image-modeclaims. - IMAGE_
FILE_ SOURCE_ ID - This producer’s teardown key.
Functions§
- is_
image_ path - True when
pathis a fileimage-modepresents. - register_
image_ media_ source - Register
ImageFileMediaSourceagainst the boot-time media registry.