From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs Subject: bug#19824: 25.0.50; Support goal column in multi-line minibuffer Date: Tue, 10 Feb 2015 02:45:33 +0200 Organization: LINKOV.NET Message-ID: <871tlyppaq.fsf@mail.linkov.net> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1423529424 7957 80.91.229.3 (10 Feb 2015 00:50:24 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 10 Feb 2015 00:50:24 +0000 (UTC) To: 19824@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Feb 10 01:50:19 2015 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1YKz1u-00028n-Ka for geb-bug-gnu-emacs@m.gmane.org; Tue, 10 Feb 2015 01:50:18 +0100 Original-Received: from localhost ([::1]:35935 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YKz1u-00026k-33 for geb-bug-gnu-emacs@m.gmane.org; Mon, 09 Feb 2015 19:50:18 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:35213) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YKz1h-0001qp-Ub for bug-gnu-emacs@gnu.org; Mon, 09 Feb 2015 19:50:06 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YKz1e-0002SR-Ii for bug-gnu-emacs@gnu.org; Mon, 09 Feb 2015 19:50:05 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:47394) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YKz1e-0002SB-G4 for bug-gnu-emacs@gnu.org; Mon, 09 Feb 2015 19:50:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1YKz1e-0004q5-4n for bug-gnu-emacs@gnu.org; Mon, 09 Feb 2015 19:50:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 10 Feb 2015 00:50:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 19824 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.142352939918586 (code B ref -1); Tue, 10 Feb 2015 00:50:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 10 Feb 2015 00:49:59 +0000 Original-Received: from localhost ([127.0.0.1]:38634 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YKz1a-0004pg-Ex for submit@debbugs.gnu.org; Mon, 09 Feb 2015 19:49:58 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:33320) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YKz1Y-0004pT-Hd for submit@debbugs.gnu.org; Mon, 09 Feb 2015 19:49:57 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YKz1S-0002Mb-6w for submit@debbugs.gnu.org; Mon, 09 Feb 2015 19:49:51 -0500 Original-Received: from lists.gnu.org ([2001:4830:134:3::11]:53090) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YKz1S-0002MX-3h for submit@debbugs.gnu.org; Mon, 09 Feb 2015 19:49:50 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:35031) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YKz1R-0001bR-2X for bug-gnu-emacs@gnu.org; Mon, 09 Feb 2015 19:49:50 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YKz1N-0002MC-Sp for bug-gnu-emacs@gnu.org; Mon, 09 Feb 2015 19:49:49 -0500 Original-Received: from ps18281.dreamhost.com ([69.163.222.226]:56868 helo=ps18281.dreamhostps.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YKz1N-0002Ly-ND for bug-gnu-emacs@gnu.org; Mon, 09 Feb 2015 19:49:45 -0500 Original-Received: from localhost.linkov.net (ps18281.dreamhostps.com [69.163.222.226]) by ps18281.dreamhostps.com (Postfix) with ESMTP id 0FFB037E696606 for ; Mon, 9 Feb 2015 16:49:42 -0800 (PST) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (x86_64-pc-linux-gnu) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.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-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:99225 Archived-At: Tags: patch In the single-line minibuffer the goal column was handled by using the point's absolute position that is the same as the column on the single line. However, this doesn't work on the multi-line minibuffer. This patch adds support for the goal column on multi-line input in the minibuffer: diff --git a/lisp/simple.el b/lisp/simple.el index 25293ed..58b4870 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -1990,7 +1990,14 @@ (defun next-line-or-history-element (&optional arg) next element of the minibuffer history in the minibuffer." (interactive "^p") (or arg (setq arg 1)) - (let ((old-point (point))) + (let* ((old-point (point)) + ;; Remember the original goal column of possibly multi-line input + ;; excluding the length of the prompt on the first line. + (prompt-end (minibuffer-prompt-end)) + (old-column (unless (and (eolp) (> (point) prompt-end)) + (if (= (line-number-at-pos) 1) + (max (- (current-column) (1- prompt-end)) 0) + (current-column))))) (condition-case nil (with-no-warnings (next-line arg)) @@ -1998,7 +2005,14 @@ (defun next-line-or-history-element (&optional arg) ;; Restore old position since `line-move-visual' moves point to ;; the end of the line when it fails to go to the next line. (goto-char old-point) - (next-history-element arg))))) + (next-history-element arg) + ;; Restore the original goal column on the last line + ;; of possibly multi-line input. + (goto-char (point-max)) + (when old-column + (if (= (line-number-at-pos) 1) + (move-to-column (+ old-column (1- (minibuffer-prompt-end)))) + (move-to-column old-column))))))) (defun previous-line-or-history-element (&optional arg) "Move cursor vertically up ARG lines, or to the previous history element. @@ -2006,7 +2020,14 @@ (defun previous-line-or-history-element (&optional arg) previous element of the minibuffer history in the minibuffer." (interactive "^p") (or arg (setq arg 1)) - (let ((old-point (point))) + (let* ((old-point (point)) + ;; Remember the original goal column of possibly multi-line input + ;; excluding the length of the prompt on the first line. + (prompt-end (minibuffer-prompt-end)) + (old-column (unless (and (eolp) (> (point) prompt-end)) + (if (= (line-number-at-pos) 1) + (max (- (current-column) (1- prompt-end)) 0) + (current-column))))) (condition-case nil (with-no-warnings (previous-line arg)) @@ -2014,7 +2035,15 @@ (defun previous-line-or-history-element (&optional arg) ;; Restore old position since `line-move-visual' moves point to ;; the beginning of the line when it fails to go to the previous line. (goto-char old-point) - (previous-history-element arg))))) + (previous-history-element arg) + ;; Restore the original goal column on the first line + ;; of possibly multi-line input. + (goto-char (minibuffer-prompt-end)) + (if old-column + (if (= (line-number-at-pos) 1) + (move-to-column (+ old-column (1- (minibuffer-prompt-end)))) + (move-to-column old-column)) + (goto-char (line-end-position))))))) (defun next-complete-history-element (n) "Get next history element which completes the minibuffer before the point.