emacs-tangents
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Question: what is Emacs mode?


From: Qiantan Hong
Subject: Re: Question: what is Emacs mode?
Date: Thu, 29 Apr 2021 03:39:34 +0000

Thanks for Jean’s input!

Now I’m stuck on one particular design choice

> 3. Suppose we now have node-local variables and node-local modes, what’s the 
> relation
>    between those of parent nodes and child nodes?
>    It seems natural to let child node inherit modes and variables from parent 
> nodes.
>    E.g., I might just turn on outline-mode on the ‘((Section title-A …)) node 
> in
>    (defun very-complex-function-that-require-a-paper ()
>      ‘((Section title-A
>         (Paragraph lorem ipsum)
>          (Section subtitle-B
>            (Paragraph lorem ipsum))))
>        *code*)
>    And it affects the whole sub-tree.
>    However, are there cases that one don’t want a whole subtree to inherit a 
> mode/variable?
>    Can we safely assume they all get inherited?

I’m hitting an implementation problem when trying to implement the “inherit” 
model.
Because modes are stored as node-local variables (or, node-local environment),
it makes functions that have mode-specific advices/hooks installed searching up 
through the document tree multiple time on every invocation.

One alternative is don’t implement “inherited” variables, but instead copy the 
surrounding
bindings when making new nodes, to fake “inherit”. This will cost lots of space 
however.

I have one way to improve the hopeless naive implementation of “inherited” 
model in mind.
The naive environment implementation is a deep-binding implementation. One can 
switch
to shallow-binding, maintaining the effective environment at selected node,
making variable accesses O(1). However, this is complicated by the fact that 
the structure
of our document tree is frequently changing, and getting it correct might be 
very difficult.

Any thoughts?

reply via email to

[Prev in Thread] Current Thread [Next in Thread]