[Top][All Lists]

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

Re: visual-region-mode?

From: Juri Linkov
Subject: Re: visual-region-mode?
Date: Mon, 17 Sep 2018 01:55:53 +0300
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (x86_64-pc-linux-gnu)

> By the way, this definition of region is flawed.
> The mark is buffer-local, while the point is buffer-and-window-local.
> Display a buffer B in windows X and Y, mark a region in window X, then
> switch to window Y. Suddenly, an entirely unrelated fragment of text
> is highlighted as region.
> A consistent definition of a persistent region would make it an
> interval between two buffer-local markers, both of which are distinct
> from the point.
> A consistent definition of a transient region would make the mark also
> buffer-and-window-local, so that buffer B in windows X and Y could
> have completely independently marked regions.

Yes, this is an annoying problem.  As a workaround, it's easy
to make the mark buffer-and-window-local with this simple code:

  (defvar-local mark-active-window nil)

  (add-hook 'activate-mark-hook   (lambda () (setq mark-active-window 
  (add-hook 'deactivate-mark-hook (lambda () (setq mark-active-window nil)))

  (defun redisplay--update-mark-active-window (window)
    (when mark-active-window
      (setq mark-active (eq mark-active-window window))))

  (add-to-list 'pre-redisplay-functions #'redisplay--update-mark-active-window)

I'm not sure if a new customizable option is necessary to define the
preferable behavior like with the option `highlight-nonselected-windows'.

reply via email to

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