Skip to content

Conversation

@kiyoka
Copy link

@kiyoka kiyoka commented Jan 12, 2026

Description

This PR fixes a backward compatibility issue where mozc.el cannot display the candidate window when used with older versions of mozc_emacs_helper.

After investigating, I confirmed with the Mozc developers that the protocol change in commit ec4ff27 was simply a field rename from candidates to candidate-window with no functional changes.

The fix modifies mozc.el to support both field names, ensuring it works with both old and new versions of mozc_emacs_helper without breaking existing setups.

Issue IDs

#1424

Steps to test new behaviors

  • OS: [e.g. Linux with Emacs]
  • Steps:
    1. Use mozc.el (v2.30.5618 or later) with an older mozc_emacs_helper (v2.29.5160.102 or earlier)
    2. Activate mozc-mode and start typing in Japanese
    3. Confirm that the candidate window appears correctly
    4. Check the Messages buffer for debug output showing which field is being used

Additional context

This change ensures backward compatibility by checking for candidate-window first (new protocol) and falling back to candidates (old protocol) if not present. Debug logging has been added to help identify which protocol version is being used.

Ensure compatibility with both old and new versions of mozc_emacs_helper by supporting both candidate window field names. Prioritize `candidate-window` and fall back to `candidates` if not present. Add debug logging output.

Fixes google#1424
@google-cla
Copy link

google-cla bot commented Jan 12, 2026

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@kiyoka
Copy link
Author

kiyoka commented Jan 12, 2026

I have signed the CLA. Could you please re-run the CLA check?

Copy link
Collaborator

@hiroyuki-komatsu hiroyuki-komatsu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your contribution.

(cands (mozc-protobuf-get output 'candidates))
(candidates (progn
(when (or cand-window cands)
(message "mozc.el: Using '%s' field for candidates"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this show a message every key event?

How about simplifying as follows?

(candidates (or (mozc-protobuf-get output 'candidate-window)
                (mozc-protobuf-get output 'candidates)))

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, it was displaying a message on every key event. I've removed the message and simplified the code as you suggested.

(preedit (mozc-protobuf-get output 'preedit))
(cand-window (mozc-protobuf-get output 'candidate-window))
(cands (mozc-protobuf-get output 'candidates))
(candidates (progn
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a comment why candidates is also checked here (e.g. ; candiates is also checked for backward compatibility (see: #1424)).

- Simplify candidate field handling using (or ...) syntax
- Remove verbose debug message
- Add comment explaining backward compatibility
@kiyoka
Copy link
Author

kiyoka commented Jan 24, 2026

Updated per your suggestions. Tested with both old and new mozc_emacs_helper versions.

Copy link
Collaborator

@hiroyuki-komatsu hiroyuki-komatsu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for update!

(let ((result (mozc-protobuf-get output 'result))
(preedit (mozc-protobuf-get output 'preedit))
(candidates (mozc-protobuf-get output 'candidate-window)))
(let* ((result (mozc-protobuf-get output 'result))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use let here, since let* is no longer necessary.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, I overlooked that. Fixed now.

Use let instead of let* since sequential binding is no longer needed.
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.

2 participants