7

I normally use indirect buffers while I edit python code in python-mode, I create them by running clone-indirect-buffer-other-window. While the syntax highlighting of the main buffer looks just fine, sometimes it is wrong in the indirect one. Specifically, it seems like some closing quotes are ignored adn so big chunks of my code are coloured as if they were part of long literal string.

I have not found references of this elsewhere, and have not clue why it could be happening. Does anybody know why this is and/or how to solve it?

This question could be related, be he does not mention indirect buffers (I only have this problem with those), and also my indirect buffer do not refresh to proper syntax highlighting even if a wait several minutes.

jmlorenzi
  • 283
  • 1
  • 5
  • Why are you using an indirect buffer in the first place? You can show the main buffer in two different windows, if that is what you are after. – Lindydancer Aug 08 '15 at 16:07
  • 1
    If the problem exists with the most recent public release of Emacs, then consider filing a bug report with as many details as possible regarding the issue. If you are using an older version of Emacs, then try the most recent public release. If you are using Emacs Trunk, then also consider filing a bug report with lots of details. – lawlist Aug 08 '15 at 16:41
  • @Lindydancer indirect buffers are more useful if I want to keep two fixed places of a long buffer open after switching my windows to other buffers – jmlorenzi Aug 08 '15 at 20:24
  • @lawlist Yes, I will play around to get more details and send the bug. I have just reproduced the error with in `emacs -q` – jmlorenzi Aug 08 '15 at 20:25

2 Answers2

1

You can try Just Another Cloning package.

Installation: Put jac.el into any directory from your load-path and put

 (autoload 'jac "jac")

into your init file.

Usage: With the buffer you want to clone type M-x jac RET.

It copies the buffer content of the original buffer and synchronizes text modifications of both buffers but does not touch text properties. That way fontlock can do its work in both buffers independently. That makes different major modes inclusively highlighting possible.

Maybe, it also avoids the bug with the highlighting of different regions of a phyton file. (Just try it.)

Tobias
  • 32,569
  • 1
  • 34
  • 75
0

Indirect buffers suck. They may look like "just what I need", but it's very rarely the case, and then sooner or later you bump into problems. IOW, I think they are an attractive nuisance.

I recommend you try and figure out why you want to use indirect-buffers and then try to look for other ways to get the same result.

E.g. you say:

indirect buffers are more useful if I want to keep two fixed places
of a long buffer open after switching my windows to other buffers

There are many other ways which are a lot less intrusive than using indirect buffers. E.g. using registers, bookmarks, or maybe with a package which tries to remember which point was used for your buffers individually in each window. E.g. in Emacs's master branch we have now enabled switch-to-buffer-preserve-window-point by default, which should provide some of the behavior you were looking for via indirect buffers.

Stefan
  • 26,154
  • 3
  • 46
  • 84
  • 1
    This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post. - [From Review](/review/low-quality-posts/4983) – erikstokes Jan 05 '16 at 22:50
  • If you don;t recognize it as a valid answer, it's because you're not familiar enough with indirect-buffers. – Stefan Jan 07 '16 at 05:34
  • @Stefan while you may be right, you're also not following this site's requested format: if you can answer the question, write an answer. If the question is invalid and should be changed, write a comment. – Trevoke Jun 24 '16 at 14:56
  • The question is definitely valid, and I've heard it many times, which is why I think it's important to answer it as it is rather than to try and get the author to "fix it". I much prefer losing a few rep-points than dogmatically following some policy. – Stefan Jun 25 '16 at 00:35
  • 1
    I agree with Stefan. Question and answer are valid. The answer could be formulated more neutral. E.g., "Indirect buffers suck. They" could be replaced by "Indirect buffers". – Tobias Jan 16 '19 at 11:26
  • Probably 99% of my usage of indirect buffers is to obtain multiple differently-narrowed views of a single buffer simultaneously (occasionally using a different major mode in the indirect buffer(s)). If there are alternative solutions to that, I would be very interested to know. – phils Sep 13 '19 at 13:36
  • @phils: rather than answer here, I'd suggest you make that into 2 fresh new questions. BTW, don't get me wrong on "indirect buffers suck": it doesn't mean that existing alternatives always suck less. – Stefan Sep 13 '19 at 15:59