unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#38665: [PATCH] Add nosqueeze for fill-paragraph
@ 2019-12-18 22:29 Jefferson Carpenter
  2020-05-19  4:13 ` Stefan Kangas
  0 siblings, 1 reply; 8+ messages in thread
From: Jefferson Carpenter @ 2019-12-18 22:29 UTC (permalink / raw)
  To: 38665


[-- Attachment #1.1: Type: text/plain, Size: 562 bytes --]

Just added this patch for myself, thought I would pass it along for comments and/or for merging should you think it a good idea.



Use case: I'm writing markdown text that goes something like 



    Outputs a 12-character string  blah blah blah blah or if blah blah blah, returns `"            "`.



In which the markdown contains a literal string with 12 spaces.  When I run fill-paragraph on that, the spaces get collapsed down to 1 space, so I added a customization option to keep the 12-space string unchanged.



Jefferson

[-- Attachment #1.2: Type: text/html, Size: 988 bytes --]

[-- Attachment #2: 0001-Add-nosqueeze-for-fill-paragraph.patch --]
[-- Type: application/octet-stream, Size: 2208 bytes --]

From 3bc23f6dbe4f0975f93d6e9640f13ab41a496725 Mon Sep 17 00:00:00 2001
From: Jefferson Carpenter <jefferson.carpenter@transunion.com>
Date: Wed, 18 Dec 2019 16:16:56 -0600
Subject: [PATCH] Add nosqueeze for fill-paragraph

---
 etc/NEWS               |  5 +++++
 lisp/textmodes/fill.el | 10 ++++++++--
 2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/etc/NEWS b/etc/NEWS
index cf4e705a52..7825851fb0 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -533,6 +533,11 @@ The HIST argument of 'read-from-minibuffer' now works correctly with
 buffer-local variables.  This means that different buffers can have
 their own separated input history list if desired.
 
+---
+** New user option 'fill-paragraph-nosqueeze'.
+This passes non-nil NOSQUEEZE to fill-region functions during
+fill-paragraph invocations.
+
 \f
 * Editing Changes in Emacs 27.1
 
diff --git a/lisp/textmodes/fill.el b/lisp/textmodes/fill.el
index c285491a30..6f9eb2a725 100644
--- a/lisp/textmodes/fill.el
+++ b/lisp/textmodes/fill.el
@@ -59,6 +59,12 @@ words are categorized."
   :group 'fill
   :version "26.1")
 
+(defcustom fill-paragraph-nosqueeze nil
+  "Non-nil means to leave whitespace other than line breaks
+  untouched."
+  :type 'boolean
+  :group 'fill)
+
 (defvar fill-paragraph-function nil
   "Mode-specific function to fill a paragraph, or nil if there is none.
 If the function returns nil, then `fill-paragraph' does its normal work.
@@ -890,8 +896,8 @@ region, instead of just filling the current paragraph."
                            ;; Can't use fill-region-as-paragraph, since this
                            ;; paragraph may still contain hard newlines.  See
                            ;; fill-region.
-                           (fill-region beg end justify)
-                         (fill-region-as-paragraph beg end justify))))))
+                           (fill-region beg end justify fill-paragraph-nosqueeze)
+                         (fill-region-as-paragraph beg end justify fill-paragraph-nosqueeze))))))
            fill-pfx))
       ;; If we didn't change anything in the buffer (and the buffer
       ;; was previously unmodified), then flip the modification status
-- 
2.20.1 (Apple Git-117)


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

* bug#38665: [PATCH] Add nosqueeze for fill-paragraph
  2019-12-18 22:29 bug#38665: [PATCH] Add nosqueeze for fill-paragraph Jefferson Carpenter
@ 2020-05-19  4:13 ` Stefan Kangas
  2020-05-19 14:15   ` Eli Zaretskii
  0 siblings, 1 reply; 8+ messages in thread
From: Stefan Kangas @ 2020-05-19  4:13 UTC (permalink / raw)
  To: Jefferson Carpenter; +Cc: 38665

Jefferson Carpenter <jefferson@aoeu2code.com> writes:

> Just added this patch for myself, thought I would pass it along for comments and/or for merging should you think it a good idea.
>
> Use case: I'm writing markdown text that goes something like
>
>     Outputs a 12-character string blah blah blah blah or if blah blah blah, returns `"            "`.
>
> In which the markdown contains a literal string with 12 spaces.  When I run fill-paragraph on that, the spaces get collapsed down to 1 space, so I added a customization option to keep the 12-space string unchanged.

Thanks for the patch, and sorry for the much the delayed response.

