I need to convert all nested lists present in buffer to org-mode headers using elisp. How can I do this?
1.2.7.2 Some Header Name
-> **** Some Header Name
I need to convert all nested lists present in buffer to org-mode headers using elisp. How can I do this?
1.2.7.2 Some Header Name
-> **** Some Header Name
Here's a quick and dirty function to do the conversion - it just looks for lines starting with up to 4 numbers. Paste it into your *scratch* buffer, type C-x C-e after it, switch to the buffer to convert, then enter M-x convert-headers.
(defun convert-headers ()
(interactive)
(beginning-of-buffer)
(replace-regexp "^[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+ " "**** ")
(beginning-of-buffer)
(replace-regexp "^[0-9]+\\.[0-9]+\\.[0-9]+ " "*** ")
(beginning-of-buffer)
(replace-regexp "^[0-9]+\\.[0-9]+ " "** ")
(beginning-of-buffer)
(replace-regexp "^[0-9]+ " "* "))