emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* how to convert a non-org list to org headings
@ 2022-07-06 15:15 Uwe Brauer
  2022-07-06 15:31 ` Kaushal Modi
  0 siblings, 1 reply; 5+ messages in thread
From: Uwe Brauer @ 2022-07-06 15:15 UTC (permalink / raw)
  To: emacs-orgmode

Hi 

I have a file that contains a list as:


1.1 Funciones de una variable

1.1.1. Catálogo de funciones. Translaciones y dilataciones

1.1.2. Derivación

1.1.2.1. Optimización. Tasa de cambio

1.1.2.2. Aproximación de funciones

1.1.2.3.1. Interpolación vs. ajuste

1.1.2.3.2. Polinomio de Taylor

1.1.2.3. Ceros de funciones (método de Newton-Raphson)

1.1.3. Integración

1.1.3.1. Integral definida. Aplicaciones

1.1.3.2. Integral impropia

1.1.3.2.1. De 1.ª especie

1.1.3.2.2. De 2ª especie



Etc, that is a non org list but I would like to convert 
it to the corresponding headings

** Funciones de una variable

*** Catálogo de funciones. Translaciones y dilataciones

Etc, any idea how to do this in a quick way?

Regards

Uwe Brauer 
-- 
I strongly condemn Putin's war of aggression against the Ukraine.
I support to deliver weapons to Ukraine's military. 
I support the ban of Russia from SWIFT.
I support the EU membership of the Ukraine. 



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

* Re: how to convert a non-org list to org headings
  2022-07-06 15:15 how to convert a non-org list to org headings Uwe Brauer
@ 2022-07-06 15:31 ` Kaushal Modi
  2022-07-06 16:12   ` Marcin Borkowski
  2022-07-06 19:53   ` Uwe Brauer
  0 siblings, 2 replies; 5+ messages in thread
From: Kaushal Modi @ 2022-07-06 15:31 UTC (permalink / raw)
  To: emacs-org list

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

On Wed, Jul 6, 2022 at 11:17 AM Uwe Brauer <oub@mat.ucm.es> wrote:

> Hi
>
> I have a file that contains a list as:
>
>
> 1.1 Funciones de una variable
>
> 1.1.1. Catálogo de funciones. Translaciones y dilataciones
>
> 1.1.2. Derivación
>
> 1.1.2.1. Optimización. Tasa de cambio
>
> 1.1.2.2. Aproximación de funciones
>
> 1.1.2.3.1. Interpolación vs. ajuste
>
> 1.1.2.3.2. Polinomio de Taylor
>
> 1.1.2.3. Ceros de funciones (método de Newton-Raphson)
>
> 1.1.3. Integración
>
> 1.1.3.1. Integral definida. Aplicaciones
>
> 1.1.3.2. Integral impropia
>
> 1.1.3.2.1. De 1.ª especie
>
> 1.1.3.2.2. De 2ª especie
>
>
>
> Etc, that is a non org list but I would like to convert
> it to the corresponding headings
>
> ** Funciones de una variable
>
> *** Catálogo de funciones. Translaciones y dilataciones
>
> Etc, any idea how to do this in a quick way?
>

The method that I show below is quick but not robust. You'll need to review
all the replacements.

- Do query-replace-regexp [default binding: C-M-%]
- Search for [0-9]+\.
- Replace with *

Running that on your example gives:

=====
*1 Funciones de una variable

*** Catálogo de funciones. Translaciones y dilataciones

*** Derivación

**** Optimización. Tasa de cambio

**** Aproximación de funciones

***** Interpolación vs. ajuste

***** Polinomio de Taylor

**** Ceros de funciones (método de Newton-Raphson)

*** Integración

**** Integral definida. Aplicaciones

**** Integral impropia

***** De *ª especie

***** De 2ª especie
=====

You'll need to manually fix up the " *1 Funciones de una variable" and "
***** De *ª especie" lines.

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

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

* Re: how to convert a non-org list to org headings
  2022-07-06 15:31 ` Kaushal Modi
@ 2022-07-06 16:12   ` Marcin Borkowski
  2022-07-06 19:55     ` Uwe Brauer
  2022-07-06 19:53   ` Uwe Brauer
  1 sibling, 1 reply; 5+ messages in thread
