From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Grant Rettke Newsgroups: gmane.emacs.help Subject: How to evaluate a function when a defcustom variable is either set or saved? Date: Tue, 14 Jun 2016 20:13:10 -0500 Message-ID: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1465953223 14729 80.91.229.3 (15 Jun 2016 01:13:43 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 15 Jun 2016 01:13:43 +0000 (UTC) To: Emacs Help Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Jun 15 03:13:43 2016 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1bCzOm-0007eQ-1J for geh-help-gnu-emacs@m.gmane.org; Wed, 15 Jun 2016 03:13:40 +0200 Original-Received: from localhost ([::1]:38998 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bCzOk-0007Hy-Kl for geh-help-gnu-emacs@m.gmane.org; Tue, 14 Jun 2016 21:13:38 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:44762) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bCzOM-0007Hi-1J for help-gnu-emacs@gnu.org; Tue, 14 Jun 2016 21:13:15 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bCzOJ-00027T-Rf for help-gnu-emacs@gnu.org; Tue, 14 Jun 2016 21:13:12 -0400 Original-Received: from mail-it0-x230.google.com ([2607:f8b0:4001:c0b::230]:36561) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bCzOJ-00027P-Mt for help-gnu-emacs@gnu.org; Tue, 14 Jun 2016 21:13:11 -0400 Original-Received: by mail-it0-x230.google.com with SMTP id a5so92713469ita.1 for ; Tue, 14 Jun 2016 18:13:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:from:date:message-id:subject:to :content-transfer-encoding; bh=UMR0HaSB3zb8uayjdSW1KcWcQKJaalBidk/PlmQiOIc=; b=W+3iSvzyH6MVZ7NHIc9YZb0oCSYZyW9mVmEeUyBoC8dhlvspmYDHRMMqcbJl24PvfJ /byS6i8dhIgLQ3f/kIXc0IO1b/QQBTr8+WLjdGjkWIWZzylUmkIIlnlbFsbDtWQCLGk6 e4V0GanF7fF6Ut8GUgim9C52jZyfxSIjq7XLusixWHh0weXJd8Sf+P8F52sGrK+SFnkq ThyAJDb4WEkTosvYv0v6hEDSgffvtGQYT45Yqs5PrqnxTcrZJPY6Z3v3e8thtR+Wv8p+ vg6n4Hetz1oLj/c895VCIwDX050TfZJ6RDYY2nC8/P8JFyTYb5qwj1iauAf3lsouN9Xt mS5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:sender:from:date:message-id:subject :to:content-transfer-encoding; bh=UMR0HaSB3zb8uayjdSW1KcWcQKJaalBidk/PlmQiOIc=; b=FHC9qutn9Y8FeerJt4J5mQzV/OVhM8iH/kVueBZ5oGgT9Zzll3ZZjACwuw33jZLFPG PHy2Au94x4jRQBVJ/QzIQvALqMYrgcrUzOVh3nenTSzjJDbmfBbbQg2/VITl3aH5tPtZ JKnWbQVjqGRXznQ8k87foC+2SiYlSzwqL6AYx129LwtPBIOeh7SYlbAhu2fQzgu2mFhd /pC3c4I2feBstZRDsZlzOYPRUJ+O5GIuSf/o60+UCocOGlKPy3qd7lDlyrhFHS86MYKM q/2coWxnZaA1IrxP+oFYE5xlwvCdz7ON/FDW8ryoCGikci0J6y8x52vUEEbnh8fdBaQi BKTA== X-Gm-Message-State: ALyK8tKAAXtSXXLRFJ/b2DT5VCVqwZmfQbp+0ldAv/LSLv4vgG1FtzxgAaH9qoBVfhHJ5kMv85E8+TjBEbPOzQ== X-Received: by 10.36.11.84 with SMTP id 81mr13092679itd.76.1465953191123; Tue, 14 Jun 2016 18:13:11 -0700 (PDT) Original-Received: by 10.79.84.199 with HTTP; Tue, 14 Jun 2016 18:13:10 -0700 (PDT) X-Google-Sender-Auth: EbECmR8D5PvanIzrYb7xUjLI9Iw X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:4001:c0b::230 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.org gmane.emacs.help:110441 Archived-At: Good evening, The Easy Customization user guide [explains that] any changes you make will= =E2=80=9Cnot take effect until you set or save [them]=E2=80=9D. That makes sense. After the set or save occurs, I would like to evaluate a function. The goal= of the function is to calculate some runtime values that need to be re-calcula= ted every time that the variable is changed. The desire to let the users easily explore reconfiguration via the Easy Customize UI and run the configuration= code each time they make a change *without* restarting Emacs. For example, it might look like this (fake on-change property added): =E2=94=8C=E2=94=80=E2=94=80=E2=94=80=E2=94=80 =E2=94=82 (defun on-test-string-change (old new) =E2=94=82 "Testing." =E2=94=82 (message "test-string just changed from %S to %S" old new)) =E2=94=82 =E2=94=82 (defcustom test-string "test" =E2=94=82 "Practice" =E2=94=82 :type 'string =E2=94=82 :group 'test =E2=94=82 :on-change #'on-test-string-change) =E2=94=94=E2=94=80=E2=94=80=E2=94=80=E2=94=80 Suppose the user enters the Easy Customization interface, makes a change, a= nd then saves or sets it; this would appear in the `Messages' buffer: =E2=94=8C=E2=94=80=E2=94=80=E2=94=80=E2=94=80 =E2=94=82 "test-string just changed from \"foo\" to \"bar\"" =E2=94=94=E2=94=80=E2=94=80=E2=94=80=E2=94=80 I read the documentation for Easy Customize and didn=E2=80=99t find anythin= g like this. I read the code for `customize-set-value' and `customize-set-variable' and didn=E2=80=99t find anything like that. I searched for Emacs events that would apply and didn=E2=80=99t find any. T= he buffer local variable and buffer contents after change events jumped out, but aren= =E2=80=99t the right thing for this. Question =E2=80=A2 How would one normally go about doing something like this? =E2=80=A2 Is this a common topic when using the Easy Customization UI? Sincerely, Grant Rettke [explains that] https://www.gnu.org/software/emacs/manual/html_node/emacs/Changing-a-Variab= le.html#Changing-a-Variable