|
From: | martin rudalics |
Subject: | Re: Patch: Syntax and Hard Newlines |
Date: | Sat, 18 Nov 2006 15:34:36 +0100 |
User-agent: | Mozilla Thunderbird 1.0 (Windows/20041206) |
> BTW: How about this problem? I'm not sure what I should do now. > Could somebody please give some suggestions? Thanks. 1. Define `longlines-wrap-region' somewhat like the following untested (defun longlines-wrap-region (beg end) "Wrap lines between BEG and END." (save-excursion (save-restriction (goto-char end) (unless (eolp) (forward-line)) (setq end (point)) (goto-char beg) (forward-line -1) (setq beg (point)) (narrow-to-region beg end) (remove-overlays nil nil 'longlines t) (while (not (eobp)) (save-restriction (narrow-to-region (line-beginning-position) (line-end-position)) (while (and (move-to-column fill-column) (save-match-data (not (looking-at "[ \t]*$"))) (or (longlines-find-break-backward) (progn (move-to-column fill-column) (longlines-find-break-forward)))) (let* ((from (save-excursion (skip-chars-backward " \t") (point))) (to (save-excursion (skip-chars-forward " \t") (point))) (overlay (make-overlay from to))) ;; Overlay with display property. (overlay-put overlay 'display "\n") (overlay-put overlay 'longlines t) (narrow-to-region (point) (point-max))))) (forward-line))))) 2. Modify the remainder of longlines.el accordingly (I'd wrap only regions between `window-start' and `window-end'). 3. Redefine `next-line' and `previous-line' to treat an overlay with a display property of "\n" just as another newline (possibly guided by an additional "soft" parameter). 4. Add two new commands `beginning-of-line-soft' and `end-of-line-soft' that handle such overlays as well.
[Prev in Thread] | Current Thread | [Next in Thread] |