Tim Cross <theophil...@gmail.com> writes: > Arthur Miller <arthur.mil...@live.com> writes: > >> Tim Cross <theophil...@gmail.com> writes: >> >>> Hi, >>> >>> when you are editing source blocks are you using org-edit-special, normally >>> bound to C-c ') or are you just editing the source blocks directly within >>> the >>> org buffer? >> No I don't narrow. > > Note that org-edit-special isn't really narrowing. Rather, it opens a > new buffer (there are options to control how it does this i.e. replace > org buffer, split to open in new buffer, open in new frame etc) which puts > the source block > into the native mode for the language being edited. For example, if > your editing an emacs-lisp block, the edit special buffer will be in > emacs-lisp-mode and will have all the facilities you would normally have > when opening an emacs lisp file. > > What it sounds like you want to do is just have all the (for example) > emacs-lisp mode and associated minor modes activated when your cursor is > within a source block within the org buffer. This is extremely difficult > to. Part of the problem is that modes like emacs-lisp-mode are designed > to operate on buffers.
Yes indeed. I am quite aware of difficulties involved. I did myself a small [[https://github.com/amno1/dired-auto-readme][hack to dired mode to "auto show" readme files]], and got into all those problems there. That one major mode per buffer is starting to be a limitation. What we really would need is a major mode per region, or some other mean to be able to combine modes. Maybe something like a "primary mode" which would be what Emacs opens into when a file is loaded, i.e. 'org-mode' in this example and secondary modes, which would be other major modes loaded, and somehow activated per region or I don't know. But that is a day-dreaming :). It would require rebuilding entire machinery. > There are some 'special' packages, like mmm-mode > which try to support this type of functionality, but to be honest, I've > never found them very good and they often have significant performance > problems. Yes I know. I tried with mmm-mode, didn't really work well for me. > Of course, this is emacs and you can probably get something mostly > working, but it will take considerable effort and may well have > performance hits as well as other unexpected side effects. I think your > definitely 'swimming against the flow' and suspect that in the end, you Haha, definitely :-). But that is the story of my entire life ;-). Yes, in this case, that is correct. What I am doing here is bending entire org-mode to do something it is not supposed to do. If you are interested you can take a look at [[https://github.com/amno1/.emacs.d/blob/main/init.org][my little app on my github]]: Look at "org hacks" under generator heading. > will spend far more time trying to maintain your hacks rather than > actually focusing on the work you want to get done. I originally went down a That is what is hapening, but I started this as a hobby project as well as a learning experience. I really suck at both Emacs internals and elisp, so I need something like this as a learning project. > Anyway, good luck. Thanks, and thank you for the tips and feedback.