* How to format paragraph and not to lose spaces between 2 characters?
@ 2021-10-06 5:41 Jean Louis
2021-10-06 6:04 ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-10-06 6:07 ` Emanuel Berg via Users list for the GNU Emacs text editor
0 siblings, 2 replies; 8+ messages in thread
From: Jean Louis @ 2021-10-06 5:41 UTC (permalink / raw)
To: Help GNU Emacs
I have particular need to format paragraph without getting specific
spaces between specific characters disturbed:
Stage 1, paragraph is there
---------------------------
This is example paragraph. This is example paragraph. This is example
paragraph. This is example paragraph. This is example paragraph. This
is example paragraph.This is example paragraph. This is example
paragraph. This is example paragraph.This is example paragraph. This
is example paragraph. This is example paragraph.
Stage 2, after insert of ❰ ❱, paragraph gets somewhere dis-aligned
---------------------------------------------------------------------
❰ ❱ This is example paragraph. This is example paragraph. This is example
paragraph. This is example paragraph. This is example paragraph. This
is example paragraph.This is example paragraph. This is example
paragraph. This is example paragraph.This is example paragraph. This
is example paragraph. This is example paragraph.
Stage 3, I wish to press M-q to re-format paragraph, then I lose
spaces between: ❰ ❱ -- and my goal is NOT to lose those spaces:
❰ ❱ This is example paragraph. This is example paragraph. This is
example paragraph. This is example paragraph. This is example
paragraph. This is example paragraph.This is example paragraph. This
is example paragraph. This is example paragraph.This is example
paragraph. This is example paragraph. This is example paragraph.
Is there a way to solve this so that I do not lose spaces?
One solution I know is to insert a non-breaking space:
❰ ❱
Is there a solution without using non-breaking space?
Jean
Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns
In support of Richard M. Stallman
https://stallmansupport.org/
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: How to format paragraph and not to lose spaces between 2 characters?
2021-10-06 5:41 How to format paragraph and not to lose spaces between 2 characters? Jean Louis
@ 2021-10-06 6:04 ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-10-06 6:07 ` Emanuel Berg via Users list for the GNU Emacs text editor
1 sibling, 0 replies; 8+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-10-06 6:04 UTC (permalink / raw)
To: help-gnu-emacs
Jean Louis wrote:
> This is example paragraph. This is example paragraph.
> This is example paragraph. This is example paragraph.
> This is example paragraph. This is example paragraph.This is
> example paragraph. This is example paragraph. This is
> example paragraph.This is example paragraph. This is example
> paragraph. This is example paragraph.
Here:
https://www.lipsum.com/feed/html
And here you have it:
❰ ❱ This is example paragraph. This is example paragraph.
This is example paragraph. This is example paragraph.
This is example paragraph. This is example paragraph.This is
example paragraph. This is example paragraph. This is
example paragraph.This is example paragraph. This is example
paragraph. This is example paragraph.
--
underground experts united
https://dataswamp.org/~incal
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: How to format paragraph and not to lose spaces between 2 characters?
2021-10-06 5:41 How to format paragraph and not to lose spaces between 2 characters? Jean Louis
2021-10-06 6:04 ` Emanuel Berg via Users list for the GNU Emacs text editor
@ 2021-10-06 6:07 ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-10-06 10:02 ` Jean Louis
2021-10-06 10:18 ` [solved] " Jean Louis
1 sibling, 2 replies; 8+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-10-06 6:07 UTC (permalink / raw)
To: help-gnu-emacs
Jean Louis wrote:
> Is there a way to solve this so that I do not lose spaces?
Here:
Not Breaking
The ‘fill-nobreak-predicate’ hook lets you avoid line breaks
at certain places. For example if you’re French, you might
be used to typing a space in front of colons, question
marks, exclamation marks, etc. [1] This might lead to the
following problem:
Where do we write the question marks |
? We use a space in front of them. |
To avoid this, add ‘fill-french-nobreak-p’ to
‘fill-nobreak-predicate’.
Emacs comes with a ‘fill-single-word-nobreak-p’ to not
dangle the first or last word of a sentence, and
HtmlMode/SgmlMode sets up ‘sgml-fill-nobreak’ to keep a tag
and first attribute together. For more nobreaks see
* NobreakFade – a few miscellaneous nobreaks
* PerlPodGt – POD C<<, S<> and C<!>
* texinfo-nobreak.el – workarounds for makeinfo
https://www.emacswiki.org/emacs/FillParagraph
--
underground experts united
https://dataswamp.org/~incal
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: How to format paragraph and not to lose spaces between 2 characters?
2021-10-06 6:07 ` Emanuel Berg via Users list for the GNU Emacs text editor
@ 2021-10-06 10:02 ` Jean Louis
2021-10-06 10:24 ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-10-06 10:18 ` [solved] " Jean Louis
1 sibling, 1 reply; 8+ messages in thread
From: Jean Louis @ 2021-10-06 10:02 UTC (permalink / raw)
To: help-gnu-emacs
* Emanuel Berg via Users list for the GNU Emacs text editor <help-gnu-emacs@gnu.org> [2021-10-06 09:11]:
> The ‘fill-nobreak-predicate’ hook lets you avoid line breaks
> at certain places. For example if you’re French, you might
> be used to typing a space in front of colons, question
> marks, exclamation marks, etc. [1] This might lead to the
> following problem:
If I have ❰ ❱ then what should I add to `fill-nobreak-predicate'
variable?
--
Jean
Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns
In support of Richard M. Stallman
https://stallmansupport.org/
^ permalink raw reply [flat|nested] 8+ messages in thread
* [solved] Re: How to format paragraph and not to lose spaces between 2 characters?
2021-10-06 6:07 ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-10-06 10:02 ` Jean Louis
@ 2021-10-06 10:18 ` Jean Louis
2021-10-06 14:35 ` Emanuel Berg via Users list for the GNU Emacs text editor
1 sibling, 1 reply; 8+ messages in thread
From: Jean Louis @ 2021-10-06 10:18 UTC (permalink / raw)
To: help-gnu-emacs
Thanks, I guess that easiest is to solve my use case and use
non-breaking space. I consider it solved, better this way then that I
fiddle with settings.
Org mode style is nice, though not enough visual for my purposes and
more or less it works only for numbered lines and headings.
,----
| 1. [X] A line of something, like a task for example.
`----
What I personally need is to mark TODO/DONE anywhere in the text in
any kind of mode, including Asciidoc mode, plain text and similar. And
to be able to mark TODO/DONE anywhere on the line.
Like this, it has non-breaking spaces between: ❰ ❱ which may not be
visible on screen, but depending of the Emacs theme, I can see the
non-breaking space as underline:
,----
| ❰ ❱ A line of something, like a task for example.
`----
Then when it is done, I can quickly convert it to DONE.
,----
| ❰DONE❱ A line of something, like a task for example.
`----
And I use only one command: M-x rcd-check which is bound to key. One
could customize it as one wish, maybe like [✔]
Functions are below:
(defun rcd-check ()
"Replace matches of CHECK-IN with CHECK-OUT in a line.
It is useful to toggle [ ] to [✔]"
(interactive)
(let* ((start (line-beginning-position))
(end (line-end-position))
(line (buffer-substring start end)))
(rcd-check-start)
(save-excursion
(cond ((string-match (regexp-quote rcd-check-in) line)
(replace-regexp (regexp-quote rcd-check-in) rcd-check-out nil start end))
((string-match (regexp-quote rcd-check-out) line)
(replace-regexp (regexp-quote rcd-check-out) rcd-check-in nil start end))))))
(defvar rcd-check-in "❰ ❱")
(defvar rcd-check-out "❰DONE❱")
(defun rcd-check-start ()
"Insert variable `rcd-check-in' at the beginning of line."
(interactive)
(let* ((start (line-beginning-position))
(end (line-end-position))
(line (buffer-substring start end)))
(when (and (not (string-match rcd-check-in line))
(not (string-match rcd-check-out line)))
(save-excursion
(goto-char start)
(insert rcd-check-in " "))
(when (= start end)
(goto-char (line-end-position))))))
--
Jean
Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns
In support of Richard M. Stallman
https://stallmansupport.org/
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: How to format paragraph and not to lose spaces between 2 characters?
2021-10-06 10:02 ` Jean Louis
@ 2021-10-06 10:24 ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-10-06 13:00 ` tomas
0 siblings, 1 reply; 8+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-10-06 10:24 UTC (permalink / raw)
To: help-gnu-emacs
Jean Louis wrote:
>> The ‘fill-nobreak-predicate’ hook lets you avoid line
>> breaks at certain places. For example if you’re French, you
>> might be used to typing a space in front of colons,
>> question marks, exclamation marks, etc. This might lead to
>> the following problem:
>
> If I have ❰ ❱ then what should I add to
> `fill-nobreak-predicate' variable?
If you have NO-BREAK SPACE it shouldn't brake anyway (that's
the purpose) so then you can just fill as you
would, transparently.
If you want it to be 100% transparent so you can use normal
spaces (but why?) I'd start at something like this
(looking-at "\s\\{2,\\}")
but I give no guarantees it will or can work.
Because if you want this, again, use NO-BREAK SPACE :)
--
underground experts united
https://dataswamp.org/~incal
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: How to format paragraph and not to lose spaces between 2 characters?
2021-10-06 10:24 ` Emanuel Berg via Users list for the GNU Emacs text editor
@ 2021-10-06 13:00 ` tomas
0 siblings, 0 replies; 8+ messages in thread
From: tomas @ 2021-10-06 13:00 UTC (permalink / raw)
To: help-gnu-emacs
[-- Attachment #1: Type: text/plain, Size: 1104 bytes --]
On Wed, Oct 06, 2021 at 12:24:13PM +0200, Emanuel Berg via Users list for the GNU Emacs text editor wrote:
> Jean Louis wrote:
>
> >> The ‘fill-nobreak-predicate’ hook lets you avoid line
> >> breaks at certain places. For example if you’re French, you
> >> might be used to typing a space in front of colons,
> >> question marks, exclamation marks, etc. This might lead to
> >> the following problem:
> >
> > If I have ❰ ❱ then what should I add to
> > `fill-nobreak-predicate' variable?
>
> If you have NO-BREAK SPACE it shouldn't brake anyway (that's
> the purpose) so then you can just fill as you
> would, transparently.
>
> If you want it to be 100% transparent so you can use normal
> spaces (but why?) I'd start at something like this
>
> (looking-at "\s\\{2,\\}")
^^
Alternatively you could say "\\s-..." instead, which would catch
everything with the syntax property "space", which non-breaking
spaces usually have (it'll depend on your current syntax table,
though, which can be seen as a plus or as a minus).
Cheers
- t
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [solved] Re: How to format paragraph and not to lose spaces between 2 characters?
2021-10-06 10:18 ` [solved] " Jean Louis
@ 2021-10-06 14:35 ` Emanuel Berg via Users list for the GNU Emacs text editor
0 siblings, 0 replies; 8+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-10-06 14:35 UTC (permalink / raw)
To: help-gnu-emacs
Jean Louis wrote:
> (let* ((start (line-beginning-position))
"beg"
> (when (and (not (string-match rcd-check-in line))
> (not (string-match rcd-check-out line)))
(not A) and (not B) = not (A or B) [1] so
(unless (or (string-...
(string-...
And 5 warnings from the byte-compiler. You've had them many
times ...
Also, you have a good reason you want this?
[1] https://en.wikipedia.org/wiki/De_Morgan%27s_laws
--
underground experts united
https://dataswamp.org/~incal
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2021-10-06 14:35 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-10-06 5:41 How to format paragraph and not to lose spaces between 2 characters? Jean Louis
2021-10-06 6:04 ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-10-06 6:07 ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-10-06 10:02 ` Jean Louis
2021-10-06 10:24 ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-10-06 13:00 ` tomas
2021-10-06 10:18 ` [solved] " Jean Louis
2021-10-06 14:35 ` Emanuel Berg via Users list for the GNU Emacs text editor
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).