editor

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 23, 2026 License: CC0-1.0 Imports: 12 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package editor runs the user's editor without a shell and retains private drafts until a caller explicitly discards them after confirmation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Command

func Command(configured string, getenv func(string) string) ([]string, error)

Command chooses configured, $VISUAL, $EDITOR, then vi, in that order.

func Edit

func Edit(ctx context.Context, argv []string, d *Draft, stdin io.Reader, stdout, stderr io.Writer) (string, error)

Edit appends the draft path to argv, runs the editor with the supplied streams, and reads the resulting buffer. It never discards the draft, even on success.

func FormatTaskBuffer

func FormatTaskBuffer(title, notes string) string

FormatTaskBuffer places the title on line one and separates notes with a blank.

func ParseLogBuffer

func ParseLogBuffer(s string) (title, notes string, err error)

ParseLogBuffer uses the first non-empty line as the title, then parses notes like ParseTaskBuffer.

func ParseTaskBuffer

func ParseTaskBuffer(s string) (title, notes string, err error)

ParseTaskBuffer trims the first line as the title and skips one blank separator line, preserving the remaining notes verbatim.

func SplitWords

func SplitWords(s string) ([]string, error)

SplitWords splits whitespace-separated arguments, honoring single quotes, double quotes and backslash escapes. It never expands shell expressions.

Types

type Draft

type Draft struct{ Path string }

Draft is a buffer retained until its mutation is confirmed or discarded.

func (*Draft) Discard

func (d *Draft) Discard() error

Discard removes the buffer. Call only after confirmation or explicit discard.

type Drafts

type Drafts struct {
	Dir   string
	Clock clock.Clock
}

Drafts stores editor buffers privately under Dir. A nil Clock uses real time.

func (Drafts) New

func (d Drafts) New(initial string) (*Draft, error)

New durably writes initial to a private <UTC timestamp>-<8 hex>.md file.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL