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: line/wrap-prefix patch Date: Sat, 05 Jul 2008 23:30:50 +0200 Message-ID: <87bq1cggs5.fsf@escher.local.home> References: <61zlp3k2xx.fsf@fencepost.gnu.org> <87abh1i6xm.fsf@escher.local.home> <8763rlpe4u.fsf@escher.local.home> <87d4lt5f0e.fsf@catnip.gol.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1215293486 8469 80.91.229.12 (5 Jul 2008 21:31:26 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 5 Jul 2008 21:31:26 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Jul 05 23:32:12 2008 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.50) id 1KFFMW-00038S-Ou for ged-emacs-devel@m.gmane.org; Sat, 05 Jul 2008 23:32:09 +0200 Original-Received: from localhost ([127.0.0.1]:39601 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KFFLf-0005QS-G7 for ged-emacs-devel@m.gmane.org; Sat, 05 Jul 2008 17:31:15 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KFFLX-0005Og-30 for emacs-devel@gnu.org; Sat, 05 Jul 2008 17:31:07 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KFFLV-0005NQ-T4 for emacs-devel@gnu.org; Sat, 05 Jul 2008 17:31:06 -0400 Original-Received: from [199.232.76.173] (port=44089 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KFFLV-0005NG-KC for emacs-devel@gnu.org; Sat, 05 Jul 2008 17:31:05 -0400 Original-Received: from main.gmane.org ([80.91.229.2]:33603 helo=ciao.gmane.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1KFFLV-0001Aa-4W for emacs-devel@gnu.org; Sat, 05 Jul 2008 17:31:05 -0400 Original-Received: from list by ciao.gmane.org with local (Exim 4.43) id 1KFFLQ-0000CJ-9S for emacs-devel@gnu.org; Sat, 05 Jul 2008 21:31:00 +0000 Original-Received: from i5387d749.versanet.de ([83.135.215.73]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 05 Jul 2008 21:31:00 +0000 Original-Received: from stephen.berman by i5387d749.versanet.de with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 05 Jul 2008 21:31:00 +0000 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 86 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: i5387d749.versanet.de User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux) X-detected-kernel: by monty-python.gnu.org: Linux 2.6, seldom 2.4 (older, 4) 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:100375 Archived-At: On Sat, 05 Jul 2008 09:52:17 +0900 Miles Bader wrote: > Stephen Berman writes: >>> To get varying prefixes, you can use the `wrap-prefix' text property. >> >> Yes, I see this when I evaluate e.g. (put-text-property (point) (1+ >> (point)) 'wrap-prefix " ") with the cursor on the first character of >> a wrapped word. Is this the right way to use this text property? > > You can put the property over the entire region of text that the > wrap-prefix applies to; there's no need to know which words will > actually get wrapped. Ah, thank you, that didn't occur to me. [...] > The "right" indendation depends only on the text following the > preceding _hard_ line-start, i.e, the preceding "non-wrap prefix". [...] > The tricky part is getting the wrap-prefix " " by examining the > current non-wrap prefix, " - " in this case. Currently there's no > way of having the display engine do it, so one could alternatively have > a font-lock-like mechanism that turned hard paragraph prefixes into > wrap-prefix text properties. On Fri, 04 Jul 2008 17:25:15 -0400 Stefan Monnier wrote: > I'd expect it to be a job for jit-lock. Thanks to both of you for these suggestions. The following seems to DTRT, at least according to my minimal testing; no doubt it could be improved: (defun srb-adaptive-indent (beg end) "Indent the region between BEG and END with adaptive filling." (goto-char beg) (let ((lbp (line-beginning-position)) (lep (line-end-position))) (put-text-property lbp lep 'wrap-prefix (fill-context-prefix lbp lep))) (while (re-search-forward "\n" (point-max) t) (forward-char) (let ((lbp (line-beginning-position)) (lep (line-end-position))) (put-text-property lbp lep 'wrap-prefix (fill-context-prefix lbp lep))))) (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)) (set-buffer-modified-p mod))))) Miles continued: >> ********* >> I was really hoping you would respond to the display problem at >> window-start. I find it very dissatisfying to regard this as a >> "misfeature" of Emacs redisplay and leave it that, as RMS seemed to >> conclude was the only course to take. > > I haven't been able the reproduce it so far, so I need to try to do so > more thoroughly. I'll try to do so this weekend. Do you use a proportional font? I always used a monospaced font (mostly Dejavu Sans Mono) and with that the recipe I gave is reliable. But I just tried it with a proportional font (Dejavu Sans), and to my surprise my recipe failed, i.e. the indentation remained visible at window-start. No idea why fixed and proportional fonts differ here. Steve Berman