Guest User

Untitled

a guest
Mar 25th, 2018
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. (defun mw-org-insert-item-with-ina-ts-when-on-such-item ()
  2. "When on org timestamp item insert org timestamp item with current time.
  3. This holds only for inactive timestamps."
  4. (when (save-excursion
  5. (let ((item-pos (org-in-item-p)))
  6. (when item-pos
  7. (goto-char item-pos)
  8. (org-list-at-regexp-after-bullet-p org-ts-regexp-inactive))))
  9. (let ((item-pos (org-in-item-p))
  10. (pos (point)))
  11. (assert item-pos)
  12. (goto-char item-pos)
  13. (let* ((struct (org-list-struct))
  14. (prevs (org-list-prevs-alist struct))
  15. (s (concat (with-temp-buffer
  16. (org-insert-time-stamp nil t t)
  17. (buffer-string)) " ")))
  18. (setq struct (org-list-insert-item pos struct prevs nil s))
  19. (org-list-write-struct struct (org-list-parents-alist struct))
  20. (looking-at org-list-full-item-re)
  21. (goto-char (match-end 0))
  22. (end-of-line)))
  23. t))
  24.  
  25. (add-hook
  26. 'org-metareturn-hook 'mw-org-insert-item-with-ina-ts-when-on-such-item)
Add Comment
Please, Sign In to add comment