From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stephen Berman Newsgroups: gmane.emacs.devel Subject: Re: word-wrap (visual-line) and indents Date: Tue, 25 May 2010 21:39:15 +0200 Message-ID: <87sk5fhiu4.fsf@escher.home> References: <9B319A0D-0385-48AD-BF12-884232B365C2@gmail.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: dough.gmane.org 1274816386 3034 80.91.229.12 (25 May 2010 19:39:46 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Tue, 25 May 2010 19:39:46 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue May 25 21:39:45 2010 connect(): No such file or directory Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1OGzyb-0002bQ-7D for ged-emacs-devel@m.gmane.org; Tue, 25 May 2010 21:39:45 +0200 Original-Received: from localhost ([127.0.0.1]:54752 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OGzya-0001JF-OH for ged-emacs-devel@m.gmane.org; Tue, 25 May 2010 15:39:44 -0400 Original-Received: from [140.186.70.92] (port=47219 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OGzyU-0001JA-9i for emacs-devel@gnu.org; Tue, 25 May 2010 15:39:39 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OGzyT-0006tG-0T for emacs-devel@gnu.org; Tue, 25 May 2010 15:39:38 -0400 Original-Received: from lo.gmane.org ([80.91.229.12]:43644) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OGzyS-0006t5-Ld for emacs-devel@gnu.org; Tue, 25 May 2010 15:39:36 -0400 Original-Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1OGzyP-0002UB-Nf for emacs-devel@gnu.org; Tue, 25 May 2010 21:39:33 +0200 Original-Received: from i59f561cc.versanet.de ([89.245.97.204]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 25 May 2010 21:39:33 +0200 Original-Received: from stephen.berman by i59f561cc.versanet.de with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 25 May 2010 21:39:33 +0200 X-Injected-Via-Gmane: http://gmane.org/ connect(): No such file or directory Original-Lines: 56 Original-X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: i59f561cc.versanet.de User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:125268 Archived-At: On Tue, 25 May 2010 13:05:08 -0400 Stefan Monnier wrote: >> Speaking of word-wrapping, I thought now would be a good time to bring >> up the missing feature of per-line indentation when word wrapping. >> A recent conversation is quoted below, pointing out that word-wrap is >> less than ideal when it comes to displaying e-mail (and the like). >> A similar example would be org-mode, where you would begin a (buffer) >> line with "- " or " - " and where word-wrap would, ideally, >> recognize such indentations. > > The C code already has hooks that make such a thing possible: > Just place a `wrap-prefix' property on the long-line which specify what > prefix to use when wrapping the line. > > So all we need is a new minor-mode that uses jit-lock-register and then > sets up this property using something like fill-context-prefix. See . You followed up with some suggestions, incorporated in the code below (I had included the commented out lines, but you thought they should be separate features). Maybe this could be the basis for such a minor mode. Steve Berman (defun srb-adaptive-indent (beg end) "Indent the region between BEG and END with adaptive filling." (goto-char beg) (while (let ((lbp (line-beginning-position)) (lep (line-end-position))) (put-text-property lbp lep 'wrap-prefix (fill-context-prefix lbp lep)) (search-forward "\n" end t)))) (define-minor-mode srb-adaptive-wrap-mode "Wrap the buffer text with adaptive filling." :lighter "" (save-excursion (save-restriction (widen) (let ((buffer-undo-list t) (inhibit-read-only t) (mod (buffer-modified-p))) (if srb-adaptive-wrap-mode (progn ;; (setq word-wrap t) ;; (unless (member '(continuation) fringe-indicator-alist) ;; (push '(continuation) fringe-indicator-alist)) (jit-lock-register 'srb-adaptive-indent)) (jit-lock-unregister 'srb-adaptive-indent) (remove-text-properties (point-min) (point-max) '(wrap-prefix pref)) ;; (setq fringe-indicator-alist ;; (delete '(continuation) fringe-indicator-alist)) ;; (setq word-wrap nil)) (restore-buffer-modified-p mod))))))