Browse Source

Show "true" varname

master
Maxime Wack 4 years ago
parent
commit
55e29b486a
2 changed files with 24 additions and 11 deletions
  1. +21
    -11
      functions.R
  2. +3
    -0
      notes.org

+ 21
- 11
functions.R View File

@@ -1,3 +1,8 @@
detectBadName <- function(name)
{
!grepl("^[[:alpha:]]([[:alnum:]]|[_.])*$", name)
}

getType <- function(object)
{
if (is.list(object))
@@ -20,21 +25,26 @@ getType <- function(object)
listObjects <- function()
{
noms <- ls(envir = .GlobalEnv)
objects <- lapply(noms, get, envir = .GlobalEnv)
types <- lapply(objects, get_type)

Map(cat, types, noms, "\n") -> nul
}
objects <- mget(noms, envir = .GlobalEnv)
types <- lapply(objects, getType)

vars <- lapply(noms, function(nom)
{
if (detectBadName(nom))
{
nom <- gsub("\\n", "\\\\n", nom)
nom <- gsub("\\t", "\\\\t", nom)
paste0("`", nom, "`")
} else nom
})

list_objects()
noms <- gsub("\\n", "⏎", noms)
noms <- gsub("\\t", "⭾", noms)

class(unclass(x)) -> list | other
length(x)
names(x)
Map(cat, types, noms, vars, "\n") -> nul
}

default_limit <- 5
current_limit <- default_limit
listObjects()

objectContent <- function(x)
{


+ 3
- 0
notes.org View File

@@ -3,6 +3,9 @@
*** TODO Define the format to convey all the needed information

| islist | type | pretty name | size ? | canonical name |
lt label varname
l -> +/" " if list
t -> type

** TODO Allow user-defined actions on object at point
* Notes


Loading…
Cancel
Save