org-mode 输入时间设置

在org-mode中,如何设置才能C-c . Enter 之后插入的直接是当前日期和时间啊?把时间也显示出来。 还有C-c C-s Enter 的时候,能不能直接把当前日期、时间插入到文档中啊?

C-h k (describe-key) 来查看 C-c . (org-time-stamp) 的用法:

C-c . runs the command org-time-stamp (found in org-mode-map), which is an interactive Lisp closure in `org.el’.

It is bound to C-c ., .

(org-time-stamp ARG &optional INACTIVE)

Prompt for a date/time and insert a time stamp.

If the user specifies a time like HH:MM or if this command is called with at least one prefix argument, the time stamp contains the date and the time. Otherwise, only the date is included.

All parts of a date not specified by the user are filled in from the timestamp at point, if any, or the current date/time otherwise.

If there is already a timestamp at the cursor, it is replaced.

With two universal prefix arguments, insert an active timestamp with the current time without prompting the user.

When called from lisp, the timestamp is inactive if INACTIVE is non-nil.

(强调是我后加的)

这只是个说明文件,我不知道应该怎么去设置啊

我能看到它设定的方式(语言),但是对lisp不了解,不知道怎么自定义设置。

我可以依照别人的配置自定义func,但是那样就有点麻烦了

这说得很明白了吧?要满足你的需求,加俩 universal prefix arguments 就行, 就是 C-u

哦,谢谢。是我对它的语言不懂,没看过lisp的说明文档。

  • C-u C-c . 当前时间
  • C-c . 00:00 指定时间为 00:00
  • C-c . +1d 当前日期加 1
6 个赞

可以在输入某个相关时间的snippets片段后,自动设置为当前时间吗?
例如: create : time 输入之后: create: 2019-08-02 类似的.

看不懂你在说什么

他的意思是 类似于create 冒号 time update 冒号 time

自动将time转成当前时间 crete冒号llll就不用管了

就是正则替换的自动化

对, 那么正则替换方式,可以在snippets片段中实现吗?
具体实现方式:在反引号( ` )执行emacs脚本

获取文件路径:`file-attributes (buffer-file-name)`
获取当前时间戳:
1. `(current-time-string)`
2. `(format-time-string "<%Y-%m-%d %H:%M>" (current-time))`

Writing snippets

1 个赞

可以在snippet代码中实现

但是你得看看文档 yasnippet可以执行代码 你可以做很多的事情