unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#14973: Unfill for Emacs
@ 2013-07-28  6:36 Xue Fuqiao
  2013-07-28 14:28 ` Drew Adams
  2013-07-28 14:53 ` Eli Zaretskii
  0 siblings, 2 replies; 8+ messages in thread
From: Xue Fuqiao @ 2013-07-28  6:36 UTC (permalink / raw)
  To: 14973

tags patch

There are fill-{paragraph, column}, but I didn't find an unfill command,
can we add them (maybe in fill.el)?

(defun unfill-paragraph ()
  "Replace newline characters in current paragraph by single spaces.

This command does the inverse of `fill-paragraph'."
  (interactive)
  (let ((fill-column most-positive-fixnum))
    (fill-paragraph nil)))

(defun unfill-region (beg end)
  "Replace newline characters in region by single spaces.

If called non-interactively, BEG and END are the beginning and end of
the text to unfill.
This command does the inverse of `fill-region'."
  (interactive "r")
  (let ((fill-column most-positive-fixnum))
    (fill-region beg end)))

-- 
Best regards, Xue Fuqiao.
http://www.gnu.org/software/emacs/





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#14973: Unfill for Emacs
  2013-07-28  6:36 Xue Fuqiao
@ 2013-07-28 14:28 ` Drew Adams
  2013-07-28 14:53 ` Eli Zaretskii
  1 sibling, 0 replies; 8+ messages in thread
From: Drew Adams @ 2013-07-28 14:28 UTC (permalink / raw)
  To: Xue Fuqiao, 14973

Just one terminology point: what you describe and implement is not
unfilling.  These are fill commands, not unfill commands.

Unfilling is the inverse of filling.  Unfilling undoes the last filling
operation on the same region or whatever.  It restores contiguous
whitespace chars that were collapsed, etc.

What you have instead might be called "join lines" or "remove line
breaks".  But even those names do not accurately characterize it, because
it also fills: it insists on the kind of whitespace separation imposed
by filling: no contiguous whitespace chars (except possibly indentation
and after sentence ends).

That does not mean that this could not be useful.  But we might not want
to falsely advertise what it does.

