From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Drew Adams" Newsgroups: gmane.emacs.devel Subject: RE: Should ending successful Isearch with C-g restore the relative window position? Date: Tue, 15 Jan 2013 14:04:53 -0800 Message-ID: References: <7E5B63603B074626914E5DAEB90E738B@us.oracle.com> <83fw23qf57.fsf@gnu.org> <1712F3B8AF3D49DD9AC9F829FF560543@us.oracle.com> <834niiqubh.fsf@gnu.org> <75F694ACD7DA4E0482195A15331657BA@us.oracle.com> <83zk0ape2h.fsf@gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_NextPart_000_0114_01CDF329.4B748AB0" X-Trace: ger.gmane.org 1358287514 25898 80.91.229.3 (15 Jan 2013 22:05:14 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 15 Jan 2013 22:05:14 +0000 (UTC) Cc: emacs-devel@gnu.org, dmoncayo@gmail.com To: "'Eli Zaretskii'" Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Jan 15 23:05:32 2013 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1TvEdN-000298-EN for ged-emacs-devel@m.gmane.org; Tue, 15 Jan 2013 23:05:29 +0100 Original-Received: from localhost ([::1]:44626 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TvEd6-0000CT-QV for ged-emacs-devel@m.gmane.org; Tue, 15 Jan 2013 17:05:12 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:45395) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TvEd2-0000CG-L3 for emacs-devel@gnu.org; Tue, 15 Jan 2013 17:05:10 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TvEd1-0002Is-GT for emacs-devel@gnu.org; Tue, 15 Jan 2013 17:05:08 -0500 Original-Received: from userp1040.oracle.com ([156.151.31.81]:17065) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TvEcz-00026L-Qq; Tue, 15 Jan 2013 17:05:05 -0500 Original-Received: from acsinet22.oracle.com (acsinet22.oracle.com [141.146.126.238]) by userp1040.oracle.com (Sentrion-MTA-4.2.2/Sentrion-MTA-4.2.2) with ESMTP id r0FM4wIq032752 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 15 Jan 2013 22:04:59 GMT Original-Received: from acsmt358.oracle.com (acsmt358.oracle.com [141.146.40.158]) by acsinet22.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id r0FM4vku027813 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 15 Jan 2013 22:04:58 GMT Original-Received: from abhmt118.oracle.com (abhmt118.oracle.com [141.146.116.70]) by acsmt358.oracle.com (8.12.11.20060308/8.12.11) with ESMTP id r0FM4v88014547; Tue, 15 Jan 2013 16:04:57 -0600 Original-Received: from dradamslap1 (/10.159.246.149) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 15 Jan 2013 14:04:56 -0800 X-Mailer: Microsoft Office Outlook 11 In-Reply-To: <83zk0ape2h.fsf@gnu.org> Thread-Index: Ac3zQyoz5X0Ot2UbROm4rhUX31flTQAJWaTw X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.6157 X-Source-IP: acsinet22.oracle.com [141.146.126.238] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 156.151.31.81 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:156411 Archived-At: This is a multi-part message in MIME format. ------=_NextPart_000_0114_01CDF329.4B748AB0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit > > Thanks for the explanation. So it sounds like this is not > > an enhancement we can expect anytime soon. > > Depends on the availability of motivated volunteers ;-) Well I'm certainly no expert here. And I believe you when you say that it will be difficult to fix this adequately. I took a quick stab at it anyway. Please try the attached patch, as a first attempt. It does not provide for the new behavior to be optional - dunno whether that is needed. I did not check the many possible Isearch code paths and use cases. I just checked it quickly. So far, it seems to DTRT for the few things I tried. If this happens to actually be TRT, great. But the change I made is trivial, so I assume there must be more to it, to DTRT in all cases. I hope that passing this along might allow someone to enlighten me further or perhaps encourage someone to provide a more complete solution. All I did was this: 1. Save the relative window line number of point, before searching, in `isearch-mode'. 2. Restore that, in `isearch-cancel'. HTH. ------=_NextPart_000_0114_01CDF329.4B748AB0 Content-Type: application/octet-stream; name="isearch-2013-01-15.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="isearch-2013-01-15.patch" diff -c isearch-patched-2013-01-15.el isearch.el=0A= *** isearch-patched-2013-01-15.el Tue Jan 15 13:54:02 2013=0A= --- isearch.el Tue Jan 15 13:49:58 2013=0A= ***************=0A= *** 605,612 ****=0A= (defvar isearch-opoint 0)=0A= ;; The window configuration active at the beginning of the search.=0A= (defvar isearch-window-configuration nil)=0A= - ;; The line number of point before searching, relative to the line = number of `window-start'.=0A= - (defvar isearch-win-pt-line nil)=0A= =0A= ;; Flag to indicate a yank occurred, so don't move the cursor.=0A= (defvar isearch-yank-flag nil)=0A= --- 605,610 ----=0A= ***************=0A= *** 829,836 ****=0A= isearch-start-hscroll (window-hscroll)=0A= =0A= isearch-opoint (point)=0A= - isearch-win-pt-line (- (line-number-at-pos)=0A= - (line-number-at-pos (window-start)))=0A= search-ring-yank-pointer nil=0A= isearch-opened-overlays nil=0A= isearch-input-method-function input-method-function=0A= --- 827,832 ----=0A= ***************=0A= *** 1312,1319 ****=0A= ;; This calls pop-state function and restores original point.=0A= (let ((isearch-cmds (last isearch-cmds)))=0A= (isearch--set-state (car isearch-cmds)))=0A= ! (goto-char isearch-opoint)=0A= ! (when isearch-win-pt-line (recenter isearch-win-pt-line)))=0A= (isearch-done t) ; Exit isearch..=0A= (isearch-clean-overlays)=0A= (signal 'quit nil)) ; ..and pass on quit signal.=0A= --- 1308,1314 ----=0A= ;; This calls pop-state function and restores original point.=0A= (let ((isearch-cmds (last isearch-cmds)))=0A= (isearch--set-state (car isearch-cmds)))=0A= ! (goto-char isearch-opoint))=0A= (isearch-done t) ; Exit isearch..=0A= (isearch-clean-overlays)=0A= (signal 'quit nil)) ; ..and pass on quit signal.=0A= =0A= Diff finished. Tue Jan 15 20:54:28 2013=0A= ------=_NextPart_000_0114_01CDF329.4B748AB0--