diff --git a/doc/emacs/basic.texi b/doc/emacs/basic.texi index a6b71db4bea..cdc183c2a40 100644 --- a/doc/emacs/basic.texi +++ b/doc/emacs/basic.texi @@ -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 diff --git a/etc/NEWS b/etc/NEWS index 37a017c4db1..d69d0001135 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -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'. diff --git a/lisp/menu-bar.el b/lisp/menu-bar.el index 761f0603c75..47c6a8f0613 100644 --- a/lisp/menu-bar.el +++ b/lisp/menu-bar.el @@ -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 diff --git a/lisp/visual-wrap.el b/lisp/visual-wrap.el index f8e00b9c685..1cb49538eae 100644 --- a/lisp/visual-wrap.el +++ b/lisp/visual-wrap.el @@ -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