The best characterization of what this code does is "fill as one line".
(But even that assumes a line length less than `most-positive-fixnum'.)
And that is my suggestion:

 `fill-paragraph-as-one-line'
 `fill-region-as-one-line'





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#14973: Unfill for Emacs
  2013-07-28  6:36 Xue Fuqiao
  2013-07-28 14:28 ` Drew Adams
@ 2013-07-28 14:53 ` Eli Zaretskii
  2013-07-28 15:14   ` Christopher Schmidt
  1 sibling, 1 reply; 8+ messages in thread
From: Eli Zaretskii @ 2013-07-28 14:53 UTC (permalink / raw)
  To: Xue Fuqiao; +Cc: 14973

> Date: Sun, 28 Jul 2013 14:36:05 +0800
> From: Xue Fuqiao <xfq.free@gmail.com>
> 
> There are fill-{paragraph, column}, but I didn't find an unfill command,
> can we add them (maybe in fill.el)?
> 
> (defun unfill-paragraph ()
>   "Replace newline characters in current paragraph by single spaces.
> 
> This command does the inverse of `fill-paragraph'."
>   (interactive)
>   (let ((fill-column most-positive-fixnum))
>     (fill-paragraph nil)))

You need a special command to replace one character by another?





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#14973: Unfill for Emacs
       [not found] ` <<834nbezqex.fsf@gnu.org>
@ 2013-07-28 15:06   ` Drew Adams
  2013-07-28 16:59     ` Jambunathan K
  0 siblings, 1 reply; 8+ messages in thread
From: Drew Adams @ 2013-07-28 15:06 UTC (permalink / raw)
  To: Eli Zaretskii, Xue Fuqiao; +Cc: 14973

> > There are fill-{paragraph, column}, but I didn't find an unfill command,
> > can we add them (maybe in fill.el)?
> >
> > (defun unfill-paragraph ()
> >   "Replace newline characters in current paragraph by single spaces.
> 
> You need a special command to replace one character by another?

A user might not *need* that, provided s?he were knowledgeable wrt
replacement commands or wrt Lisp.  But a user might *want* that.

The question is whether such commands should be added to Emacs, as a
convenience.  I have no opinion about that.  But if they are added then
I would prefer that the command names reflect better what the commands do
(see my previous comment).





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#14973: Unfill for Emacs
  2013-07-28 14:53 ` Eli Zaretskii
@ 2013-07-28 15:14   ` Christopher Schmidt
  0 siblings, 0 replies; 8+ messages in thread
From: Christopher Schmidt @ 2013-07-28 15:14 UTC (permalink / raw)
  To: 14973

Eli Zaretskii <eliz@gnu.org> writes:
> You need a special command to replace one character by another?

The command does more than that, e.g. it honours
sentence-end-double-space.

I do not think there is any need to add this command to vanilla Emacs.
Just use set-fill-column (C-x f).

        Christopher





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#14973: Unfill for Emacs
  2013-07-28 15:06   ` bug#14973: Unfill for Emacs Drew Adams
@ 2013-07-28 16:59     ` Jambunathan K
  2013-07-28 18:31       ` Josh
  0 siblings, 1 reply; 8+ messages in thread
From: Jambunathan K @ 2013-07-28 16:59 UTC (permalink / raw)
  To: Drew Adams; +Cc: Xue Fuqiao, 14973


>> You need a special command to replace one character by another?

This is what I use for deleting newlines and thus create "long" lines.
Seem to work well for me.

,----
| M-^ runs the command delete-indentation, which is an interactive
| compiled Lisp function in `simple.el'.
| 
| It is bound to M-^.
| 
| (delete-indentation &optional ARG)
| 
| Join this line to previous and fix up whitespace at join.
| If there is a fill prefix, delete it from the beginning of this line.
| With argument, join this line to following line.
`----






^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#14973: Unfill for Emacs
  2013-07-28 16:59     ` Jambunathan K
@ 2013-07-28 18:31       ` Josh
  2022-01-26 17:25         ` Lars Ingebrigtsen
  0 siblings, 1 reply; 8+ messages in thread
From: Josh @ 2013-07-28 18:31 UTC (permalink / raw)
  To: Jambunathan K; +Cc: Xue Fuqiao, 14973

On Sun, Jul 28, 2013 at 9:59 AM, Jambunathan K <kjambunathan@gmail.com> wrote:
>
>>> You need a special command to replace one character by another?
>
> This is what I use for deleting newlines and thus create "long" lines.
> Seem to work well for me.
>
> ,----
> | M-^ runs the command delete-indentation, which is an interactive
> | compiled Lisp function in `simple.el'.
> |
> | It is bound to M-^.
> |
> | (delete-indentation &optional ARG)
> |
> | Join this line to previous and fix up whitespace at join.
> | If there is a fill prefix, delete it from the beginning of this line.
> | With argument, join this line to following line.
> `----

Perhaps it would make sense to extend delete-indentation to apply to
active regions in the same way as commands like replace-string,
whitespace-cleanup, etc.  This could make "unfilling" a paragraph as
simple as M-h M-^, perhaps with an intervening C-n to move point to
the desired position.  Alternatively, a bare negative prefix argument
(M-- M-^) could trigger that behavior without need of an active
region.





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#14973: Unfill for Emacs
  2013-07-28 18:31       ` Josh
@ 2022-01-26 17:25         ` Lars Ingebrigtsen
  0 siblings, 0 replies; 8+ messages in thread
From: Lars Ingebrigtsen @ 2022-01-26 17:25 UTC (permalink / raw)
  To: Josh; +Cc: Xue Fuqiao, Jambunathan K, 14973

Josh <josh@foxtail.org> writes:

> Perhaps it would make sense to extend delete-indentation to apply to
> active regions in the same way as commands like replace-string,
> whitespace-cleanup, etc.  This could make "unfilling" a paragraph as
> simple as M-h M-^, perhaps with an intervening C-n to move point to
> the desired position.

(I'm going through old bug reports that unfortunately weren't resolved
at the time.)

Looks like the command was changed to work just like this in:

commit 0cd250e9583deb1e1f4d8dae2ec44c4f7c13efa6
Author:     Basil L. Contovounesios <contovob@tcd.ie>
AuthorDate: Wed Mar 27 15:13:25 2019 +0000

    Fix recently extended delete-indentation behavior

So I think this covers the proposed new commands, and I'm therefore
closing this bug report.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2022-01-26 17:25 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <<CAAF+z6G7rJzqONuZa5Aat9eK5hGUcM3TGrt7mKon8uzMa3FWkg@mail.gmail.com>
     [not found] ` <<834nbezqex.fsf@gnu.org>
2013-07-28 15:06   ` bug#14973: Unfill for Emacs Drew Adams
2013-07-28 16:59     ` Jambunathan K
2013-07-28 18:31       ` Josh
2022-01-26 17:25         ` Lars Ingebrigtsen
2013-07-28  6:36 Xue Fuqiao
2013-07-28 14:28 ` Drew Adams
2013-07-28 14:53 ` Eli Zaretskii
2013-07-28 15:14   ` Christopher Schmidt

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.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).