From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: spamfilteraccount@gmail.com Newsgroups: gmane.emacs.help Subject: Re: Monitoring variable changes Date: 9 Oct 2006 23:09:44 -0700 Organization: http://groups.google.com Message-ID: <1160460584.450494.187070@i3g2000cwc.googlegroups.com> References: <1160194109.535613.109730@e3g2000cwe.googlegroups.com> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" X-Trace: sea.gmane.org 1160462667 26271 80.91.229.2 (10 Oct 2006 06:44:27 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 10 Oct 2006 06:44:27 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Oct 10 08:44:24 2006 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1GXBLK-0005o4-Ip for geh-help-gnu-emacs@m.gmane.org; Tue, 10 Oct 2006 08:43:59 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GXBHo-00006u-8a for geh-help-gnu-emacs@m.gmane.org; Tue, 10 Oct 2006 02:40:20 -0400 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!postnews.google.com!i3g2000cwc.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 28 Original-NNTP-Posting-Host: 194.88.55.211 Original-X-Trace: posting.google.com 1160460588 30007 127.0.0.1 (10 Oct 2006 06:09:48 GMT) Original-X-Complaints-To: groups-abuse@google.com Original-NNTP-Posting-Date: Tue, 10 Oct 2006 06:09:48 +0000 (UTC) In-Reply-To: <1160194109.535613.109730@e3g2000cwe.googlegroups.com> User-Agent: G2/1.0 X-HTTP-UserAgent: Opera/9.00 (X11; Linux i686; U; en),gzip(gfe),gzip(gfe) Complaints-To: groups-abuse@google.com Injection-Info: i3g2000cwc.googlegroups.com; posting-host=194.88.55.211; posting-account=b98TkQ0AAAD7PsllN8gfWGRoPOPWdnv4 Original-Xref: shelby.stanford.edu gnu.emacs.help:142334 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:37953 Archived-At: spamfilteraccount@gmail.com wrote: > > Is there a better way to do this than saving the previous value of the > user option and comparing it to the current value every time before I > try to use the preprocessed value? The best solution I could come up with was creating a wrapper function which ensures the cached value is always up-to-date. It does the some kind of preprocessing for different variables. I copy it here for reference: (defun get-cached-value (sourcevar) "Return cached value for the given source variable SOURCEVAR." (let ((cachevar (intern (concat (symbol-name sourcevar) "-cache"))) (prevvar (intern (concat (symbol-name sourcevar) "-prev")))) (unless (and (boundp cachevar) (eq (eval prevvar) (eval sourcevar))) (set cachevar ;; do some caching/preprocessing here ...) (set prevvar (eval sourcevar))) (eval cachevar))) Invocation: (get-cached-value 'varname)