-
Notifications
You must be signed in to change notification settings - Fork 33
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
Add mmm-indent-region #75
base: master
Are you sure you want to change the base?
Conversation
Provides a function which can indent all submodes partially in the region, even if they don't take up an entire line or have special indentation needs (e.g. narrowing). Also adds a somewhat less convoluted implementation of mmm-indent-line-narrowed, which has roughly equivalent function to the first one except it falls back to mmm-indent-line when there isn't a region to narrow.
This fixes one last problem I was having with indenting regions which overlapped but did not fully contain a submode overlay. It also causes submodes which take up less than one line or start in the middle of a line to e indented properly. The change to |
mmm-region.el
Outdated
(overlay-end mmm-current-overlay)) | ||
indent-function) | ||
indent-function))))) | ||
(if mmm-current-overlay |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But mmm-current-overlay
can be outdated, can't it?
That's why we call mmm-update-submode-region
down there.
Also makes mmm-indent-line-narrowed update the submode region before testing the current overlay.
Apologies for the delay. I've moved both commands to mmm-cmds, made |
Looking at the description again, I have to ask:
Does that mean that the line indentation function still performs incorrectly in certain cases? That seems like it should be fixed first.
|
Yes, there was a bug in I agree that an indent-region-function should only be used for perf in a Suppose we have the toy mode: (require 'mmm-mode)
;;;###autoload
(define-derived-mode kek-mode prog-mode "kek"
(mmm-add-classes `((c :submode js-mode :front "ccc" :back "ddd")))
(mmm-add-mode-ext-class 'kek-mode nil 'c))
(provide 'kek-mode) And the toy buffer: ccc let a = 2 ddd test ccc function (a, b) { }
let a = 2 ddd hello What do we do if the user presses TAB? Do we indent all of the modes, the The current behavior is Neither is more "correct" imo but allowing us to indent multiple submodes per |
Obviously, you will. But by the rules of the mode that the position at the indentation belongs to. Where is point in this example anyway?
That's the same as just pressing TAB. And anyway, if the point is on the first line, how would you indent the |
Provides a function which can indent all submodes partially in the region, even
if they don't take up an entire line or have special indentation needs (e.g. narrowing).
Also adds a somewhat less convoluted implementation of mmm-indent-line-narrowed,
which works similarly to the first one except it falls back to mmm-indent-line when
there isn't a region to narrow.