emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Marcin Borkowski <mbork@mbork.pl>
To: Kaushal Modi <kaushal.modi@gmail.com>
Cc: emacs-org list <emacs-orgmode@gnu.org>
Subject: Re: how to convert a non-org list to org headings
Date: Wed, 06 Jul 2022 18:12:45 +0200	[thread overview]
Message-ID: <877d4qb4oy.fsf@mbork.pl> (raw)
In-Reply-To: <CAFyQvY19PsjUjD2F7shsHoKG8+s5yOrn5o+bErsiYbuZ5E3y3A@mail.gmail.com>


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


  reply	other threads:[~2022-07-06 16:13 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2022-07-06 19:55     ` Uwe Brauer
2022-07-06 19:53   ` Uwe Brauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=877d4qb4oy.fsf@mbork.pl \
    --to=mbork@mbork.pl \
    --cc=emacs-orgmode@gnu.org \
    --cc=kaushal.modi@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).