Skip to content

[222_49] fix math mode tab cycling for backtick, brackets and pipe#2916

Merged
wumoin merged 2 commits intoMoganLab:mainfrom
1sh-repalto:1sh-repalto/222_49/fix-math-mode-tab-cycling-for-backtick-brackets-pipe
Mar 5, 2026
Merged

[222_49] fix math mode tab cycling for backtick, brackets and pipe#2916
wumoin merged 2 commits intoMoganLab:mainfrom
1sh-repalto:1sh-repalto/222_49/fix-math-mode-tab-cycling-for-backtick-brackets-pipe

Conversation

@1sh-repalto
Copy link
Contributor

Fixes #2910
In math mode, backtick (`), square brackets ([, ]), and vertical bar (|) do not show the Tab cycle focus box popup

Summary

Enable the Tab cycle popup for keys bound to procedures (make-lprime, math-bracket-open) in math mode, so users can discover and cycle through variants using Tab.

Developer document: devel/222_49.md

Issue Found

In math-edit.scm, the tabcycle-symbols function only handled string-type keyboard bindings. Keys like `, [, and | are bound to procedures (e.g., make-lprime, math-bracket-open), so tabcycle-symbols returned an empty list and no popup was shown — even though these keys have Tab variants defined in math-kbd.scm.

;; Before: procedure bindings were rejected
(base (if (string? primary-sym)
          `((symbol-completion ,primary-sym))
          '()))  ;; <-- always empty for procedures

Changes

  1. Extended lambda-to-symbol in TeXmacs/progs/math/math-edit.scm to handle make-lprime and math-bracket-open. For brackets, left and right args are concatenated for unique display (e.g., [], [[, ]], ][).

  2. Modified tabcycle-symbols to use function-to-symbol for procedure-bound primary symbols:

;; After: handles both string and procedure bindings
(base (cond
        ((string? primary-sym)
         `((symbol-completion ,primary-sym)))
        ((procedure? primary-sym)
         (let ((sym (function-to-symbol kbd-res)))
           (if sym (list sym) '())))
        (else '())))
  1. Fixed deduplication filter to extract primary-name from base instead of using primary-sym directly, preventing crashes when primary-sym is a procedure.

How to Test

  1. Open Mogan Editor
  2. Enter math mode by pressing $
  3. Type ` (backtick) — verify a Tab cycle popup appears showing prime variants
  4. Press Tab to cycle through the variants
  5. Type [ — verify a popup appears showing bracket pair variants ([], [[, ]], ][)
  6. Type | — verify a popup appears showing pipe variants
  7. Type a — verify the existing Tab cycle behavior (a → α) still works correctly
tab-cycle-fix.mp4

@1sh-repalto 1sh-repalto changed the title [222 49] fix math mode tab cycling for backtick, brackets and pipe [222_49] fix math mode tab cycling for backtick, brackets and pipe Mar 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

数学模式下波浪号、方括号、竖线没有Tab循环框

2 participants