Custom timestamp in emacs orgmode

I would like to insert a custom timestamp in emacs orgmode . I want to insert only the current time (no date!) In this form: [HH: MM] by pressing C-c -. I am completely new to lisp and could not figure out how to do this. My starting point for my ~/.emacs-file is like this:

(defun org-my-custom-timestamp ()
  (interactive)
  ( :SOME_CODE: )
)


(define-key global-map "\C-c-" 'org-my-custom-timestamp)

Now, it's just a definition of my custom function called org-my-custom-timestamp, "interactivity" and label assignment. However, I have tried different things for :SOME_CODE:without any success.

What can be set in a function to make it work as described?

Do any of the experienced emacs users even consider this a practical exercise, or is there a smarter way to do this? Perhaps org-mode-internal?

+5
source share
1 answer

The local Org mode map has an entry that links C-c -, so we must change it instead of the global one:

(defun org-my-custom-timestamp ()
  (interactive)
  (insert (format-time-string "[%H:%M]")))
(add-hook 'org-mode-hook
          (lambda ()
            (local-set-key "\C-c-" 'org-my-custom-timestamp)))

Remember once again that it replaces the command org-ctrl-c-minustied to C-c -the default in Org mode with your own.

+5
source

All Articles