all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#33640: 27.0.50; Wrong column when prompt contains combining characters
@ 2018-12-05 23:05 Juri Linkov
  2018-12-06  7:02 ` Eli Zaretskii
  0 siblings, 1 reply; 4+ messages in thread
From: Juri Linkov @ 2018-12-05 23:05 UTC (permalink / raw)
  To: 33640

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'





^ permalink raw reply related	[flat|nested] 4+ messages in thread

* bug#33640: 27.0.50; Wrong column when prompt contains combining characters
  2018-12-05 23:05 bug#33640: 27.0.50; Wrong column when prompt contains combining characters Juri Linkov
@ 2018-12-06  7:02 ` Eli Zaretskii
  2018-12-06  7:15   ` Eli Zaretskii
  2018-12-06 22:31   ` Juri Linkov
  0 siblings, 2 replies; 4+ messages in thread
From: Eli Zaretskii @ 2018-12-06  7:02 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 33640

> From: Juri Linkov <juri@linkov.net>
> Date: Thu, 06 Dec 2018 01:05:24 +0200
> 
> Eli, do you think this fix should be installed to the emacs-26 branch?

Yes, but please also test it with file names that include double-width
characters.  You can find the list of such characters in
characters.el (search for "East Asian Wide" there).  The success
criterion is that minibuffer navigation works with these characters
not worse than C-n/C-p in "normal" buffers.

Thanks.





^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#33640: 27.0.50; Wrong column when prompt contains combining characters
  2018-12-06  7:02 ` Eli Zaretskii
@ 2018-12-06  7:15   ` Eli Zaretskii
  2018-12-06 22:31   ` Juri Linkov
  1 sibling, 0 replies; 4+ messages in thread
From: Eli Zaretskii @ 2018-12-06  7:15 UTC (permalink / raw)
  To: juri; +Cc: 33640

> Date: Thu, 06 Dec 2018 09:02:37 +0200
> From: Eli Zaretskii <eliz@gnu.org>
> Cc: 33640@debbugs.gnu.org
> 
> The success criterion is that minibuffer navigation works with these
> characters not worse than C-n/C-p in "normal" buffers.

Just to explain this part a bit more: on GUI frames, double-width
characters are not necessarily displayed at twice the width of other
characters from the same font; their actual width in pixels varies
with fonts.  This could cause one-column shifts in either direction
when using C-n/C-p across such characters.  I'm saying that what you
see in the minibuffer should be not worse than what you see in
"normal" buffers for those characters.





^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#33640: 27.0.50; Wrong column when prompt contains combining characters
  2018-12-06  7:02 ` Eli Zaretskii
  2018-12-06  7:15   ` Eli Zaretskii
@ 2018-12-06 22:31   ` Juri Linkov
  1 sibling, 0 replies; 4+ messages in thread
From: Juri Linkov @ 2018-12-06 22:31 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 33640

tags 33640 fixed
close 33640 26.2
thanks

>> Eli, do you think this fix should be installed to the emacs-26 branch?
>
> Yes, but please also test it with file names that include double-width
> characters.  You can find the list of such characters in
> characters.el (search for "East Asian Wide" there).  The success
> criterion is that minibuffer navigation works with these characters
> not worse than C-n/C-p in "normal" buffers.

I tested also with double-width characters, and they work without problems
before and after applying this patch.  So I pushed it to the emacs-26 branch.





^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-12-06 22:31 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-12-05 23:05 bug#33640: 27.0.50; Wrong column when prompt contains combining characters Juri Linkov
2018-12-06  7:02 ` Eli Zaretskii
2018-12-06  7:15   ` Eli Zaretskii
2018-12-06 22:31   ` Juri Linkov

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.