add tag
निरंजन
I see a definition which has `__`; which if I am not mistaken means it is an internal function. I want to tweak just some text present in it. No change in the actual code, nothing serious really. That function is written with `\cs_new_protected:Npn`. I first tried to renew it with `\RenewDocumentCommand{\macro}{ }{tweaked def}` and it prompted me with an error saying `\macro` isn't defined. Then I thought as it isn't defined, let's issue `\NewDocumentCommand{\macro}{ }{tweaked def}`. Doing this compiled without errors, but there was no change in the behavior of the `\macro`. I then issued the same command from the source, i.e., `\cs_new_protected:Npn`. It again prompted me with an error, but this time it was saying that \macro is already defined :joy:.

I am pretty sure that I am missing something very basic and simple, but I found the error messages very paradoxical.

In `interface3.pdf` I simply searched for the word 'renew' and it turned out that in a 343 pages-long PDF; this word is completely absent.

In the same guide, I found out that there is a way to 'undefine' macros with `\cs_undefine:N \macro`, so I issued it, then I expected the `\macro` to be forgotten completely. I copy-pasted the entire `\cs_new_protected:Npn` definition from the source after `undefin`ing it, edited the text I wanted to change and compiled the document, but I still got the same error saying `\macro` is already defined. What should I do now?
Top Answer
Joseph Wright
At the code level, the split is not `new`/`renew` but rather `new`/`(g)set`. This is because most code that needs to `set` a function will be in a relatively 'tight' situation, where checking is not desirable. We also need to have a  way to define functions which have indeterminate status. So you want either `\cs_set_protected:Npn` (local to the current group level) or `\cs_gset_protected:Npn` (global).

Note that internal functions are exactly that. If you need a (long term) change to an `expl3` internal function, either in the kernel or a third-party package, please initiate a discussion about a suitable interface.

I'm not sure of your issue with `\cs_undefine:N` without an example.

Enter question or answer id or url (and optionally further answer ids/urls from the same question) from

Separate each id/url with a space. No need to list your own answers; they will be imported automatically.