Emacs功能打开文件[current date] .tex [英] Emacs function to open file [current date].tex
本文介绍了Emacs功能打开文件[current date] .tex的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试编写一个使用当前日期创建文件的emacs函数。我是新来的emacs,所以我有变量和语法的麻烦。这是我有的:
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)))
我不明白emacs如何使用变量足够好让它将时间字符串设置为变量,并将该变量提供给find-file函数。任何帮助是赞赏。
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")))))
主要区别:
- 不同的格式字符串,它提供日期而不是时间这是你想要的,我想)
- 指定目录(
〜/
) - 如果你不这样做,你会得到所有的文件,根据当前的工作目录是什么在你调用的功能 - 更好的功能名称
- Different format string, which gives date instead of time (which is what you want, I think)
- specifying the directory (
~/
) -- 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 - better function name
这篇关于Emacs功能打开文件[current date] .tex的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文