unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Pedro Andres Aranda Gutierrez <paaguti@gmail.com>
To: 54381@debbugs.gnu.org
Subject: bug#54381: Handling a corner case
Date: Thu, 17 Mar 2022 08:09:37 +0100	[thread overview]
Message-ID: <CAO48Bk_3BCEwcXUD=etuwyPhYm9kCsQdUL2QDP1BFA-eu4C5Nw@mail.gmail.com> (raw)
In-Reply-To: <CAO48Bk8mEYpQyk8Nz02_xFSuiT3GRBXGATuJnDj-JrNrE4COvg@mail.gmail.com>


[-- Attachment #1.1: Type: text/plain, Size: 562 bytes --]

Attached the wrong file
/PA

On Thu, 17 Mar 2022 at 07:38, Pedro Andres Aranda Gutierrez <
paaguti@gmail.com> wrote:

> Hi,
>
> just updating the patch for reference. Now handles the green-field
> deployment, i.e. I create a new init.el file and decide where I want to
> store the custom-file, but custom-file doesn't exist yet.
>
> Best, /PA
>
> --
> Fragen sind nicht da um beantwortet zu werden,
> Fragen sind da um gestellt zu werden
> Georg Kreisler
>


-- 
Fragen sind nicht da um beantwortet zu werden,
Fragen sind da um gestellt zu werden
Georg Kreisler

[-- Attachment #1.2: Type: text/html, Size: 1203 bytes --]

[-- Attachment #2: 003-auto-load-custom.diff --]
[-- Type: text/x-patch, Size: 2128 bytes --]

diff --git a/lisp/cus-edit.el b/lisp/cus-edit.el
index 7932031397..4d4daeb6cb 100644
--- a/lisp/cus-edit.el
+++ b/lisp/cus-edit.el
@@ -4710,6 +4710,14 @@ custom-group-state-update
 \f
 ;;; Reading and writing the custom file.

+;;;###autoload
+(defcustom custom-file-load-p t
+  "Load `custom-file' if it is not nil.
+Set this variable to `nil' if you want to define `custom-file' but not load it.
+This was possible. As per the old definition,someone could just define the variable
+and not load the file."
+  :type 'boolean)
+
 ;;;###autoload
 (defcustom custom-file nil
   "File used for storing customization information.
@@ -4722,10 +4730,12 @@ custom-file
 something like the following in your init file:

 (setq custom-file \"~/.config/emacs-custom.el\")
-(load custom-file)

-Note that both lines are necessary: the first line tells Custom to
-save all customizations in this file, but does not load it.
+This will load `custom-file' after the `user-init-file' if
+a) the file exists,
+b) `custom-file-load-p' is `t', and
+c) it was not loaded before explicitly with
+  (load-file custom-file).

 When you change this variable outside Custom, look in the
 previous custom file (usually your init file) for the
diff --git a/lisp/startup.el b/lisp/startup.el
index 9f0b23c904..472e5f7ebd 100644
--- a/lisp/startup.el
+++ b/lisp/startup.el
@@ -1494,6 +1494,17 @@ command-line
     (when (featurep 'native-compile)
       (startup--update-eln-cache))

+    ;; Load the `custom-file' if it was not loaded before (see documentation)
+
+    ;; if the user defined the custom-file and didn't reset `custom-file-load-p'
+    (when (and custom-file custom-file-load-p)
+      ;; make sure that you get the expanded custom-file name
+      ;; because that's what appears in `load-history'
+      (let ((real-custom-file (expand-file-name custom-file)))
+        ;; if it was loaded, assoc will return non-nil
+        (unless (assoc real-custom-file load-history)
+          (load real-custom-file t))))
+
     (when (and deactivate-mark transient-mark-mode)
       (with-current-buffer (window-buffer)
         (deactivate-mark)))

      reply	other threads:[~2022-03-17  7:09 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-14  8:21 bug#54381: 29.0.50; Automatically load custom-file Pedro Andres Aranda Gutierrez
2022-03-14  9:47 ` Lars Ingebrigtsen
2022-03-14  9:48   ` Lars Ingebrigtsen
2022-03-14 15:14     ` bug#54381: [External] : " Drew Adams
2022-03-14 13:15   ` Eli Zaretskii
2022-03-14 15:26     ` Robert Pluim
2022-03-14 16:19       ` Pedro Andres Aranda Gutierrez
2022-03-14 16:36         ` Robert Pluim
2022-03-14 16:47           ` Pedro Andres Aranda Gutierrez
2022-03-14 17:53             ` Robert Pluim
2022-03-15  7:51               ` Pedro Andres Aranda Gutierrez
2022-03-14 13:58   ` Robert Pluim
2022-04-14 14:05     ` Lars Ingebrigtsen
2022-03-17  6:38 ` bug#54381: Handling a corner case Pedro Andres Aranda Gutierrez
2022-03-17  7:09   ` Pedro Andres Aranda Gutierrez [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAO48Bk_3BCEwcXUD=etuwyPhYm9kCsQdUL2QDP1BFA-eu4C5Nw@mail.gmail.com' \
    --to=paaguti@gmail.com \
    --cc=54381@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

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