Closed d-torrance closed 3 years ago
How do you figure this will work, since a buffer can be in just one mode but may contain both Macaulay2 code and SimpleDoc code?
How do you figure this will work, since a buffer can be in just one mode but may contain both Macaulay2 code and SimpleDoc code?
By toggling back and forth between the two as necessary using M2-toggle-simple-doc-mode
.
Such toggling will be annoying, so people will be tempted to have files that consist entirely of simple doc code. What about a file extension for such files, and add it to auto-mode-alist
?
If this is a separate mode, then please put it in a separate file. It would be good to also separate M2-mode
and M2-comint-mode
, but I never got around to doing that. Also, I don't like hardcoding the keywords in M2-simple-doc-keywords
.
I have to say, my preference is to revert #18. I don't think the simplifications there are worth adding the complexity in this PR. For #13 specifically, I've seen other languages with modes that support special indentation inside docstrings without the need for a separate mode and I think that would be an easier solution. But if you must add a new mode, perhaps M2-doc-mode
or M2-docstring-mode
is a better name.
Also, would be great if you could check that the additions don't introduce new linting errors (see https://github.com/melpa/melpa/pull/6984 for links to how to run the checks).
I've seen other languages with modes that support special indentation inside docstrings without the need for a separate mode and I think that would be an easier solution.
I like this idea. I'll convert this to a draft for now and play around with it some more.
Closing. I plan to work on indentation for SimpleDoc
strings later, but in another pull request.
The new indent/newline behavior I introduced in #18 totally broke writing
SimpleDoc
documentation. Since it doesn't use parentheses, everything is automatically flushed to the far left:Of course, users can still get around this by turning off
electric-indent-mode
, or just usingC-j
for newlines, but I figured taking a stab at tackling #13 would be nice.This PR is a first draft a new major mode,
M2-simple-doc-mode
. It's derived fromM2-mode
and only defines a newindent-line-function
. Users can toggle between the two withM2-toggle-simple-doc-mode
(currently bound toC-c C-s
, but I'm open to suggestions!) With this mode enabled, tabbing works as expected:It's not perfect yet (
Inputs
,Outputs
, andCannedExample
don't quite work yet), but it's certainly better than the current behavior!