I think this could go in, if some people find it useful.

Any other opinions?

Best regards,
Stefan Kangas





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

* bug#38665: [PATCH] Add nosqueeze for fill-paragraph
  2020-05-19  4:13 ` Stefan Kangas
@ 2020-05-19 14:15   ` Eli Zaretskii
  2020-05-19 14:22     ` Stefan Kangas
  0 siblings, 1 reply; 8+ messages in thread
From: Eli Zaretskii @ 2020-05-19 14:15 UTC (permalink / raw)
  To: Stefan Kangas; +Cc: 38665, jefferson

> From: Stefan Kangas <stefan@marxist.se>
> Date: Mon, 18 May 2020 21:13:27 -0700
> Cc: 38665@debbugs.gnu.org
> 
> > Use case: I'm writing markdown text that goes something like
> >
> >     Outputs a 12-character string blah blah blah blah or if blah blah blah, returns `"            "`.
> >
> > In which the markdown contains a literal string with 12 spaces.  When I run fill-paragraph on that, the spaces get collapsed down to 1 space, so I added a customization option to keep the 12-space string unchanged.
> 
> Thanks for the patch, and sorry for the much the delayed response.
> 
> I think this could go in, if some people find it useful.

It sounds strange to me to have a defcustom for this.  Are you saying
that you want this no-squeeze variant for all or many M-q commands or
for prolonged periods of time?  It sounds like a one-off feature, so
perhaps some special value of the prefix argument, like zero or maybe
"C-u C-u", would be a better UI, as that would allow one to activate
this option for a specific command.





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

* bug#38665: [PATCH] Add nosqueeze for fill-paragraph
  2020-05-19 14:15   ` Eli Zaretskii
@ 2020-05-19 14:22     ` Stefan Kangas
  2020-05-19 23:59       ` Phil Sainty
  0 siblings, 1 reply; 8+ messages in thread
From: Stefan Kangas @ 2020-05-19 14:22 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 38665, jefferson

Eli Zaretskii <eliz@gnu.org> writes:

> It sounds like a one-off feature, so perhaps some special value of the
> prefix argument, like zero or maybe "C-u C-u", would be a better UI,
> as that would allow one to activate this option for a specific
> command.

Agreed.  Jefferson, would you like to work on an updated patch?

Best regards,
Stefan Kangas





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

* bug#38665: [PATCH] Add nosqueeze for fill-paragraph
  2020-05-19 14:22     ` Stefan Kangas
@ 2020-05-19 23:59       ` Phil Sainty
  2020-05-21  1:51         ` Phil Sainty
  2020-10-01  2:44         ` Lars Ingebrigtsen
  0 siblings, 2 replies; 8+ messages in thread
From: Phil Sainty @ 2020-05-19 23:59 UTC (permalink / raw)
  To: Stefan Kangas; +Cc: 38665, jefferson

On 2020-05-20 02:22, Stefan Kangas wrote:
> Eli Zaretskii <eliz@gnu.org> writes:
>> It sounds like a one-off feature, so perhaps some special value of
>> the prefix argument, like zero or maybe "C-u C-u", would be a
>> better UI, as that would allow one to activate this option for a
>> specific command.
> 
> Agreed.  Jefferson, would you like to work on an updated patch?

To complicate things slightly, I have a patch languishing in my
"get back to at some point" pile for enhancing the use of prefix
arguments when filling text:

https://lists.gnu.org/r/emacs-devel/2016-11/msg00300.html

Reviewing that thread, employing C-u C-u arose:
https://lists.gnu.org/r/emacs-devel/2016-11/msg00313.html

My suggestion there for C-u C-u was:

>>> That could mean "prompt for the fill-prefix, and use the default
>>> column and justify values", but it might be more useful to instead
>>> make it prompt for *everything* -- justify, fill-column,
>>> fill-prefix, and maybe left-margin too.
>>> 
>>> The default value would be provided in each case, so you could
>>> just RET your way past the ones you didn't want to change.

I think we could blend the 'nosqueeze' option into all this, but if
the new changes could happen in a way which wouldn't create any serious
conflicts for the other changes I'm still hoping to get made, that
would be grand.

Or if someone is motivated, please feel free to run with what I'd
already done.  I may have some more-recent local WIP on my other
machine; I'll have a look for that later.


-Phil






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

