From: Jefferson Carpenter <jefferson@aoeu2code.com>
To: 38665@debbugs.gnu.org
Subject: bug#38665: [PATCH] Add nosqueeze for fill-paragraph
Date: Wed, 18 Dec 2019 22:29:22 +0000 [thread overview]
Message-ID: <16f1b2142c1.db34a11d477759.6290031006911449352@aoeu2code.com> (raw)
[-- 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)
next reply other threads:[~2019-12-18 22:29 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-18 22:29 Jefferson Carpenter [this message]
2020-05-19 4:13 ` bug#38665: [PATCH] Add nosqueeze for fill-paragraph 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=16f1b2142c1.db34a11d477759.6290031006911449352@aoeu2code.com \
--to=jefferson@aoeu2code.com \
--cc=38665@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.