Skip to content

Commit

Permalink
Tweaks.
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.r-project.org/R/trunk@85513 00db46b3-68df-0310-9c12-caf00c1e9a41
  • Loading branch information
hornik committed Nov 12, 2023
1 parent 88d380a commit 1978052
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 20 deletions.
1 change: 1 addition & 0 deletions src/library/utils/NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ S3method(edit, matrix)
S3method(edit, vignette)
S3method(format, MethodsFunction)
S3method(format, "aspell")
S3method(format, "aspell_inspect_context")
S3method(format, "news_db")
S3method(format, "object_size")
S3method(format, "roman")
Expand Down
44 changes: 24 additions & 20 deletions src/library/utils/R/aspell.R
Original file line number Diff line number Diff line change
Expand Up @@ -370,38 +370,42 @@ function(x)
y
}

print.aspell_inspect_context <-
format.aspell_inspect_context <-
function(x, ..., byfile = FALSE)
{
if(byfile) {
s <- split(x, x$File)
nms <- names(s)
for(i in seq_along(s)) {
e <- s[[i]]
writeLines(c(sprintf("File '%s':", nms[i]),
sprintf(" Line %s: \"%s\", \"%s\", \"%s\"",
format(e$Line),
gsub("\"", "\\\"", e$Left ), e$Original,
gsub("\"", "\\\"", e$Right)),
""))
}
chunks <- if(byfile) {
chunks <- split(x, x$File)
Map(function(u, e)
c(sprintf("File '%s':", u),
sprintf(" Line %s: \"%s\", \"%s\", \"%s\"",
format(e$Line),
gsub("\"", "\\\"", e$Left ), e$Original,
gsub("\"", "\\\"", e$Right)),
""),
names(chunks),
chunks)
} else {
y <- sprintf(" %s:%s:%s\n %s%s%s\n %s%s",
x$File, x$Line, x$Column,
x$Left, x$Original, x$Right,
strrep(" ", as.integer(x$Column) - 1L),
strrep("^", nchar(x$Original)))
chunks <- split(y, x$Original)
chunks <- Map(function(u, v)
paste(c(paste("Word:", u), v),
collapse = "\n"),
names(chunks),
chunks)
writeLines(unlist(chunks))
Map(function(u, v)
paste(c(paste("Word:", u), v),
collapse = "\n"),
names(chunks),
chunks)
}
invisible(x)
unlist(chunks, use.names = FALSE)
}

print.aspell_inspect_context <-
function(x, ..., byfile = FALSE)
{
writeLines(format(x, ..., byfile = byfile))
invisible(x)
}

## For spell-checking the R manuals:

Expand Down

0 comments on commit 1978052

Please sign in to comment.