fredefox
fredefox

Reputation: 711

Emacs continuation lines before screen edge

I would like Emacs to display a line continuation at a specified column -- say column 80 -- rather than at the edge of the screen. Is this possible? I know that I can use visual-line-mode and possibly configure that to soft-break the lines at some pre-defined width, but I prefer working on logical lines and would therefore prefer not to use visual-line-mode.

Upvotes: 0

Views: 185

Answers (1)

phils
phils

Reputation: 73274

Setting the window margins more or less does this, but it's going to cause some problems (at minimum, it can interfere with splitting windows).

If you want to dig deeper, this might be a starting point.

(defvar my-right-margin-column 80
  "Used by `my-right-margin-update'.")

(defun my-right-margin-update ()
  "Make the right margin occupy all space beyond `my-right-margin-column'.

See `my-right-margin-auto-update'."
  (set-window-margins
   nil 0 (max 0 (- (+ (window-text-width)
                      (or (cdr (window-margins)) 0))
                   my-right-margin-column)))
  (set-window-parameter nil 'min-margins '(0 . 0)))

(defun my-right-margin-auto-update ()
  "Configure buffer-local `window-configuration-change-hook'."
  (add-hook 'window-configuration-change-hook
            #'my-right-margin-update nil :local))

(add-hook 'text-mode-hook #'my-right-margin-auto-update)

Upvotes: 1

Related Questions