all messages for Emacs-related lists mirrored at yhetil.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; 9+ 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] 9+ messages in thread

end of thread, other threads:[~2024-01-10 22:16 UTC | newest]

Thread overview: 9+ 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
2024-01-10 22:16             ` Stefan Kangas

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.