diff options
author | Dmitry Gutov <dgutov@yandex.ru> | 2022-07-11 14:17:45 +0300 |
---|---|---|
committer | Dmitry Gutov <dgutov@yandex.ru> | 2022-07-11 14:17:45 +0300 |
commit | d4875e1235375feb8d67bad8b1a76e64445f3b1a (patch) | |
tree | f011f6df1cc03dfb724fdffae09886f6589c3adb /lisp/composite.el | |
parent | 9c00d6c3f6f45755a20d093bbd821673fc7ac405 (diff) | |
parent | b283e36cf1902eeb6d532077e1f46270aa1224e1 (diff) | |
download | emacs-d4875e1235375feb8d67bad8b1a76e64445f3b1a.tar.gz |
Merge branch 'master' into scratch/etags-regenscratch/etags-regen
Diffstat (limited to 'lisp/composite.el')
-rw-r--r-- | lisp/composite.el | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/lisp/composite.el b/lisp/composite.el index d7ac75708c9..6fcf637584e 100644 --- a/lisp/composite.el +++ b/lisp/composite.el @@ -474,6 +474,25 @@ after a sequence of character events." (aset gstring (1- len) nil)) gstring) +(defun lgstring-glyph-boundary (gstring startpos endpos) + "Return buffer position at or after ENDPOS where grapheme from GSTRING ends. +STARTPOS is the position where the grapheme cluster starts; it is returned +by `find-composition'." + (let ((nglyphs (lgstring-glyph-len gstring)) + (idx 0) + glyph found) + (while (and (not found) (< idx nglyphs)) + (setq glyph (lgstring-glyph gstring idx)) + (cond + ((or (null glyph) + (= (+ startpos (lglyph-from glyph)) endpos)) + (setq found endpos)) + ((>= (+ startpos (lglyph-to glyph)) endpos) + (setq found (+ startpos (lglyph-to glyph) 1))) + (t + (setq idx (1+ idx))))) + (or found endpos))) + (defun compose-glyph-string (gstring from to) (let ((glyph (lgstring-glyph gstring from)) from-pos to-pos) |