I consume legumes daily and found that using baking soda completely eliminated gaseous emissions from them.
For lentils, I soak 20 g in water with 1/4 tsp baking soda for a hour. Then discard the liquid before cooking.
For refried black beans I first bring 65 g of beans to simmer then add 1/4 tsp baking soda and stir briskly.
Once I implemented this protocol I found that onions and prunes were also causing gas. Seems any stone fruit gives me gas because this also happens with apricots. I haven’t found a way to fix the stone fruit. But the onions can be fixed by heating them with lime juice before consuming.
Hope that helps.