From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Robert Pluim Newsgroups: gmane.emacs.devel Subject: Re: Default emacs init file location confusion Date: Wed, 08 Jan 2020 09:04:25 +0100 Message-ID: References: <83y2ukc55g.fsf@gnu.org> <85C8025D-ACFD-4DEB-B030-E46B3109323E@gnu.org> <83lfqjckjn.fsf@gnu.org> <83blrfci4q.fsf@gnu.org> <837e23chdm.fsf@gnu.org> <834kx7cgmh.fsf@gnu.org> <87tv56bjop.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="13306"; mail-complaints-to="usenet@blaine.gmane.org" Cc: "Mingde \(Matthew\) Zeng" , smartlitchi@gmail.com, emacs-devel To: Elias =?utf-8?Q?M=C3=A5rtenson?= Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Jan 08 09:06:14 2020 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1ip6Kx-000q8W-Ln for ged-emacs-devel@m.gmane.org; Wed, 08 Jan 2020 09:05:07 +0100 Original-Received: from localhost ([::1]:39354 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ip6Kw-0001hT-3N for ged-emacs-devel@m.gmane.org; Wed, 08 Jan 2020 03:05:06 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:47263) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ip6KL-0000rT-W8 for emacs-devel@gnu.org; Wed, 08 Jan 2020 03:04:31 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ip6KK-00042Y-Lq for emacs-devel@gnu.org; Wed, 08 Jan 2020 03:04:29 -0500 Original-Received: from mail-wr1-x42d.google.com ([2a00:1450:4864:20::42d]:35700) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ip6KK-00041k-Dc for emacs-devel@gnu.org; Wed, 08 Jan 2020 03:04:28 -0500 Original-Received: by mail-wr1-x42d.google.com with SMTP id g17so2326989wro.2 for ; Wed, 08 Jan 2020 00:04:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:gmane-reply-to-list:date:in-reply-to :message-id:mime-version:content-transfer-encoding; bh=/WGbBzTi210gMUhGVPaH0PWPRZpIlj/RhQJNBnlh7hQ=; b=n5FlloVe8ubPAJqpVqxoNjDRIJw1Qhz+rHArCtpgLPa3bv6DgQxaXQlI2wr0/xY0ht ajOfBVs0zZ2v0IOlu8loUE0bmBXEw15iIVvnDOjD8NcX4YA05qZGYrux5i9kbNeKdQI0 chomfEjdwiZzC9fv/jKEpV3dyplcBCzlAS4fAXqIJGBopNdbhuTnB1g1VygS2FePxK/Z thpZtPjO/WPzd6cr4zkUoC7dEB7x3wGfUI0hmLArRYfRFxAHRobQwiPKfsQ0WQMlPYb+ bjflqduYe6ebq+pjM4b8WyGrG7DBOrIJEdOQVTeHC/0RvPEzQ97G9taGdzbdCxPA/thv mzcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references :gmane-reply-to-list:date:in-reply-to:message-id:mime-version :content-transfer-encoding; bh=/WGbBzTi210gMUhGVPaH0PWPRZpIlj/RhQJNBnlh7hQ=; b=Q+xuxEw1RgOHUiIBbcWqHeYsxaHDG2o2MSSFKjl5mycEATJwEIxzjjpNB03OSCmo8e mX3GzfHrMepkh3MDrWro6YvNlZZx0Oc73TCXt6F9HS68Gjw8uDJOBbzryaAE+ry235l8 H0KZrqWKgvXaTpvgwm02p121KacQZdTzhdAbZAuEglz7P6qtYhlQ3Ottp/mGk/M9KnBT 7F1wApzrgrjxYD96r6BN89q8VmkMEeKjJWlFPqNFW7uJUHbvgN9NIwoTEB/ovUIl1hT8 DFR46EMCig7ILQIQMKmmmGYAyk5/qAWU51nTScZLkGy93SqHvElTUhAnMZTfCQo2ql5J 34bA== X-Gm-Message-State: APjAAAWpKn3Qdrd/Psnj7BS+w//uppHsWKehgXxWrm7GQWdkGgz7am5X ykRHPYmDN8PiHdR40+qime0UUKC8FAw= X-Google-Smtp-Source: APXvYqyvcQnrsOgEX82jKwQuZ7n0ZtI/70Bc8ElTR5zkyL1FK/605aR+DXfEedDg5pfGSHvrbHRBGA== X-Received: by 2002:adf:c746:: with SMTP id b6mr2801083wrh.298.1578470666886; Wed, 08 Jan 2020 00:04:26 -0800 (PST) Original-Received: from rpluim-mac ([149.5.228.1]) by smtp.gmail.com with ESMTPSA id b10sm3291462wrt.90.2020.01.08.00.04.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jan 2020 00:04:26 -0800 (PST) Gmane-Reply-To-List: yes In-Reply-To: ("Elias =?utf-8?Q?M=C3=A5rtenson=22's?= message of "Wed, 8 Jan 2020 13:33:20 +0800") X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::42d X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:244107 Archived-At: >>>>> On Wed, 8 Jan 2020 13:33:20 +0800, Elias M=C3=A5rtenson said: Elias> Having thought about it some more, I came up with this proposal:= Emacs Elias> could check if both directories exist, and if so, provide an int= eractive Elias> choice for the user to pick which one to use. If the user don't = want to Elias> have to answer this question every time Emacs starts up, they ca= n delete Elias> one of the directories. That seems like the worst of both worlds. I=CA=BCd say the principle of least surprise says that emacs should prefer ~/.emacs.d if neither of two directories exist (which would end up creating it), and prefer ~/.config/emacs if that exists (but not create it), which allows people who want to use the xdg stuff to do so easily. Concretely: diff --git a/lisp/startup.el b/lisp/startup.el index 04a37bf59e..ebf9d33a97 100644 --- a/lisp/startup.el +++ b/lisp/startup.el @@ -497,28 +497,20 @@ startup--xdg-config-default (defvar startup--xdg-config-home-emacs) =20 ;; Return the name of the init file directory for Emacs, assuming -;; XDG-DIR is the XDG location and USER-NAME is the user name. -;; If USER-NAME is nil or "", use the current user. -;; Prefer the XDG location unless it does does not exist and the -;; .emacs.d location does exist. +;; XDG-DIR is the XDG location and USER-NAME is the user name. If +;; USER-NAME is nil or "", use the current user. Prefer the XDG +;; location unless it does not exist, in which case we prefer the +;; .emacs.d location (even if it does not exist) (defun startup--xdg-or-homedot (xdg-dir user-name) + (let ((user-name (if (and user-name (not (string-equal user-name ""))) + user-name + init-file-user))) (if (file-exists-p xdg-dir) xdg-dir - (let ((emacs-d-dir (concat "~" user-name - (if (eq system-type 'ms-dos) - "/_emacs.d/" - "/.emacs.d/")))) - (if (or (file-exists-p emacs-d-dir) - (if (eq system-type 'windows-nt) - (if (file-directory-p (concat "~" user-name)) - (directory-files (concat "~" user-name) nil - "\\`[._]emacs\\(\\.elc?\\)?\\'")) - (file-exists-p (concat "~" init-file-user - (if (eq system-type 'ms-dos) - "/_emacs" - "/.emacs"))))) - emacs-d-dir - xdg-dir)))) + (concat "~" user-name + (if (eq system-type 'ms-dos) + "/_emacs.d/" + "/.emacs.d/"))))) =20 (defun normal-top-level () "Emacs calls this function when it first starts up.