unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: spamfilteraccount@gmail.com
Subject: Re: Monitoring variable changes
Date: 9 Oct 2006 23:09:44 -0700	[thread overview]
Message-ID: <1160460584.450494.187070@i3g2000cwc.googlegroups.com> (raw)
In-Reply-To: <1160194109.535613.109730@e3g2000cwe.googlegroups.com>


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)

      reply	other threads:[~2006-10-10  6:09 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-10-07  4:08 Monitoring variable changes spamfilteraccount
2006-10-10  6:09 ` spamfilteraccount [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1160460584.450494.187070@i3g2000cwc.googlegroups.com \
    --to=spamfilteraccount@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).