Add lowercase conversion fun for org blocks

master
Jacopo De Simoi 6 years ago
parent 46a80642be
commit b07083567e
  1. 26
      global.org

@ -863,6 +863,32 @@
#+BEGIN_SRC emacs-lisp
(setq org-src-fontify-natively t)
#+END_SRC
*** Lowercase org blocks
There is a new trend to use lowercase in the org block
definitions; this gist (taken from the [[https://scripter.co/org-keywords-lower-case/][Scripter blog]]) lowercases
all instances in the current buffer
#+begin_src emacs-lisp
(defun modi/lower-case-org-keywords ()
"Lower case Org keywords and block identifiers.
Example: \"#+TITLE\" -> \"#+title\"
\"#+BEGIN_EXAMPLE\" -> \"#+begin_example\"
Inspiration:
https://code.orgmode.org/bzg/org-mode/commit/13424336a6f30c50952d291e7a82906c1210daf0."
(interactive)
(save-excursion
(goto-char (point-min))
(let ((case-fold-search nil)
(count 0))
;; Match examples: "#+FOO bar", "#+FOO:", "=#+FOO=", "~#+FOO~",
;; "‘#+FOO’", "“#+FOO”", ",#+FOO bar",
;; "#+FOO_bar<eol>", "#+FOO<eol>".
(while (re-search-forward "\\(?1:#\\+[A-Z_]+\\(?:_[[:alpha:]]+\\)*\\)\\(?:[ :=~’”]\\|$\\)" nil :noerror)
(setq count (1+ count))
(replace-match (downcase (match-string-no-properties 1)) :fixedcase nil nil 1))
(message "Lower-cased %d matches" count))))
#+end_src
*** Clocking
#+BEGIN_SRC emacs-lisp
;; Separate drawers for clocking and logs

Loading…
Cancel
Save