From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Oliver Scholz Newsgroups: gmane.emacs.help Subject: Re: Indenting Emacs Lisp only with tabs? Date: Fri, 04 Sep 2009 07:51:45 +0200 Organization: Arcor Message-ID: <4aa0aaf3$0$32669$9b4e6d93@newsspool2.arcor-online.net> References: <01128ee8-a5d2-4cd6-bdb3-4e8067a2b61f@y36g2000yqh.googlegroups.com> <2911e90a-05ec-43d3-b7d7-9aacbed7dbce@x37g2000yqj.googlegroups.com> <4a9ea93d$0$31877$9b4e6d93@newsspool3.arcor-online.net> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1252061484 5526 80.91.229.12 (4 Sep 2009 10:51:24 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 4 Sep 2009 10:51:24 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Sep 04 12:51:17 2009 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1MjWNw-0002W8-PK for geh-help-gnu-emacs@m.gmane.org; Fri, 04 Sep 2009 12:51:17 +0200 Original-Received: from localhost ([127.0.0.1]:39361 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MjWNv-0001Oe-Ku for geh-help-gnu-emacs@m.gmane.org; Fri, 04 Sep 2009 06:51:15 -0400 Original-Path: news.stanford.edu!usenet.stanford.edu!news.tele.dk!news.tele.dk!small.news.tele.dk!npeer.de.kpn-eurorings.net!npeer-ng0.de.kpn-eurorings.net!newsfeed.arcor.de!newsspool2.arcor-online.net!news.arcor.de.POSTED!not-for-mail Original-Newsgroups: gnu.emacs.help User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Original-Lines: 59 Original-NNTP-Posting-Date: 04 Sep 2009 07:51:47 CEST Original-NNTP-Posting-Host: d17dc399.newsspool2.arcor-online.net Original-X-Trace: DXC=G?R]AEf3BPd]l@YUW5NBknA9EHlD; 3Ycb4Fo<]lROoRa^YC2XCjHcbiGG>E7THD0 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:67858 Archived-At: Following up on myself ... I don't follow the discussion on 'elastic tabstops'. Whatever makes one happy, I guess. However with regard to using proportional fonts for programming modes in Emacs, I wrote: [...] > I actually thought about this some time ago. I believe it would be > possible, not really complicated even, to fix this. Emacs could simply > put a display property with the value > > `(space :align-to ) > > on the leading space or tab characters on each line. And there you go: > proportional fonts with flawless indentation. > > The only complication would be that font-lock does not naturally handle > the `display' property; but if my memory serves well, all the necessary > mechanics are in place and this would only be a minor obstacle. The proof-of-concept turns out to be quite trivial. I am putting it here, in case anybody actually wants to play with it. The following assumes that indentation consists only of space characters. (defconst propindent-font-lock-keywords `(("^ +" (0 (progn (propindent-fix-whitespace (match-beginning 0) (match-end 0)) nil))))) (defun propindent-fix-whitespace (from to) (put-text-property from to 'display `(space :align-to ,(- to from)))) (defun propindent-spice-up-font-lock () (add-to-list 'font-lock-extra-managed-props 'display) (font-lock-add-keywords nil propindent-font-lock-keywords)) One Problem is, that this fixes indentation only relative to the *beginning* of the previous line. So, if you have for instance a typical `let' expression in Lisp, the clauses starting from the second one would be lined up vertically, but the first one on line with the "let" would not. To fix this, the function would have to check for the pixel position of the corresponding character on the previous line and fix the visible indentation accordingly. It seems that the :align-to property may take a pixel value; unfortunately I am not aware of any way to check for the pixel position of a character position in a window. There are drawbacks, anyways: since proportional fonts in general take considerably less horizontal space, fixing this would actually reduce visible indentation. Oliver -- 18 Fructidor an 217 de la Révolution Liberté, Egalité, Fraternité!