Shulchan Arukh, Orach Chayim 153:20שולחן ערוך, אורח חיים קנ״ג:כ׳
There is one who says [regarding] a Torah scroll that is assumed to have belonged to Reuven's ancestors, that the community may not possess it.
Mishnah Berurah 153:99משנה ברורה קנ״ג:צ״ט
...
Shulchan Arukh, Yoreh De'ah 259:2שולחן ערוך, יורה דעה רנ״ט:ב׳
Moneys donated for purposes of the synagogue or of the cemetery, may, if the community sees fit to do so, be diverted to the use of the House of Study or to the maintenance of a Religious School, even against the will of the donors; but moneys collected for the support of a school cannot be commuted to the synagogue.
RMI.—Only where there is ground for apprehension that there will not be sufficient money for school purposes [if this money were to be diverted to the synagogue]; but where the members of the community support the schools generously (so that if this money is spent for a synagogue they will surely furnish more money for the schools); in such a case, it is permitted, even in a place where it is [usually] forbidden to change the will of the donor. If one donates a sum of money for a purpose for which there is no need [at present]; as, for example, he donates a site for a House of Study and for certain reasons the building cannot be erected immediately, the donor cannot retract, but the site remains until the House of Study is eventually erected. All this applies in places where there is no established custom. But where it is established that the Gabbai or the assembled community has the right to commute the funds from one charitable purpose to another, we follow the usual custom; for we presume that the donor makes his donation subject to custom and that the authorities accept it with this condition at heart [that they may dispose of it at their discretion]. Of course, where the donor expressly stipulates that his donation shall not be subject to change, naturally it cannot be commuted.
RMI.—Only where there is ground for apprehension that there will not be sufficient money for school purposes [if this money were to be diverted to the synagogue]; but where the members of the community support the schools generously (so that if this money is spent for a synagogue they will surely furnish more money for the schools); in such a case, it is permitted, even in a place where it is [usually] forbidden to change the will of the donor. If one donates a sum of money for a purpose for which there is no need [at present]; as, for example, he donates a site for a House of Study and for certain reasons the building cannot be erected immediately, the donor cannot retract, but the site remains until the House of Study is eventually erected. All this applies in places where there is no established custom. But where it is established that the Gabbai or the assembled community has the right to commute the funds from one charitable purpose to another, we follow the usual custom; for we presume that the donor makes his donation subject to custom and that the authorities accept it with this condition at heart [that they may dispose of it at their discretion]. Of course, where the donor expressly stipulates that his donation shall not be subject to change, naturally it cannot be commuted.
Siftei Kohen on Shulchan Arukh, Yoreh De'ah 259:6:1שפתי כהן על שולחן ערוך יורה דעה רנ״ט:ו׳:א׳
...