[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: how to convert a non-org list to org headings
From: |
Marcin Borkowski |
Subject: |
Re: how to convert a non-org list to org headings |
Date: |
Wed, 06 Jul 2022 18:12:45 +0200 |
User-agent: |
mu4e 1.1.0; emacs 29.0.50 |
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