* Saving variables for use between emacs sessions
@ 2022-09-15 10:54 uzibalqa
2022-09-15 11:46 ` [External] : " Drew Adams
0 siblings, 1 reply; 12+ messages in thread
From: uzibalqa @ 2022-09-15 10:54 UTC (permalink / raw)
To: uzibalqa via Users list for the GNU Emacs text editor
How can I save variable that can be reused between emacs sessions?
^ permalink raw reply [flat|nested] 12+ messages in thread
* RE: [External] : Saving variables for use between emacs sessions
2022-09-15 10:54 Saving variables for use between emacs sessions uzibalqa
@ 2022-09-15 11:46 ` Drew Adams
2022-09-15 12:49 ` Robert Pluim
0 siblings, 1 reply; 12+ messages in thread
From: Drew Adams @ 2022-09-15 11:46 UTC (permalink / raw)
To: uzibalqa, uzibalqa via Users list for the GNU Emacs text editor
> How can I save variable that can be reused between emacs sessions?
Lots of ways. Some:
1. savehist.el
2. desktop.el
3. Bookmark+ bookmark variable-list bookmark
https://www.emacswiki.org/emacs/BookmarkPlus#FunctionSequenceVarlistBookmarks
4. If it's a user option (defcustom), then in your `custom-file' (or init file).
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [External] : Saving variables for use between emacs sessions
2022-09-15 11:46 ` [External] : " Drew Adams
@ 2022-09-15 12:49 ` Robert Pluim
2022-09-15 13:26 ` Marcin Borkowski
0 siblings, 1 reply; 12+ messages in thread
From: Robert Pluim @ 2022-09-15 12:49 UTC (permalink / raw)
To: Drew Adams
Cc: uzibalqa, uzibalqa via Users list for the GNU Emacs text editor
>>>>> On Thu, 15 Sep 2022 11:46:57 +0000, Drew Adams <drew.adams@oracle.com> said:
>> How can I save variable that can be reused between emacs sessions?
Drew> Lots of ways. Some:
Drew> 1. savehist.el
Drew> 2. desktop.el
Drew> 3. Bookmark+ bookmark variable-list bookmark
Drew> https://www.emacswiki.org/emacs/BookmarkPlus#FunctionSequenceVarlistBookmarks
Drew> 4. If it's a user option (defcustom), then in your `custom-file' (or init file).
And in emacs-29, `define-multisession-variable', although thatʼs
intended more for packages than user config.
Robert
--
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [External] : Saving variables for use between emacs sessions
2022-09-15 12:49 ` Robert Pluim
@ 2022-09-15 13:26 ` Marcin Borkowski
2022-09-15 14:57 ` Drew Adams
2022-09-15 16:51 ` uzibalqa
0 siblings, 2 replies; 12+ messages in thread
From: Marcin Borkowski @ 2022-09-15 13:26 UTC (permalink / raw)
To: Robert Pluim
Cc: Drew Adams, uzibalqa,
uzibalqa via Users list for the GNU Emacs text editor
On 2022-09-15, at 14:49, Robert Pluim <rpluim@gmail.com> wrote:
>>>>>> On Thu, 15 Sep 2022 11:46:57 +0000, Drew Adams <drew.adams@oracle.com> said:
>
> >> How can I save variable that can be reused between emacs sessions?
> Drew> Lots of ways. Some:
>
> Drew> 1. savehist.el
> Drew> 2. desktop.el
> Drew> 3. Bookmark+ bookmark variable-list bookmark
>
> Drew> https://www.emacswiki.org/emacs/BookmarkPlus#FunctionSequenceVarlistBookmarks
>
> Drew> 4. If it's a user option (defcustom), then in your `custom-file' (or init file).
>
> And in emacs-29, `define-multisession-variable', although thatʼs
> intended more for packages than user config.
Also, the `persist' package.
--
Marcin Borkowski
http://mbork.pl
^ permalink raw reply [flat|nested] 12+ messages in thread
* RE: [External] : Saving variables for use between emacs sessions
2022-09-15 13:26 ` Marcin Borkowski
@ 2022-09-15 14:57 ` Drew Adams
2022-09-15 16:51 ` uzibalqa
1 sibling, 0 replies; 12+ messages in thread
From: Drew Adams @ 2022-09-15 14:57 UTC (permalink / raw)
To: Marcin Borkowski, Robert Pluim
Cc: uzibalqa, uzibalqa via Users list for the GNU Emacs text editor
And of course there's just writing one or more
variable values to a separate file, on your own.
As I said, there are _lots_ of ways to save var
values persistently.
OP's request was far too vague. "How can I save
a value?" is about as unspecific as it gets...
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [External] : Saving variables for use between emacs sessions
2022-09-15 13:26 ` Marcin Borkowski
2022-09-15 14:57 ` Drew Adams
@ 2022-09-15 16:51 ` uzibalqa
2022-09-15 17:23 ` Drew Adams
1 sibling, 1 reply; 12+ messages in thread
From: uzibalqa @ 2022-09-15 16:51 UTC (permalink / raw)
To: Marcin Borkowski
Cc: Robert Pluim, Drew Adams,
uzibalqa via Users list for the GNU Emacs text editor
Sent with Proton Mail secure email.
------- Original Message -------
On Thursday, September 15th, 2022 at 1:26 PM, Marcin Borkowski <mbork@mbork.pl> wrote:
> On 2022-09-15, at 14:49, Robert Pluim rpluim@gmail.com wrote:
>
> > > > > > > On Thu, 15 Sep 2022 11:46:57 +0000, Drew Adams drew.adams@oracle.com said:
> >
> > >> How can I save variable that can be reused between emacs sessions?
> > Drew> Lots of ways. Some:
> >
> > Drew> 1. savehist.el
> > Drew> 2. desktop.el
> > Drew> 3. Bookmark+ bookmark variable-list bookmark
> >
> > Drew> https://www.emacswiki.org/emacs/BookmarkPlus#FunctionSequenceVarlistBookmarks
> >
> > Drew> 4. If it's a user option (defcustom), then in your `custom-file' (or init file).
> >
> > And in emacs-29, `define-multisession-variable', although thatʼs
> > intended more for packages than user config.
>
>
> Also, the `persist' package.
Right, I want to have a user option, but although I want to allow a user to set the value,
I also would like to set a value in an automatic way, using a function that does the
necessary calculations, and stares the answer in the variable.
How does one let a user change a value, and how can I save it automatically as well?
^ permalink raw reply [flat|nested] 12+ messages in thread
* RE: [External] : Saving variables for use between emacs sessions
2022-09-15 16:51 ` uzibalqa
@ 2022-09-15 17:23 ` Drew Adams
2022-09-16 0:56 ` uzibalqa
0 siblings, 1 reply; 12+ messages in thread
From: Drew Adams @ 2022-09-15 17:23 UTC (permalink / raw)
To: uzibalqa, Marcin Borkowski
Cc: Robert Pluim,
uzibalqa via Users list for the GNU Emacs text editor
> Right, I want to have a user option, but although I want to allow a user
> to set the value,
> I also would like to set a value in an automatic way, using a function
> that does the
> necessary calculations, and stares the answer in the variable.
>
> How does one let a user change a value, and how can I save it
> automatically as well?
Just define the option with defcustom.
Users can use Customize to change the
value and save that new setting to their
`custom-file' or init file.
Or they can use `custom*' functions to
set and to save. Or you can use such
functions to do that for them "in an
automatic way".
Just look into what's available - it's
all there. You, yourself, can easily
check it out.
^ permalink raw reply [flat|nested] 12+ messages in thread
* RE: [External] : Saving variables for use between emacs sessions
2022-09-15 17:23 ` Drew Adams
@ 2022-09-16 0:56 ` uzibalqa
2022-09-16 2:19 ` Drew Adams
0 siblings, 1 reply; 12+ messages in thread
From: uzibalqa @ 2022-09-16 0:56 UTC (permalink / raw)
To: Drew Adams
Cc: Marcin Borkowski, Robert Pluim,
uzibalqa via Users list for the GNU Emacs text editor
------- Original Message -------
On Thursday, September 15th, 2022 at 5:23 PM, Drew Adams <drew.adams@oracle.com> wrote:
> > Right, I want to have a user option, but although I want to allow a user
> > to set the value,
> > I also would like to set a value in an automatic way, using a function
> > that does the
> > necessary calculations, and stares the answer in the variable.
> >
> > How does one let a user change a value, and how can I save it
> > automatically as well?
>
>
> Just define the option with defcustom.
>
> Users can use Customize to change the
> value and save that new setting to their
> `custom-file' or init file. Or they can use` custom*' functions to
> set and to save. Or you can use such
> functions to do that for them "in an
> automatic way".
>
> Just look into what's available - it's
> all there. You, yourself, can easily
> check it out.
I have coded as follows
(defgroup tpframe-pos nil
"Set position of frame."
:group 'convenience)
(defcustom tpfxpos 8
"X position of initial frame."
:group 'tpframe-pos
:type 'integer)
(defcustom tpfypos 8
"Y position of initial frame."
:group 'tpframe-pos
:type 'integer)
Then I have a function that changes the values with
(setq tpfxpos nlft) and (setq tpfypos ntop)
The difficulty that that after I run another the command emacs again in from terminal,
the values updated by the function are not reflected in `M-x customize-group`.
^ permalink raw reply [flat|nested] 12+ messages in thread
* RE: [External] : Saving variables for use between emacs sessions
2022-09-16 0:56 ` uzibalqa
@ 2022-09-16 2:19 ` Drew Adams
2022-09-16 2:40 ` uzibalqa
0 siblings, 1 reply; 12+ messages in thread
From: Drew Adams @ 2022-09-16 2:19 UTC (permalink / raw)
To: uzibalqa
Cc: Marcin Borkowski, Robert Pluim,
uzibalqa via Users list for the GNU Emacs text editor
> > Just define the option with defcustom.
> >
> > Users can use Customize to change the
> > value and save that new setting to their
> > `custom-file' or init file. Or they can use` custom*' functions to
> > set and to save. Or you can use such
> > functions to do that for them "in an
> > automatic way".
> >
> > Just look into what's available - it's
> > all there. You, yourself, can easily
> > check it out.
>
> I have coded as follows
> (defgroup tpframe-pos nil
> "Set position of frame."
> :group 'convenience)
> (defcustom tpfxpos 8
> "X position of initial frame."
> :group 'tpframe-pos :type 'integer)
> (defcustom tpfypos 8
> "Y position of initial frame."
> :group 'tpframe-pos :type 'integer)
>
> Then I have a function that changes the values with
> (setq tpfxpos nlft) and (setq tpfypos ntop)
What part of this:
> > use `custom*' functions to set and to save.
^^^^^^^^^ ^^^^
did you not understand? Or did you just ignore
it all?
Do you think `setq' is a `custom*' function?
Do you think it saves the variable value
persistently?
^ permalink raw reply [flat|nested] 12+ messages in thread
* RE: [External] : Saving variables for use between emacs sessions
2022-09-16 2:19 ` Drew Adams
@ 2022-09-16 2:40 ` uzibalqa
2022-09-16 7:30 ` Jean Louis
0 siblings, 1 reply; 12+ messages in thread
From: uzibalqa @ 2022-09-16 2:40 UTC (permalink / raw)
To: Drew Adams
Cc: Marcin Borkowski, Robert Pluim,
uzibalqa via Users list for the GNU Emacs text editor
------- Original Message -------
On Friday, September 16th, 2022 at 2:19 AM, Drew Adams <drew.adams@oracle.com> wrote:
> > > Just define the option with defcustom.
> > >
> > > Users can use Customize to change the
> > > value and save that new setting to their
> > > `custom-file' or init file. Or they can use` custom*' functions to
> > > set and to save. Or you can use such
> > > functions to do that for them "in an
> > > automatic way".
> > >
> > > Just look into what's available - it's
> > > all there. You, yourself, can easily
> > > check it out.
> >
> > I have coded as follows
> > (defgroup tpframe-pos nil
> > "Set position of frame."
> > :group 'convenience)
> > (defcustom tpfxpos 8
> > "X position of initial frame."
> > :group 'tpframe-pos :type 'integer)
> > (defcustom tpfypos 8
> > "Y position of initial frame."
> > :group 'tpframe-pos :type 'integer)
> >
> > Then I have a function that changes the values with
> > (setq tpfxpos nlft) and (setq tpfypos ntop)
>
>
> What part of this:
>
> > > use `custom*' functions to set and to save.
>
> ^^^^^^^^^ ^^^^
>
> did you not understand? Or did you just ignore
> it all?
>
> Do you think `setq' is a` custom*' function?
> Do you think it saves the variable value
> persistently?
I do not understand. Once I define a variable with the declaration "defcustom",
how can I make a function change the value?
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [External] : Saving variables for use between emacs sessions
2022-09-16 2:40 ` uzibalqa
@ 2022-09-16 7:30 ` Jean Louis
2022-09-16 8:05 ` uzibalqa
0 siblings, 1 reply; 12+ messages in thread
From: Jean Louis @ 2022-09-16 7:30 UTC (permalink / raw)
To: uzibalqa
Cc: Drew Adams, Marcin Borkowski, Robert Pluim,
uzibalqa via Users list for the GNU Emacs text editor
* 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'.
--
Jean
Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns
In support of Richard M. Stallman
https://stallmansupport.org/
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [External] : Saving variables for use between emacs sessions
2022-09-16 7:30 ` Jean Louis
@ 2022-09-16 8:05 ` uzibalqa
0 siblings, 0 replies; 12+ messages in thread
From: uzibalqa @ 2022-09-16 8:05 UTC (permalink / raw)
To: Jean Louis
Cc: Drew Adams, Marcin Borkowski, Robert Pluim,
uzibalqa via Users list for the GNU Emacs text editor
------- 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)) )
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2022-09-16 8:05 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-09-15 10:54 Saving variables for use between emacs sessions uzibalqa
2022-09-15 11:46 ` [External] : " Drew Adams
2022-09-15 12:49 ` Robert Pluim
2022-09-15 13:26 ` Marcin Borkowski
2022-09-15 14:57 ` Drew Adams
2022-09-15 16:51 ` uzibalqa
2022-09-15 17:23 ` Drew Adams
2022-09-16 0:56 ` uzibalqa
2022-09-16 2:19 ` Drew Adams
2022-09-16 2:40 ` uzibalqa
2022-09-16 7:30 ` Jean Louis
2022-09-16 8:05 ` uzibalqa
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.