I'm trying to write an emacs function that uses the current date to create a file. I'm new to emacs and so I'm having trouble with variables and syntax. Here's what I have:
(defun daily ()
(interactive)
(let daily-name (format-time-string "%T"))
(find-file (daily-name)))
I don't understand how emacs uses variables well enough to get it to set the time string as a variable and feed that variable into the find-file function. Any help is appreciated.
To build on what others are saying:
(defun daily-tex-file ()
(interactive)
(let ((daily-name (format-time-string "%Y-%m-%d")))
(find-file (expand-file-name (concat "~/" daily-name ".tex")))))
Main differences:
~/
) -- if you don't put this, you'll get files all over the place, depending on what the current working directory is at the moment you invoke the function(defun daily ()
(interactive)
(let ((daily-name (format-time-string "%T")))
(find-file (format "%s.tex" daily-name))))
Calling M-x daily
now opens a file "12:34:56.tex".
(defun daily ()
(interactive)
(let ((daily-name (format-time-string "%T")))
(find-file (concat daily-name ".tex"))))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With