From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: David Kastrup Newsgroups: gmane.emacs.devel Subject: Re: Is there something like `on-display-functions'? Date: Wed, 27 Jan 2010 15:27:16 +0100 Organization: Organization?!? Message-ID: <87hbq7wrln.fsf@lola.goethe.zz> References: <20100127135716.GA3432@muc.de> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1264602705 28991 80.91.229.12 (27 Jan 2010 14:31:45 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 27 Jan 2010 14:31:45 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Jan 27 15:31:38 2010 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 1Na8vh-0003iq-KX for ged-emacs-devel@m.gmane.org; Wed, 27 Jan 2010 15:31:38 +0100 Original-Received: from localhost ([127.0.0.1]:42098 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Na8vi-00032w-ST for ged-emacs-devel@m.gmane.org; Wed, 27 Jan 2010 09:31:38 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Na8rz-0007yM-Bc for emacs-devel@gnu.org; Wed, 27 Jan 2010 09:27:47 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Na8ru-0007qp-9f for emacs-devel@gnu.org; Wed, 27 Jan 2010 09:27:46 -0500 Original-Received: from [199.232.76.173] (port=55641 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Na8ru-0007qc-0n for emacs-devel@gnu.org; Wed, 27 Jan 2010 09:27:42 -0500 Original-Received: from lo.gmane.org ([80.91.229.12]:48013) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1Na8rt-0001T5-FH for emacs-devel@gnu.org; Wed, 27 Jan 2010 09:27:41 -0500 Original-Received: from list by lo.gmane.org with local (Exim 4.50) id 1Na8rp-00022b-Hh for emacs-devel@gnu.org; Wed, 27 Jan 2010 15:27:37 +0100 Original-Received: from p5b2c378b.dip.t-dialin.net ([91.44.55.139]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 27 Jan 2010 15:27:37 +0100 Original-Received: from dak by p5b2c378b.dip.t-dialin.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 27 Jan 2010 15:27:37 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 78 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: p5b2c378b.dip.t-dialin.net X-Face: 2FEFf>]>q>2iw=B6, xrUubRI>pR&Ml9=ao@P@i)L:\urd*t9M~y1^:+Y]'C0~{mAl`oQuAl \!3KEIp?*w`|bL5qr,H)LFO6Q=qx~iH4DN; i"; /yuIsqbLLCh/!U#X[S~(5eZ41to5f%E@'ELIi$t^ Vc\LWP@J5p^rst0+('>Er0=^1{]M9!p?&:\z]|;&=NP3AhB!B_bi^]Pfkw User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.90 (gnu/linux) Cancel-Lock: sha1:dilZ6DGg0bnFnrcGoJslzvG0Llo= X-detected-operating-system: by monty-python.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:120504 Archived-At: Alan Mackenzie writes: > Hi, Emacs, > > Is there some hook called each time something's about to be displayed on > the screen (regardless of whether or not font-lock is enabled)? > > If there is, I could use it to apply the appropriate text properties to > C++ template delimiters as they're about to be displayed, thus > potentially speeding up startup for C++ (and like languages). > > Yes, I've tried searching for it and not found it. (info "(elisp) Other display specs") You can make any display specification conditional. To do that, package it in another list of the form `(when CONDITION . SPEC)'. Then the specification SPEC applies only when CONDITION evaluates to a non-`nil' value. During the evaluation, `object' is bound to the string or buffer having the conditional `display' property. `position' and `buffer-position' are bound to the position within `object' and the buffer position where the `display' property was found, respectively. Both positions can be different when `object' is a string. Since CONDITION gets evaluated, you can use it for pretty much anything you like, even if you decide to let it result in nil always. That's pretty much butt-ugly but works. preview-latex uses this to prioritize its image rendering in order to have on-screen images rendered first. One of the rare cases where XEmacs has a nicer API for some job. This use of the Emacs API can't be called more than a hack. Using the Emacs API, in prv-emacs.el: (defun preview-add-urgentization (fun ov &rest rest) "Cause FUN (function call form) to be called when redisplayed. FUN must be a form with OV as first argument, REST as the remainder, returning T." (let ((dispro (overlay-get ov 'display))) (unless (eq (car dispro) 'when) (overlay-put ov 'display `(when (,fun ,ov ,@rest) . ,dispro))))) (defun preview-remove-urgentization (ov) "Undo urgentization of OV by `preview-add-urgentization'. Returns the old arguments to `preview-add-urgentization' if there was any urgentization." (let ((dispro (overlay-get ov 'display))) (when (eq (car-safe dispro) 'when) (prog1 (car (cdr dispro)) (overlay-put ov 'display (cdr (cdr dispro))))))) Using the XEmacs API, in prv-xemacs.el: (defun preview-add-urgentization (fun ov &rest rest) "Cause FUN (function call form) to be called when redisplayed. FUN must be a form with OV as first argument, REST as the remainder, returning T. An alternative is to give what `preview-remove-urgentization' returns, this will reinstate the previous state." (set-extent-initial-redisplay-function ov (if (null rest) fun `(lambda (ov) (,fun ,ov ,@rest))))) (defun preview-remove-urgentization (ov) "Undo urgentization of OV by `preview-add-urgentization'. Returns the old arguments to `preview-add-urgentization' if there was any urgentization." (prog1 (list (extent-property ov 'initial-redisplay-function) ov) (set-extent-initial-redisplay-function ov nil))) -- David Kastrup