emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Lower-casing blocks and keywords
@ 2018-01-24 15:21 Kaushal Modi
  2018-01-24 16:18 ` Eric S Fraga
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Kaushal Modi @ 2018-01-24 15:21 UTC (permalink / raw)
  To: Nicolas Goaziou, emacs-org list

[-- Attachment #1: Type: text/plain, Size: 329 bytes --]

Hello Nicolas,

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?

Thanks.
-- 

Kaushal Modi

[-- Attachment #2: Type: text/html, Size: 604 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Lower-casing blocks and keywords
  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
  2 siblings, 0 replies; 5+ messages in thread
From: Eric S Fraga @ 2018-01-24 16:18 UTC (permalink / raw)
  To: Kaushal Modi; +Cc: emacs-org list, Nicolas Goaziou

[-- Attachment #1: Type: text/plain, Size: 480 bytes --]

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

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 194 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Lower-casing blocks and keywords
  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
  2 siblings, 0 replies; 5+ messages in thread
From: Eric S Fraga @ 2018-01-24 16:19 UTC (permalink / raw)
  To: Kaushal Modi; +Cc: emacs-org list, Nicolas Goaziou

[-- Attachment #1: Type: text/plain, Size: 147 bytes --]

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

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 194 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Lower-casing blocks and keywords
  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
  2 siblings, 1 reply; 5+ messages in thread
From: Nicolas Goaziou @ 2018-01-25 20:17 UTC (permalink / raw)
  To: Kaushal Modi; +Cc: emacs-org list

Hello,

Kaushal Modi <kaushal.modi@gmail.com> 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 Goaziou                                                0x80A93738

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Lower-casing blocks and keywords
  2018-01-25 20:17 ` Nicolas Goaziou
@ 2018-02-02 16:56   ` Kaushal Modi
  0 siblings, 0 replies; 5+ messages in thread
From: Kaushal Modi @ 2018-02-02 16:56 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: emacs-org list

[-- 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 --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2018-02-02 16:59 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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

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