News for hackers. Stuff that matters.
Re:Sorting in Emacs by owl57 on Saturday August 12, 2023 @09:47AM (#37100124)
You technically described how to make a word sorting macro execute arbitrary code.

Fascinating to think how that doesn't mean it's bad advice. That is, unless your threat model includes targeted attacks by three-letter-scale adversaries — and then you maybe just don't open untrusted files in Emacs or use advice from strangers on HN.

Re:Sorting in Emacs by tom_ on Saturday August 12, 2023 @10:04AM (#37100292)
That's a good point. My assumption, not that I ever stated it, was that the list would be one you'd typed out yourself, or was one that was just there in code already, and you could verify by eye that it's just string literals.

Using Python's eval with empty globals and locals dicts (consult the docs) could make this safer, though I've only ever had to use that for defending against accidents rather than malice. And now this quick thing is becoming increasingly complicated, and maybe you'd be better off engineering it properly.

Re:Sorting in Emacs by ktm5j on Saturday August 12, 2023 @12:57PM (#37102066)
This is actually a rather common thing to do.. I have functions that run shell commands in my spacemacs config to do things like this. For example I've got one that runs `date` to insert today's date in a particular format.