From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Thien-Thi Nguyen Newsgroups: gmane.emacs.help Subject: Re: Can I avoid using `clear-image-cache'? Date: Fri, 06 May 2005 12:35:32 +0200 Organization: sometimes Message-ID: <7ewtqcbq17.fsf@ada2.unipv.it> References: NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1115381888 2046 80.91.229.2 (6 May 2005 12:18:08 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Fri, 6 May 2005 12:18:08 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri May 06 14:18:07 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1DU1ku-0004Yr-7Z for geh-help-gnu-emacs@m.gmane.org; Fri, 06 May 2005 14:16:33 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1DU1ox-000083-5S for geh-help-gnu-emacs@m.gmane.org; Fri, 06 May 2005 08:20:43 -0400 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!canoe.uoregon.edu!hammer.uoregon.edu!logbridge.uoregon.edu!news.tele.dk!news.tele.dk!small.news.tele.dk!news-fra1.dfn.de!news-stu1.dfn.de!news.belwue.de!LF.net!quimby.gnus.org!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 43 Original-NNTP-Posting-Host: ada2.unipv.it Original-X-Trace: quimby.gnus.org 1115375735 19870 193.204.44.145 (6 May 2005 10:35:35 GMT) Original-X-Complaints-To: usenet@quimby.gnus.org Original-NNTP-Posting-Date: Fri, 6 May 2005 10:35:35 +0000 (UTC) User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) Cancel-Lock: sha1:5kcpLA9HWzGrCCqgK7D610BnvC8= Original-Xref: shelby.stanford.edu gnu.emacs.help:130717 Original-To: help-gnu-emacs@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor 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:26370 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:26370 Mathias Dahl writes: > I probably can change the code to work the way > `insert-image-file' does, but I would rather like to, in some > way, be able to flush one particular image from the image cache. > > Can this be done or do I need to write a more advanced piece of code? yes. ;-) > For now I will use `clear-image-cache' although it feels "ugly". i just looked at image.c:1661 (lookup_image), which sez: /* If not found, create a new image and cache it. */ if (img == NULL) probably immediately prior to this block is the best place to add a file timestamp check. that's not as pretty a solution as fully generalizing the check to some kind of `:volatile VOLATILE-SPEC': :volatile VOLATILE-SPEC If VOLATILE-SPEC is t, take extra steps to check for "image change" so that image-cache lookup can DTRT [obviously this documentation can be improved ;-]. If :file is specified, use the timestamp of the file. Otherwise, compute a hash of the data and use that to detect change. VOLATILE-SPEC may also be a function that takes one argument, either the file timestamp or the data (as a string), and returns non-nil to indicate that the image has changed. i was all fired up and ready to do some quick munging and post code (thereby procrastinating on other emacs munging for vms :-), but then i saw how image.c leaves file loading to each image type (not enough abstraction for my tastes) so all the gumption seeped away... perhaps post-release i (or someone else) will do the requisite refactoring so that :volatile or like can be added more easily. thi