Skip to content

LaTeX-like symbol substitution: Combining characters cause formatting problems #225

@saf-dmitry

Description

@saf-dmitry

When performing a LaTeX-like symbol substiution, description strings for some completion candidates in the "*Completions*" buffer appear misaligned, when the first character in a description string is a combining diacritical mark:

Image

The same issue when using Company completion framework with the CAPF frontend enabled. Here, the description strings even appear in wrong color:

Image

This is apparently because the space character immediately preceding the combining diacritical mark gets "consumed", that is, combined with the diacritical mark.

Emacs version: 30.2
Julia mode version: From GitHub on 2025-08-21

Experimenting with different fonts has shown that the formatting issue manifests itself if and only if a font does not support proper rendering of combined characters. Ironically, the JuliaMono font (among some others) does support it and it causes the formatting problem.

Suggested solution: Adding a zero-width space character (U+200B) before completions starting with a combining diacritical mark (or, for that matter, all completions) when defining :annotation-function property in the julia--latexsub-capf-list function:

(defun julia--latexsub-capf-list (beg end pred)
  "Return list suitable for use in `completion-at-point-functions' of latexsubs."
  (list beg end julia-mode-latexsubs :exclusive 'no
        :annotation-function (lambda (s)
                               (concat " \u200b" (gethash s julia-mode-latexsubs)))
        :exit-function (julia--latexsub-exit-function beg)
        :predicate pred))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions