Skip to main content

TransientContext

Struct TransientContext 

Source
pub struct TransientContext {
    pub major_mode: Option<String>,
    pub minor_modes: Vec<String>,
    pub buffer: Option<BufferId>,
    pub args: Args,
}
Expand description

Registry of named transient builders, populated at boot by each owning mode crate (magit registers magit-dispatch / magit-file-dispatch; per the module doc, which-key / command palette / future plugin transients are meant to reuse the same mechanism). Effect::OpenTransient { source } carries only the name — resolving it to an actual TransientSpec (which can’t cross into lattice-grammar’s Effect enum directly, since TransientSpec lives downstream of it) happens here, at the renderer’s effect-handling site. Mirrors PickerRegistry’s named-source shape, simplified: transients have no candidate generator or arg-schema concept, just a name and a builder.

Read-only after boot in practice (each owning crate’s install populates it once), so this stays a plain mutex-guarded map rather than an ArcSwap RCU registry like PickerRegistry — there’s no runtime plugin-load use case for it yet. MG.23h: where a transient was opened from, so a builder can vary its rows.

A dispatch menu bound globally has to degrade: rows that act on the thing under the cursor are meaningless in a buffer that has no such thing, and a row whose only useful reading depends on which buffer you are in should say the useful thing. Emacs magit answers both with predicates on its prefix definitions — :if-derived for “any buffer of this family” and :if-mode for “exactly this major” — and this is the same question, asked of the two mode axes.

Major and minors are separate fields on purpose. A flat list of active mode ids can only answer one of those two questions; magit’s dispatch asks both of them about the same key (j is “jump to section” in magit-status and “display status” everywhere else, while its whole “Applying changes” group is gated on the looser family test).

What is deliberately absent: the buffer id, the cursor, and the selection. A builder produces rows; it does not act. The row’s action receives its own ActionContext, which already carries the underlying buffer, its cursor and any Visual region — resolved at fire time, when they are current. Duplicating them here would be speculative surface that could also go stale between build and fire.

Fields§

§major_mode: Option<String>

The active major mode’s id, if the buffer has one. The :if-mode question.

§minor_modes: Vec<String>

The active minor mode ids. The :if-derived question is asked here: a magit buffer is one where magit-core-mode is active, whatever its major happens to be.

§buffer: Option<BufferId>

MR.4: the buffer the menu was opened over.

A builder whose rows depend on something the buffer owns — magit’s dispatch offers rebase --continue only while a rebase is stopped, and which repository that is depends on the buffer — cannot answer from the mode axes alone. None mid-boot, where the builder degrades exactly as it does for the mode fields.

Still not the cursor or the selection: a row’s own action receives those at fire time, when they are current.

§args: Args

TR.3a: the arguments the open carried (Effect::OpenTransient { args }).

The one field here that is not a fact about WHERE the menu was opened — it is what it was opened FOR, and it is what lets a menu drill down. Org’s capture menu has a row per template; the fields menu that row opens reads the template key from here rather than from guest memory, which <Esc> never clears.

Implementations§

Source§

impl TransientContext

Source

pub fn is_major(&self, id: &str) -> bool

True iff id is the active major — :if-mode.

Source

pub fn has_minor(&self, id: &str) -> bool

True iff id is an active minor — the family test a mode’s shared minor answers, standing in for :if-derived.

Trait Implementations§

Source§

impl Clone for TransientContext

Source§

fn clone(&self) -> TransientContext

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for TransientContext

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for TransientContext

Source§

fn default() -> TransientContext

Returns the “default value” for a type. Read more
Source§

impl PartialEq for TransientContext

Source§

fn eq(&self, other: &TransientContext) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for TransientContext

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more