help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [External] : Saving variables for use between emacs sessions


From: uzibalqa
Subject: Re: [External] : Saving variables for use between emacs sessions
Date: Fri, 16 Sep 2022 08:05:03 +0000

------- Original Message -------
On Friday, September 16th, 2022 at 7:30 AM, Jean Louis <bugs@gnu.support> wrote:


> * uzibalqa uzibalqa@proton.me [2022-09-16 05:42]:
> 
> > I do not understand. Once I define a variable with the declaration 
> > "defcustom",
> > how can I make a function change the value?
> 
> 
> Hyperbole link:
> {C-h f defcustom RET}
> 
> where it says:
> 
> This macro calls ‘custom-declare-variable’. If you want to
> programmatically alter a customizable variable (for instance, to
> write a package that extends the syntax of a variable), you can
> call that function directly.
> 
> Hyperbole link:
> 
> {C-h f custom-declare-variable RET}
> 
> (custom-declare-variable SYMBOL DEFAULT DOC &rest ARGS)
> 
> Like ‘defcustom’, but SYMBOL and DEFAULT are evaluated as normal arguments.
> DEFAULT should be an expression to evaluate to compute the default value,
> not the default value itself.
> 
> That way you can programmatically change variables created by
> `defcustom'.

I would need some help with using it, particularly with using SYMBOL, and 
DEFAULT where
the value itself cannot be used.

For instance

(defgroup frame-pos nil

  "Set position of frame."

  :group 'convenience)

(defcustom fxpos 8

  "X position of initial frame."

  :type 'integer

  :group 'frame-pos)

This is the function that should update the value in defcustom 

(defun frame-shift (frame)

  (let* ( (lft (car (frame-position)))

          (wdt (frame-outer-width frame))

          (nlft (+ lft (/ wdt 2))) )

    (set-frame-position frame nlft ntop)

    (custom-declare-variable 'typex-fxpos nlft)) )






reply via email to

[Prev in Thread] Current Thread [Next in Thread]