From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: charles@aurox.ch (Charles A. Roelli) Newsgroups: gmane.emacs.bugs Subject: bug#34723: 27.0.50; customize and improve diff-mode recentering Date: Tue, 05 Mar 2019 21:11:13 +0100 Message-ID: References: <87o96rprs3.fsf@mail.linkov.net> <83y35tcnci.fsf@gnu.org> Reply-To: charles@aurox.ch Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="137285"; mail-complaints-to="usenet@blaine.gmane.org" Cc: 34723@debbugs.gnu.org, juri@linkov.net To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Mar 05 21:00:33 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1h1GEq-000ZV0-Pq for geb-bug-gnu-emacs@m.gmane.org; Tue, 05 Mar 2019 21:00:32 +0100 Original-Received: from localhost ([127.0.0.1]:48555 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h1GEp-0001fD-Ha for geb-bug-gnu-emacs@m.gmane.org; Tue, 05 Mar 2019 15:00:31 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:46526) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h1GEQ-0001T4-JJ for bug-gnu-emacs@gnu.org; Tue, 05 Mar 2019 15:00:07 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h1GEO-0002AA-Gq for bug-gnu-emacs@gnu.org; Tue, 05 Mar 2019 15:00:05 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:48176) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h1GEM-00028o-Qj for bug-gnu-emacs@gnu.org; Tue, 05 Mar 2019 15:00:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1h1GEM-0006dT-ES for bug-gnu-emacs@gnu.org; Tue, 05 Mar 2019 15:00:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: charles@aurox.ch (Charles A. Roelli) Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 05 Mar 2019 20:00:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 34723 X-GNU-PR-Package: emacs Original-Received: via spool by 34723-submit@debbugs.gnu.org id=B34723.155181595225418 (code B ref 34723); Tue, 05 Mar 2019 20:00:02 +0000 Original-Received: (at 34723) by debbugs.gnu.org; 5 Mar 2019 19:59:12 +0000 Original-Received: from localhost ([127.0.0.1]:33487 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1h1GDX-0006bs-NO for submit@debbugs.gnu.org; Tue, 05 Mar 2019 14:59:11 -0500 Original-Received: from nestroy.aurox.ch ([82.195.237.20]:35124) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1h1GDV-0006bd-0d for 34723@debbugs.gnu.org; Tue, 05 Mar 2019 14:59:09 -0500 Original-Received: from nestroy.aurox.ch (nestroy.aurox.ch [127.0.0.1]) by nestroy.aurox.ch (Postfix) with ESMTP id 44DSQG5DGCzlqX for <34723@debbugs.gnu.org>; Tue, 5 Mar 2019 19:59:02 +0000 (UTC) Authentication-Results: nestroy.aurox.ch (amavisd-new); dkim=pass (1024-bit key) reason="pass (just generated, assumed good)" header.d=aurox.ch DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=aurox.ch; h= references:reply-to:subject:subject:in-reply-to:to:from:from :message-id:date:date; s=dkim2; t=1551815938; x=1554407939; bh=K olrfUGVdqdj0Qxhhwzrbci2F8xft+Fo0edfQ5kNbmE=; b=Fl5Q+jc4hTVk8o7Dp /ah2buBdO1CRhA5/0EIEU7KJscPBuAPA+ZotElsTttMfzg0oe1mYdvVT324Wi/4h LyrdF7yyIwNNC/nUPSvZKwtr7FbY5mNITGAVHCCNUjBZnlO8yZfkbJ6PWdfvl4fw CFrdNIZUaMK0JRFj0GCk+E35Jc= X-Virus-Scanned: Debian amavisd-new at nestroy.aurox.ch Original-Received: from nestroy.aurox.ch ([127.0.0.1]) by nestroy.aurox.ch (nestroy.aurox.ch [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id EHC71yDme5LF for <34723@debbugs.gnu.org>; Tue, 5 Mar 2019 19:58:58 +0000 (UTC) Original-Received: from gray (unknown [IPv6:2a02:1206:4512:5f50:c62c:3ff:fe30:b864]) by nestroy.aurox.ch (Postfix) with ESMTPSA id 44DSQ96mmVzlqB; Tue, 5 Mar 2019 19:58:57 +0000 (UTC) In-reply-to: <83y35tcnci.fsf@gnu.org> (message from Eli Zaretskii on Tue, 05 Mar 2019 18:11:57 +0200) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:156068 Archived-At: > Date: Tue, 05 Mar 2019 18:11:57 +0200 > From: Eli Zaretskii > CC: juri@linkov.net, 34723@debbugs.gnu.org > > > > (setq isearch-push-state-function > > > (lambda () > > > (when (and isearch-success (not (pos-visible-in-window-p))) > > > (reposition-window)) > > > `(lambda (cmd) > > > (when isearch-success > > > (set-window-start nil ,(window-start)))))) > > > > Can we add something like this to isearch.el, maybe as a defcustom? > > Or maybe we could add it in a way such that other packages that show > > search results (grep, xref) could use the same function to reposition > > the window. The function could inspect a defcustom in simple.el to > > decide whether (or how) to reposition the window. > > Isn't it easier to temporarily bind scroll-margin to a non-zero value, > then force redisplay? > > Or maybe I'm missing something in this discussion. I'm not sure how binding scroll-margin would change the behavior here. IIUC the aim of this snippet is to reposition the window to show as much of the function definition (or diff hunk, or some other text structure) that includes the search hit as possible. For example, if you evaluate the snippet from emacs -Q, then type, for example M-x find-library RET simple.el RET C-s quit-flag Then Emacs positions the window to show the definition (from the beginning) of the function containing the search hit. When you try that again in another session without evaluating the snippet, Emacs centers the search hit in the window, giving you less useful context.