Introduce a global variant of visual-wrap-prefix-mode

* doc/emacs/basic.texi (Continuation Lines):

* etc/NEWS:

* lisp/visual-wrap.el (visual-wrap-prefix-mode): Document this
new global minor mode.
(global-visual-wrap-prefix-mode): New global minor mode.
This commit is contained in:
Po Lu 2024-02-01 16:08:47 +08:00
parent cd2c45a389
commit b86bc02096
3 changed files with 22 additions and 9 deletions

View file

@ -632,15 +632,18 @@ long, by using Auto Fill mode. @xref{Filling}.
@cindex continuation lines, visual wrap prefix
@findex visual-wrap-prefix-mode
@findex global-visual-wrap-prefix-mode
Normally, the first character of each continuation line is
positioned at the beginning of the screen line where it is displayed.
The minor mode @code{visual-wrap-prefix-mode} arranges that
continuation lines be prefixed by slightly adjusted versions of the
fill prefixes (@pxref{Fill Prefix}) of their respective logical lines,
so that indentation characters or the prefixes of source code comments
are replicated across every continuation line, and the appearance of
such comments or indentation is not broken. These prefixes are only
shown on display, and does not change the buffer text in any way.
The minor mode @code{visual-wrap-prefix-mode} and its global
counterpart @code{global-visual-wrap-prefix-mode} (@pxref{Minor
Modes}) arranges that continuation lines be prefixed by slightly
adjusted versions of the fill prefixes (@pxref{Fill Prefix}) of their
respective logical lines, so that indentation characters or the
prefixes of source code comments are replicated across every
continuation line, and the appearance of such comments or indentation
is not broken. These prefixes are only shown on display, and does not
change the buffer text in any way.
Sometimes, you may need to edit files containing many long logical
lines, and it may not be practical to break them all up by adding

View file

@ -318,7 +318,9 @@ will receive a 'wrap-prefix' automatically computed from the line's
surrounding context, such that continuation lines are indented on
display as if they were filled with 'M-q' or similar. Unlike 'M-q',
the indentation only happens on display, and doesn't change the buffer
text in any way.
text in any way. The global minor mode
'global-visual-wrap-prefix-mode' enables this minor mode in all
buffers.
(This minor mode is the 'adaptive-wrap' ELPA package renamed and
lightly edited for inclusion in Emacs.)

View file

@ -173,7 +173,9 @@ by `visual-wrap-extra-indent'."
;;;###autoload
(define-minor-mode visual-wrap-prefix-mode
"Display continuation lines with prefixes from surrounding context."
"Display continuation lines with prefixes from surrounding context.
To enable this minor mode across all buffers, enable
`global-visual-wrap-prefix-mode'."
:lighter ""
:group 'visual-line
(if visual-wrap-prefix-mode
@ -192,5 +194,11 @@ by `visual-wrap-extra-indent'."
(widen)
(remove-text-properties (point-min) (point-max) '(wrap-prefix nil))))))
;;;###autoload
(define-globalized-minor-mode global-visual-wrap-prefix-mode
visual-wrap-prefix-mode visual-wrap-prefix-mode
:init-value nil
:group 'visual-line)
(provide 'visual-wrap)
;;; visual-wrap.el ends here