Q:  I am seeking a proposed modification of simple.el at lines 5251 to 5308 of the master branch relating to highlighting a selected region to achieve a better visual representation when the same buffer is displayed in more than one window (same frame or a different frame) -- with different window-start/window-end positions.

The first couple of screen-shots are with the default highlight-nonselected-windows set to nil. The last screen-shot is with highlight-nonselected-windows set to t. The test file for this example is the library simple.el.

I have only selected the four (4) lines of code in the second window in the first screen-shot, yet (12) lines of code are highlighted in the first window in the second-screen-shot. The third screen-shot displays both.

GOAL: The same four (4) lines of code should be highlighted in all three screen-shots.

Example Example Example

1 Answer 1


Not sure what the question is. Are you asking for code that gives you the behavior you want? Are you asking that Emacs Dev change simple.el so that it behaves as you want?

At any rate, this is the problem: Each window has its own window point, which is the position that point would have if that window were selected. This means that the region when that window is selected is not the same as it is when another window is selected.

What you are asking for, as behavior, is to highlight the same text in each window (if it is shown in a given window). But that would not be highlighting the region for that window. You can do that, but you would need to use a different overlay (or text property) - you should not expect the region highlighting to highlight something other than the region.

So instead of modifying the simple.el code that highlights the region in each window, consider writing your own code that highlights, in each window that shows it, the text that is selected as the region in the selected window. You know as well as anyone how to do that. The point is that you would need to do it (unless someone else volunteers code that does that).

So this answer does not give you what you want, but maybe it helps understand why what you really want should not be to try to modify simple.el: the region is buffer/window-specific.

See the Elisp manual, node Window Point. (But I imagine you already know this.)

  • Thank you for helping me to better understand that the regions were different in each window. I'll set up a buffer highlighting of the initial selected region that does not change when switching windows, and is removed when the region is no longer active.
    – lawlist
    Feb 20, 2016 at 23:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.