Emacs function to open the file [current date] .tex

I am trying to write an emacs function that uses the current date to create a file. I'm new to emacs, so I have problems with variables and syntax. Here is 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 force it to set the time string as a variable and pass that variable to the find-file function. Any help is appreciated.

+3
source share
4 answers

Based on what others say:

(defun daily-tex-file ()
  (interactive)
  (let ((daily-name (format-time-string "%Y-%m-%d")))
    (find-file (expand-file-name (concat "~/" daily-name ".tex")))))

The main differences:

  • A different format string in which the date is given instead of time (which is what I want)
  • (~/) - , , ,
+2
(defun daily ()     
  (interactive)     
  (let ((daily-name (format-time-string "%T")))
      (find-file (concat daily-name ".tex"))))
+1
(defun daily ()
  (interactive)
  (let ((daily-name (format-time-string "%T")))
    (find-file (format "%s.tex" daily-name))))

M-x daily "12: 34: 56.tex".

0

​​ . :

(defun daily ()
  (interactive)
  (let ((daily-name (format-time-string "%T")))
    (find-file daily-name)))

, , (daily-name) ; daily-name , .

, :

(defun daily ()
  (interactive)
  (find-file (format-time-string "%T")))
0

Source: https://habr.com/ru/post/1792587/


All Articles