From b07083567eebe2108e67352466bcceb6e5dd2bc8 Mon Sep 17 00:00:00 2001 From: Jacopo De Simoi Date: Thu, 8 Oct 2020 10:19:48 -0400 Subject: [PATCH] Add lowercase conversion fun for org blocks --- global.org | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/global.org b/global.org index 23dcd28..5e21ed6 100644 --- a/global.org +++ b/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", "#+FOO". + (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