unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#56662: 29.0.50; Funny region highlights when highlight-nonselected-windows is t
@ 2022-07-20 11:35 Visuwesh
  2022-07-20 12:38 ` Eli Zaretskii
  2022-07-20 18:05 ` Juri Linkov
  0 siblings, 2 replies; 21+ messages in thread
From: Visuwesh @ 2022-07-20 11:35 UTC (permalink / raw)
  To: 56662

[-- Attachment #1: Type: text/plain, Size: 437 bytes --]

If two windows show a single buffer, then the region highlighting is
strange in the non-selected window.  It is not hard to reproduce,

    1. emacs -Q
    2. Visit a longish file.
    3. C-x 3 and scroll up in any of the window.
    4. M-: (setq highlight-nonselected-windows t) RET.
    5. Create an active region and compare the highlighting.

I'm attaching a screenshot to demonstrate the issue in case the
reproducer wasn't clear.


[-- Attachment #2: screenshot_202207201702.png --]
[-- Type: image/png, Size: 386771 bytes --]

[-- Attachment #3: Type: text/plain, Size: 7656 bytes --]


In GNU Emacs 29.0.50 (build 22, x86_64-pc-linux-gnu, X toolkit, Xaw scroll bars)
 of 2022-07-17 built on astatine
Repository revision: 5db4ec20fe4b428e15aa53208c9a9bfb037c0f30
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12101003
System Description: Debian GNU/Linux bookworm/sid

Configured using:
 'configure --with-sound=alsa --with-x-toolkit=lucid --with-json
 --without-xaw3d --without-gconf --without-libsystemd --without-cairo'

Configured features:
ACL DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG JSON
LIBOTF LIBSELINUX LIBXML2 MODULES NOTIFY INOTIFY PDUMPER PNG RSVG
SECCOMP SOUND SQLITE3 THREADS TIFF TOOLKIT_SCROLL_BARS WEBP X11 XDBE XFT
XIM XINPUT2 XPM LUCID ZLIB

Important settings:
  value of $LC_MONETARY: ta_IN.UTF-8
  value of $LC_NUMERIC: ta_IN.UTF-8
  value of $LANG: en_GB.UTF-8
  locale-coding-system: utf-8-unix

Major mode: Group

Minor modes in effect:
  shell-dirtrack-mode: t
  gnus-undo-mode: t
  recentf-mode: t
  eros-mode: t
  pdf-occur-global-minor-mode: t
  minibuffer-depth-indicate-mode: t
  repeat-mode: t
  display-time-mode: t
  display-battery-mode: t
  winner-mode: t
  delete-selection-mode: t
  straight-use-package-mode: t
  straight-package-neutering-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  show-paren-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tab-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  undelete-frame-mode: t
  buffer-read-only: t
  indent-tabs-mode: t
  transient-mark-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t

Load-path shadows:
/home/viz/lib/emacs/straight/build/faceup/faceup hides /home/viz/lib/ports/emacs/lisp/emacs-lisp/faceup

Features:
(shadow ecomplete emacsbug sh-script smie files-x ement-taxy svg-lib
dabbrev avy inspector misc expand-region text-mode-expansions
cc-mode-expansions the-org-mode-expansions er-basic-expansions
expand-region-core expand-region-custom cl-print shell-command+
cus-start smerge-mode log-edit add-log time-stamp executable mule-util
flyspell ispell org-pdftools pdf-annot facemenu org-noter org-element
avl-tree ob-C ob-shell shell ob-racket async ob-async cdlatex texmathp
ol-eww eww xdg url-queue mm-url ol-rmail ol-mhe ol-irc ol-info ol-gnus
nnselect ol-docview doc-view ol-bibtex ol-bbdb ol-w3m ol-doi
org-link-doi org-tempo tempo org-id org-refile ol-man org ob ob-tangle
ob-ref ob-lob ob-table ob-exp org-macro org-footnote org-src ob-comint
org-pcomplete pcomplete org-list org-faces org-entities org-version
ob-emacs-lisp ob-core ob-eval org-table oc-basic bibtex ol org-keys oc
org-compat org-macs org-loaddefs flow-fill mm-archive sort gnus-cite
mail-extr textsec uni-scripts idna-mapping ucs-normalize uni-confusable
textsec-check qp gnus-async gnus-bcklg gnus-ml network-stream nsm
nndraft nnmh nnfolder nnmaildir nnagent nnml nnnil gnus-agent gnus-srvr
gnus-score score-mode nnvirtual gnus-msg gnus-art mm-uu mml2015 mm-view
mml-smime smime gnutls dig nntp gnus-cache gnus-sum gnus-group gnus-undo
gnus-start gnus-dbus gnus-cloud nnimap nnmail mail-source utf7 netrc
nnoo parse-time iso8601 gnus-spec gnus-int gnus-range message sendmail
yank-media rfc822 mml mml-sec epa epg rfc6068 epg-config mm-decode
mm-bodies mm-encode mail-parse rfc2231 rfc2047 rfc2045 ietf-drums
mailabbrev gmm-utils mailheader gnus-win gnus nnheader gnus-util
mail-utils range mm-util mail-prsvr tabify man misearch multi-isearch
pulse etags fileloop generator imenu-xref xref bug-reference cc-mode
cc-fonts cc-guess cc-menus cc-cmds cc-styles cc-align cc-engine cc-vars
cc-defs shortdoc help-fns radix-tree reveal noutline outline
cursor-sensor recentf tree-widget vc-backup log-view pcvs-util vc diff
vc-git diff-mode vc-dispatcher display-line-numbers ement-room-list
ement ement-notify notifications ement-room face-remap shr pixel-fill
kinsoku url-file url-dired puny svg ement-lib ement-api ement-structs
plz color ement-macros taxy-magit-section magit-section taxy ewoc dns
server paredit edmacro kmacro eros time-date checkdoc lisp-mnt
flymake-proc flymake project warnings thingatpt wordel-autoloads
sokoban-autoloads ement-autoloads svg-lib-autoloads
taxy-magit-section-autoloads magit-section-autoloads dash-autoloads
taxy-autoloads plz-autoloads nov-autoloads esxml-autoloads kv-autoloads
transmission-autoloads lua-mode-autoloads nix-mode-autoloads
racket-mode-autoloads pos-tip-autoloads faceup-autoloads eros-autoloads
flymake-shellcheck-autoloads writegood-mode-autoloads
siege-mode-autoloads paredit-autoloads puni-autoloads
expand-region-autoloads filladapt-autoloads compose quail
scroll-other-window org-pdftools-autoloads org-noter-autoloads
change-env-autoloads math-delimiters-autoloads doct-autoloads
ob-async-autoloads async-autoloads emacs-ob-racket-autoloads
valign-autoloads cdlatex-autoloads auctex-autoloads tex-site pdf-occur
ibuf-ext ibuffer ibuffer-loaddefs tablist advice tablist-filter
semantic/wisent/comp semantic/wisent semantic/wisent/wisent
semantic/util-modes semantic/util semantic semantic/tag semantic/lex
semantic/fw mode-local cedet pdf-isearch let-alist pdf-misc imenu
pdf-tools package browse-url url url-proxy url-privacy url-expand
url-methods url-history url-cookie generate-lisp-file url-domsuf
url-util mailcap url-handlers url-parse auth-source eieio eieio-core
json map byte-opt url-vars compile comint ansi-color cus-edit edebug
debug backtrace find-func wid-edit pdf-view password-cache jka-compr
pdf-cache pdf-info tq pdf-util pdf-macs image-mode dired-x dired
dired-loaddefs exif pdf-tools-autoloads tablist-autoloads mb-depth
repeat visual-fill-autoloads olivetti-autoloads time format-spec battery
dbus filenotify xml dom disp-table lacarte-autoloads
shell-command-plus-autoloads winner ring delsel cus-load easy-mmode
avy-autoloads finder-inf vc-backup-autoloads compat-autoloads icalendar
diary-lib diary-loaddefs cal-menu calendar cal-loaddefs rx filecache
imenu-xref-autoloads derived chemtable-autoloads molar-mass-autoloads
saveplace-pdf-view saveplace bookmark text-property-search pp
saveplace-pdf-view-autoloads pcase inspector-autoloads xr-autoloads
straight-autoloads cl-seq info cl-extra help-mode straight subr-x
cl-macs gv cl-loaddefs cl-lib bytecomp byte-compile cconv vz-nh-theme
vz-options-theme rmc iso-transl tooltip eldoc paren electric uniquify
ediff-hook vc-hooks lisp-float-type elisp-mode mwheel term/x-win x-win
term/common-win x-dnd tool-bar dnd fontset image regexp-opt fringe
tabulated-list replace newcomment text-mode lisp-mode prog-mode register
page tab-bar menu-bar rfn-eshadow isearch easymenu timer select
scroll-bar mouse jit-lock font-lock syntax font-core term/tty-colors
frame minibuffer nadvice seq simple cl-generic indonesian philippine
cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao
korean japanese eucjp-ms cp51932 hebrew greek romanian slovak czech
european ethiopic indian cyrillic chinese composite emoji-zwj charscript
charprop case-table epa-hook jka-cmpr-hook help abbrev obarray oclosure
cl-preloaded button loaddefs faces cus-face macroexp files window
text-properties overlay sha1 md5 base64 format env code-pages mule
custom widget keymap hashtable-print-readable backquote threads dbusbind
inotify dynamic-setting system-font-setting font-render-setting
x-toolkit xinput2 x multi-tty make-network-process emacs)

Memory information:
((conses 16 947872 144120) (symbols ?0 41864 354) (strings 32 202927 26256) (string-bytes 1 8898786) (vectors 16 115827) (vector-slots 8 2229479 69518) (floats 8 2323 1272) (intervals ?8 44532 3002) (buffers 992 ?O))

^ permalink raw reply	[flat|nested] 21+ messages in thread

* bug#56662: 29.0.50; Funny region highlights when highlight-nonselected-windows is t
  2022-07-20 11:35 bug#56662: 29.0.50; Funny region highlights when highlight-nonselected-windows is t Visuwesh
@ 2022-07-20 12:38 ` Eli Zaretskii
  2022-07-20 12:43   ` Visuwesh
  2022-07-20 18:05 ` Juri Linkov
  1 sibling, 1 reply; 21+ messages in thread
From: Eli Zaretskii @ 2022-07-20 12:38 UTC (permalink / raw)
  To: Visuwesh; +Cc: 56662

> From: Visuwesh <visuweshm@gmail.com>
> Date: Wed, 20 Jul 2022 17:05:11 +0530
> 
>     1. emacs -Q
>     2. Visit a longish file.
>     3. C-x 3 and scroll up in any of the window.
>     4. M-: (setq highlight-nonselected-windows t) RET.
>     5. Create an active region and compare the highlighting.

What is wrong with this behavior?  In each window the region between
the mark and point is highlighted, as you requested by turning on that
option.

What am I missing?





^ permalink raw reply	[flat|nested] 21+ messages in thread

* bug#56662: 29.0.50; Funny region highlights when highlight-nonselected-windows is t
  2022-07-20 12:38 ` Eli Zaretskii
@ 2022-07-20 12:43   ` Visuwesh
  2022-07-20 12:48     ` Eli Zaretskii
  0 siblings, 1 reply; 21+ messages in thread
From: Visuwesh @ 2022-07-20 12:43 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 56662

[புதன் ஜூலை 20, 2022] Eli Zaretskii wrote:

>> From: Visuwesh <visuweshm@gmail.com>
>> Date: Wed, 20 Jul 2022 17:05:11 +0530
>> 
>>     1. emacs -Q
>>     2. Visit a longish file.
>>     3. C-x 3 and scroll up in any of the window.
>>     4. M-: (setq highlight-nonselected-windows t) RET.
>>     5. Create an active region and compare the highlighting.
>
> What is wrong with this behavior?  In each window the region between
> the mark and point is highlighted, as you requested by turning on that
> option.
>
> What am I missing?

Since the point is local to the window, it felt natural that the region
would be too.  But since the region simply highlights the text between
the point and the mark, the current behaviour is not strange indeed.  I
guess there's nothing to do here and this bug can be closed?





^ permalink raw reply	[flat|nested] 21+ messages in thread

* bug#56662: 29.0.50; Funny region highlights when highlight-nonselected-windows is t
  2022-07-20 12:43   ` Visuwesh
@ 2022-07-20 12:48     ` Eli Zaretskii
  2022-07-20 20:16       ` Kévin Le Gouguec
  0 siblings, 1 reply; 21+ messages in thread
From: Eli Zaretskii @ 2022-07-20 12:48 UTC (permalink / raw)
  To: Visuwesh; +Cc: 56662

> From: Visuwesh <visuweshm@gmail.com>
> Cc: 56662@debbugs.gnu.org
> Date: Wed, 20 Jul 2022 18:13:16 +0530
> 
> [புதன் ஜூலை 20, 2022] Eli Zaretskii wrote:
> 
> >> From: Visuwesh <visuweshm@gmail.com>
> >> Date: Wed, 20 Jul 2022 17:05:11 +0530
> >> 
> >>     1. emacs -Q
> >>     2. Visit a longish file.
> >>     3. C-x 3 and scroll up in any of the window.
> >>     4. M-: (setq highlight-nonselected-windows t) RET.
> >>     5. Create an active region and compare the highlighting.
> >
> > What is wrong with this behavior?  In each window the region between
> > the mark and point is highlighted, as you requested by turning on that
> > option.
> >
> > What am I missing?
> 
> Since the point is local to the window, it felt natural that the region
> would be too.

And it is.  But the mark originally is the same.  If you switch to the
other window and set its mark in a different place, you will have
completely separate and independent highlighting.

> But since the region simply highlights the text between the point
> and the mark, the current behaviour is not strange indeed.  I guess
> there's nothing to do here and this bug can be closed?

Yes, I think this is the intended behavior.





^ permalink raw reply	[flat|nested] 21+ messages in thread

* bug#56662: 29.0.50; Funny region highlights when highlight-nonselected-windows is t
  2022-07-20 11:35 bug#56662: 29.0.50; Funny region highlights when highlight-nonselected-windows is t Visuwesh
  2022-07-20 12:38 ` Eli Zaretskii
@ 2022-07-20 18:05 ` Juri Linkov
  1 sibling, 0 replies; 21+ messages in thread
From: Juri Linkov @ 2022-07-20 18:05 UTC (permalink / raw)
  To: Visuwesh; +Cc: 56662

> If two windows show a single buffer, then the region highlighting is
> strange in the non-selected window.  It is not hard to reproduce,
>
>     1. emacs -Q
>     2. Visit a longish file.
>     3. C-x 3 and scroll up in any of the window.
>     4. M-: (setq highlight-nonselected-windows t) RET.
>     5. Create an active region and compare the highlighting.

This is a long-standing problem.  I used to use a workaround:
https://lists.gnu.org/archive/html/emacs-devel/2018-09/msg00716.html
But it doesn't work correctly anymore.  Then tried to use advice since
can't use deactivate-mark-hook because when clicking mouse in another window
with the same buffer it calls both activate-mark and deactivate-mark,
but deactivate-mark checks if the region is active (region-active-p),
and doesn't advance further because mark-active was set to nil in the
redisplay hook below.  OTOH, the advice is used unconditionally.

#+begin_src emacs-lisp
(defvar-local mark-active-window nil)

(advice-add 'activate-mark :after
            (lambda (&rest _args)
              (setq mark-active-window (selected-window)))
            '((name . mark-active-window)))

(advice-add 'deactivate-mark :after
            (lambda (&rest _args)
              (setq mark-active-window nil))
            '((name . mark-active-window)))

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

(add-hook 'pre-redisplay-functions #'redisplay--update-mark-active-window)
#+end_src

But still a problem: when compiled without optimization CFLAGS='-O0' then
quick region selection experiences lags that results in wrong selection.
Another problem is that in ‘follow-mode’ ‘set-mark-command’ messes up windows.





^ permalink raw reply	[flat|nested] 21+ messages in thread

* bug#56662: 29.0.50; Funny region highlights when highlight-nonselected-windows is t
  2022-07-20 12:48     ` Eli Zaretskii
@ 2022-07-20 20:16       ` Kévin Le Gouguec
  2022-07-21  6:22         ` Eli Zaretskii
  0 siblings, 1 reply; 21+ messages in thread
From: Kévin Le Gouguec @ 2022-07-20 20:16 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 56662, Visuwesh

Eli Zaretskii <eliz@gnu.org> writes:

>> >> From: Visuwesh <visuweshm@gmail.com>
>> >> Date: Wed, 20 Jul 2022 17:05:11 +0530
>> >> 
>> >>     1. emacs -Q
>> >>     2. Visit a longish file.
>> >>     3. C-x 3 and scroll up in any of the window.
>> >>     4. M-: (setq highlight-nonselected-windows t) RET.
>> >>     5. Create an active region and compare the highlighting.
>> >
>> > What is wrong with this behavior?  In each window the region between
>> > the mark and point is highlighted, as you requested by turning on that
>> > option.
>> >
>> > What am I missing?
>> 
>> Since the point is local to the window, it felt natural that the region
>> would be too.
>
> And it is.  But the mark originally is the same.  If you switch to the
> other window and set its mark in a different place, you will have
> completely separate and independent highlighting.

Mm.  I was very interested in your answer because a big pet peeve of
mine is not being able to activate a region in window-1, move to
window-2 showing another portion of the same buffer, and work on that
second portion while stealing glances at what I highlighted in window-1.

Now I see that if I hit C-SPC in window-2 I can indeed change the
highlighting in that window while keeping the highlighting in window-1
untouched, however…

(1) Haven't been able to find a reproducible recipe, but on occasion,
    when hitting C-SPC in window-2, the highlighting in window-1
    sometimes "snaps" and updates to match the mark I just set in
    window-2.

(2) AFAICT I have to keep a region activated in window-2 for window-1 to
    retain its highlighting.

    For the use-case described above though, the first thing I do when
    moving to window-2 is C-g to deactivate the region, and AFAICT that
    deactivates the highlighting in window-2.

    I kind of wish there was a third value for this user option;
    e.g. (setq highlight-nonselected-windows 'lazy) to signify "keep
    highlighting as-is when leaving the window, and never update it
    until the window becomes current again"? 🤷

    Not sure how well-defined that proposal is though (e.g. what should
    happen when part of the highlighted region is erased); and I have no
    idea how much work it would be to actually implement that.

If any of (2) makes sense, could this bug remain open as a wishlist
item?  It's a bit frustrating to (a) highlight part of a window I want
to glance at for reference (b) move to another window to work on another
location (c) lose the highlighting because that location "just happens"
to be in the same buffer.





^ permalink raw reply	[flat|nested] 21+ messages in thread

* bug#56662: 29.0.50; Funny region highlights when highlight-nonselected-windows is t
  2022-07-20 20:16       ` Kévin Le Gouguec
@ 2022-07-21  6:22         ` Eli Zaretskii
  2022-07-21 11:22           ` Visuwesh
  0 siblings, 1 reply; 21+ messages in thread
From: Eli Zaretskii @ 2022-07-21  6:22 UTC (permalink / raw)
  To: Kévin Le Gouguec; +Cc: 56662, visuweshm

> From: Kévin Le Gouguec <kevin.legouguec@gmail.com>
> Cc: Visuwesh <visuweshm@gmail.com>,  56662@debbugs.gnu.org
> Date: Wed, 20 Jul 2022 22:16:26 +0200
> 
> (1) Haven't been able to find a reproducible recipe, but on occasion,
>     when hitting C-SPC in window-2, the highlighting in window-1
>     sometimes "snaps" and updates to match the mark I just set in
>     window-2.

Probably because you did something that deactivated the mark there.
It's very easy to deactivate the mark.  Which is why this feature is
only good for very short periods of time, and shouldn't be expected to
DTRT in any scenario except temporarily having more than one window
with highlight -- unless you never display the same buffer in several
windows.

>     I kind of wish there was a third value for this user option;
>     e.g. (setq highlight-nonselected-windows 'lazy) to signify "keep
>     highlighting as-is when leaving the window, and never update it
>     until the window becomes current again"? 🤷

How would that work, if you take into consideration that the region is
between the mark and point?

And again, are you talking about the same buffer displayed in several
windows, or are you talking about different buffers?  For the latter
case, I think the problems you describe don't exist.

> If any of (2) makes sense, could this bug remain open as a wishlist
> item?

I don't see how it could work, but maybe I'm missing something.

In any case, does someone volunteer to work on this?  Because if not,
we'll just have another bug report that is open forever.





^ permalink raw reply	[flat|nested] 21+ messages in thread

* bug#56662: 29.0.50; Funny region highlights when highlight-nonselected-windows is t
  2022-07-21  6:22         ` Eli Zaretskii
@ 2022-07-21 11:22           ` Visuwesh
  2022-07-21 12:19             ` Eli Zaretskii
  2022-07-23  7:08             ` Lars Ingebrigtsen
  0 siblings, 2 replies; 21+ messages in thread
From: Visuwesh @ 2022-07-21 11:22 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 56662, Kévin Le Gouguec

[வியாழன் ஜூலை 21, 2022] Eli Zaretskii wrote:

>>     I kind of wish there was a third value for this user option;
>>     e.g. (setq highlight-nonselected-windows 'lazy) to signify "keep
>>     highlighting as-is when leaving the window, and never update it
>>     until the window becomes current again"? 🤷
>
> How would that work, if you take into consideration that the region is
> between the mark and point?

I can think of one way this could potentially work is by checking if the
mark was made when window was active so making the mark "window-aware"?
I.e., if two windows A and B show the same buffer and the user typed
C-SPC when in window A, then the region would not show up in window B.
Does this make sense?  But I'm not sure if this heuristic will work at
all times as it bends the notion of "active region" way too much.

> In any case, does someone volunteer to work on this?  Because if not,
> we'll just have another bug report that is open forever.

I have no problems closing this but I will let the others speak before I
do.  





^ permalink raw reply	[flat|nested] 21+ messages in thread

* bug#56662: 29.0.50; Funny region highlights when highlight-nonselected-windows is t
  2022-07-21 11:22           ` Visuwesh
@ 2022-07-21 12:19             ` Eli Zaretskii
  2022-07-21 12:32               ` Visuwesh
  2022-07-23  7:08             ` Lars Ingebrigtsen
  1 sibling, 1 reply; 21+ messages in thread
From: Eli Zaretskii @ 2022-07-21 12:19 UTC (permalink / raw)
  To: Visuwesh; +Cc: 56662, kevin.legouguec

> From: Visuwesh <visuweshm@gmail.com>
> Cc: Kévin Le Gouguec <kevin.legouguec@gmail.com>,
>   56662@debbugs.gnu.org
> Date: Thu, 21 Jul 2022 16:52:06 +0530
> 
> [வியாழன் ஜூலை 21, 2022] Eli Zaretskii wrote:
> 
> >>     I kind of wish there was a third value for this user option;
> >>     e.g. (setq highlight-nonselected-windows 'lazy) to signify "keep
> >>     highlighting as-is when leaving the window, and never update it
> >>     until the window becomes current again"? 🤷
> >
> > How would that work, if you take into consideration that the region is
> > between the mark and point?
> 
> I can think of one way this could potentially work is by checking if the
> mark was made when window was active so making the mark "window-aware"?
> I.e., if two windows A and B show the same buffer and the user typed
> C-SPC when in window A, then the region would not show up in window B.
> Does this make sense?

So what happens if the user then types "C-x o" to switch to B?





^ permalink raw reply	[flat|nested] 21+ messages in thread

* bug#56662: 29.0.50; Funny region highlights when highlight-nonselected-windows is t
  2022-07-21 12:19             ` Eli Zaretskii
@ 2022-07-21 12:32               ` Visuwesh
  2022-07-21 12:39                 ` Eli Zaretskii
  0 siblings, 1 reply; 21+ messages in thread
From: Visuwesh @ 2022-07-21 12:32 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 56662, kevin.legouguec

[வியாழன் ஜூலை 21, 2022] Eli Zaretskii wrote:

>> From: Visuwesh <visuweshm@gmail.com>
>> Cc: Kévin Le Gouguec <kevin.legouguec@gmail.com>,
>>   56662@debbugs.gnu.org
>> Date: Thu, 21 Jul 2022 16:52:06 +0530
>> 
>> [வியாழன் ஜூலை 21, 2022] Eli Zaretskii wrote:
>> 
>> >>     I kind of wish there was a third value for this user option;
>> >>     e.g. (setq highlight-nonselected-windows 'lazy) to signify "keep
>> >>     highlighting as-is when leaving the window, and never update it
>> >>     until the window becomes current again"? 🤷
>> >
>> > How would that work, if you take into consideration that the region is
>> > between the mark and point?
>> 
>> I can think of one way this could potentially work is by checking if the
>> mark was made when window was active so making the mark "window-aware"?
>> I.e., if two windows A and B show the same buffer and the user typed
>> C-SPC when in window A, then the region would not show up in window B.
>> Does this make sense?
>
> So what happens if the user then types "C-x o" to switch to B?

Ideally, nothing.  Only the active window changes but the region
highlighting before and after should be the same.  Here's another
question: what about delete-selection-mode when the active window is B?
I think there is no satisfactory answer in this area and this bug should
be simply closed (but I'm interested to see an answer though).





^ permalink raw reply	[flat|nested] 21+ messages in thread

* bug#56662: 29.0.50; Funny region highlights when highlight-nonselected-windows is t
  2022-07-21 12:32               ` Visuwesh
@ 2022-07-21 12:39                 ` Eli Zaretskii
  2022-07-21 14:35                   ` Visuwesh
  0 siblings, 1 reply; 21+ messages in thread
From: Eli Zaretskii @ 2022-07-21 12:39 UTC (permalink / raw)
  To: Visuwesh; +Cc: 56662, kevin.legouguec

> From: Visuwesh <visuweshm@gmail.com>
> Cc: 56662@debbugs.gnu.org,  kevin.legouguec@gmail.com
> Date: Thu, 21 Jul 2022 18:02:32 +0530
> 
> >> I can think of one way this could potentially work is by checking if the
> >> mark was made when window was active so making the mark "window-aware"?
> >> I.e., if two windows A and B show the same buffer and the user typed
> >> C-SPC when in window A, then the region would not show up in window B.
> >> Does this make sense?
> >
> > So what happens if the user then types "C-x o" to switch to B?
> 
> Ideally, nothing.  Only the active window changes but the region
> highlighting before and after should be the same.

But that's a bug: region highlighting should definitely work in a
selected window.

> Here's another question: what about delete-selection-mode when the
> active window is B?

What about it?





^ permalink raw reply	[flat|nested] 21+ messages in thread

* bug#56662: 29.0.50; Funny region highlights when highlight-nonselected-windows is t
  2022-07-21 12:39                 ` Eli Zaretskii
@ 2022-07-21 14:35                   ` Visuwesh
  2022-07-21 15:54                     ` Eli Zaretskii
  0 siblings, 1 reply; 21+ messages in thread
From: Visuwesh @ 2022-07-21 14:35 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 56662, kevin.legouguec

[வியாழன் ஜூலை 21, 2022] Eli Zaretskii wrote:

>> >> I can think of one way this could potentially work is by checking if the
>> >> mark was made when window was active so making the mark "window-aware"?
>> >> I.e., if two windows A and B show the same buffer and the user typed
>> >> C-SPC when in window A, then the region would not show up in window B.
>> >> Does this make sense?
>> >
>> > So what happens if the user then types "C-x o" to switch to B?
>> 
>> Ideally, nothing.  Only the active window changes but the region
>> highlighting before and after should be the same.
>
> But that's a bug: region highlighting should definitely work in a
> selected window.
>

It won't be a bug if the region is considered window-local.
"Window-local" because the region was made when in window A and so its
"active"-ness is confined to window A.

>> Here's another question: what about delete-selection-mode when the
>> active window is B?
>
> What about it?

If we were to make the region window-local, then should
delete-selection-mode delete the region when in window B?





^ permalink raw reply	[flat|nested] 21+ messages in thread

* bug#56662: 29.0.50; Funny region highlights when highlight-nonselected-windows is t
  2022-07-21 14:35                   ` Visuwesh
@ 2022-07-21 15:54                     ` Eli Zaretskii
  2022-07-21 16:13                       ` Visuwesh
  0 siblings, 1 reply; 21+ messages in thread
From: Eli Zaretskii @ 2022-07-21 15:54 UTC (permalink / raw)
  To: Visuwesh; +Cc: 56662, kevin.legouguec

> From: Visuwesh <visuweshm@gmail.com>
> Cc: 56662@debbugs.gnu.org,  kevin.legouguec@gmail.com
> Date: Thu, 21 Jul 2022 20:05:58 +0530
> 
> >> > So what happens if the user then types "C-x o" to switch to B?
> >> 
> >> Ideally, nothing.  Only the active window changes but the region
> >> highlighting before and after should be the same.
> >
> > But that's a bug: region highlighting should definitely work in a
> > selected window.
> >
> 
> It won't be a bug if the region is considered window-local.

That's what the default already does, doesn't it?

> "Window-local" because the region was made when in window A and so its
> "active"-ness is confined to window A.
> 
> >> Here's another question: what about delete-selection-mode when the
> >> active window is B?
> >
> > What about it?
> 
> If we were to make the region window-local, then should
> delete-selection-mode delete the region when in window B?

If it's highlighted, yes.





^ permalink raw reply	[flat|nested] 21+ messages in thread

* bug#56662: 29.0.50; Funny region highlights when highlight-nonselected-windows is t
  2022-07-21 15:54                     ` Eli Zaretskii
@ 2022-07-21 16:13                       ` Visuwesh
  2022-07-21 16:34                         ` Eli Zaretskii
  0 siblings, 1 reply; 21+ messages in thread
From: Visuwesh @ 2022-07-21 16:13 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 56662, kevin.legouguec

[வியாழன் ஜூலை 21, 2022] Eli Zaretskii wrote:

>> > But that's a bug: region highlighting should definitely work in a
>> > selected window.
>>
>> It won't be a bug if the region is considered window-local.
>
> That's what the default already does, doesn't it?
>

No?  If I deactivate the mark in window A, it deactivates the mark in
window B too.





^ permalink raw reply	[flat|nested] 21+ messages in thread

* bug#56662: 29.0.50; Funny region highlights when highlight-nonselected-windows is t
  2022-07-21 16:13                       ` Visuwesh
@ 2022-07-21 16:34                         ` Eli Zaretskii
  2022-07-21 17:00                           ` Visuwesh
  0 siblings, 1 reply; 21+ messages in thread
From: Eli Zaretskii @ 2022-07-21 16:34 UTC (permalink / raw)
  To: Visuwesh; +Cc: 56662, kevin.legouguec

> From: Visuwesh <visuweshm@gmail.com>
> Cc: 56662@debbugs.gnu.org,  kevin.legouguec@gmail.com
> Date: Thu, 21 Jul 2022 21:43:28 +0530
> 
> [வியாழன் ஜூலை 21, 2022] Eli Zaretskii wrote:
> 
> >> > But that's a bug: region highlighting should definitely work in a
> >> > selected window.
> >>
> >> It won't be a bug if the region is considered window-local.
> >
> > That's what the default already does, doesn't it?
> >
> 
> No?  If I deactivate the mark in window A, it deactivates the mark in
> window B too.

If you deactivate the mark, there's no region, so I'm not sure why
you want to see highlighting in that case.

Are we talking about the Emacs region highlighting, or are we talking
about some other highlighting?  As the manual explains, the Emacs
selection highlighting is different from other applications in several
important ways.





^ permalink raw reply	[flat|nested] 21+ messages in thread

* bug#56662: 29.0.50; Funny region highlights when highlight-nonselected-windows is t
  2022-07-21 16:34                         ` Eli Zaretskii
@ 2022-07-21 17:00                           ` Visuwesh
  2022-07-21 22:14                             ` Kévin Le Gouguec
  2022-07-23  7:09                             ` Lars Ingebrigtsen
  0 siblings, 2 replies; 21+ messages in thread
From: Visuwesh @ 2022-07-21 17:00 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 56662, kevin.legouguec

close 56662
thanks

[வியாழன் ஜூலை 21, 2022] Eli Zaretskii wrote:

>> From: Visuwesh <visuweshm@gmail.com>
>> Cc: 56662@debbugs.gnu.org,  kevin.legouguec@gmail.com
>> Date: Thu, 21 Jul 2022 21:43:28 +0530
>> 
>> [வியாழன் ஜூலை 21, 2022] Eli Zaretskii wrote:
>> 
>> >> > But that's a bug: region highlighting should definitely work in a
>> >> > selected window.
>> >>
>> >> It won't be a bug if the region is considered window-local.
>> >
>> > That's what the default already does, doesn't it?
>> >
>> 
>> No?  If I deactivate the mark in window A, it deactivates the mark in
>> window B too.
>
> If you deactivate the mark, there's no region, so I'm not sure why
> you want to see highlighting in that case.
>

OK, I see the full picture now, now that I re-read your reply to Kevin.
If you change the mark in window B, then the region highlighting will be
different from that of window A.  But currently there's no way to make
window A highlight the region whilst having no region highlight in
window B unless the point and the mark is the same in window B.  I hope
I am right.  I think this is what Kevin (and I) want IIUC.

> Are we talking about the Emacs region highlighting, or are we talking
> about some other highlighting?  As the manual explains, the Emacs
> selection highlighting is different from other applications in several
> important ways.

We are talking about Emacs region highlighting, and yes I do understand
the difference between Emacs and other applications.

In any case, I don't think there's any reasonable action we can take.
"Active region" is already bending Emacs quite a bit, the current
scenario seems to break the camel's hump in unexpected ways (altho
there's always a reason to explain the behaviour).  Closing the bug
report.





^ permalink raw reply	[flat|nested] 21+ messages in thread

* bug#56662: 29.0.50; Funny region highlights when highlight-nonselected-windows is t
  2022-07-21 17:00                           ` Visuwesh
@ 2022-07-21 22:14                             ` Kévin Le Gouguec
  2022-07-24 16:41                               ` Juri Linkov
  2022-07-23  7:09                             ` Lars Ingebrigtsen
  1 sibling, 1 reply; 21+ messages in thread
From: Kévin Le Gouguec @ 2022-07-21 22:14 UTC (permalink / raw)
  To: Visuwesh; +Cc: Eli Zaretskii, 56662

Visuwesh <visuweshm@gmail.com> writes:

>> If you deactivate the mark, there's no region, so I'm not sure why
>> you want to see highlighting in that case.
>
> OK, I see the full picture now, now that I re-read your reply to Kevin.
> If you change the mark in window B, then the region highlighting will be
> different from that of window A.  But currently there's no way to make
> window A highlight the region whilst having no region highlight in
> window B unless the point and the mark is the same in window B.  I hope
> I am right.  I think this is what Kevin (and I) want IIUC.

Right.  Paraphrasing my message, I like to keep useful snippets
highlighted in one window while working in another; it's frustrating to
have this break down just because both windows happen to display the
same buffer.

>> Are we talking about the Emacs region highlighting, or are we talking
>> about some other highlighting?  As the manual explains, the Emacs
>> selection highlighting is different from other applications in several
>> important ways.
>
> We are talking about Emacs region highlighting, and yes I do understand
> the difference between Emacs and other applications.
>
> In any case, I don't think there's any reasonable action we can take.
> "Active region" is already bending Emacs quite a bit, the current
> scenario seems to break the camel's hump in unexpected ways (altho
> there's always a reason to explain the behaviour).  Closing the bug
> report.

That's fair.  My argument for keeping it open would be that people who
would be able and willing to scratch that itch in the future might not
think to search for closed reports; but then again I suppose there's not
a lot of information in our present discussion that they wouldn't be
able to rediscover on their own.

Thanks for reporting this nonetheless; if anything, seeing someone else
bothered by the current behaviour was mildly cathartic.





^ permalink raw reply	[flat|nested] 21+ messages in thread

* bug#56662: 29.0.50; Funny region highlights when highlight-nonselected-windows is t
  2022-07-21 11:22           ` Visuwesh
  2022-07-21 12:19             ` Eli Zaretskii
@ 2022-07-23  7:08             ` Lars Ingebrigtsen
  1 sibling, 0 replies; 21+ messages in thread
From: Lars Ingebrigtsen @ 2022-07-23  7:08 UTC (permalink / raw)
  To: Visuwesh; +Cc: Eli Zaretskii, 56662, Kévin Le Gouguec

Visuwesh <visuweshm@gmail.com> writes:

> I can think of one way this could potentially work is by checking if the
> mark was made when window was active so making the mark "window-aware"?
> I.e., if two windows A and B show the same buffer and the user typed
> C-SPC when in window A, then the region would not show up in window B.
> Does this make sense?  But I'm not sure if this heuristic will work at
> all times as it bends the notion of "active region" way too much.

I think what you're asking for here is really to make the mark a window
entity instead of a buffer thing.  (The point can be specified per
window, but the mark can't.)

I think that sounds like an interesting feature (and would allow having
different highlighted regions in different windows displaying the same
buffer), but sounds like it would be very backwards-incompatible.

I've also been annoyed by how showing the same buffer in two windows
isn't more...  "separate".  When editing two different sections of the
same buffer at the same time, it's really easy to get pretty confused
(especially when jumping to the mark with `C-x C-x').






^ permalink raw reply	[flat|nested] 21+ messages in thread

* bug#56662: 29.0.50; Funny region highlights when highlight-nonselected-windows is t
  2022-07-21 17:00                           ` Visuwesh
  2022-07-21 22:14                             ` Kévin Le Gouguec
@ 2022-07-23  7:09                             ` Lars Ingebrigtsen
  1 sibling, 0 replies; 21+ messages in thread
From: Lars Ingebrigtsen @ 2022-07-23  7:09 UTC (permalink / raw)
  To: Visuwesh; +Cc: Eli Zaretskii, 56662, kevin.legouguec

Visuwesh <visuweshm@gmail.com> writes:

> In any case, I don't think there's any reasonable action we can take.
> "Active region" is already bending Emacs quite a bit, the current
> scenario seems to break the camel's hump in unexpected ways (altho
> there's always a reason to explain the behaviour).  Closing the bug
> report.

It seems like the "close" didn't take according to debbugs?  So I'm
closing the bug for real now.






^ permalink raw reply	[flat|nested] 21+ messages in thread

* bug#56662: 29.0.50; Funny region highlights when highlight-nonselected-windows is t
  2022-07-21 22:14                             ` Kévin Le Gouguec
@ 2022-07-24 16:41                               ` Juri Linkov
  2022-07-24 17:32                                 ` Eli Zaretskii
  0 siblings, 1 reply; 21+ messages in thread
From: Juri Linkov @ 2022-07-24 16:41 UTC (permalink / raw)
  To: Kévin Le Gouguec; +Cc: Eli Zaretskii, 56662, Visuwesh

>> In any case, I don't think there's any reasonable action we can take.
>> "Active region" is already bending Emacs quite a bit, the current
>> scenario seems to break the camel's hump in unexpected ways (altho
>> there's always a reason to explain the behaviour).  Closing the bug
>> report.
>
> That's fair.  My argument for keeping it open would be that people who
> would be able and willing to scratch that itch in the future might not
> think to search for closed reports; but then again I suppose there's not
> a lot of information in our present discussion that they wouldn't be
> able to rediscover on their own.

It's very easy to make region highlighting window-local with just

diff --git a/lisp/simple.el b/lisp/simple.el
index 5443d961e1..04002073bd 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -6944,7 +6944,7 @@ redisplay--update-region-highlight
                            (eq window (minibuffer-selected-window))))))
         (funcall redisplay-unhighlight-region-function rol)
       (let* ((pt (window-point window))
-             (mark (mark))
+             (mark (or (window-parameter window 'mark) (mark)))
              (start (min pt mark))
              (end   (max pt mark))
              (new

Then the main task would be to find the right logic of setting
the window-local mark.  Since this feature request is closed,
here is a possible starting point for anyone who wants to experiment
with the prototype trying different use cases:

  (add-hook 'activate-mark-hook
            (lambda () (set-window-parameter nil 'mark (mark))))
  (add-hook 'deactivate-mark-hook
            (lambda () (set-window-parameter nil 'mark nil)))
  (add-hook 'window-selection-change-functions
            (lambda (window)
              (when (eq window (selected-window))
                (set-marker (mark-marker) (window-parameter window 'mark)))))





^ permalink raw reply related	[flat|nested] 21+ messages in thread

* bug#56662: 29.0.50; Funny region highlights when highlight-nonselected-windows is t
  2022-07-24 16:41                               ` Juri Linkov
@ 2022-07-24 17:32                                 ` Eli Zaretskii
  0 siblings, 0 replies; 21+ messages in thread
From: Eli Zaretskii @ 2022-07-24 17:32 UTC (permalink / raw)
  To: Juri Linkov; +Cc: visuweshm, 56662, kevin.legouguec

> From: Juri Linkov <juri@linkov.net>
> Cc: Visuwesh <visuweshm@gmail.com>,  Eli Zaretskii <eliz@gnu.org>,
>   56662@debbugs.gnu.org
> Date: Sun, 24 Jul 2022 19:41:20 +0300
> 
> It's very easy to make region highlighting window-local with just
> 
> diff --git a/lisp/simple.el b/lisp/simple.el
> index 5443d961e1..04002073bd 100644
> --- a/lisp/simple.el
> +++ b/lisp/simple.el
> @@ -6944,7 +6944,7 @@ redisplay--update-region-highlight
>                             (eq window (minibuffer-selected-window))))))
>          (funcall redisplay-unhighlight-region-function rol)
>        (let* ((pt (window-point window))
> -             (mark (mark))
> +             (mark (or (window-parameter window 'mark) (mark)))
>               (start (min pt mark))
>               (end   (max pt mark))
>               (new
> 
> Then the main task would be to find the right logic of setting
> the window-local mark.  Since this feature request is closed,
> here is a possible starting point for anyone who wants to experiment
> with the prototype trying different use cases:
> 
>   (add-hook 'activate-mark-hook
>             (lambda () (set-window-parameter nil 'mark (mark))))
>   (add-hook 'deactivate-mark-hook
>             (lambda () (set-window-parameter nil 'mark nil)))
>   (add-hook 'window-selection-change-functions
>             (lambda (window)
>               (when (eq window (selected-window))
>                 (set-marker (mark-marker) (window-parameter window 'mark)))))
> 

Don't forget that this must only happen if
highlight-nonselected-windows is non-nil.





^ permalink raw reply	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2022-07-24 17:32 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-20 11:35 bug#56662: 29.0.50; Funny region highlights when highlight-nonselected-windows is t Visuwesh
2022-07-20 12:38 ` Eli Zaretskii
2022-07-20 12:43   ` Visuwesh
2022-07-20 12:48     ` Eli Zaretskii
2022-07-20 20:16       ` Kévin Le Gouguec
2022-07-21  6:22         ` Eli Zaretskii
2022-07-21 11:22           ` Visuwesh
2022-07-21 12:19             ` Eli Zaretskii
2022-07-21 12:32               ` Visuwesh
2022-07-21 12:39                 ` Eli Zaretskii
2022-07-21 14:35                   ` Visuwesh
2022-07-21 15:54                     ` Eli Zaretskii
2022-07-21 16:13                       ` Visuwesh
2022-07-21 16:34                         ` Eli Zaretskii
2022-07-21 17:00                           ` Visuwesh
2022-07-21 22:14                             ` Kévin Le Gouguec
2022-07-24 16:41                               ` Juri Linkov
2022-07-24 17:32                                 ` Eli Zaretskii
2022-07-23  7:09                             ` Lars Ingebrigtsen
2022-07-23  7:08             ` Lars Ingebrigtsen
2022-07-20 18:05 ` Juri Linkov

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).