* the «inverse» function of join-lines
@ 2023-10-24 9:25 Uwe Brauer
2023-10-24 9:37 ` Emanuel Berg
` (2 more replies)
0 siblings, 3 replies; 12+ messages in thread
From: Uwe Brauer @ 2023-10-24 9:25 UTC (permalink / raw)
To: help-gnu-emacs
Hi
I am not sure that the term inverse is here very appropriate, but I
can't come with another term.
Here is the problem. Suppose you have text like this
this is important blabla
but we also want
So I want to obtain
this is important blabla but we also want
The easiest way of doing it, is to put the cursor on b of but and run
joint-line (which is an alias for delete-indentation)
However most of the time my cursor is on a in blabla, if I then run
kill-line I obtain
this is important blabla but we also want
And I need to run delete-horizontal-space.
If I define
(defun my-join-line-from-above ()
(interactive)
(save-excursion
(kill-line nil)
(delete-horizontal-space nil)))
And use it I end up
this is important blablabut we also want
So I wonder is there a function that does what I want, and is a bit more
sophisticated then what I cooked up?
Thanks
Uwe Brauer
--
Warning: Content may be disturbing to some audiences
I strongly condemn Hamas bestialic terroristic attack on Israel, especially the despicable pogroms.
I strongly condemn Putin's war of aggression against Ukraine.
I support to deliver weapons to Ukraine's military.
I support the NATO membership of Ukraine.
I support the EU membership of Ukraine.
https://addons.thunderbird.net/en-US/thunderbird/addon/gmail-conversation-view/
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: the «inverse» function of join-lines
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:10 ` Tim Landscheidt
2 siblings, 0 replies; 12+ messages in thread
From: Emanuel Berg @ 2023-10-24 9:37 UTC (permalink / raw)
To: help-gnu-emacs
Uwe Brauer wrote:
> Here is the problem. Suppose you have text like this
>
> this is important blabla
> but we also want
>
> So I want to obtain
>
> this is important blabla but we also want
Here is the solution:
`unfill-region'
--
underground experts united
https://dataswamp.org/~incal
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: the «inverse» function of join-lines
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 10:10 ` Tim Landscheidt
2 siblings, 2 replies; 12+ messages in thread
From: Yuri Khan @ 2023-10-24 9:47 UTC (permalink / raw)
To: help-gnu-emacs
On Tue, 24 Oct 2023 at 16:26, Uwe Brauer <oub@mat.ucm.es> wrote:
> Here is the problem. Suppose you have text like this
>
> this is important blabla
> but we also want
>
> So I want to obtain
>
> this is important blabla but we also want
>
> The easiest way of doing it, is to put the cursor on b of but and run
> joint-line (which is an alias for delete-indentation)
>
> However most of the time my cursor is on a in blabla
I have the following function on M-J, in addition to standard
delete-indentation on M-^:
(defun yk-join-lines ()
"Join the current line with the next one."
(interactive)
(delete-indentation 1))
(Incidentally, they make up a good pair as J is just below 6 on Colemak.)
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: the «inverse» function of join-lines
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:10 ` Tim Landscheidt
2023-10-24 12:18 ` Uwe Brauer
2023-10-24 12:50 ` Nikolay Kudryavtsev
2 siblings, 2 replies; 12+ messages in thread
From: Tim Landscheidt @ 2023-10-24 10:10 UTC (permalink / raw)
To: help-gnu-emacs
Uwe Brauer <oub@mat.ucm.es> wrote:
> I am not sure that the term inverse is here very appropriate, but I
> can't come with another term.
> Here is the problem. Suppose you have text like this
> this is important blabla
> but we also want
> So I want to obtain
> this is important blabla but we also want
> The easiest way of doing it, is to put the cursor on b of but and run
> joint-line (which is an alias for delete-indentation)
> However most of the time my cursor is on a in blabla, if I then run
> kill-line I obtain
> this is important blabla but we also want
> And I need to run delete-horizontal-space.
> If I define
> (defun my-join-line-from-above ()
> (interactive)
> (save-excursion
> (kill-line nil)
> (delete-horizontal-space nil)))
> And use it I end up
> this is important blablabut we also want
> So I wonder is there a function that does what I want, and is a bit more
> sophisticated then what I cooked up?
My work flow usually assumes that "related" text lines form
a paragraph. Thus, I use fill-paragraph (M-q) to (re-)for-
mat those, normalizing whitespace along the way.
Tim
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: the «inverse» function of join-lines
2023-10-24 9:47 ` Yuri Khan
@ 2023-10-24 10:12 ` Yuri Khan
2023-10-24 12:17 ` Uwe Brauer
1 sibling, 0 replies; 12+ messages in thread
From: Yuri Khan @ 2023-10-24 10:12 UTC (permalink / raw)
To: help-gnu-emacs
On Tue, 24 Oct 2023 at 16:47, Yuri Khan <yuri.v.khan@gmail.com> wrote:
> I have the following function on M-J, in addition to standard
> delete-indentation on M-^:
>
> (defun yk-join-lines ()
> "Join the current line with the next one."
> (interactive)
> (delete-indentation 1))
(Someone might say this is superfluous and any other way to invoke
delete-indentation with a prefix argument, like M-6 M-^, would work
just as well. Well, it’s not for me, I don’t like long key sequences
for frequent actions.)
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: the «inverse» function of join-lines
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
1 sibling, 1 reply; 12+ messages in thread
From: Uwe Brauer @ 2023-10-24 12:17 UTC (permalink / raw)
To: help-gnu-emacs
[-- Attachment #1: Type: text/plain, Size: 1035 bytes --]
> On Tue, 24 Oct 2023 at 16:26, Uwe Brauer <oub@mat.ucm.es> wrote:
> I have the following function on M-J, in addition to standard
> delete-indentation on M-^:
> (defun yk-join-lines ()
> "Join the current line with the next one."
> (interactive)
> (delete-indentation 1))
Ah, of course, I should have read the documentation more carefully. Thanks.
> (Incidentally, they make up a good pair as J is just below 6 on Colemak.)
Not sure I understand that keybinding, are you rebinding
M-j runs the command default-indent-new-line
Or do you mean (meta shift j)
--
Warning: Content may be disturbing to some audiences
I strongly condemn Hamas bestialic terroristic attack on Israel, especially the despicable pogroms.
I strongly condemn Putin's war of aggression against Ukraine.
I support to deliver weapons to Ukraine's military.
I support the NATO membership of Ukraine.
I support the EU membership of Ukraine.
https://addons.thunderbird.net/en-US/thunderbird/addon/gmail-conversation-view/
[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 5673 bytes --]
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: the «inverse» function of join-lines
2023-10-24 10:10 ` Tim Landscheidt
@ 2023-10-24 12:18 ` Uwe Brauer
2023-10-24 12:50 ` Nikolay Kudryavtsev
1 sibling, 0 replies; 12+ messages in thread
From: Uwe Brauer @ 2023-10-24 12:18 UTC (permalink / raw)
To: help-gnu-emacs
[-- Attachment #1: Type: text/plain, Size: 780 bytes --]
> Uwe Brauer <oub@mat.ucm.es> wrote:
> My work flow usually assumes that "related" text lines form
> a paragraph. Thus, I use fill-paragraph (M-q) to (re-)for-
> mat those, normalizing whitespace along the way.
Well that works well in the context of ordinary text, but not so much in
equations or code I would say
--
Warning: Content may be disturbing to some audiences
I strongly condemn Hamas bestialic terroristic attack on Israel, especially the despicable pogroms.
I strongly condemn Putin's war of aggression against Ukraine.
I support to deliver weapons to Ukraine's military.
I support the NATO membership of Ukraine.
I support the EU membership of Ukraine.
https://addons.thunderbird.net/en-US/thunderbird/addon/gmail-conversation-view/
[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 5673 bytes --]
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: the «inverse» function of join-lines
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
1 sibling, 1 reply; 12+ messages in thread
From: Nikolay Kudryavtsev @ 2023-10-24 12:50 UTC (permalink / raw)
To: help-gnu-emacs
Incidentally I have a somewhat related question I've been wondering
about recently.
So I have a massive txt ebook that I've been slowly reediting into an
org file, for the purposes of easier navigation and textual analysis.
It is also fill-paragraphed. I've been considering the idea of removing
all superfluous line breaks.
Now, mechanically it's quite doable - you check for sentence end
punctuation signs at line endings and if there isn't one you remove the
line break. There would of course be some false positives...
This task seems like a somewhat common editing task, so I've been
wondering if someone has a working code for it already, maybe there are
some gotchas there, that I haven't though about.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: the «inverse» function of join-lines
2023-10-24 12:17 ` Uwe Brauer
@ 2023-10-24 14:23 ` Yuri Khan
0 siblings, 0 replies; 12+ messages in thread
From: Yuri Khan @ 2023-10-24 14:23 UTC (permalink / raw)
To: help-gnu-emacs
On Tue, 24 Oct 2023 at 19:18, Uwe Brauer <oub@mat.ucm.es> wrote:
> Not sure I understand that keybinding, are you rebinding
> M-j runs the command default-indent-new-line
>
> Or do you mean (meta shift j)
Yes, that. Alt+Shift+6 to join with previous line, Alt+Shift+J with next.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: the «inverse» function of join-lines
2023-10-24 12:50 ` Nikolay Kudryavtsev
@ 2023-10-24 14:43 ` Uwe Brauer
2023-11-23 15:50 ` Nikolay Kudryavtsev
0 siblings, 1 reply; 12+ messages in thread
From: Uwe Brauer @ 2023-10-24 14:43 UTC (permalink / raw)
To: help-gnu-emacs
[-- Attachment #1: Type: text/plain, Size: 1647 bytes --]
>>> "NK" == Nikolay Kudryavtsev <nikolay.kudryavtsev@gmail.com> writes:
> Incidentally I have a somewhat related question I've been wondering
> about recently.
> So I have a massive txt ebook that I've been slowly reediting into an
> org file, for the purposes of easier navigation and textual analysis.
> It is also fill-paragraphed. I've been considering the idea of
> removing all superfluous line breaks.
> Now, mechanically it's quite doable - you check for sentence end
> punctuation signs at line endings and if there isn't one you remove
> the line break. There would of course be some false positives...
> This task seems like a somewhat common editing task, so I've been
> wondering if someone has a working code for it already, maybe there
> are some gotchas there, that I haven't though about.
I usually run first unfill-paragraph-or-region (found in
org-mode-map), which is an interactive compiled Lisp function in
‘next-longline.el’.
And then use either
1. Virtual-auto-fill-mode on
2. Or auto-fill-on, and run fill-paragraph and friends
But of course as you said, false positives. Etc but as a first approach it is quite good.
--
Warning: Content may be disturbing to some audiences
I strongly condemn Hamas bestialic terroristic attack on Israel, especially the despicable pogroms.
I strongly condemn Putin's war of aggression against Ukraine.
I support to deliver weapons to Ukraine's military.
I support the NATO membership of Ukraine.
I support the EU membership of Ukraine.
https://addons.thunderbird.net/en-US/thunderbird/addon/gmail-conversation-view/
[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 5673 bytes --]
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: the «inverse» function of join-lines
2023-10-24 14:43 ` Uwe Brauer
@ 2023-11-23 15:50 ` Nikolay Kudryavtsev
2023-11-23 20:57 ` Emanuel Berg
0 siblings, 1 reply; 12+ messages in thread
From: Nikolay Kudryavtsev @ 2023-11-23 15:50 UTC (permalink / raw)
To: help-gnu-emacs
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.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: the «inverse» function of join-lines
2023-11-23 15:50 ` Nikolay Kudryavtsev
@ 2023-11-23 20:57 ` Emanuel Berg
0 siblings, 0 replies; 12+ messages in thread
From: Emanuel Berg @ 2023-11-23 20:57 UTC (permalink / raw)
To: help-gnu-emacs
Nikolay Kudryavtsev wrote:
> Weirdly I have not found unfill-paragraph-or-region anywhere
> in the org mode.
From the Emacs wiki,
(defun unfill-region (beg end)
"Unfill the region, joining text paragraphs into a single line.
\nhttp://emacswiki.org/emacs/unfillregion"
(interactive "*r")
(let ((fill-column (point-max)))
(fill-region beg end) ))
--
underground experts united
https://dataswamp.org/~incal
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2023-11-23 20:57 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2023-11-23 20:57 ` Emanuel Berg
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).