From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Stephen Berman Newsgroups: gmane.emacs.bugs Subject: bug#27191: 26.0.50; Long history items in minibuffer (again) Date: Thu, 01 Jun 2017 22:46:15 +0200 Message-ID: <874lvzh1wo.fsf@rosalinde> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: blaine.gmane.org 1496350073 3908 195.159.176.226 (1 Jun 2017 20:47:53 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 1 Jun 2017 20:47:53 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux) To: 27191@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Jun 01 22:47:46 2017 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dGX0U-0000aE-B0 for geb-bug-gnu-emacs@m.gmane.org; Thu, 01 Jun 2017 22:47:46 +0200 Original-Received: from localhost ([::1]:46598 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dGX0Z-0008UU-Bp for geb-bug-gnu-emacs@m.gmane.org; Thu, 01 Jun 2017 16:47:51 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:43589) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dGWzq-0007nB-5S for bug-gnu-emacs@gnu.org; Thu, 01 Jun 2017 16:47:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dGWzm-0000vp-VE for bug-gnu-emacs@gnu.org; Thu, 01 Jun 2017 16:47:06 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:47345) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dGWzm-0000vk-Ro for bug-gnu-emacs@gnu.org; Thu, 01 Jun 2017 16:47:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1dGWzm-0007rZ-JS for bug-gnu-emacs@gnu.org; Thu, 01 Jun 2017 16:47:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Stephen Berman Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 01 Jun 2017 20:47:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 27191 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.149634999430188 (code B ref -1); Thu, 01 Jun 2017 20:47:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 1 Jun 2017 20:46:34 +0000 Original-Received: from localhost ([127.0.0.1]:50022 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dGWzJ-0007qq-Tx for submit@debbugs.gnu.org; Thu, 01 Jun 2017 16:46:34 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:52222) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dGWzH-0007qe-9x for submit@debbugs.gnu.org; Thu, 01 Jun 2017 16:46:32 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dGWzA-0000ei-KF for submit@debbugs.gnu.org; Thu, 01 Jun 2017 16:46:26 -0400 Original-Received: from lists.gnu.org ([2001:4830:134:3::11]:37092) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dGWzA-0000ec-H3 for submit@debbugs.gnu.org; Thu, 01 Jun 2017 16:46:24 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:43171) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dGWz8-0007SW-RR for bug-gnu-emacs@gnu.org; Thu, 01 Jun 2017 16:46:24 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dGWz5-0000cv-LZ for bug-gnu-emacs@gnu.org; Thu, 01 Jun 2017 16:46:22 -0400 Original-Received: from mout.gmx.net ([212.227.15.15]:60717) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dGWz5-0000cE-AS for bug-gnu-emacs@gnu.org; Thu, 01 Jun 2017 16:46:19 -0400 Original-Received: from rosalinde ([83.135.25.157]) by mail.gmx.com (mrgmx003 [212.227.17.190]) with ESMTPSA (Nemesis) id 0MX1dc-1dLuG402E8-00Vvx0 for ; Thu, 01 Jun 2017 22:46:16 +0200 X-Provags-ID: V03:K0:+Ew1LLOha+Zitq6Q8/j7q6QQq9PiZVoALgyhnJXvNS/UB70tAdv m67O992qC+FntYQ+Nfci1t7eA+YwCfY19Bi2JPoZdALIOzQrbDJ1SrIKttWObY9/gYaxI2T D8cmSeCFbPdsxKDpCvHK7PORrg4BjY/neIWLRmQMZrpfMOoopBG3gwdYVHvMJuvYdCOh1cY L9wB49RUIJCmisw7w0xjg== X-UI-Out-Filterresults: notjunk:1;V01:K0:EJaViKljWzk=:CeZIAyBtMt9qLyAnwepp1v omUJ9snAwV84ucRr5czE8+DqN7aNeJtU4blVZ4J4HQ65oAGaN1fluhFpEc+9O+4rV4rh3M2rC 6d28J/OKXKD8JmGae6OgWArPlUsNcvffuyduCrvVbMnzzoJpmhUI7Rbqo1FhpMQ7+HMnjWN6U XOfiwpAgiNfAbS0nmgtviT9W7O6iZeNcEE8lD2dgQkjAQQdEChhb53dVTRfB108vM1N0Jv6z3 vre4h8+jWDDxQqETqkGg/KTE6Y2Y8iqdZKjt7EuoaAL6Ms73ShCdiRR1sbUY1PEag/mtXK6e5 Wp3PcVNxE4tDasFATCar4O9Fm/xVleoZvIYwuPgn4XBg3FTs0ySO89Hb7H7wZai3VI4A2cSJh w0AhKNf4aj74dZ2IWvK6FeEYbyeOGbb4aFJIlJWVk9YmA5DFRBQrcS1cE3KZGB/at3/HaUPxY mfBAN/h2dMdV2wMZpdzo8PNdsL5TgIKTptljHacS6+HG5f5tbVGkpoCDPWKIwyhx3Rl0j85KU czK219PgLCO37MIRd0urwcN4jNIcezQSboODGdnG7jrm+uBPc3fUHe/HmBe6zBsF3U6x+juym UHm12FohYmCxBcnR4Io2ezlJ8W6vd7LMk9VpaFeKCPri0ARaISEOFRNFyCPi53y8tB1otuO4R fLnFxACCtwUMn3Wv/34dtQhzn+txSOmnJb9kNoHtRyRz8lUGVtEVIA0X7GTR12Y+Sdg6fTTq8 9xOggmPGB8JtlV1Ix3dhfuwzccjX/ElM+KPxTe+2NbnM0rMI+VBxEfo0y4k= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x 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: 208.118.235.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:133141 Archived-At: --=-=-= Content-Type: text/plain 0. emacs -Q 1. C-x C-f ~/foo/bar/very/long/file/name/that/overflows/minibuffer/window/line/when/displayed 2. C-x C-f => The file name entered in step 1 appears in the minibuffer, with point on the "w" of "when" (i.e., column 80, the end of the visual line). If at step 2 instead of you type `M-p', then point is at the end of the file name in the minibuffer. This is what I expected for too. The result with is due to the fix for bug#22544. In the bug thread (http://lists.gnu.org/archive/html/bug-gnu-emacs/2016-02/msg00357.html), the above problem was noted: > > Can't we special-case a line that isn't broken into several visual > > lines, and put the cursor at the end of such lines only? That'd be > > the best. > > The problem here is that like bash and other shells with histories do, > we need to put the cursor at the end of the previous history element > so the user can start editing it immediately (usually deleting the chars > from the end of the logical line). OTOH, a subsequent should > continue navigating the history and put the next previous element to the > minibuffer. But then can't be used to move between visual lines. > This is a lose-lose situation, unless we'll find some clever DWIM. The attached patch isn't particularly clever, but (unless I've overlooked something) DWIM: it puts point at the end of a history element longer than window-width, and if such an element is a single line, the next displays the previous history element. Otherwise, moves by visual lines (specifically also in multi-line history elements, including those with lines longer than window-width). (I wanted to add tests for this, but I haven't been able to figure out how to emulate minibuffer history navigation non-interactively.) In GNU Emacs 26.0.50 (build 30, x86_64-pc-linux-gnu, GTK+ Version 3.22.8) of 2017-05-29 built on rosalinde Repository revision: c503188f8079ae73d95abd0bce0f53d104b03205 Windowing system distributor 'The X.Org Foundation', version 11.0.11901000 2017-06-01 Stephen Berman Improve navigation through minibuffer history * lisp/simple.el (previous-line-or-history-element): If the element extends beyond window-width, go to its logical end, since that is the natural target for editing history elements. If it consists of a single line, move by logical lines to hit beginning-of-buffer immediately and get the previous history element. Otherwise, move by visual lines. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment Content-Description: previous-line-or-history-element patch diff --git a/lisp/simple.el b/lisp/simple.el index ea3a495fbc..1b96bce773 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -2140,7 +2140,16 @@ previous-line-or-history-element (current-column))))) (condition-case nil (with-no-warnings - (previous-line arg)) + ;; If the history element consists of a single line longer + ;; than window-width, move by logical lines to hit + ;; beginning-of-buffer immediately and get the previous + ;; history element. Otherwise, move by visual lines. + (if (and (save-excursion + (end-of-line) + (> (current-column) (window-width))) + (= (line-number-at-pos) 1)) + (previous-logical-line arg) + (previous-line arg))) (beginning-of-buffer ;; Restore old position since `line-move-visual' moves point to ;; the beginning of the line when it fails to go to the previous line. @@ -2162,10 +2171,9 @@ previous-line-or-history-element ;; would move to the previous history element, not to a possible upper ;; visual line from the end of logical line in `line-move-visual' mode. (end-of-visual-line) - ;; Since `end-of-visual-line' puts the cursor at the beginning - ;; of the next visual line, move it one char back to the end - ;; of the first visual line (bug#22544). - (unless (eolp) (backward-char 1))))))) + ;; If the line extends beyond window-width, go to its logical end, + ;; since that is the natural target for editing history elements. + (unless (eolp) (end-of-line))))))) (defun next-complete-history-element (n) "Get next history element which completes the minibuffer before the point. --=-=-=--