unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Define const variable if not available
@ 2025-01-05  9:43 Heime via Users list for the GNU Emacs text editor
  2025-01-19 11:00 ` Joel Reicher
  0 siblings, 1 reply; 7+ messages in thread
From: Heime via Users list for the GNU Emacs text editor @ 2025-01-05  9:43 UTC (permalink / raw)
  To: Heime via Users list for the GNU Emacs text editor

I have a series of elisp files that define some variables.
But if some variable has not been defined in some other file,
the variable has to be defined in the file.  How can I do it?

;; ----------------------------------------------------

;; File kasrgira.el

(defconst groovador-waypt
  (concat orellana-waypt "/groovador")

  "Directory path to the Groovador component.")

;; ----------------------------------------------------

;; File kalimpong.el

;; if groovador-waypt does not exist, define it here 

;; ----------------------------------------------------




^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Define const variable if not available
  2025-01-05  9:43 Define const variable if not available Heime via Users list for the GNU Emacs text editor
@ 2025-01-19 11:00 ` Joel Reicher
  2025-01-19 11:09   ` Basile Starynkevitch
  2025-01-19 21:38   ` Heime via Users list for the GNU Emacs text editor
  0 siblings, 2 replies; 7+ messages in thread
From: Joel Reicher @ 2025-01-19 11:00 UTC (permalink / raw)
  To: Heime via Users list for the GNU Emacs text editor; +Cc: Heime

Heime via Users list for the GNU Emacs text editor 
<help-gnu-emacs@gnu.org> writes:

> I have a series of elisp files that define some variables.  But 
> if some variable has not been defined in some other file, the 
> variable has to be defined in the file.  How can I do it?

Do you mean how do you figure out if your code has already defined 
something so just in case it hasn't some other code you also wrote 
can do it?

Regards,

        - Joel



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Define const variable if not available
  2025-01-19 11:00 ` Joel Reicher
@ 2025-01-19 11:09   ` Basile Starynkevitch
  2025-01-19 21:38   ` Heime via Users list for the GNU Emacs text editor
  1 sibling, 0 replies; 7+ messages in thread
From: Basile Starynkevitch @ 2025-01-19 11:09 UTC (permalink / raw)
  To: Joel Reicher, Heime via Users list for the GNU Emacs text editor; +Cc: Heime

On Sun, 2025-01-19 at 22:00 +1100, Joel Reicher wrote:
> Heime via Users list for the GNU Emacs text editor 
> <help-gnu-emacs@gnu.org> writes:
> 
> > I have a series of elisp files that define some variables.  But 
> > if some variable has not been defined in some other file, the 
> > variable has to be defined in the file.  How can I do it?
> 
> Do you mean how do you figure out if your code has already defined 
> something so just in case it hasn't some other code you also wrote 
> can do it?
> 
> Regards,
> 
>         - Joel
> 


From what I understand, you want to use the boundp function in your Elisp code.


NB my open source project is https://github.com/RefPerSys/RefPerSys/

-- 
Basile STARYNKEVITCH           <basile@starynkevitch.net>
8 rue de la Faïencerie
92340 Bourg-la-Reine,          France
http://starynkevitch.net/Basile & https://github.com/bstarynk 




^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Define const variable if not available
  2025-01-19 11:00 ` Joel Reicher
  2025-01-19 11:09   ` Basile Starynkevitch
@ 2025-01-19 21:38   ` Heime via Users list for the GNU Emacs text editor
  2025-01-19 23:32     ` Joel Reicher
  1 sibling, 1 reply; 7+ messages in thread
From: Heime via Users list for the GNU Emacs text editor @ 2025-01-19 21:38 UTC (permalink / raw)
  To: Joel Reicher; +Cc: Heime via Users list for the GNU Emacs text editor






Sent with Proton Mail secure email.

On Sunday, January 19th, 2025 at 11:00 PM, Joel Reicher <joel.reicher@gmail.com> wrote:

> Heime via Users list for the GNU Emacs text editor
> help-gnu-emacs@gnu.org writes:
> 
> > I have a series of elisp files that define some variables. But
> > if some variable has not been defined in some other file, the
> > variable has to be defined in the file. How can I do it?
> 
> 
> Do you mean how do you figure out if your code has already defined
> something so just in case it hasn't some other code you also wrote
> can do it?
> 
> Regards, - Joel


I have this variable that depends upon the value of amazones-waypt.
But if I do not include the file where amazones-waypt is defined,
I want to set amazones-waypt to some value in the falkotr.el file.

;;;  falkotr.el

(defvar falkotr-waypt
  (concat amazones-waypt "/falkotr")

  "Path to falkotr packages.")




^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Define const variable if not available
  2025-01-19 21:38   ` Heime via Users list for the GNU Emacs text editor
