# [texworks] Early thoughts

Jonathan Kew jonathan at jfkew.plus.com
Thu Sep 18 15:26:05 CEST 2008

Hi Will, nice to have you here!

On 18 Sep 2008, at 1:17 PM, Will Robertson wrote:

> Hello,
>
> Now there's a mailing list for TeXworks (which nobody told me about!)

Sorry! (It's mentioned on the texworks pages both at TUG and Google,
though.)

> I don't feel so bad about posting suggestions for the program :) What
> follows is a serious "wish" list in that while I wish it was there,
> I'm still going to use the program without these features.
>
> I'm trying hard not to suggest ideas that would complexify the
> program.
>
> I'll omit bugs and behaviour that could be improved in favour of the
> bug tracker…whenever I get around to doing that.

Thanks for your comments -- as always, plenty of good thoughts here.

> (1) The UI can be simplified! The following items should be dropped
> from the "Format" menu since they're already (rightly) included in the
> preferences:
>    - "Font…"
>    - "Wrap lines"
>    - "Syntax Coloring"

Well, they're not the same thing. The Preferences dialog sets the
defaults for newly-opened editor windows; the Format menu items affect
the current window only.

Now maybe that's not necessary or helpful; maybe these settings should
be "global", not set for individual windows at all. Anyone have
thoughts on this?

> (2) I'd really like the Find/Replace panels to be merged :)

Could do, though some apps that do this end up with rather a lot of
options and buttons in the resulting dialog.

Care to come up with a proposed design? :)

> (3) Filtering the list of "Processing tools" (pdfLaTeX, etc.) could be
> done quite reliably to omit options that don't make sense. E.g.,
>
>  Matches ^\\usepackage([.*])?{fontspec} (etc.) -> XeLaTeX
>  Matches ^\\usepackage([.*])?{microtype} (etc.) -> pdfLaTeX
>  None of the above & matches ^\\bye -> Plain
>  Matches ^\\bibliography\{ -> BibTeX
>
> You'd only need a very small number of regexps, I think, to match the
> majority of cases most of the time. And this would simply things in
> the UI very nicely.

I considered doing something along these lines; I was thinking more in
terms of auto-detecting a default engine even without a TeXShop-style
comment at the start, rather than filtering the list, but it'd be a
similar idea. This would have problems, though, with a doc that does
something like

\usepackage{ifxetex}
\ifxetex
\usepackage[no-math]{fontspec}
\setmainfont{Times-Roman}
\else
\usepackage[utf8]{inputenc}
\usepackage{times}
\usepackage{microtype}
\fi
% ....etc

But it's probably worth trying to do something, anyhow. (Might also
want to detect \usepackage{pst*} and default to using simpdftex.)

> For the people that will complain that it doesn't work in their tiny,
> specific, edge case, just offer an option to turn off the filtering.
> (Or a secret preference to edit the filtering regexps.)

I'm intending to put several things like this -- e.g., the regexps for
syntax coloring and for tag detection -- into simple text files in the
"resources" folder, so they can easily be customized.

> (5) As well as command completion, I'd like automatic trigger stuff.
> E.g., typing \begin{ on an otherwise empty line would immediately
> insert an \end{ on the next line and then fill in both environment
> delimiters at the same time as you typed the name of the environment.
> Editing one of them would edit the other, simultaneously.

Yes, that'd be slick.

> (6) Smart <return> behaviour.
>  - Match the indentation of the previous line
>  - To generalise this idea, match the "prefix" of the previous line,
> such as "[%]*[ ]*" or even "%<[a-zA-Z]*>[ ]*" (for .dtx files)
>  - Increase the indentation when the previous line contains
> \begin{([a-zA-Z]*)} but doesn't contain \end{\1}
>  - Increase the indentation when the previous line ends with {
>  - Hitting delete after a smart indentation or a smart line prefix
> insertion would undo the "smart whatever" rather than just backspacing
> a key.

Ditto.

Thanks,

JK