On Sun, Aug 9, 2015 at 3:12 AM, Nicolas Goaziou <m...@nicolasgoaziou.fr> wrote: > Probably something like this (untested) > > (let ((case-fold-search t))
That is a valuable example for us to learn from. Right off the bat I wouldn't have though to indent that way, but would have noticed quickly enough when I didn't account for the case! There were 276 blocks corrected. Here is the final version with a tweaked regex and removed and removal of my original replacement desire. Thank you Nicolas. ┌──── │ (let ((case-fold-search t)) │ (while (re-search-forward "^\s*#[+]BEGIN_SRC" nil t) │ (let ((element (org-element-at-point))) │ (when (eq (org-element-type element) 'src-block) │ (if (not (org-element-property :name element)) │ (let ((i (org-get-indentation))) │ (beginning-of-line) │ (save-excursion (insert "#+NAME: " (org-id-new) "\n")) │ (indent-to i) │ (forward-line 2))))))) └──── if you are unfamiliar with that indent-to bit, here is ax example of what it handled correctly: #+NAME: FD94197F-0A18-480E-8DEA-F5943B860105 #+BEGIN_SRC emacs-lisp (add-to-list 'load-path "~/src/org-mode/lisp") #+END_SRC #+NAME: F4D65E13-0E55-4443-A7A7-13DD64A13051 #+BEGIN_SRC emacs-lisp (add-to-list 'load-path "~/src/org-mode/lisp") #+END_SRC #+NAME: 705F4F89-0431-42A3-A10D-1C528945CAC7 #+BEGIN_SRC emacs-lisp (add-to-list 'load-path "~/src/org-mode/lisp") #+END_SRC #+NAME: 233C2AFF-A257-4091-875C-945E3189AFEB #+BEGIN_SRC emacs-lisp (add-to-list 'load-path "~/src/org-mode/lisp") #+END_SRC #+NAME: FC730EEE-A32B-449D-94EA-EBB750D89204 #+BEGIN_SRC emacs-lisp (add-to-list 'load-path "~/src/org-mode/lisp") #+END_SRC - Foo #+NAME: FD94197F-0A18-480E-8DEA-F5943B860105 #+BEGIN_SRC emacs-lisp (add-to-list 'load-path "~/src/org-mode/lisp") #+END_SRC - Foo #+NAME: FD94197F-0A18-480E-8DEA-F5943B860105 #+BEGIN_SRC emacs-lisp (add-to-list 'load-path "~/src/org-mode/lisp") #+END_SRC - Foo #+NAME: FD94197F-0A18-480E-8DEA-F5943B860105 #+BEGIN_SRC emacs-lisp (add-to-list 'load-path "~/src/org-mode/lisp") #+END_SRC - Foo #+NAME: FD94197F-0A18-480E-8DEA-F5943B860105 #+BEGIN_SRC emacs-lisp (add-to-list 'load-path "~/src/org-mode/lisp") #+END_SRC