Re: [O] Lower-casing blocks and keywords

2018-02-02 Thread Kaushal Modi
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


Re: [O] Lower-casing blocks and keywords

2018-01-25 Thread Nicolas Goaziou
Hello,

Kaushal Modi  writes:

> 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.


Regards,

-- 
Nicolas Goaziou0x80A93738



Re: [O] Lower-casing blocks and keywords

2018-01-24 Thread Eric S Fraga
Ignore previous email.  Slightly misread your request.  Not as trivial... ;-)
-- 
Eric S Fraga via Emacs 27.0.50, Org release_9.1.6-352-g92176c


signature.asc
Description: PGP signature


Re: [O] Lower-casing blocks and keywords

2018-01-24 Thread Eric S Fraga
On Wednesday, 24 Jan 2018 at 15:21, Kaushal Modi wrote:
> Did you do that lower-casing by hand? Or do you have an elisp snippet or
> some script that does that?

I have no idea how Nicolas did the changes but, remember, org has the
full power of Emacs behind it (it's all text ;-)) so a simple
query-replace-regexp (or without query) using an appropriate regex to
catch all directives will do the job?

-- 
Eric S Fraga via Emacs 27.0.50, Org release_9.1.6-352-g92176c


signature.asc
Description: PGP signature