* bug#38665: [PATCH] Add nosqueeze for fill-paragraph
  2020-05-19 23:59       ` Phil Sainty
@ 2020-05-21  1:51         ` Phil Sainty
  2020-10-01  2:44         ` Lars Ingebrigtsen
  1 sibling, 0 replies; 8+ messages in thread
From: Phil Sainty @ 2020-05-21  1:51 UTC (permalink / raw)
  To: Stefan Kangas; +Cc: 38665, jefferson

On 2020-05-20 11:59, Phil Sainty wrote:
> I may have some more-recent local WIP on my other machine;
> I'll have a look for that later.

Having checked this, I do have a fairly sizeable WIP diff
against my initial patch, and it all still applies with
only one minor context change.  That's all I've checked
though -- I haven't tried to work out exactly where I got
to with the changes, or which problems still needed to be
figured out.

The additional changes are very much WIP and messy, so
there's not a nice patch to put anywhere; but if someone
is interested in actively working on this feature in the
near future, and didn't mind picking through some mess,
then let me know.

-Phil






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

* bug#38665: [PATCH] Add nosqueeze for fill-paragraph
  2020-05-19 23:59       ` Phil Sainty
  2020-05-21  1:51         ` Phil Sainty
@ 2020-10-01  2:44         ` Lars Ingebrigtsen
  2022-11-25  1:36           ` Stefan Kangas
  1 sibling, 1 reply; 8+ messages in thread
From: Lars Ingebrigtsen @ 2020-10-01  2:44 UTC (permalink / raw)
  To: Phil Sainty; +Cc: 38665, jefferson, Stefan Kangas

Phil Sainty <psainty@orcon.net.nz> writes:

> My suggestion there for C-u C-u was:
>
>>>> That could mean "prompt for the fill-prefix, and use the default
>>>> column and justify values", but it might be more useful to instead
>>>> make it prompt for *everything* -- justify, fill-column,
>>>> fill-prefix, and maybe left-margin too.
>>>> The default value would be provided in each case, so you could
>>>> just RET your way past the ones you didn't want to change.
>
> I think we could blend the 'nosqueeze' option into all this, but if
> the new changes could happen in a way which wouldn't create any serious
> conflicts for the other changes I'm still hoping to get made, that
> would be grand.
>
> Or if someone is motivated, please feel free to run with what I'd
> already done.  I may have some more-recent local WIP on my other
> machine; I'll have a look for that later.

I think the idea is sound -- there's so many variations of what you'd
possibly want this command to do, so prompting seems good: Neither user
options nor adding more prefix combinations would help, I think.

If you could finish up the WIP and post the patch, that'd be great.

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





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

* bug#38665: [PATCH] Add nosqueeze for fill-paragraph
  2020-10-01  2:44         ` Lars Ingebrigtsen
@ 2022-11-25  1:36           ` Stefan Kangas
  0 siblings, 0 replies; 8+ messages in thread
From: Stefan Kangas @ 2022-11-25  1:36 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: Phil Sainty, 38665, Eli Zaretskii, jefferson

Lars Ingebrigtsen <larsi@gnus.org> writes:

> Phil Sainty <psainty@orcon.net.nz> writes:
>
>> My suggestion there for C-u C-u was:
>>
>>>>> That could mean "prompt for the fill-prefix, and use the default
>>>>> column and justify values", but it might be more useful to instead
>>>>> make it prompt for *everything* -- justify, fill-column,
>>>>> fill-prefix, and maybe left-margin too.
>>>>> The default value would be provided in each case, so you could
>>>>> just RET your way past the ones you didn't want to change.
>>
>> I think we could blend the 'nosqueeze' option into all this, but if
>> the new changes could happen in a way which wouldn't create any serious
>> conflicts for the other changes I'm still hoping to get made, that
>> would be grand.
>>
>> Or if someone is motivated, please feel free to run with what I'd
>> already done.  I may have some more-recent local WIP on my other
>> machine; I'll have a look for that later.
>
> I think the idea is sound -- there's so many variations of what you'd
> possibly want this command to do, so prompting seems good: Neither user
> options nor adding more prefix combinations would help, I think.
>
> If you could finish up the WIP and post the patch, that'd be great.

That was 2 years ago.  Phil, did you make any progress with your patch?





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

end of thread, other threads:[~2022-11-25  1:36 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-18 22:29 bug#38665: [PATCH] Add nosqueeze for fill-paragraph Jefferson Carpenter
2020-05-19  4:13 ` Stefan Kangas
2020-05-19 14:15   ` Eli Zaretskii
2020-05-19 14:22     ` Stefan Kangas
2020-05-19 23:59       ` Phil Sainty
2020-05-21  1:51         ` Phil Sainty
2020-10-01  2:44         ` Lars Ingebrigtsen
2022-11-25  1:36           ` Stefan Kangas

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).