My [Code-Format plugin](https://github.com/codebrainz/code-format) uses the `documents_array` symbol, but this symbol is not exported to plugins anymore. Got an undefined symbol error for this in the Debug Messages. Adding `GEANY_API_SYMBOL` macro to `documents_array` in `document.c` fixes the issue.
--- Reply to this email directly or view it on GitHub: https://github.com/geany/geany/issues/964
Can you not use `document_find_by_id()` as is recommended by the [API docs](http://www.geany.org/manual/reference/document_8h.html#ad1bf4d7a9d5bd299793e...
But, as its documented to be in the API it looks simply like its a bug.
--- Reply to this email directly or view it on GitHub: https://github.com/geany/geany/issues/964#issuecomment-196130599
@elextr no, I need to loop over each document.
--- Reply to this email directly or view it on GitHub: https://github.com/geany/geany/issues/964#issuecomment-196133558
@codebrainz you could use the hated foreach macro then.
There is an argument to be made that given the semantics of the pointers in `documents_array` could be dangerous, since they can point to differing documents during their lifetime, it might be better to remove the array from the API instead, and leave the recommended `document_find_by_id()` as the only access.
--- Reply to this email directly or view it on GitHub: https://github.com/geany/geany/issues/964#issuecomment-196136269
`document_find_by_id()` doesn't allow you to iterate over the documents.
--- Reply to this email directly or view it on GitHub: https://github.com/geany/geany/issues/964#issuecomment-196138580
I said the [`foreach`](http://www.geany.org/manual/reference/document_8h.html#aa6a3efff88c48b5d33ac...) macro
--- Reply to this email directly or view it on GitHub: https://github.com/geany/geany/issues/964#issuecomment-196139196
The `foreach_document()` macro needs to access the documents array, if you remove access to the documents array, that macro can't work.
--- Reply to this email directly or view it on GitHub: https://github.com/geany/geany/issues/964#issuecomment-196139649
IIUC it uses a pointer hidden in another structure, not the direct access to the symbol.
--- Reply to this email directly or view it on GitHub: https://github.com/geany/geany/issues/964#issuecomment-196140513
It accesses `geany_data->documents_array`, yes, but that still gives access to the document pointers (ex. via the `documents` macro). It would be no safer with respect to the lifetime issues.
--- Reply to this email directly or view it on GitHub: https://github.com/geany/geany/issues/964#issuecomment-196141017
Oh, I misread it, it returns an index to the array, I read it as returning an ID, ok, we probably need a `foreach_document_id` macro.
--- Reply to this email directly or view it on GitHub: https://github.com/geany/geany/issues/964#issuecomment-196141903
I think we should just remove the global variables like this which are already accessible through `geany_data` from the plugin API (ie. remove the doc-comments, or move them to the `geany_data` member docs). They were already broken on Windows since the beginning and for a few versions on Linux and friends and it has caused a huge outcry, so it's probably safe to do.
--- Reply to this email directly or view it on GitHub: https://github.com/geany/geany/issues/964#issuecomment-196511075
Can't you use `GeanyData::documents_array` instead of the global?
--- Reply to this email directly or view it on GitHub: https://github.com/geany/geany/issues/964#issuecomment-196511913
Okay, looks like we broke API at some point, but is it wise to re-add that when it's accessible through `GeanyData`?
--- Reply to this email directly or view it on GitHub: https://github.com/geany/geany/issues/964#issuecomment-196513085
No I don't think it's wise. I think we should just remove it('s docs) from the plugin API. It's cleaner to access it through `geany_data`, and the macro madness already uses that pointer anyway.
--- Reply to this email directly or view it on GitHub: https://github.com/geany/geany/issues/964#issuecomment-196514221
It accesses geany_data->documents_array, yes, but that still gives access to the document pointers (ex. via the documents macro). It would be no safer with respect to the lifetime issues.
what life time issues? Since we are single threaded we can safely assume that documents don't go away during a loop
--- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/geany/geany/issues/964#issuecomment-196697311
what life time issues?
If a plugin held on to a `GeanyDocument` pointer and a document was closed and one was opened, the `GeanyDocument` pointer might still point to a document but a different document. It's not an issue during loops, and exists for any function that gives access to a `GeanyDocument`, I'm just telling the issue @elextr is talking about.
--- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/geany/geany/issues/964#issuecomment-196707216
Closed #964 via #966.
--- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/geany/geany/issues/964#event-702542693
github-comments@lists.geany.org