Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatically update chunk name #54

Open
ghost opened this issue Jan 28, 2019 · 4 comments
Open

Automatically update chunk name #54

ghost opened this issue Jan 28, 2019 · 4 comments

Comments

@ghost
Copy link

ghost commented Jan 28, 2019

Thanks for the great tool!

Q1: Suppose I created the following two chunks:

```{r MyOwesomeCodeChunk1} plot(cars) ```

```{r MyOwesomeCodeChunk2} plot(cars) ```

I deleted the first code chunk, and then create a new chunk.

The new chunk automatically get a name as MyOwesomeCodeChunk2. However, the previous second chunk MyOwesomeCodeChunk2 (which is now the first chunk) stay as MyOwesomeCodeChunk2. Therefore, there are now two chunks with the same name as MyOwesomeCodeChunk2.

How to fix this?

Q2: Some of my chunks got names like MyOwesomeCodeChunk001, MyOwesomeCodeChunk002, ... some of them got names like MyOwesomeCodeChunk08, MyOwesomeCodeChunk09. How to fix them?

Q3: Can I automatically delet all the chunk names?

Q4: How to disable automatically naming chunk?

Thanks!

@yonicd
Copy link
Collaborator

yonicd commented Jan 29, 2019

first the low hanging fruit

Q3: we didn't write a function for this, but it shouldn't be a problem to create one.
Q4: remedy::remedy_opts$set(basic = TRUE) (the help docs of remedy::chunkr need to be updated to expose those options (cc @ColinFay )

i am not sure how you are creating the new chunks, since there are several ways to do this now. can you explain again what addins/functions you are using?

using the addin chunk, there is a problem in the counter.

if you have two chunks lets say


``{r remedy001}


``

``{r remedy002}


``

and remove the first one


``{r remedy002}


``

then move the cursor above the remaining chunk and add a chunk the counter will work right


``{r remedy001}


``

``{r remedy002}


``

but if the cursor is below the counter will not pick it up that it needs to skip 02


``{r remedy002}


``

``{r remedy002}


``

on the other hand the chunkname addin is a bit smarter at counting, which leads into the 02 002 question.

chunkname first counts how many chunks you have and adjusts the 0 padding accordingly. it also will understand if a number has been used already in the chunk names. so the problem of chunk addin disappears.

Since chunkname came a bit later in development than chunk, they arent synched yet, but i'll add it to the list of issues to solve for the next release.

thank you for bringing up this issue!

@ghost
Copy link
Author

ghost commented Jan 29, 2019

Thanks for the reply! Very helpful.

@statnmap
Copy link
Member

There must be some answers to this in {namer}: https://github.com/lockedata/namer

@yonicd
Copy link
Collaborator

yonicd commented Oct 17, 2019

This feature predated {namer}. It is on the TODO list of things to fix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants