From: Nikolay Kudryavtsev <nikolay.kudryavtsev@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: Re: the «inverse» function of join-lines
Date: Thu, 23 Nov 2023 18:50:06 +0300 [thread overview]
Message-ID: <68695a9c-367e-4dc4-b687-6db750dfc066@gmail.com> (raw)
In-Reply-To: <874jigozch.fsf@mat.ucm.es>
Weirdly I have not found unfill-paragraph-or-region anywhere in the org
mode.
But there are different unfill paragraph\region functions on EmacsWiki.
None of them had the advanced functionality I was looking for, so I
hacked up a better one for myself:
(defun unfill-region (beg end)
(interactive "*r")
(replace-regexp-in-region
"\\([^\.\\!\\?:]\\)\n\s*\\([^-\\*[:digit:][:upper:]\s]+\\)"
"\\1 \\2" beg end))
This works just about perfectly, since it checks both sides of the line
break, before removing it. You know, there's the famous quote by H. L.
Mencken that "For every complex problem there is an /answer/ that is
clear, /simple/ and wrong." I guess what's also true is that for every
complex problem there's a simple and incomprehensible regular expression
solution. Me starting to like regexps nowadays also probably means that,
I'll end up in a mental asylum soon enough. ;-)
P.S. I don't really understand why do I have to put \s into the second
group, but without explicitly doing that it just keeps eating whitespace
from the first \s. I guess, sometimes the less you know, the longer you
live.
next prev parent reply other threads:[~2023-11-23 15:50 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-24 9:25 the «inverse» function of join-lines Uwe Brauer
2023-10-24 9:37 ` Emanuel Berg
2023-10-24 9:47 ` Yuri Khan
2023-10-24 10:12 ` Yuri Khan
2023-10-24 12:17 ` Uwe Brauer
2023-10-24 14:23 ` Yuri Khan
2023-10-24 10:10 ` Tim Landscheidt
2023-10-24 12:18 ` Uwe Brauer
2023-10-24 12:50 ` Nikolay Kudryavtsev
2023-10-24 14:43 ` Uwe Brauer
2023-11-23 15:50 ` Nikolay Kudryavtsev [this message]
2023-11-23 20:57 ` Emanuel Berg
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.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=68695a9c-367e-4dc4-b687-6db750dfc066@gmail.com \
--to=nikolay.kudryavtsev@gmail.com \
--cc=help-gnu-emacs@gnu.org \
/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.
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).