From: Marcin Borkowski @ 2022-07-06 16:12 UTC (permalink / raw)
  To: Kaushal Modi; +Cc: emacs-org list


On 2022-07-06, at 17:31, Kaushal Modi <kaushal.modi@gmail.com> wrote:

> On Wed, Jul 6, 2022 at 11:17 AM Uwe Brauer <oub@mat.ucm.es> wrote:
>
>> Hi
>>
>> I have a file that contains a list as:
>>
>>
>> 1.1 Funciones de una variable

No period after "1.1" above - makes things slightly more difficult.

> The method that I show below is quick but not robust. You'll need to review
> all the replacements.
>
> - Do query-replace-regexp [default binding: C-M-%]
> - Search for [0-9]+\.
> - Replace with *

This might be a bit overzealous if there are more numbers with a period
after them.  Another way would be to add ^\(\**\) at the beginning of
the regex (and a \1 in the replacement) and go through the file as many
times as there are nesting levels.

You could also try Elisp as the replacement - see
https://www.gnu.org/software/emacs/manual/html_node/emacs/Regexp-Replace.html,
https://www.masteringemacs.org/article/evaluating-lisp-forms-regular-expressions
and
http://mbork.pl/2013-09-18_Selective_replacement_in_LaTeX_documents_(en) .

You could probably use keyboard macros, too - see e.g.
http://mbork.pl/2021-02-20_Using_keyboard_macros_to_emulate_query_replace .

Hth,

-- 
Marcin Borkowski
http://mbork.pl


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

* Re: how to convert a non-org list to org headings
  2022-07-06 15:31 ` Kaushal Modi
  2022-07-06 16:12   ` Marcin Borkowski
@ 2022-07-06 19:53   ` Uwe Brauer
  1 sibling, 0 replies; 5+ messages in thread
From: Uwe Brauer @ 2022-07-06 19:53 UTC (permalink / raw)
  To: emacs-orgmode

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


> On Wed, Jul 6, 2022 at 11:17 AM Uwe Brauer <oub@mat.ucm.es> wrote:

> The method that I show below is quick but not robust. You'll need to review
> all the replacements.

> - Do query-replace-regexp [default binding: C-M-%]
> - Search for [0-9]+\.
> - Replace with *

Thanks, I tried [0-9]* and that failed. 

Yours worked but I had first to fix some missing space and . 

thanks

[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 5673 bytes --]

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

* Re: how to convert a non-org list to org headings
  2022-07-06 16:12   ` Marcin Borkowski
@ 2022-07-06 19:55     ` Uwe Brauer
  0 siblings, 0 replies; 5+ messages in thread
From: Uwe Brauer @ 2022-07-06 19:55 UTC (permalink / raw)
  To: emacs-orgmode

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


> On 2022-07-06, at 17:31, Kaushal Modi <kaushal.modi@gmail.com> wrote:


> No period after "1.1" above - makes things slightly more difficult.

Right, I repaired those manually before running queery resplace 

> This might be a bit overzealous if there are more numbers with a period
> after them.  Another way would be to add ^\(\**\) at the beginning of
> the regex (and a \1 in the replacement) and go through the file as many
> times as there are nesting levels.

Ah ok, but right now Kaushal's proposed solution is good enough for me

> You could also try Elisp as the replacement - see
> https://www.gnu.org/software/emacs/manual/html_node/emacs/Regexp-Replace.html,
> https://www.masteringemacs.org/article/evaluating-lisp-forms-regular-expressions
> and
> http://mbork.pl/2013-09-18_Selective_replacement_in_LaTeX_documents_(en) .

> You could probably use keyboard macros, too - see e.g.
> http://mbork.pl/2021-02-20_Using_keyboard_macros_to_emulate_query_replace .

I thought about this, but usually I end up faster using a function (or
query replace) there was a time a liked keyboards macros, but now I find
them a bit dangerous.

Regards


[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 5673 bytes --]

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

end of thread, other threads:[~2022-07-06 20:04 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-07-06 15:15 how to convert a non-org list to org headings Uwe Brauer
2022-07-06 15:31 ` Kaushal Modi
2022-07-06 16:12   ` Marcin Borkowski
2022-07-06 19:55     ` Uwe Brauer
2022-07-06 19:53   ` Uwe Brauer

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