[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Longlines mode and visual-line mode... again
From: |
Danil Orlov |
Subject: |
Longlines mode and visual-line mode... again |
Date: |
Sun, 15 Dec 2013 22:42:36 +0200 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
Hello.
The main feature for me(and I hop for many others too) in longlines mode is
soft line wrap on given column. Occasionally, ll-mode is obsolete, and we
have
visual-line instead of it. That's ok. But that new mode doesn't have this useful
feature from the box. That's not ok.
So, what is typical action for a typical emacs user who wants to get soft line
break, avoiding to see message about ll-mode could be dropped in any
next
release? Right! He goes to:
http://www.emacswiki.org/emacs/VisualLineMode
And copy this fragment into his .emacs or what-else-he-use:
================================================================================
(defvar visual-wrap-column nil)
(defun set-visual-wrap-column (new-wrap-column &optional buffer)
"Force visual line wrap at NEW-WRAP-COLUMN in BUFFER (defaults
to current buffer) by setting the right-hand margin on every
window that displays BUFFER. A value of NIL or 0 for
NEW-WRAP-COLUMN disables this behavior."
(interactive (list (read-number "New visual wrap column, 0 to disable: " (or
visual-wrap-column fill-column 0))))
(if (and (numberp new-wrap-column)
(zerop new-wrap-column))
(setq new-wrap-column nil))
(with-current-buffer (or buffer (current-buffer))
(visual-line-mode t)
(set (make-local-variable 'visual-wrap-column) new-wrap-column)
(add-hook 'window-configuration-change-hook 'update-visual-wrap-column nil
t)
(let ((windows (get-buffer-window-list)))
(while windows
(when (window-live-p (car windows))
(with-selected-window (car windows)
(update-visual-wrap-column)))
(setq windows (cdr windows))))))
(defun update-visual-wrap-column ()
(if (not visual-wrap-column)
(set-window-margins nil nil)
(let* ((current-margins (window-margins))
(right-margin (or (cdr current-margins) 0))
(current-width (window-width))
(current-available (+ current-width right-margin)))
(if (<= current-available visual-wrap-column)
(set-window-margins nil (car current-margins))
(set-window-margins nil (car current-margins)
(- current-available visual-wrap-column))))))
================================================================================
And why this little piece of functionality cannot be integrated
into
visual-line mode? Especially if visual-line-mode is recommended as replacement
for ll-mode.
- Re: trunk r115472: Make 'configure' work out-of-the-box on Solaris., (continued)
- Re: trunk r115472: Make 'configure' work out-of-the-box on Solaris., Eli Zaretskii, 2013/12/14
- Re: trunk r115472: Make 'configure' work out-of-the-box on Solaris., Glenn Morris, 2013/12/14
- Re: trunk r115472: Make 'configure' work out-of-the-box on Solaris., Stefan Monnier, 2013/12/14
- Re: trunk r115472: Make 'configure' work out-of-the-box on Solaris., Paul Eggert, 2013/12/15
- Re: trunk r115472: Make 'configure' work out-of-the-box on Solaris., Eli Zaretskii, 2013/12/15
- Re: trunk r115472: Make 'configure' work out-of-the-box on Solaris., Stefan Monnier, 2013/12/15
- Re: trunk r115472: Make 'configure' work out-of-the-box on Solaris., martin rudalics, 2013/12/16
- Re: trunk r115472: Make 'configure' work out-of-the-box on Solaris., Paul Eggert, 2013/12/16
- Re: trunk r115472: Make 'configure' work out-of-the-box on Solaris., martin rudalics, 2013/12/16
- Re: trunk r115472: Make 'configure' work out-of-the-box on Solaris., martin rudalics, 2013/12/15
- Longlines mode and visual-line mode... again,
Danil Orlov <=
- Re: Longlines mode and visual-line mode... again, Stefan Monnier, 2013/12/15