From 6022e47b19161375fd2159299def5c76c915956d Mon Sep 17 00:00:00 2001
From: Mattias Andrée <maandree@kth.se>
Date: Fri, 25 Jun 2021 18:09:21 +0200
Subject: Fix bugs
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Mattias Andrée <maandree@kth.se>
---
 emacs/Makefile | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

(limited to 'emacs/Makefile')

diff --git a/emacs/Makefile b/emacs/Makefile
index beebde0..23f2aa3 100644
--- a/emacs/Makefile
+++ b/emacs/Makefile
@@ -3,13 +3,18 @@ include ../common.mk
 
 install:
 	mkdir -p -- ~/.config
-	if test -d ~/.emacs.d; then \
-		test ! -e ~/.config/emacs && \
-		mv -- ~/.emacs.d ~/.config/emacs; \
+	if test -L ~/.emacs.d; then \
+		test "$$(readlink -- ~/.emacs.d)" = .config/emacs; \
 	else \
-		mkdir -p -- ~/.config/emacs; \
+		set -e; \
+		if test -d ~/.emacs.d; then \
+			test ! -e ~/.config/emacs; \
+			mv -- ~/.emacs.d ~/.config/emacs; \
+		else \
+			mkdir -p -- ~/.config/emacs; \
+		fi; \
+		ln -sf -- .config/emacs ~/.emacs.d; \
 	fi
-	ln -sf -- .config/emacs ~/.emacs.d
 	printf '; %s\n\n' 'This file is generated by ~/.dotfiles/emacs/Makefile' > ~/.config/emacs/init.el
 	cat -- init.el >> ~/.config/emacs/init.el
 	if $(CHECK_INSTALLED) emacs-go-mode 2>/dev/null; then\
-- 
cgit v1.2.3-70-g09d2