all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Juri Linkov <juri@linkov.net>
To: Alan Mackenzie <acm@muc.de>
Cc: 17453@debbugs.gnu.org
Subject: bug#17453: Framework extending window functions for Follow Mode (etc.).
Date: Tue, 10 Nov 2015 02:51:41 +0200	[thread overview]
Message-ID: <87611a8x96.fsf@mail.linkov.net> (raw)
In-Reply-To: <20151109154124.GC2284@acm.fritz.box> (Alan Mackenzie's message of "Mon, 9 Nov 2015 15:41:24 +0000")

>> I tried to not use isearch-string-out-of-window/isearch-back-into-window
>> at all, but I can't get a useful behavior in such situation of scrolling
>> out of the window with the current search hit.  Could you show how you see
>> it should work in this case in follow-mode?
>
> To start with, set
>
>   (global-set-key [next] 'follow-scroll-up)
>   (global-set-key [prior] 'follow-scroll-down)
>   (setq isearch-allow-scroll t)
>
> .  Then start an Isearch not too close to the start of a buffer with
> Follow Mode enabled with at least two windows.  Type something to get a
> search match highlighted.  Now <PageUp> and <PageDown> should scroll that
> match between Follow Mode windows, the boundaries of that scrolling being
> the top of the LH window and the bottom of the RH window.
>
> To make this work properly, the four variables in
> isearch-string-out-of-window, w-start, w-end, w-L1, w-L-1, are set to the
> positions in the entire group of windows, by setting the proposed
> &optional argument GROUP to t in the calls to certain window functions,
> e.g.
>
>      (let ((w-start (window-start nil t))
>                                       ^

Could you provide the shortest patch to test the behavior that you describe?
For now I tried the following, is this what you want to generalise with
a new framework?

diff --git a/lisp/isearch.el b/lisp/isearch.el
index b762884..3b61505 100644
--- a/lisp/isearch.el
+++ b/lisp/isearch.el
@@ -2237,10 +2237,19 @@ (defun isearch-string-out-of-window (isearch-point)
 together with as much of the search string as will fit; the symbol
 `above' if we need to scroll the text downwards; the symbol `below',
 if upwards."
-  (let ((w-start (window-start))
-        (w-end (window-end nil t))
-        (w-L1 (save-excursion (move-to-window-line 1) (point)))
-        (w-L-1 (save-excursion (move-to-window-line -1) (point)))
+  (let ((w-start (window-start (and (fboundp 'follow-all-followers)
+                                    (car (follow-all-followers)))))
+        (w-end (window-end (and (fboundp 'follow-all-followers)
+                                (car (last (follow-all-followers))))
+                           t))
+        (w-L1 (save-excursion
+                (when (fboundp 'follow-all-followers)
+                  (select-window (car (follow-all-followers))))
+                (move-to-window-line 1) (point)))
+        (w-L-1 (save-excursion
+                 (when (fboundp 'follow-all-followers)
+                   (select-window (car (last (follow-all-followers)))))
+                 (move-to-window-line -1) (point)))
         start end)                  ; start and end of search string in buffer
     (if isearch-forward
         (setq end isearch-point  start (or isearch-other-end isearch-point))

>> The problem is that you are trying to design a new framework,
>> but not demonstrated yet how it would be useful generally in cases
>> other than a specific combination of isearch/follow-mode.
>
> Any elisp software which manipulates windows will be able to work better
> by considering entire FM groups.  I did some grepping: here are some
> examples which the new framework could improve:
>
> `kill-ring-save' should blink the cursor on the matching other-end, if
> that is visible.  With FM active, and other end being in a different
> window, currently it wrongly outputs a message instead.
>
> `window-screen-lines' could be enhanced (optionally) to return the number
> of screen lines in the entire group.
>
> `blink-matching-open' could be enhanced to handle FM windows properly.
>
> `ns-scroll-bar-move' (probably) should `set-window-start' for the entire
> window group.  This (might) avoid scrolling such that the RH follow
> window is displaying empty space.
>
>
> One point about this new framework is that it is "harmless" in the sense
> that anything which worked (or failed to work) prior to it will continue
> unchanged unless specifically amended.  It's disadvantage is that it adds
> a little to the bulk of things people need to know or to look up in
> manuals.
>
> I think Follow Mode should become easier to use, both for users and for
> hackers, especially given that wide screens (>200 characters) are now the
> norm rather than the exception.  At the moment Follow Mode is
> ridiculously difficult to start (manually splitting windows, doing M-x
> follow-mode) and even more difficult to hack for - just what interfaces
> are currently available for making a package work with FM?  Answer: none
> at all.  This new framework is intended to go some way to closing the
> gap.
>
> The alternative to a framework is a bugfix which is specific to Isearch.
> Even this would require some sort of interface definition and
> abstraction.  At a minimum, for "part 3" of the bug, Isearch would need
> somehow to obtain the bounds of the group of windows.
>
> The last alternative is a quick and dirty fix where Isearch would just
> call Follow Mode functions.  I don't think anybody really wants this.
>
> Would it help if I actually made the source available?  If so, where?  I
> don't really think it would be appropriate to dump a patch of this size
> on emacs-devel, and the time to commit the changes to master has clearly
> not yet arrived.

You are trying to do everything at once.  To successfully achieve your goals
it would be much more clear for us to see the progress step by step, i.e.
if at first you demonstrated how to fix the co-operation between Isearch and
Follow Mode by a quick and dirty fix like in the patch above then we could see
how well your fixes work, and also what places need generalisation,
and how your new framework would be useful here and for other packages
that might benefit from it.  By such inductive method we could quickly
arrive to a conclusion without much friction.





  reply	other threads:[~2015-11-10  0:51 UTC|newest]

Thread overview: 57+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-05 19:29 Framework extending window functions for Follow Mode (etc.) Alan Mackenzie
2015-11-05 19:36 ` John Wiegley
2015-11-05 20:00   ` Alan Mackenzie
2015-11-07 13:07 ` Alan Mackenzie
2015-11-09 22:30   ` John Wiegley
2015-11-10 11:27     ` Alan Mackenzie
2015-11-10 13:13     ` Alan Mackenzie
2015-11-10 15:20       ` John Wiegley
2015-11-10 22:29       ` John Wiegley
2015-11-11  0:30         ` Alan Mackenzie
2015-11-11  0:34           ` John Wiegley
2015-11-11 16:15             ` Alan Mackenzie
2015-11-11 16:50               ` John Wiegley
2015-11-11 17:15                 ` Comms and building Emacs. [Re: Framework extending window functions for Follow Mode (etc.).] Alan Mackenzie
2015-11-11 17:58                   ` Alan Mackenzie
2015-11-07 13:26 ` Framework extending window functions for Follow Mode (etc.) martin rudalics
2015-11-07 13:57   ` Alan Mackenzie
2015-11-07 15:18     ` martin rudalics
2015-11-07 16:12       ` Alan Mackenzie
2015-11-07 17:07         ` martin rudalics
2015-11-07 18:55           ` Alan Mackenzie
2015-11-08  9:22             ` martin rudalics
2015-11-08 12:13               ` Alan Mackenzie
2015-11-08 18:10                 ` martin rudalics
2015-11-08 19:57                   ` Alan Mackenzie
2015-11-09  8:25                     ` martin rudalics
2015-11-09 17:03                       ` Alan Mackenzie
2015-11-07 17:54 ` Artur Malabarba
2015-11-07 18:24   ` Alan Mackenzie
2015-11-07 21:58     ` Juri Linkov
2015-11-08  0:29       ` Alan Mackenzie
2015-11-08  9:23         ` martin rudalics
2015-11-09  0:50         ` Juri Linkov
2015-11-09 15:41           ` bug#17453: " Alan Mackenzie
2015-11-09 15:41           ` Alan Mackenzie
2015-11-10  0:51             ` Juri Linkov [this message]
2015-11-10 11:08               ` bug#17453: " Alan Mackenzie
2015-11-11  0:12                 ` Juri Linkov
2015-11-11 16:19                   ` Alan Mackenzie
2015-11-12  0:52                     ` Juri Linkov
2015-11-12  8:22                       ` martin rudalics
2015-11-12 20:14                         ` Juri Linkov
2015-11-17 22:55                           ` Alan Mackenzie
2015-11-18  0:38                             ` Juri Linkov
2015-11-18 17:58                               ` Alan Mackenzie
2015-11-18 21:28                                 ` Alan Mackenzie
2015-11-19  0:45                                 ` Juri Linkov
2015-11-25 19:33                                   ` Alan Mackenzie
2015-11-26 23:03                                     ` Juri Linkov
2015-11-30 20:37                                       ` Alan Mackenzie
2015-12-01  0:07                                         ` Juri Linkov
2015-12-05 16:40                                           ` Alan Mackenzie
2015-12-05 23:06                                             ` Juri Linkov
2015-12-07 19:15                                               ` Alan Mackenzie
2015-12-08  0:42                                                 ` Juri Linkov
2015-11-12 22:15                       ` Alan Mackenzie
2015-11-09  0:50         ` Juri Linkov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87611a8x96.fsf@mail.linkov.net \
    --to=juri@linkov.net \
    --cc=17453@debbugs.gnu.org \
    --cc=acm@muc.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.