org-time-stamp
inserts at point (see definition of point
in the Emacs manual) so you are in complete control of where the string is inserted. If it is not inserted where you expect, then you need to move point
(i.e. your cursor) to the appropriate place. Note that point
is between two characters: the character that your cursor is on and the character before it.
org-time-stamp
is also used by other functions (e.g. org-schedule
) to insert the time stamp, so it does not insert anything extra: if anything extra needs to be added, it is added by the caller either manually or using PRE and POST arguments of org-insert-time-stamp
, depending where you want to insert the strings.
You can define your own function to make it do what you want, e.g.:
(defun my/org-time-stamp-on-new-line ()
(interactive)
(end-of-line)
(insert "\n")
(org-time-stamp nil))
or
(defun my/org-time-stamp-on-new-line ()
(interactive)
(end-of-line)
(org-insert-time-stamp nil nil nil "\n"))
If you don't want to change point
, you can do this:
(defun my/org-time-stamp-on-new-line ()
(interactive)
(save-excursion
(end-of-line)
(org-insert-time-stamp nil nil nil "\n")))
You call it with M-x my/org-time-stamp-on-new-line
or you can bind it to a key e.g.
(define-key org-mode-map (kbd "C-c z") #'my/org-time-stamp-on-new-line)