Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

race condition in starting mmm-mode? #86

Closed
stephe-ada-guru opened this issue Apr 14, 2018 · 2 comments
Closed

race condition in starting mmm-mode? #86

stephe-ada-guru opened this issue Apr 14, 2018 · 2 comments

Comments

@stephe-ada-guru
Copy link
Contributor

(aside; just started using mmm-mode, and so far it works fine, except for this issue)

I'm writing wisi-grammar-mode, a mode for wisi grammar files; similar to bison/yacc grammar files; they have embedded code in elisp or Ada in the grammar actions. To get proper indentation in the grammar actions, I'm using mmm-mode.

It works fine interactively, but fails in my tests. To run a test, I spawn a new emacs, load a wisi-grammar file, run indent, save the result. Then a makefile diffs the test result with the original.

I saw issue #80 about -batch mode; I'm using emacs -Q, so that's not the issue.

To start mmm normally, I've set:
(setq mmm-global-mode 'classes)
(add-to-list 'mmm-mode-ext-classes-alist '(wisi-grammar-mode nil wisi-action))

That relies on post-command-hook to start mmm-mode, which means it runs after the test function, which is the first command run in the spawned emacs. So in the test code, I set:
(add-hook 'wisi-grammar-mode-hook 'mmm-mode-on)

That sets indent-line-function, and an overlay, but the indent is still wrong, so something is still not being set properly.

@stephe-ada-guru
Copy link
Contributor Author

I figured out the cause of the problem; my test uses 'indent-region', and wisi-grammar-mode provides 'indent-region-function', but mmm only provides 'indent-line-function'. My indent-region sends the buffer contents to an external process that computes the indent.

It might make sense for a new mmm-indent-region to call the appropriate indent-region on each subregion. I'll give that a try.

@dgutov
Copy link
Owner

dgutov commented Apr 14, 2018

Makes sense. One tricky part is to properly delineate regions like this (e.g. skip the ones that don't include a newline, for instance).

@dgutov dgutov closed this as completed Jul 5, 2020
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

No branches or pull requests

2 participants