I'd just like to get the filename of the most recently modified PDF file in my /tmp/ directory, using elisp. Is there a function for that?

  • If the thing which is writing the file to the tmp directory is also under the control of Emacs, it would be cleaner if you weren't guessing at the filename it created. Potentially have Emacs create a tmp filename and pass that to the program to use. YMMV, and your original approach probably does the job for you in practice, but I'd be looking for a way to not have to rely on it.
    – phils
    Jan 18, 2022 at 20:56
  • emacs.stackexchange.com/tags/elisp/info
    – Drew
    Jan 18, 2022 at 22:46

1 Answer 1


(shell-command-to-string "ls -t /tmp/*.pdf | head -1")

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.