emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 54971f5c14: Add an option to display the cursor at the beginning


From: Po Lu
Subject: master 54971f5c14: Add an option to display the cursor at the beginning of any preedit text
Date: Sun, 9 Jan 2022 08:01:34 -0500 (EST)

branch: master
commit 54971f5c14fd430208bd456d9f6efcb28b6abe28
Author: Po Lu <luangruo@yahoo.com>
Commit: Po Lu <luangruo@yahoo.com>

    Add an option to display the cursor at the beginning of any preedit text
    
    Believe it or not, people actually want this, because it makes
    Emacs behave closer to some other editors such as WPS Office.
    
    * lisp/term/x-win.el
    (x-display-cursor-at-start-of-preedit-string): New user option.
    (x-preedit-text): Respect new option.
---
 lisp/term/x-win.el | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/lisp/term/x-win.el b/lisp/term/x-win.el
index 13b48f4611..e52e488eda 100644
--- a/lisp/term/x-win.el
+++ b/lisp/term/x-win.el
@@ -1489,6 +1489,12 @@ If you don't want stock icons, set the variable to nil."
                                       (string :tag "Stock/named")))))
   :group 'x)
 
+(defcustom x-display-cursor-at-start-of-preedit-string nil
+  "If non-nil, display the cursor at the start of any pre-edit text."
+  :version "29.1"
+  :type 'boolean
+  :group 'x)
+
 (defconst x-gtk-stock-cache (make-hash-table :weakness t :test 'equal))
 
 (defun x-gtk-map-stock (file)
@@ -1529,10 +1535,13 @@ EVENT is a preedit-text event."
     (delete-overlay x-preedit-overlay)
     (setq x-preedit-overlay nil))
   (when (nth 1 event)
-    (setq x-preedit-overlay (make-overlay (point) (point)))
-    (overlay-put x-preedit-overlay 'window (selected-window))
-    (overlay-put x-preedit-overlay 'before-string
-                 (propertize (nth 1 event) 'face '(:underline t)))))
+    (let ((string (propertize (nth 1 event) 'face '(:underline t))))
+      (setq x-preedit-overlay (make-overlay (point) (point)))
+      (overlay-put x-preedit-overlay 'window (selected-window))
+      (overlay-put x-preedit-overlay 'before-string
+                   (if x-display-cursor-at-start-of-preedit-string
+                       (propertize string 'cursor t)
+                     string)))))
 
 (define-key special-event-map [preedit-text] 'x-preedit-text)
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]