; Minor improvements in 'visual-wrap-prefix-mode'

* lisp/visual-wrap.el (visual-wrap-extra-indent): Add :version.
(visual-wrap-fill-context-prefix): Doc fix.
* lisp/menu-bar.el (menu-bar-line-wrapping-menu): Move the menu to
a better place, improve the help-echo text.

* etc/NEWS:
* doc/emacs/basic.texi (Continuation Lines): Improve documentation
and indexing of 'visual-wrap-prefix-mode'.
This commit is contained in:
Eli Zaretskii 2024-01-27 10:38:14 +02:00
parent 08007a030e
commit 43e2f3acdd
4 changed files with 23 additions and 19 deletions

View file

@ -630,7 +630,7 @@ before they get too long, by inserting newlines. If you prefer, you
can make Emacs insert a newline automatically when a line gets too
long, by using Auto Fill mode. @xref{Filling}.
@cindex continuation lines, wrapping with prefix
@cindex continuation lines, visual wrap prefix
@findex 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.
@ -639,7 +639,8 @@ 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.
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

@ -319,15 +319,15 @@ name detection.
+++
** New minor mode 'visual-wrap-prefix-mode'.
When enabled, continuation lines displayed for a wrapped long line
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.
When enabled, continuation lines displayed for a folded long line will
receive a 'wrap-prefix' automatically computed from the line's
surrounding context by the function 'fill-context-prefix', which
generally indents continuation lines as if the line were filled with
'M-q', or similar.
This minor mode is the 'adaptive-wrap' ELPA package renamed and
lightly edited for inclusion in Emacs.
(This minor mode is the 'adaptive-wrap' ELPA package renamed and
lightly edited for inclusion in Emacs.)
+++
** New user option 'gud-highlight-current-line'.

View file

@ -1438,6 +1438,14 @@ mail status in mode line"))
(defvar menu-bar-line-wrapping-menu
(let ((menu (make-sparse-keymap "Line Wrapping")))
(bindings--define-key menu [visual-wrap]
'(menu-item "Visual Wrap Prefix mode" visual-wrap-prefix-mode
:help "Display continuation lines with visual context-dependent prefix"
:visible (menu-bar-menu-frame-live-and-visible-p)
:button (:toggle
. (bound-and-true-p visual-wrap-prefix-mode))
:enable t))
(bindings--define-key menu [word-wrap]
'(menu-item "Word Wrap (Visual Line mode)"
menu-bar--visual-line-mode-enable
@ -1467,13 +1475,6 @@ mail status in mode line"))
(not word-wrap)))
:visible (menu-bar-menu-frame-live-and-visible-p)
:enable (not (truncated-partial-width-window-p))))
(bindings--define-key menu [visual-wrap]
'(menu-item "Visual Wrap Prefix" visual-wrap-prefix-mode
:help "Display continuation lines with contextual prefix"
:visible (menu-bar-menu-frame-live-and-visible-p)
:button (:toggle . (bound-and-true-p visual-wrap-prefix-mode))
:enable t))
menu))
(defvar menu-bar-search-options-menu

View file

@ -59,6 +59,7 @@ extra indent = 2
ullamco laboris nisi ut aliquip ex ea commodo consequat."
:type 'integer
:safe 'integerp
:version "30.1"
:group 'visual-line)
(defun visual-wrap--face-extend-p (face)
@ -111,8 +112,9 @@ extra indent = 2
""))))
(defun visual-wrap-fill-context-prefix (beg end)
"Like `fill-context-prefix', but with length adjusted by
`visual-wrap-extra-indent'."
"Compute visual wrap prefix from text between FROM and TO.
This is like `fill-context-prefix', but with prefix length adjusted
by `visual-wrap-extra-indent'."
(let* ((fcp
;; `fill-context-prefix' ignores prefixes that look like
;; paragraph starts, in order to avoid inadvertently