Discussion:
[TxMt] merge mads379/align.tmbundle into source:Align Assignments command
Tim Bates
2018-11-14 12:07:03 UTC
Permalink
It would be nice if the Align Assignments command absorbed the smart code from the align bundle, which appears moribund (?), but which is much smarter about alignments.

https://github.com/mads379/align.tmbundle
Allan Odgaard
2018-11-14 12:34:13 UTC
Permalink
Post by Tim Bates
It would be nice if the Align Assignments command absorbed the smart
code from the align bundle, which appears moribund (?), but which is
much smarter about alignments.
I’m not keen on switching to a preferneces based system because
majority of users will not want to customize the Align Assignments
command, and I am also not sure what cases (handled by the default
command) where the user would actually want to change it.

But it would be useful to know where the current command gets it wrong
or how it can be improved.
Tim Bates
2018-11-14 17:43:08 UTC
Permalink
Post by Tim Bates
It would be nice if the Align Assignments command absorbed the smart code from the align bundle, which appears moribund (?), but which is much smarter about alignments.
I’m not keen on switching to a preferneces based system because majority of users will not want to customize the Align Assignments command, and I am also not sure what cases (handled by the default command) where the user would actually want to change it.
But it would be useful to know where the current command gets it wrong or how it can be improved.
For one, given this selection in an R script:

#' selDVs = c("ht1", "ht2")
#' mzData <- twinData[twinData$zygosity %in% "MZFF", ]
#' dzData <- twinData[twinData$zygosity %in% "DZFF", ]


align does the right thing, and aligns the <- assignments. The built-in align does nothing. So having the built-in do the right thing here would be good.


The preferences system could be independent of user intervention, no? Just get bundle maintainers to include an align preference. Like this one for R
And the ready-made align command in TM could inherit/import these.


{ shellVariables = (
{ name = 'TM_SOURCE_ALIGNMENT_PATTERN';
value = '[
{
"comment" : "align on assignments",
"regexp" : "=|<-|->",
"minimum_spacing_before" : " ",
"minimum_spacing_after" : " ",
"padding" : "before"
},
{
"comment" : "align right-hand side formulae assignments",
"regexp" : "~",
"minimum_spacing_before" : " ",
"minimum_spacing_after" : " ",
"padding" : "before"
},
{
"comment" : "align any stacked assignments on a line",
"regexp" : ";",
"minimum_spacing_before" : "",
"minimum_spacing_after" : " ",
"padding" : "before"
},
{
"comment" : "align any comments",
"regexp" : "#",
"minimum_spacing_before" : " ",
"minimum_spacing_after" : " ",
"padding" : "before"
}]';
},
);
}
Allan Odgaard
2018-11-15 01:22:36 UTC
Permalink
Post by Tim Bates
#' selDVs = c("ht1", "ht2")
#' mzData <- twinData[twinData$zygosity %in% "MZFF", ]
#' dzData <- twinData[twinData$zygosity %in% "DZFF", ]
Do you use `<-` interchangeably with `=`? So the desired result is:

#' selDVs = c("ht1", "ht2")
#' mzData <- twinData[twinData$zygosity %in% "MZFF", ]
#' dzData <- twinData[twinData$zygosity %in% "DZFF", ]
Post by Tim Bates
align does the right thing, and aligns the <- assignments. The
built-in align does nothing. So having the built-in do the right thing
here would be good.
I see no issue with adding `<-` to the list of operators on line 9 of
Align Assignments.
Post by Tim Bates
The preferences system could be independent of user intervention, no?
Just get bundle maintainers to include an align preference. Like this
one for R
And the ready-made align command in TM could inherit/import these.
Since 99% of languages have the same assignment operators, it seems
awfully redundant, and a heuristic might be smarter than a preference
system.

For example currently, the command will first check if there are equal
characters, failing that, it will use colon.

I am thinking this could be made even smarter, so it would not just
check if the characters exist, but it will check if they are already
aligned, and if so, jump to the next character in the list, that way,
you could use Align Assignments in successesion, e.g. first to align
assignments, then press again to align the trailing line comments.
Timothy Bates
2018-11-18 10:34:13 UTC
Permalink
Thanks twould be great: one often wants the command to look out into the
line for something else to align once an initial assign is aligned. Like
commas too.
T
Post by Tim Bates
#' selDVs = c("ht1", "ht2")
#' mzData <- twinData[twinData$zygosity %in% "MZFF", ]
#' dzData <- twinData[twinData$zygosity %in% "DZFF", ]
#' selDVs = c("ht1", "ht2")
#' mzData <- twinData[twinData$zygosity %in% "MZFF", ]
#' dzData <- twinData[twinData$zygosity %in% "DZFF", ]
align does the right thing, and aligns the <- assignments. The built-in
align does nothing. So having the built-in do the right thing here would be
good.
I see no issue with adding <- to the list of operators on line 9 of Align
Assignments.
The preferences system could be independent of user intervention, no? Just
get bundle maintainers to include an align preference. Like this one for R
And the ready-made align command in TM could inherit/import these.
Since 99% of languages have the same assignment operators, it seems
awfully redundant, and a heuristic might be smarter than a preference
system.
For example currently, the command will first check if there are equal
characters, failing that, it will use colon.
I am thinking this could be made even smarter, so it would not just check
if the characters exist, but it will check if they are already aligned, and
if so, jump to the next character in the list, that way, you could use
Align Assignments in successesion, e.g. first to align assignments, then
press again to align the trailing line comments.
_______________________________________________
textmate mailing list
https://lists.macromates.com/listinfo/textmate
Loading...