Even to meditate on words of Torah is forbidden in filthy places, and in a bathhouse and in a latrine. And "a place of filth" refers to places where there is excrement or urine. And even the laws of the bathhouse are forbidden to meditate upon in the bathhouse, and likewise the laws of the latrine in the latrine. Therefore, one should think about his accounts there, so that he does not come to meditation (Magen Avraham). And mundane matters are permitted to be spoken there in the holy tongue, but it is a measure of piety to be stringent (ibid.). And likewise, the descriptive attributes such as "Merciful," "Faithful," and the like—it is permitted to say them there. But names that may not be erased—it is forbidden to mention or to meditate upon. And likewise, the giving of a greeting is forbidden there. And it has already been explained that to separate one from a prohibition is permitted even in the holy tongue and in holy matters. And likewise, if a meditation of lewdness enters his heart, it is permitted to meditate on words of Torah, for it is like separating from a prohibition (ibid.). And it has already been explained in siman 74 that facing lewdness, meditation is permitted (ibid.). And our teacher, the Rema, wrote that in a place where it is permitted to meditate on words of Torah, it is permitted to rule on a law, provided that he does not state the reason for the matter. Thus far his words. And when he does not speak in the language of a ruling, but rather says to him "do such and such for me"—it is permitted, even though a law may be learned from this (ibid.). And one who is naked—it is forbidden to hear a blessing from another, and it is forbidden for him to answer "Amen." And see in Yoreh Deah siman 1 (ibid.).
אפילו להרהר בדברי תורה – אסור במקומות המטונפין, ובמרחץ ובבית הכסא. ו"מקום הטנופת" מקרי מקומות שיש שם צואה או מי רגלים. ואפילו הלכות מרחץ אסור להרהר במרחץ, וכן הלכות בית הכסא בבית הכסא. ולכן יחשוב שם חשבונותיו, כדי שלא יבוא לידי הרהור (מגן אברהם). ודברים של חול מותר לאמרם שם בלשון הקודש, ומידת חסידות להחמיר (שם). וכן הכינוים כגון "רחום", "נאמן", וכיוצא בהם – מותר לאומרם שם. אבל שמות שאין נמחקין – אסור להזכיר ולהרהר. וכן נתינת שלום אסור שם. וכבר נתבאר דלאפרושי מאיסורא – מותר אפילו בלשון הקודש ובעניני קודש. וכן אם נכנס בלבו הרהור ערוה – מותר להרהר בדברי תורה, דהוי כמו לאפרושי מאיסורא (שם). וכבר נתבאר בסימן ע"ד דנגד ערוה מותר להרהר (שם). וכתב רבינו הרמ"א דבמקום שמותר להרהר בדברי תורה – מותר לפסוק דין, ובלבד שלא יאמר טעמו של דבר. עד כאן לשונו. וכשאינו אומר בלשון הוראה, אלא אומר לו "עשה לי כך וכך" – מותר, אף שיש ללמוד דין מזה (שם). ומי שהוא ערום – אסור לשמוע ברכה מאחר, ואסור לו לענות "אמן". ועיין ביורה דעה סימן א (שם).