[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/visual-fill-column 30fc3e4ea9: New command `visual-fill-co
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/visual-fill-column 30fc3e4ea9: New command `visual-fill-column-toggle-center-text`. |
Date: |
Sun, 23 Mar 2025 13:01:38 -0400 (EDT) |
branch: elpa/visual-fill-column
commit 30fc3e4ea9aa415eccc873e5d7c4f1bbc0491495
Author: Joost Kremers <joostkremers@fastmail.com>
Commit: Joost Kremers <joostkremers@fastmail.com>
New command `visual-fill-column-toggle-center-text`.
---
README.md | 6 ++----
visual-fill-column.el | 6 ++++++
2 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/README.md b/README.md
index 2331c6d59f..f2d2d3b873 100644
--- a/README.md
+++ b/README.md
@@ -38,11 +38,9 @@ Another use case for `visual-fill-column` is to centre the
text in a window:

-This effect is achieved by setting the user option
`visual-fill-column-center-text`. Note that `visual-fill-column-mode` is not
dependent on `visual-line-mode`, so it can be used to centre text in buffers
that use `auto-fill-mode` or in programming modes.
+This effect is achieved by setting the user option
`visual-fill-column-center-text`. You can use the Customize interface or
`setopt` to set a default value. In addition, the effect can also be toggled on
a per-buffer basis using the command: `visual-fill-column-toggle-center-text`.
-Note that `visual-fill-column-center-text` automatically becomes buffer-local
when it is set. Therefore, if you wish to make this the default, either use the
Customize interface or use `setq-default` in your init file, rather than `setq`:
-
- (setq-default visual-fill-column-center-text t)
+Keep in mind that `visual-fill-column-mode` is not dependent on
`visual-line-mode`, so it can be used to center text in buffers that use
`auto-fill-mode` or in programming modes.
Note: If you are interested in a fully distraction-free writing environment,
that not only centres the text but also removes the window decorations, the
mode line etc., take a look at
[`writeroom-mode`](https://github.com/joostkremers/writeroom-mode).
diff --git a/visual-fill-column.el b/visual-fill-column.el
index e06876f615..785c053eeb 100644
--- a/visual-fill-column.el
+++ b/visual-fill-column.el
@@ -173,6 +173,12 @@ Use this mode to activate and deactivate
`visual-line-mode' and
(visual-fill-column-mode -1)
(visual-line-mode -1))))
+(defun visual-fill-column-toggle-center-text ()
+ "Toggle centering of text in the current buffer."
+ (interactive)
+ (setq visual-fill-column-center-text (not visual-fill-column-center-text))
+ (visual-fill-column-adjust))
+
(defun turn-on-visual-fill-column-mode ()
"Turn on `visual-fill-column-mode'.
Note that `visual-fill-column-mode' is only turned on in buffers
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [nongnu] elpa/visual-fill-column 30fc3e4ea9: New command `visual-fill-column-toggle-center-text`.,
ELPA Syncer <=