@ 2025-01-19 23:32     ` Joel Reicher
  2025-01-19 23:39       ` Heime via Users list for the GNU Emacs text editor
  0 siblings, 1 reply; 7+ messages in thread
From: Joel Reicher @ 2025-01-19 23:32 UTC (permalink / raw)
  To: Heime; +Cc: Heime via Users list for the GNU Emacs text editor

Heime <heimeborgia@protonmail.com> writes:

> On Sunday, January 19th, 2025 at 11:00 PM, Joel Reicher 
> <joel.reicher@gmail.com> wrote:
>
>> Heime via Users list for the GNU Emacs text editor 
>> help-gnu-emacs@gnu.org writes:
>>
>>> I have a series of elisp files that define some variables. But 
>>> if some variable has not been defined in some other file, the 
>>> variable has to be defined in the file. How can I do it?
>>
>> Do you mean how do you figure out if your code has already 
>> defined something so just in case it hasn't some other code you 
>> also wrote can do it?
>
> I have this variable that depends upon the value of 
> amazones-waypt.  But if I do not include the file where 
> amazones-waypt is defined, I want to set amazones-waypt to some 
> value in the falkotr.el file.

Why not just include the file?

Regards,

        - Joel



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Define const variable if not available
  2025-01-19 23:32     ` Joel Reicher
@ 2025-01-19 23:39       ` Heime via Users list for the GNU Emacs text editor
  2025-01-20 17:39         ` Jean Louis
  0 siblings, 1 reply; 7+ messages in thread
From: Heime via Users list for the GNU Emacs text editor @ 2025-01-19 23:39 UTC (permalink / raw)
  To: Joel Reicher; +Cc: Heime via Users list for the GNU Emacs text editor






Sent with Proton Mail secure email.

On Monday, January 20th, 2025 at 11:32 AM, Joel Reicher <joel.reicher@gmail.com> wrote:

> Heime heimeborgia@protonmail.com writes:
> 
> > On Sunday, January 19th, 2025 at 11:00 PM, Joel Reicher
> > joel.reicher@gmail.com wrote:
> > 
> > > Heime via Users list for the GNU Emacs text editor
> > > help-gnu-emacs@gnu.org writes:
> > > 
> > > > I have a series of elisp files that define some variables. But
> > > > if some variable has not been defined in some other file, the
> > > > variable has to be defined in the file. How can I do it?
> > > 
> > > Do you mean how do you figure out if your code has already
> > > defined something so just in case it hasn't some other code you
> > > also wrote can do it?
> > 
> > I have this variable that depends upon the value of
> > amazones-waypt. But if I do not include the file where
> > amazones-waypt is defined, I want to set amazones-waypt to some
> > value in the falkotr.el file.
> 
> 
> Why not just include the file?
> 
> Regards, - Joel

I do include it.  Bun if someone want to include part of the functionality
without requiring the rest, I do not want the code to break. 




^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Define const variable if not available
  2025-01-19 23:39       ` Heime via Users list for the GNU Emacs text editor
@ 2025-01-20 17:39         ` Jean Louis
  0 siblings, 0 replies; 7+ messages in thread
From: Jean Louis @ 2025-01-20 17:39 UTC (permalink / raw)
  To: Heime; +Cc: help-gnu-emacs

* Heime via Users list for the GNU Emacs text editor <help-gnu-emacs@gnu.org> [2025-01-20 02:41]:
> I do include it.  Bun if someone want to include part of the functionality
> without requiring the rest, I do not want the code to break. 

If you wish single package to have some otherwise elsewhere defined
variable, just define it again in that single package.

Code will not break if you provide full code.

I have some very global variables and so I place them in the global
package used by all other packages.

Then you distribute 2 packages and other one loads the first one.

But if you wish to ensure single file and single package has that
variable then define it inside.

-- 
Jean Louis



^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2025-01-20 17:39 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-05  9:43 Define const variable if not available Heime via Users list for the GNU Emacs text editor
2025-01-19 11:00 ` Joel Reicher
2025-01-19 11:09   ` Basile Starynkevitch
2025-01-19 21:38   ` Heime via Users list for the GNU Emacs text editor
2025-01-19 23:32     ` Joel Reicher
2025-01-19 23:39       ` Heime via Users list for the GNU Emacs text editor
2025-01-20 17:39         ` Jean Louis

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).