From mboxrd@z Thu Jan 1 00:00:00 1970 From: Dmitrii Korobeinikov Subject: bug#35419: [Proposal] Buffer Lenses and the Case of Org-Mode (also, Jupyter) Date: Fri, 26 Apr 2019 03:00:12 +0600 Message-ID: References: <87v9z2ojf8.fsf@yantar92-laptop.i-did-not-set--mail-host-address--so-tickle-me> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="0000000000006420f00587611b81" Return-path: Received: from eggs.gnu.org ([209.51.188.92]:51031) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hJlUS-0006Is-J0 for emacs-orgmode@gnu.org; Thu, 25 Apr 2019 17:01:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hJlUQ-00043g-PA for emacs-orgmode@gnu.org; Thu, 25 Apr 2019 17:01:08 -0400 Sender: "Debbugs-submit" Resent-Message-ID: In-Reply-To: <87v9z2ojf8.fsf@yantar92-laptop.i-did-not-set--mail-host-address--so-tickle-me> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: Ihor Radchenko Cc: 35419@debbugs.gnu.org --0000000000006420f00587611b81 Content-Type: text/plain; charset="UTF-8" Dear Ihor, > Another use case for me is to speed up agenda creation. > I usually do not like to split my org files into too many. However, it > results in very large and slow org buffers later. If I can store some > parts of the org files externally and only show them if some condition > is met (say, for certain todo state of the parent entry), it would speed > up my agenda and the buffer navigation quite significantly. That's a good one! > Let me put some historical context to this proposal. > There was a discussion of similar feature in emacs-dev last year. > The idea was to implement nested buffers: > https://lists.gnu.org/archive/html/emacs-devel/2018-07/msg00863.html An interesting read, provides another use-case (collect external data in one place to easily view/edit): https://lists.gnu.org/archive/html/emacs-devel/2018-07/msg00890.html > There are also several projects, which implement part of the > functionality you described: > - mmm-mode: https://github.com/purcell/mmm-mode > - polymode: https://github.com/polymode/polymode Pretty cool stuff. For thoroughness, let's discuss how these work. I found a comment which mentions polymode's working principle. https://www.reddit.com/r/emacs/comments/50p34n/polymode_is_awesome/?depth=1 >> Polymode doesn't keep its modes in a single emacs buffer but in several indirect buffers, as many as different modes are there in a file. Consequently, polymode is as fast as switching emacs buffers because it never re-installs major modes like other multi-modes do. Dave Love's multi-mode.el gets full credit for this idea. > It looks like it slows emacs to a crawl in my main org config file. It seems to work fairly well in some of my notes files (though with some weird indenting behavior). Basically, simplicity is in place but at the cost of duplication. Lenses could avoid duplication, while yielding increased functionality and speed. (e.g. in polymode, a syntax checker couldn't yield correct results unless narrowing was constantly used, which is inefficient) Now, to MMM-mode. According to the info file: > Within the file, MMM-mode creates /submode regions/ within which other major modes are in effect. > While the point is in a submode region, the following changes occur: > <...> keymap <...> local variables <...> syntax table and indentation <...> font-lock > The submode regions are represented internally by Emacs Lisp objects known as /overlays/. > A lot of the functionality of MMM Mode---that which makes the major mode > appear to change---is implemented by saving and restoring the values of > local variables, or pseudo-variables. What I don't understand is where the modes of the submode region run and when they are turned on. Are necessary modes just allowed to run at the right time for the whole buffer? But then, how are they limited in their effect to just the necessary region? Narrowing? Could, for example, syntax checking be done efficiently that way? Could someone, please, explain? Best regards, Dmitrii. --0000000000006420f00587611b81 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Dear Ihor,

> Another use case for me is to speed up agenda creatio= n.
> I usually do not like to split my org files into too many= . However, it
> results in very large and slow org buffers lat= er. If I can store some
> parts of the org files externally an= d only show them if some condition
> is met (say, for certain = todo state of the parent entry), it would speed
> up my agenda= and the buffer navigation quite significantly.

Th= at's a good one!

> Let me put some historic= al context to this proposal.
> There was a discussion of simil= ar feature in emacs-dev last year.
> The idea was to implement= nested buffers:

An inter= esting read, provides another use-case (collect external data in one place = to easily view/edit):

> There are= also several projects, which implement part of the
> function= ality you described:

Pretty cool stuff. For= thoroughness, let's discuss how these work.

I= found a comment which mentions polymode's working principle.
https://www.reddit.com/r/emacs/comments/50p34n/polymode_is_= awesome/?depth=3D1
>> Polymode doesn't keep its mod= es in a single emacs buffer but in several indirect buffers, as many as dif= ferent modes are there in a file. Consequently, polymode is as fast as swit= ching emacs buffers because it never re-installs major modes like other mul= ti-modes do. Dave Love's multi-mode.el gets full credit for this idea.<= /div>
> It looks like it slows emacs to a crawl in my main org confi= g file. It seems to work fairly well in some of my notes files (though with= some weird indenting behavior).

Basically, simpli= city is in place but at the cost of duplication.
Lenses could avo= id duplication, while yielding increased functionality and speed.
(e.g. in polymode, a syntax checker couldn't yield correct results unl= ess narrowing was constantly used, which is inefficient)

Now, to MMM-mode. According to the info file:

> Within the file, MMM-mode creates /submode regions/ within which ot= her major modes are in effect.

> While the poin= t is in a submode region, the following changes occur:
> <.= ..> keymap <...> local variables <...> syntax table and inde= ntation <...> font-lock

> The submode reg= ions are represented internally by Emacs Lisp objects known as /overlays/.<= /div>

> A lot of the functionality of MMM Mode---that= which makes the major mode
> appear to change---is implemente= d by saving and restoring the values of
> local variables, or = pseudo-variables.

What I don't understand is w= here the modes of the submode region run and when they are turned on.
=
Are necessary modes just allowed to run at the right time for the whol= e buffer? But then, how are they limited in their effect to just the necess= ary region? Narrowing?
Could, for example, syntax checking be don= e efficiently that way?
Could someone, please, explain?

Best regards,
Dmitrii.
--0000000000006420f00587611b81--