First, let's take a look at why the change is needed. I'd like to have more flexibility in how I call the
comment.shshell script. Significantly, I'd like to be able to call something else first, perhaps
trto change line endings to the newlines ("\n") that the shell requires. Alternatively, the shell script could be replaced with another tools for applying comments, much like how the typesetting scripts call
pdflatexby default, but can be replaced by another tool like
Doing that is quite straightforward. We just write a little shell script to handle the defaults, just like we did with other actions for the mode. It's just two lines:
Notice that the default call needs to know the path to the resources directory for the mode, indicated here as the shell variable
SEE_MODE_RESOURCES. Also, I've abandoned the original meaning of the
SEE_LATEX_COMMENTvariable; now, it defines the complete behavior for the comment command, not just the string to use.
Perhaps the simplest way to make the path available is just to define
SEE_MODE_RESOURCESwith the appropriate value. To do that, we rewrite the
modeEnvironmenthandler to inject the appropriate value. I came up with this:
I've also eliminated the parameter to the handler, which had specified the language mode for SubEthaEdit. The mode details were only used in defining the environment, so it seemed sensible.
With the new
modeEnvironmenthandler, the logic for the
CommentLinesAppleScript becomes quite simple:
There is now no direct interaction with SEE; the program is written, in effect, in a domain specific language for scripting SEE, abstracting away from the details of SEE's scripting implementation.
As a final point, I'd like to emphasize that the resource path for the mode is now available to the user. For example, I prefer to have a space after the percent sign for LaTeX comments. Thus, I just define
'"$SEE_MODE_RESOURCES"/bin/comment.sh "% "'in the mode environment.