From: Kaushal Modi <kaushal.modi@gmail.com>
To: Nicolas Goaziou <mail@nicolasgoaziou.fr>
Cc: emacs-org list <emacs-orgmode@gnu.org>
Subject: Re: Lower-casing blocks and keywords
Date: Fri, 02 Feb 2018 16:56:55 +0000 [thread overview]
Message-ID: <CAFyQvY2P6URnQ-Wz3em1oAiAD+01Vkj-MLNYT_xXLW1E9bKN-g@mail.gmail.com> (raw)
In-Reply-To: <874ln9u1zt.fsf@nicolasgoaziou.fr>
[-- Attachment #1: Type: text/plain, Size: 1510 bytes --]
On Thu, Jan 25, 2018 at 3:17 PM Nicolas Goaziou <mail@nicolasgoaziou.fr>
wrote:
> > I also like the blocks and keywords to be lower-cased. I see this in the
> > latest commit on master:
> >
> https://code.orgmode.org/bzg/org-mode/commit/13424336a6f30c50952d291e7a82906c1210daf0
> >
> > Did you do that lower-casing by hand? Or do you have an elisp snippet or
> > some script that does that?
>
> IIRC, this was grep then eyeball and a macro to automatically convert
> a line.
>
I got back to this task at hand, and this elisp command works just fine
(based on export testing of a bunch of Org files).
Let me know if I missed out on something (or did over-lower-casing) :)
(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 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))))
--
Kaushal Modi
[-- Attachment #2: Type: text/html, Size: 2464 bytes --]
prev parent reply other threads:[~2018-02-02 16:59 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-24 15:21 Lower-casing blocks and keywords Kaushal Modi
2018-01-24 16:18 ` Eric S Fraga
2018-01-24 16:19 ` Eric S Fraga
2018-01-25 20:17 ` Nicolas Goaziou
2018-02-02 16:56 ` Kaushal Modi [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAFyQvY2P6URnQ-Wz3em1oAiAD+01Vkj-MLNYT_xXLW1E9bKN-g@mail.gmail.com \
--to=kaushal.modi@gmail.com \
--cc=emacs-orgmode@gnu.org \
--cc=mail@nicolasgoaziou.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).