aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuri Linkov2015-03-12 22:22:22 +0200
committerJuri Linkov2015-03-12 22:22:22 +0200
commitb91eafe31a524b391d5cec079cf8f36c2f9d5f30 (patch)
tree13e11f67e0ed42519c1189d116dfa9181201ade7
parentac4cce624c4f51cbc57a210ade0ca74a1893d636 (diff)
downloademacs-b91eafe31a524b391d5cec079cf8f36c2f9d5f30.tar.gz
emacs-b91eafe31a524b391d5cec079cf8f36c2f9d5f30.zip
Support goal column in multi-line minibuffer
* lisp/simple.el (next-line-or-history-element) (previous-line-or-history-element): Remember the goal column of possibly multi-line input, and restore it afterwards. Fixes: debbugs:19824
-rw-r--r--lisp/ChangeLog6
-rw-r--r--lisp/simple.el37
2 files changed, 39 insertions, 4 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 97253c8824e..8ddf9ed02ad 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,9 @@
12015-03-12 Juri Linkov <juri@linkov.net>
2
3 * simple.el (next-line-or-history-element)
4 (previous-line-or-history-element): Remember the goal column of
5 possibly multi-line input, and restore it afterwards. (Bug#19824)
6
12015-03-12 Rasmus Pank Roulund <emacs@pank.eu> 72015-03-12 Rasmus Pank Roulund <emacs@pank.eu>
2 8
3 * ido.el (ido-add-virtual-buffers-to-list): Include bookmark-alist 9 * ido.el (ido-add-virtual-buffers-to-list): Include bookmark-alist
diff --git a/lisp/simple.el b/lisp/simple.el
index 4deb4cfce2e..98188a07b6f 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -1992,7 +1992,14 @@ When point moves over the bottom line of multi-line minibuffer, puts ARGth
1992next element of the minibuffer history in the minibuffer." 1992next element of the minibuffer history in the minibuffer."
1993 (interactive "^p") 1993 (interactive "^p")
1994 (or arg (setq arg 1)) 1994 (or arg (setq arg 1))
1995 (let ((old-point (point))) 1995 (let* ((old-point (point))
1996 ;; Remember the original goal column of possibly multi-line input
1997 ;; excluding the length of the prompt on the first line.
1998 (prompt-end (minibuffer-prompt-end))
1999 (old-column (unless (and (eolp) (> (point) prompt-end))
2000 (if (= (line-number-at-pos) 1)
2001 (max (- (current-column) (1- prompt-end)) 0)
2002 (current-column)))))
1996 (condition-case nil 2003 (condition-case nil
1997 (with-no-warnings 2004 (with-no-warnings
1998 (next-line arg)) 2005 (next-line arg))
@@ -2000,7 +2007,14 @@ next element of the minibuffer history in the minibuffer."
2000 ;; Restore old position since `line-move-visual' moves point to 2007 ;; Restore old position since `line-move-visual' moves point to
2001 ;; the end of the line when it fails to go to the next line. 2008 ;; the end of the line when it fails to go to the next line.
2002 (goto-char old-point) 2009 (goto-char old-point)
2003 (next-history-element arg))))) 2010 (next-history-element arg)
2011 ;; Restore the original goal column on the last line
2012 ;; of possibly multi-line input.
2013 (goto-char (point-max))
2014 (when old-column
2015 (if (= (line-number-at-pos) 1)
2016 (move-to-column (+ old-column (1- (minibuffer-prompt-end))))
2017 (move-to-column old-column)))))))
2004 2018
2005(defun previous-line-or-history-element (&optional arg) 2019(defun previous-line-or-history-element (&optional arg)
2006 "Move cursor vertically up ARG lines, or to the previous history element. 2020 "Move cursor vertically up ARG lines, or to the previous history element.
@@ -2008,7 +2022,14 @@ When point moves over the top line of multi-line minibuffer, puts ARGth
2008previous element of the minibuffer history in the minibuffer." 2022previous element of the minibuffer history in the minibuffer."
2009 (interactive "^p") 2023 (interactive "^p")
2010 (or arg (setq arg 1)) 2024 (or arg (setq arg 1))
2011 (let ((old-point (point))) 2025 (let* ((old-point (point))
2026 ;; Remember the original goal column of possibly multi-line input
2027 ;; excluding the length of the prompt on the first line.
2028 (prompt-end (minibuffer-prompt-end))
2029 (old-column (unless (and (eolp) (> (point) prompt-end))
2030 (if (= (line-number-at-pos) 1)
2031 (max (- (current-column) (1- prompt-end)) 0)
2032 (current-column)))))
2012 (condition-case nil 2033 (condition-case nil
2013 (with-no-warnings 2034 (with-no-warnings
2014 (previous-line arg)) 2035 (previous-line arg))
@@ -2016,7 +2037,15 @@ previous element of the minibuffer history in the minibuffer."
2016 ;; Restore old position since `line-move-visual' moves point to 2037 ;; Restore old position since `line-move-visual' moves point to
2017 ;; the beginning of the line when it fails to go to the previous line. 2038 ;; the beginning of the line when it fails to go to the previous line.
2018 (goto-char old-point) 2039 (goto-char old-point)
2019 (previous-history-element arg))))) 2040 (previous-history-element arg)
2041 ;; Restore the original goal column on the first line
2042 ;; of possibly multi-line input.
2043 (goto-char (minibuffer-prompt-end))
2044 (if old-column
2045 (if (= (line-number-at-pos) 1)
2046 (move-to-column (+ old-column (1- (minibuffer-prompt-end))))
2047 (move-to-column old-column))
2048 (goto-char (line-end-position)))))))
2020 2049
2021(defun next-complete-history-element (n) 2050(defun next-complete-history-element (n)
2022 "Get next history element which completes the minibuffer before the point. 2051 "Get next history element which completes the minibuffer before the point.