diff options
| author | Miquel Sabaté Solà <msabate@suse.com> | 2020-04-21 09:05:44 +0200 |
|---|---|---|
| committer | Miquel Sabaté Solà <msabate@suse.com> | 2020-04-21 09:05:44 +0200 |
| commit | 4dd393528c831660f3057ef99beda4551b3d17a3 (patch) | |
| tree | c063407a5879b1b07c3d772c859b1de749da9249 | |
| parent | aa93bee0839c86fdb55656c69918821a80bbfcfc (diff) | |
| download | dotfiles-4dd393528c831660f3057ef99beda4551b3d17a3.tar.gz dotfiles-4dd393528c831660f3057ef99beda4551b3d17a3.zip | |
emacs: properly check the OS and use that
The font detection was based on the window system, which utterly failed when
starting up on server mode. Thus, we should use the `system-type' variable
instead.
Moreover, I'm taking this oportunity to create two new constants which are
convenient to check the two supported OSes, and I'm also checking the OS at the
very beginning.
Signed-off-by: Miquel Sabaté Solà <msabate@suse.com>
| -rw-r--r-- | .emacs.d/init.org | 34 |
1 files changed, 24 insertions, 10 deletions
diff --git a/.emacs.d/init.org b/.emacs.d/init.org index ee8ba6a..30e08ad 100644 --- a/.emacs.d/init.org +++ b/.emacs.d/init.org @@ -79,6 +79,19 @@ individually handled. (message "Your GNU Emacs is a bit old and some functionality will be disabled. Consider upgrading to at least v%s" recver))) #+END_SRC +Check the operating system: + +#+BEGIN_SRC elisp +(defconst IS-LINUX (eq system-type 'gnu/linux) + "Current system is GNU/Linux") + +(defconst IS-MAC (eq system-type 'darwin) + "Current system is MacOS") + +(unless (or IS-LINUX IS-MAC) + (error "This configuration has been checked only on GNU/Linux and MacOS")) +#+END_SRC + Temporarily reduce garbage collection so startup time is lower. Idea taken from [[https://github.com/purcell][@purcell]]. @@ -207,20 +220,21 @@ Use the much fancier =doom-modeline= as our modeline: (use-package all-the-icons :ensure t :config - (require 'cl-lib) - ;; Check if the fonts have been already been installed. If that is not the - ;; case, then install it now. The path detection is taken from + ;; case, then install it now. The path detection is based from ;; all-the-icons.el. - (let* ((font-dest (cl-case window-system - (x (concat (or (getenv "XDG_DATA_HOME") - (concat (getenv "HOME") "/.local/share")) - "/fonts/")) - (mac (concat (getenv "HOME") "/Library/Fonts/" )) - (ns (concat (getenv "HOME") "/Library/Fonts/" )))) + (let* ((font-dest (if IS-LINUX + (concat (or (getenv "XDG_DATA_HOME") + (concat (getenv "HOME") "/.local/share")) + "/fonts/") + (if IS-MAC + (concat (getenv "HOME") "/Library/Fonts/") + nil))) (ttf-path (concat font-dest "all-the-icons.ttf"))) - (unless (file-exists-p ttf-path) + ;; If we were able to detect the OS and we don't have a the file installed, + ;; try to do it now. + (when (and font-dest (not (file-exists-p ttf-path))) (message "Installing fonts...") (all-the-icons-install-fonts)))) |
