* change soft to hard lines and back
@ 2017-12-14 13:44 Uwe Brauer
2017-12-14 14:18 ` Hinrik Örn Sigurðsson
2017-12-14 23:52 ` Jorge A. Alfaro-Murillo
0 siblings, 2 replies; 9+ messages in thread
From: Uwe Brauer @ 2017-12-14 13:44 UTC (permalink / raw)
To: emacs-devel
Hi
For email I start to use messages-are-flowing.el (for example in
this message) which insert and display hardlines. (This is useful
when sending message to devices with small screens since then the
line ending is better displayed).
However sometimes it is a bit too much. So I still have a function
which replaces softline by hardlines, namely
(defun harden-newlines () (interactive)
(save-excursion
; (goto-char (point-min))
(mail-text) (while (search-forward "\n" nil t)
(put-text-property (1- (point)) (point) 'hard t))))
So I thought the inverse operation could be
(defun soften-newlines () (interactive)
(save-excursion
; (goto-char (point-min))
(mail-text) (while (search-forward "\n" nil t)
(put-text-property (1- (point)) (point) 'soft t))))
But unfortunately this did not work out. I tried to google for the
put-text-property function but did not find anything useful.
Somebody has an idea how to do that, replace hardlines again by
softlines?
Thanks
Uwe Brauer
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: change soft to hard lines and back
2017-12-14 13:44 change soft to hard lines and back Uwe Brauer
@ 2017-12-14 14:18 ` Hinrik Örn Sigurðsson
2017-12-14 15:18 ` Uwe Brauer
2017-12-14 23:52 ` Jorge A. Alfaro-Murillo
1 sibling, 1 reply; 9+ messages in thread
From: Hinrik Örn Sigurðsson @ 2017-12-14 14:18 UTC (permalink / raw)
To: emacs-devel
[-- Attachment #1: Type: text/plain, Size: 1348 bytes --]
You can use the function set-hard-newline-properties to mark all newlines
in some range as hard. For the inverse you can remove the 'hard property
with (remove-text-property START END '(hard nil)).
On Thu, Dec 14, 2017 at 2:44 PM, Uwe Brauer <oub@mat.ucm.es> wrote:
> Hi
>
> For email I start to use messages-are-flowing.el (for example in this
> message) which insert and display hardlines. (This is useful when sending
> message to devices with small screens since then the line ending is better
> displayed).
>
> However sometimes it is a bit too much. So I still have a function which
> replaces softline by hardlines, namely
>
> (defun harden-newlines () (interactive) (save-excursion ; (goto-char
> (point-min)) (mail-text) (while (search-forward "\n" nil t)
> (put-text-property (1- (point)) (point) 'hard t))))
> So I thought the inverse operation could be
> (defun soften-newlines () (interactive) (save-excursion ; (goto-char
> (point-min)) (mail-text) (while (search-forward "\n" nil t)
> (put-text-property (1- (point)) (point) 'soft t))))
> But unfortunately this did not work out. I tried to google for the
> put-text-property function but did not find anything useful.
>
> Somebody has an idea how to do that, replace hardlines again by softlines?
>
> Thanks
>
> Uwe Brauer
>
>
[-- Attachment #2: Type: text/html, Size: 5312 bytes --]
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: change soft to hard lines and back
2017-12-14 14:18 ` Hinrik Örn Sigurðsson
@ 2017-12-14 15:18 ` Uwe Brauer
2017-12-14 15:54 ` Michael Heerdegen
2017-12-15 2:15 ` Stefan Monnier
0 siblings, 2 replies; 9+ messages in thread
From: Uwe Brauer @ 2017-12-14 15:18 UTC (permalink / raw)
To: emacs-devel
>>> "Hinrik" == Hinrik Örn Sigurðsson <hinrik.sig@gmail.com>
>>> writes:
> You can use the function set-hard-newline-properties to mark
> all newlines in some range as hard. For the inverse you can
> remove the 'hard property with (remove-text-property START
> END '(hard nil)).
Thanks but that function must be very new. For GNU emacs 26 I
obtain
Debugger entered--Lisp error: (void-function remove-text-property)
remove-text-property(83 84 hard t) soften-newlines()
funcall-interactively(soften-newlines)
call-interactively(soften-newlines record nil)
command-execute(soften-newlines record)
execute-extended-command(nil "soften-newlines" "soft")
funcall-interactively(execute-extended-command nil
"soften-newlines" "soft")
call-interactively(execute-extended-command nil nil)
command-execute(execute-extended-command)
So I tried remove-text-properties
(defun soften-newlines () (interactive)
(save-excursion
; (goto-char (point-min))
(mail-text) (while (search-forward "\n" nil t)
(remove-text-properties (1- (point)) (point) 'hard nil))))
But it did not work, the hardlines were not removed.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: change soft to hard lines and back
2017-12-14 15:18 ` Uwe Brauer
@ 2017-12-14 15:54 ` Michael Heerdegen
2017-12-14 18:04 ` Uwe Brauer
2017-12-15 2:15 ` Stefan Monnier
1 sibling, 1 reply; 9+ messages in thread
From: Michael Heerdegen @ 2017-12-14 15:54 UTC (permalink / raw)
To: emacs-devel
Uwe Brauer <oub@mat.ucm.es> writes:
> >>> "Hinrik" == Hinrik Örn Sigurðsson <hinrik.sig@gmail.com> writes:
>
> > You can use the function set-hard-newline-properties to mark > all
> newlines in some range as hard. For the inverse you can > remove the
> 'hard property with (remove-text-property START > END '(hard nil)).
>
>
> Thanks but that function must be very new. For GNU emacs 26 I obtain
>
> Debugger entered--Lisp error: (void-function remove-text-property)
I think this was a typo - you want `remove-text-properties'.
Michael.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: change soft to hard lines and back
2017-12-14 15:54 ` Michael Heerdegen
@ 2017-12-14 18:04 ` Uwe Brauer
0 siblings, 0 replies; 9+ messages in thread
From: Uwe Brauer @ 2017-12-14 18:04 UTC (permalink / raw)
To: emacs-devel
>>> "Michael" == Michael Heerdegen <michael_heerdegen@web.de> writes:
> Uwe Brauer <oub@mat.ucm.es> writes:
>> >>> "Hinrik" == Hinrik Örn Sigurðsson <hinrik.sig@gmail.com> writes:
>>
>> > You can use the function set-hard-newline-properties to mark > all
>> newlines in some range as hard. For the inverse you can > remove the
>> 'hard property with (remove-text-property START > END '(hard nil)).
>>
>>
>> Thanks but that function must be very new. For GNU emacs 26 I obtain
>>
>> Debugger entered--Lisp error: (void-function remove-text-property)
> I think this was a typo - you want `remove-text-properties'.
> Michael.
Yes this I tried as well, but it did not work, that is hardlines were
not removed.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: change soft to hard lines and back
2017-12-14 13:44 change soft to hard lines and back Uwe Brauer
2017-12-14 14:18 ` Hinrik Örn Sigurðsson
@ 2017-12-14 23:52 ` Jorge A. Alfaro-Murillo
2017-12-15 10:20 ` Uwe Brauer
1 sibling, 1 reply; 9+ messages in thread
From: Jorge A. Alfaro-Murillo @ 2017-12-14 23:52 UTC (permalink / raw)
To: emacs-devel
Hi, Uwe.
Uwe Brauer writes:
> For email I start to use messages-are-flowing.el (for example in
> this message) which insert and display hardlines. (This is
> useful when sending message to devices with small screens since
> then the line ending is better displayed).
>
> However sometimes it is a bit too much. So I still have a
> function which replaces softline by hardlines, namely [...]
>
> But unfortunately this did not work out. I tried to google for
> the put-text-property function but did not find anything useful.
>
> Somebody has an idea how to do that, replace hardlines again by
> softlines?
Probably this would work:
#+BEGIN_SRC emacs-lisp
(defun soften-hardlines ()
(interactive)
(save-excursion
(goto-char (point-min))
(mail-text)
(while (search-forward hard-newline nil t)
(replace-match "\n"))))
#+END_SRC
Best,
--
Jorge.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: change soft to hard lines and back
2017-12-14 15:18 ` Uwe Brauer
2017-12-14 15:54 ` Michael Heerdegen
@ 2017-12-15 2:15 ` Stefan Monnier
2017-12-15 10:19 ` Uwe Brauer
1 sibling, 1 reply; 9+ messages in thread
From: Stefan Monnier @ 2017-12-15 2:15 UTC (permalink / raw)
To: emacs-devel
> (remove-text-properties (1- (point)) (point) 'hard nil))))
^^^
Handles a *list* of properties (well, actually for historical reasons
it's a plist), so you need '(hard).
Stefan
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: change soft to hard lines and back
2017-12-15 2:15 ` Stefan Monnier
@ 2017-12-15 10:19 ` Uwe Brauer
0 siblings, 0 replies; 9+ messages in thread
From: Uwe Brauer @ 2017-12-15 10:19 UTC (permalink / raw)
To: emacs-devel
>>> "Stefan" == Stefan Monnier <monnier@iro.umontreal.ca> writes:
>> (remove-text-properties (1- (point)) (point) 'hard nil))))
> ^^^
> Handles a *list* of properties (well, actually for historical reasons
> it's a plist), so you need '(hard).
Ah ok, that settles it, thanks
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: change soft to hard lines and back
2017-12-14 23:52 ` Jorge A. Alfaro-Murillo
@ 2017-12-15 10:20 ` Uwe Brauer
0 siblings, 0 replies; 9+ messages in thread
From: Uwe Brauer @ 2017-12-15 10:20 UTC (permalink / raw)
To: emacs-devel
Hi Jorge,
> Hi, Uwe.
> Uwe Brauer writes:
> Probably this would work:
> #+BEGIN_SRC emacs-lisp
> (defun soften-hardlines ()
> (interactive)
> (save-excursion
> (goto-char (point-min))
> (mail-text)
> (while (search-forward hard-newline nil t)
> (replace-match "\n"))))
> #+END_SRC
It does, thanks, I did not know about search-forward hard-newline
works also nicely.
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2017-12-15 10:20 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-12-14 13:44 change soft to hard lines and back Uwe Brauer
2017-12-14 14:18 ` Hinrik Örn Sigurðsson
2017-12-14 15:18 ` Uwe Brauer
2017-12-14 15:54 ` Michael Heerdegen
2017-12-14 18:04 ` Uwe Brauer
2017-12-15 2:15 ` Stefan Monnier
2017-12-15 10:19 ` Uwe Brauer
2017-12-14 23:52 ` Jorge A. Alfaro-Murillo
2017-12-15 10:20 ` Uwe Brauer
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.