From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: John W Higgins Newsgroups: gmane.emacs.help Subject: Re: emacs configuration Date: Thu, 30 Sep 2021 09:38:25 -0700 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="37108"; mail-complaints-to="usenet@ciao.gmane.io" To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Thu Sep 30 19:34:26 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 1mVzwu-0009Ro-HY for geh-help-gnu-emacs@m.gmane-mx.org; Thu, 30 Sep 2021 19:34:24 +0200 Original-Received: from localhost ([::1]:37452 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mVzws-0007Mh-QW for geh-help-gnu-emacs@m.gmane-mx.org; Thu, 30 Sep 2021 13:34:22 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:54288) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mVz4y-0000T8-Vw for help-gnu-emacs@gnu.org; Thu, 30 Sep 2021 12:38:41 -0400 Original-Received: from mail-ot1-x331.google.com ([2607:f8b0:4864:20::331]:43625) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mVz4x-0007nw-4y for help-gnu-emacs@gnu.org; Thu, 30 Sep 2021 12:38:40 -0400 Original-Received: by mail-ot1-x331.google.com with SMTP id x33-20020a9d37a4000000b0054733a85462so8050652otb.10 for ; Thu, 30 Sep 2021 09:38:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=3W7ITev4F1J0C9CFqH5oRiZzdwSwUKmH0nsvf0XB5Ns=; b=qkX3SyMuEB+N5mBHZ7KNu3ONnYBtP/uyGHCSrVbj3gPDYKciaZMhGughHNf7Tt+z2L S9IxdmSJrpkXELTpBpTG+lvNs9ZWErKrH9BEhRv+y/P6wkAIaftR9bAKBUi5tpVc4XQk y4JDteskNVto1UMo4tvTzomYNXXCYUn2/zF3D+angxfZAhk2ahpY0+sia2ROFwzDepCJ sLGHIrC3M47iE5h+06LpjNuIn6u3hdDmZBPuH81rEtWoiKXZyB387wg6ikhY5dxClVXk cLYJ6GF6HZnBPOT7jm3Snsy3s+pITabnwyuC843dkCpk9gD86dT943n4v/4CJ1jgL9Lv GU5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=3W7ITev4F1J0C9CFqH5oRiZzdwSwUKmH0nsvf0XB5Ns=; b=w1FvMUCb/KSBXdblpzLJqmoCgWXvFiWsMpoU+5/IQylIayoJGgX+q4QODF1veZ0XId NilJriFY1YHnJRIlXEh5URnwwAYjJ/tnH5kbNX2kXWfLJkhGiwZdRLg3Otre3m8RbNPI aXr+4orJNhcKbZCnqOiOclbpISR52PgsKms2opZ9WtsG9HRn1wRMR7zcR+SBDqDwuQjI aRlenbNqDGGwXUSw/MUy0p5FjBOzSiOb16qoxz2weOcCKD36GUMGsF4TXqBfemD3fOhU RfkcRtOHKd7Fv5OlrNV50zLiS0XTzsP3lF28xn+tsZBtDWXmLHqy9Zj13RhsTnwS461o +INw== X-Gm-Message-State: AOAM531DSFoJIKY90kTebpgVnENlpZMwSJfcSfJPyn6nhrqC2QZZaXdh 1O8qfJhL4jh2X7UYGNWKqsukGaUt0vlsWo2XJRiGu6w+FyE= X-Google-Smtp-Source: ABdhPJwUIdtKbKhKeSq9zQssFfS9pHR1bfF+jUrm7JqEHnLYUfl0MPtbT69YFqXJCpyHFhryw2eLk9iBDblc6GqZVtc= X-Received: by 2002:a05:6830:4189:: with SMTP id r9mr6125241otu.315.1633019916769; Thu, 30 Sep 2021 09:38:36 -0700 (PDT) In-Reply-To: Received-SPF: pass client-ip=2607:f8b0:4864:20::331; envelope-from=wishdev@gmail.com; helo=mail-ot1-x331.google.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, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Thu, 30 Sep 2021 13:33:23 -0400 X-Content-Filtered-By: Mailman/MimeDel 2.1.23 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:133456 Archived-At: Good Morning, On Thu, Sep 30, 2021 at 8:44 AM Jude DaShiell wrote: > Has emacs got something like an #include directive that can be used as it > is in C? If so, it might be worth using it to tidy up my .emacs file. > > This is what I've used for years - I'm sure it's not elegant or anything else - but it's served me well. First I use a ~/.emacs.d/init.el file as opposed to a ~/.emacs file - they are equivalent[1]. ;; Starting point is that load-file-name returns the name of the current file - so again for me this is ~/.emacs.d/init.el as opposed to ~/.emacs ;; Setup the config dir (setq dev-emacs-init-file load-file-name) (setq dev-emacs-config-dir (file-name-directory dev-emacs-init-file)) ;; We now have dev-emacs-config-dir with ~/.emacs.d stored ;; Setup 'init' folder (setq dev-init-dir (expand-file-name "init" dev-emacs-config-dir)) ;; Now we have dev-init-dir with ~/.emacs.d/init ;; Load all the custom files inside the init dir ;; This loads any file under the ~/.emacs.d/init folder with a file name of 000_blah.el in numerical order. ;; i.e. 001_blah.el loads before 001_foo.el or 002_blah.el (if (file-exists-p dev-init-dir) (setq init-files (directory-files dev-init-dir t "[0-9][0-9][0-9]_.*.el$"))) (dolist (file init-files) (load file)) ;; This allows me to have as many files as my brain feels is appropriate. John P.S. I'm very certain I copied this from somewhere at some point. I have no idea where or when however :) [1] - https://www.emacswiki.org/emacs/DotEmacsDotD