all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Juri Linkov <juri@linkov.net>
To: 33640@debbugs.gnu.org
Subject: bug#33640: 27.0.50; Wrong column when prompt contains combining characters
Date: Thu, 06 Dec 2018 01:05:24 +0200	[thread overview]
Message-ID: <87k1knbmmj.fsf@mail.linkov.net> (raw)

Tags: patch

If the minibuffer prompt contains combining characters in such cases
when for example dired-do-async-shell-command is invoked on a file
whose name contains COMBINING ACUTE ACCENT, then navigating the
minibuffer history with M-n and M-p puts point at incorrect positions.

This is because currently next-line-or-history-element and
previous-line-or-history-element subtract the point's position
from the column number that takes into account character composition.

This patch uses only columns in calculations.

Eli, do you think this fix should be installed to the emacs-26 branch?

diff --git a/lisp/simple.el b/lisp/simple.el
index e1922384f2..4c6ca0619a 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -2172,7 +2172,11 @@ next-line-or-history-element
 	 (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)
+			   (max (- (current-column)
+				   (save-excursion
+				     (goto-char (1- prompt-end))
+				     (current-column)))
+				0)
 			 (current-column)))))
     (condition-case nil
 	(with-no-warnings
@@ -2191,7 +2195,10 @@ next-line-or-history-element
        (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
+				(save-excursion
+				  (goto-char (1- (minibuffer-prompt-end)))
+				  (current-column))))
 	   (move-to-column old-column)))))))
 
 (defun previous-line-or-history-element (&optional arg)
@@ -2206,7 +2213,11 @@ previous-line-or-history-element
 	 (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)
+			   (max (- (current-column)
+				   (save-excursion
+				     (goto-char (1- prompt-end))
+				     (current-column)))
+				0)
 			 (current-column)))))
     (condition-case nil
 	(with-no-warnings
@@ -2225,7 +2236,10 @@ previous-line-or-history-element
        (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
+				  (save-excursion
+				    (goto-char (1- (minibuffer-prompt-end)))
+				    (current-column))))
 	     (move-to-column old-column))
 	 ;; Put the cursor at the end of the visual line instead of the
 	 ;; logical line, so the next `previous-line-or-history-element'





             reply	other threads:[~2018-12-05 23:05 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-05 23:05 Juri Linkov [this message]
2018-12-06  7:02 ` bug#33640: 27.0.50; Wrong column when prompt contains combining characters Eli Zaretskii
2018-12-06  7:15   ` Eli Zaretskii
2018-12-06 22:31   ` Juri Linkov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87k1knbmmj.fsf@mail.linkov.net \
    --to=juri@linkov.net \
    --cc=33640@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.