Our teacher, the Rema, wrote: And if he desires not to sit in his place during the third week and to speak—he has the permission to do so. And now it is the custom that they do not sit in their places for the entire thirty days, and for one's father and mother for the entire twelve months, and there is no root for this custom. Nevertheless, one should not deviate from the custom, for every place follows its custom. Thus far his words. And in my humble opinion, it appears that there is a root for this custom, for we have already written that all the customs of consolation are no longer with us, and almost all the ancient customs have been nullified. Therefore, for us as well, it is impossible to distinguish between the second week and the third, and between the third and the fourth. Therefore, we have adopted the law of the beit midrash like the law of other mourning of thirty days, and for one's father and mother twelve months, and it is correct. And this is not a contradiction to the words of the Gemara, for the words of the Gemara in this matter are merely a general custom, and wherever it is practiced—it is practiced. And behold, in the time of the Geonim, and likewise in Ashkenaz, and in the time of the Rivash—the customs changed. And this is what our teacher, the Rema, concludes: "for every place follows its custom." And our teacher, the Beit Yosef, wrote in section 3 (Shulchan Aruch Yoreh Deah 393:3): The mourner does not go out on a weekday to the beit knesset. But on Shabbat—he goes out. And we practice that on every day of the reading of the Torah the mourner goes out to the beit knesset. And our teacher, the Rema, wrote that in these lands the custom is that he does not go out except on Shabbat. Thus far his words. Behold, it is explicit that all these matters depend on custom. He further wrote that on Shabbat he may also go to the beit midrash, see there. And it is likewise explicit in Semachot, see there. And it is not understood what he shall do there, for is he not forbidden in matters of Torah for the entire seven days? And from this is a proof for the Mordechai, who wrote in the name of the Ri that a mourner on Shabbat is permitted in the study of Torah. And I am wondered why they did not bring this opinion at all, and it requires further study (and see in siman 400).
וכתב רבינו הרמ"א: ואם רוצה שלא לישב במקומו שבוע שלישית ולדבר – הרשות בידו. ועכשיו נוהגים שאין יושבין במקומן כל שלושים, ועל אביו ואמו כל שנים עשר חודש, ואין למנהג זה עיקר. ומכל מקום אין לשנות מן המנהג, כי כל מקום לפי מנהגו. עד כאן לשונו. ולעניות דעתי נראה דיש למנהג זה שורש, דכבר כתבנו דכל מנהגי תנחומין אין אתנו, וכמעט שנבטלו כל המנהגות הקדמוניות. ולכן גם זה אי אפשר לנו לחלק בין שבת שני לשלישי, ובין שלישי לרביעי. ולכן תפסנו בדין בית המדרש כבדין שארי אבלות שלושים, ועל אביו ואמו שנים עשר חודש, ונכון הוא. ואין זה סתירה לדברי הגמרא, כי דברי הגמרא בענין זה הוא רק מנהגא בעלמא, והיכי דנהוג – נהוג. והרי בזמן הגאונים, וכן באשכנז, ובזמן הריב"ש – נשתנו המנהגים. וזהו שמסיים רבינו הרמ"א "כי כל מקום לפי מנהגו". ורבינו הבית יוסף כתב בסעיף ג (שולחן ערוך יורה דעה שצג, ג): האבל אינו יוצא בחול לבית הכנסת. אבל בשבת – יוצא. ואנו נוהגין שבכל יום קריאת התורה האבל יוצא לבית הכנסת. וכתב רבינו הרמ"א דבמדינות אלו נוהגין שאין יוצא אלא בשבת. עד כאן לשונו. הרי מפורש דכל דברים אלו תלוים במנהג. עוד כתב דבשבת יכול לילך גם לבית המדרש, עיין שם. וכן מפורש בשמחות, עיין שם. ואינו מובן מה יעשה שמה, הלא אסור בדברי תורה כל שבעה. ומזה ראיה להמרדכי, שכתב בשם ר"י דאבל בשבת מותר בתלמוד תורה. ותמיהני למה לא הביאו כלל דעה זו, וצריך עיון (ועיין בסימן ת).