如何在emacs组织模式中插入当前时间

Iva*_*ets 20 emacs org-mode

是否有一种简单的方法可以在组织模式中插入当前时间(如TIME:[2012-07-02 Mon 16:44])?在手册中有很多东西(时钟,截止日期,时间表),但大多数都需要手动输入时间.

Jon*_*ier 34

C-u C-c . 将在点处插入时间戳,但Org仍会提示您一段时间(默认为当前时间).

更多:组织模式手册中的"创建时间戳".

  • “前缀参数”的解释:[组织手册](https://orgmode.org/manual/Creating-Timestamps.html#Creating-Timestamps)关于插入日期的`Cc .`快捷方式说:“带有前缀参数,它还添加了当前时间。” 手册中的意思就是 [Jon Gauthier](/sf/users/12325281/) 所说的:输入 `Cu Cc .` (<control>-<u> <control>-<c> <句号>)。前缀参数是“Cu”(在命令序列的其余部分之前同时按 <control> 和 <u> 键一次)。 (5认同)
  • 是的,我确实在手册中看到了这一点.但是为什么'Cu Cc'没有相应的Mx命令.`捷径."Mx org-time-stamp"仅将日期无时间地插入当前光标.当前日期与时间命令如何? (3认同)
  • 如果键绑定不起作用,则需要`Mx` org-time-stamp` (2认同)

小智 11

在我的安装中,即组织模式版本9,以下输入当前日期和时间而不提示任何内容

C-u C-u C-c .
Run Code Online (Sandbox Code Playgroud)


Nic*_*lin 6

在 emacs-lisp 中,你可以使用

(org-insert-time-stamp (current-time) t)
Run Code Online (Sandbox Code Playgroud)

使用默认设置,它将生成格式的时间戳

<2021-06-20 Sun 10:33>
Run Code Online (Sandbox Code Playgroud)

如果您想从任何 emacs 会话访问它,请输入

(defun insert-now-timestamp()
  "Insert org mode timestamp at point with current date and time."
  (interactive)
  (org-insert-time-stamp (current-time) t))
Run Code Online (Sandbox Code Playgroud)

在你的.emacs文件中。然后您可以使用 调用该函数M-x insert-now-timestamp

Emacs 27.2,组织模式 9.4.4。

编辑:我现在意识到这与@anachronic 的解决方案具有相同的作用。不过我把它留在这里供参考。


小智 5

C-u C-c !
Run Code Online (Sandbox Code Playgroud)

插入带有当前时间的非活动时间戳,例如:

[2018-05-08 Tue 00:30]
Run Code Online (Sandbox Code Playgroud)