From mboxrd@z Thu Jan 1 00:00:00 1970 From: Kaushal Modi Subject: Re: Lower-casing blocks and keywords Date: Fri, 02 Feb 2018 16:56:55 +0000 Message-ID: References: <874ln9u1zt.fsf@nicolasgoaziou.fr> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="94eb2c0660b43fc6d405643d9a99" Return-path: Received: from eggs.gnu.org ([208.118.235.92]:54576) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ehefG-0000cs-VE for emacs-orgmode@gnu.org; Fri, 02 Feb 2018 11:59:21 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eheeC-0003DR-R7 for emacs-orgmode@gnu.org; Fri, 02 Feb 2018 11:58:14 -0500 Received: from mail-yw0-x233.google.com ([2607:f8b0:4002:c05::233]:45082) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eheeC-0003D4-B3 for emacs-orgmode@gnu.org; Fri, 02 Feb 2018 11:57:08 -0500 Received: by mail-yw0-x233.google.com with SMTP id b16so10830089ywh.12 for ; Fri, 02 Feb 2018 08:57:07 -0800 (PST) In-Reply-To: <874ln9u1zt.fsf@nicolasgoaziou.fr> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: Nicolas Goaziou Cc: emacs-org list --94eb2c0660b43fc6d405643d9a99 Content-Type: text/plain; charset="UTF-8" On Thu, Jan 25, 2018 at 3:17 PM Nicolas Goaziou 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", "#+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)))) -- Kaushal Modi --94eb2c0660b43fc6d405643d9a99 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
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 t= he
> latest commit on master:
> https://co= de.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 bunc= h of Org files).

Let me know if I missed out on something= (or did over-lower-casing) :)

(defun modi/lower-case-org-keywords (= )
=C2=A0 "Lower case Org keywords and block identifiers.

Exa= mple: \"#+TITLE\" -> \"#+title\"
=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 \"#+BEGIN_EXAMPLE\" -> \&quo= t;#+begin_example\"

Inspiration:
http= s://code.orgmode.org/bzg/org-mode/commit/13424336a6f30c50952d291e7a82906c12= 10daf0."
=C2=A0 (interactive)
=C2=A0 (save-excursion
=C2= =A0=C2=A0=C2=A0 (goto-char (point-min))
=C2=A0=C2=A0=C2=A0 (let ((case-f= old-search nil)
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (= count 0))
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ;; Match examples: "#+FOO = bar", "#+FOO:", "=3D#+FOO=3D", "~#+FOO~"= ,
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ;;=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ",#+FOO b= ar", "#+FOO_bar<eol>", "#+FOO<eol>".=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (while (re-search-forward "\\(?1:#\\+= [A-Z_]+\\(?:_[[:alpha:]]+\\)*\\)\\(?:[ :=3D~]\\|$\\)" nil :noerror)=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (setq count (1+ count))
=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (replace-match (downcase (match-str= ing-no-properties 1)) :fixedcase nil nil 1))
=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0 (message "Lower-cased %d matches" count))))
<= /div>--

Kaushal Modi

--94eb2c0660b43fc6d405643d9a99--