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: Mon, 04 Mar 2019 20:06:13 +0100 Message-ID: References: <87o96rprs3.fsf@mail.linkov.net> Reply-To: charles@aurox.ch Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="26323"; mail-complaints-to="usenet@blaine.gmane.org" Cc: 34723@debbugs.gnu.org To: Juri Linkov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Mar 04 21:10:37 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 1h0tv3-0006ji-02 for geb-bug-gnu-emacs@m.gmane.org; Mon, 04 Mar 2019 21:10:37 +0100 Original-Received: from localhost ([127.0.0.1]:60324 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h0tv1-0003Fq-Tp for geb-bug-gnu-emacs@m.gmane.org; Mon, 04 Mar 2019 15:10:35 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:56708) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h0sjx-00062b-7o for bug-gnu-emacs@gnu.org; Mon, 04 Mar 2019 13:55:05 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h0sjw-0004Ps-CK for bug-gnu-emacs@gnu.org; Mon, 04 Mar 2019 13:55:05 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:46627) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h0sju-0004Nm-Sa for bug-gnu-emacs@gnu.org; Mon, 04 Mar 2019 13:55:04 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1h0sju-0005Tc-I4 for bug-gnu-emacs@gnu.org; Mon, 04 Mar 2019 13:55: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: Mon, 04 Mar 2019 18:55: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.155172565520995 (code B ref 34723); Mon, 04 Mar 2019 18:55:02 +0000 Original-Received: (at 34723) by debbugs.gnu.org; 4 Mar 2019 18:54:15 +0000 Original-Received: from localhost ([127.0.0.1]:60171 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1h0sj9-0005SZ-I4 for submit@debbugs.gnu.org; Mon, 04 Mar 2019 13:54:15 -0500 Original-Received: from nestroy.aurox.ch ([82.195.237.20]:59756) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1h0sj6-0005SH-T5 for 34723@debbugs.gnu.org; Mon, 04 Mar 2019 13:54:14 -0500 Original-Received: from nestroy.aurox.ch (nestroy.aurox.ch [127.0.0.1]) by nestroy.aurox.ch (Postfix) with ESMTP id 44Cq1m0b87zlC1 for <34723@debbugs.gnu.org>; Mon, 4 Mar 2019 18:54:04 +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=1551725643; x=1554317644; bh=j OX6yrxBTKFPjNyXOezMYrE93ICnUhI+wfjEfzax96o=; b=kt5AjG6QrswUW6Yuo W3xbUrpdnNEZE1JU1u6aGsnd2pccU87jcfd0tuhdZc8k6Tg+x7ByMfk6zNxrUF+Y B7Vhj6/wtqHaC2YHa8E69kQFUf/C6C5+nNpF78e/Koowyqg9aWRAbAsp46tw5tth piLhRj7Cq5GXnYeXz7MFhVX5Yg= 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 tSWRoxDT5ixa for <34723@debbugs.gnu.org>; Mon, 4 Mar 2019 18:54:03 +0000 (UTC) Original-Received: from gray (unknown [IPv6:2a02:1206:4512:5f50:c62c:3ff:fe30:b864]) by nestroy.aurox.ch (Postfix) with ESMTPSA id 44Cq1l0GSpzlBt; Mon, 4 Mar 2019 18:54:02 +0000 (UTC) In-reply-to: <87o96rprs3.fsf@mail.linkov.net> (message from Juri Linkov on Sun, 03 Mar 2019 23:33:16 +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:156040 Archived-At: > From: Juri Linkov > Date: Sun, 03 Mar 2019 23:33:16 +0200 > > I use `C-M-l' (reposition-window) to recenter during search, > and it works quite well to recenter diff hunks with > > (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. > but the problem is that I also have to change the default definition > of reposition boundaries used by `C-M-l' (reposition-window) > > (add-hook 'diff-mode-hook > (lambda () > (set (make-local-variable 'beginning-of-defun-function) > #'diff-beginning-of-hunk) > (set (make-local-variable 'end-of-defun-function) > #'diff-end-of-hunk))) > > to recenter at diff hunk boundaries, not at diff file boundaries > as defined in `diff-mode' by default, because usually there are > much more lines covered by all file changes, and when reposition-window > tries to fit all file changes into the screen, it puts the current line > at the bottom line of the window, thus not showing the lower part > of the current hunk. I noticed this too. If it makes sense, we should make these values of beginning-of-defun-function and end-of-defun-function the default.