From mboxrd@z Thu Jan 1 00:00:00 1970 From: Marco Wahl Subject: Timestamped items with M-RET Date: Sat, 17 Mar 2018 10:41:45 +0100 Message-ID: <84zi37f38m.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:58607) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ex8Ld-0000uD-Cc for emacs-orgmode@gnu.org; Sat, 17 Mar 2018 05:41:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ex8La-0000aO-3i for emacs-orgmode@gnu.org; Sat, 17 Mar 2018 05:41:57 -0400 Received: from [195.159.176.226] (port=40492 helo=blaine.gmane.org) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ex8LZ-0000Za-TS for emacs-orgmode@gnu.org; Sat, 17 Mar 2018 05:41:54 -0400 Received: from list by blaine.gmane.org with local (Exim 4.84_2) (envelope-from ) id 1ex8JU-0000zl-2s for emacs-orgmode@gnu.org; Sat, 17 Mar 2018 10:39:44 +0100 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: emacs-orgmode@gnu.org Hi! Possibly you also like the feature to create list items including the current time with key M-RET when in such item. This is for creating lists like the following: - [2018-03-17 Sat 10:19] Write to the list. - [2018-03-17 Sat 10:22] Think about wording. This is similar to the functionality already available for timer items. (info "(org) Timers") Get the functionality by adding the following code to your init file. #+begin_src emacs-lisp (defun mw-org-insert-item-with-ina-ts-when-on-such-item () "When on org timestamp item insert org timestamp item with current time. This holds only for inactive timestamps." (when (save-excursion (let ((item-pos (org-in-item-p))) (when item-pos (goto-char item-pos) (org-list-at-regexp-after-bullet-p org-ts-regexp-inactive)))) (let ((item-pos (org-in-item-p)) (pos (point))) (assert item-pos) (goto-char item-pos) (let* ((struct (org-list-struct)) (prevs (org-list-prevs-alist struct)) (s (concat (with-temp-buffer (org-insert-time-stamp nil t t) (buffer-string)) " "))) (setq struct (org-list-insert-item pos struct prevs nil s)) (org-list-write-struct struct (org-list-parents-alist struct)) (looking-at org-list-full-item-re) (goto-char (match-end 0)) (end-of-line))) t)) (add-hook 'org-metareturn-hook 'mw-org-insert-item-with-ina-ts-when-on-such-item) #+end_src The snippet can be found also at https://gist.github.com/marcowahl/8b229ec0979e901d7d90a248c85e3ede . As always, critique is welcome. In the hope that this snippet is useful also for someone else, Marco