From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Omar Polo Newsgroups: gmane.emacs.help Subject: Re: Elisp - Store path only once Date: Sat, 09 Jan 2021 12:53:11 +0100 Message-ID: References: <87a6tie5yv.fsf@omarpolo.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="20606"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: K-9 Mail for Android Cc: help-gnu-emacs@gnu.org To: wael-zwaiter@gmx.com Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Sat Jan 09 12:54:00 2021 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kyCoi-0005Gg-6Q for geh-help-gnu-emacs@m.gmane-mx.org; Sat, 09 Jan 2021 12:54:00 +0100 Original-Received: from localhost ([::1]:38614 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kyCoh-0001NR-8e for geh-help-gnu-emacs@m.gmane-mx.org; Sat, 09 Jan 2021 06:53:59 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:43102) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kyCoA-0001NK-7I for help-gnu-emacs@gnu.org; Sat, 09 Jan 2021 06:53:26 -0500 Original-Received: from mail.omarpolo.com ([144.91.116.244]:64177) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kyCo7-0007rj-FY for help-gnu-emacs@gnu.org; Sat, 09 Jan 2021 06:53:25 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=omarpolo.com; s=20200327; t=1610193193; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=O4rJCxXxDttcbgVIngR/mZnjvcD4V8tB7SpkCdThj3c=; b=u1kugf+sR45wp8v2hYqj+r0wZIIzv1xhHbcHinZXevJUm/NGVKufXqejcMeV/mdMuUp6rf p5WmDeTYr0u6/ZAYyVtJAfrCZ2SHSqzVob4ukbyQZwjKZ/Ms54/kyZ+beKoD4iIZw7Hyhz KFjNaAqlLu2VV7jBnG6NTHQDiD39FbE= Original-Received: from MIMAX2-MiPhone.homenet.telecomitalia.it (host-80-116-112-105.pool80116.interbusiness.it [80.116.112.105]) by mail.omarpolo.com (OpenSMTPD) with ESMTPSA id d6d583b1 (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256:NO); Sat, 9 Jan 2021 12:53:13 +0100 (CET) In-Reply-To: Received-SPF: pass client-ip=144.91.116.244; envelope-from=op@omarpolo.com; helo=mail.omarpolo.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.23 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-mx.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.io gmane.emacs.help:127126 Archived-At: On 9 January 2021 12:30:57 CET, wael-zwaiter@gmx=2Ecom wrote: >Am unsure whether I can require on the elisp files I have written=2E > >(require 'g-eshell) >(require 'g-utils) > >Aw getting confused, as I was simply doing > >(setq g-eshell > "/home/bard/Genadm/build/gadin-1=2E0/elisp/g-eshell=2Eel") > >(setq g-utils > "/home/bard/Genadm/build/gadin-1=2E0/elisp/g-utils=2Eel") > >(load 'g-eshell) >(load 'g-utils) > >> Sent: Saturday, January 09, 2021 at 10:54 PM >> From: "Omar Polo" >> To: wael-zwaiter@gmx=2Ecom >> Cc: help-gnu-emacs@gnu=2Eorg >> Subject: Re: Elisp - Store path only once >> >> >> wael-zwaiter@gmx=2Ecom writes: >> >> > I have a lot of customisation files for emacs stored in the >> > directory /home/bard/Genadm/build/gadin-1=2E0/elisp/=2E >> > >> > Would like to store the path so that I can define it only once=2E >> > How can I do this in Emacs Lisp=2E >> > >> > >> > (setq g-eshell >> > "/home/bard/Genadm/build/gadin-1=2E0/elisp/g-eshell=2Eel") >> > >> > (setq g-utils >> > "/home/bard/Genadm/build/gadin-1=2E0/elisp/g-utils=2Eel") >> >> Couldn't you just >> >> (add-to-list 'load-path >"/home/bard/Genadm/build/gadin-1=2E0/elisp") >> >> and then >> >> (require 'g-eshell) >> (require 'g-utils) >> >> when needed? >> >> you should definitely check the manual for more detailed information, but = the gist of it is that when you (require 'something) emacs will search for something=2Eel in all the directories listed in load= -path=2E This is like the UNIX $PATH variable if you're familiar, only for= elisp files instead=2E Now, you can require any file, given that they contains a provide at the b= ottom=2E i=2Ee=2E your g-eshell=2Eel should ends with (provide 'g-shell) this way you can avoid typing the full path every time, and is also easier= to move those files without braking you configuration=2E (Also, require is better than load because it won't evaluate the same file= two times) --=20 Sent from my Android device with K-9 Mail=2E Please excuse my brevity=2E