From: Po Lu Date: Sun, 9 Jan 2022 12:55:16 +0000 (+0800) Subject: Add an option to display the cursor at the beginning of any preedit text X-Git-Tag: emacs-29.0.90~3174 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=54971f5c14fd430208bd456d9f6efcb28b6abe28;p=emacs.git 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. --- diff --git a/lisp/term/x-win.el b/lisp/term/x-win.el index 13b48f4611c..e52e488edab 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)