From 7a3d95d70b5987e17937dc87066887d3866502cb Mon Sep 17 00:00:00 2001 From: Howard Abrams Date: Mon, 13 Dec 2021 10:45:32 -0800 Subject: [PATCH] Clearer when running on a Mac system. Which fixes a bug when running on Linux, that doesn't need the Shell PATH set (at least, not for me). --- bootstrap.org | 24 ++++++++++++++++++------ ha-config.org | 10 +++++----- ha-org-clipboard.org | 2 +- 3 files changed, 24 insertions(+), 12 deletions(-) diff --git a/bootstrap.org b/bootstrap.org index e857f04..925bc0a 100644 --- a/bootstrap.org +++ b/bootstrap.org @@ -54,6 +54,17 @@ While that enables the =:straight t= extension to =use-package=, let's just have See the details in [[https://dev.to/jkreeftmeijer/emacs-package-management-with-straight-el-and-use-package-3oc8][this essay]]. ** OS Path and Native Compilation +Helper functions to allow code for specific operating systems: +#+BEGIN_SRC emacs-lisp + (defun ha-running-on-macos? () + "Return non-nil if running on Mac OS systems." + (equal system-type 'darwin)) + + (defun ha-running-on-linux? () + "Return non-nil if running on Linux systems." + (equal system-type 'gnu/linux)) +#+END_SRC + With the way I start Emacs, I may not have the PATH I /actually/ use (from the shell) available, so we'll force it (code taken [[https://www.emacswiki.org/emacs/ExecPath][from here]]): #+BEGIN_SRC emacs-lisp @@ -71,22 +82,23 @@ With the way I start Emacs, I may not have the PATH I /actually/ use (from the s (setenv "PATH" path-from-shell) (setq exec-path (split-string path-from-shell path-separator)))) - (set-exec-path-from-shell) + (when (ha-running-on-macos?) + (set-exec-path-from-shell)) #+END_SRC Clear up a Mac-specific issue that sometimes arises since I'm switching to [[http://akrl.sdf.org/gccemacs.html][native compilation project]], as the =Emacs.app= that I use doesn't have its =bin= directory, e.g. =Emacs.app/Contents/MacOS/bin=: #+BEGIN_SRC emacs-lisp - (when (equal system-type 'darwin) + (when (ha-running-on-macos?) (add-to-list 'exec-path (concat invocation-directory "bin") t)) #+END_SRC Getting tired off all the packages that I load spewing a bunch of warnings that I can't do anything about: #+BEGIN_SRC emacs-lisp - (when (and (fboundp 'native-comp-available-p) - (native-comp-available-p)) - (setq native-comp-async-report-warnings-errors nil - native-comp-deferred-compilation t)) + (when (and (fboundp 'native-comp-available-p) + (native-comp-available-p)) + (setq native-comp-async-report-warnings-errors nil + native-comp-deferred-compilation t)) #+END_SRC ** Basic Libraries The following packages come with Emacs, but seems like they still need loading: diff --git a/ha-config.org b/ha-config.org index 2c3d4cd..c298cfc 100644 --- a/ha-config.org +++ b/ha-config.org @@ -46,11 +46,11 @@ More settings: And some Mac-specific settings: #+BEGIN_SRC emacs-lisp -(when (equal system-type 'darwin) - (setq mac-option-modifier 'meta) - (setq mac-command-modifier 'super) - (add-to-list 'default-frame-alist '(ns-transparent-titlebar . t)) - (add-to-list 'default-frame-alist '(ns-appearance . dark))) + (when (ha-running-on-macos?) + (setq mac-option-modifier 'meta) + (setq mac-command-modifier 'super) + (add-to-list 'default-frame-alist '(ns-transparent-titlebar . t)) + (add-to-list 'default-frame-alist '(ns-appearance . dark))) #+END_SRC * Support Packages ** Piper diff --git a/ha-org-clipboard.org b/ha-org-clipboard.org index 4bda7d3..f0b36e8 100644 --- a/ha-org-clipboard.org +++ b/ha-org-clipboard.org @@ -35,7 +35,7 @@ Each operating system as a different way of working with the clipboard, so let's (defun ha-get-clipboard () "Returns a list where the first entry is the content type, either :html or :text, and the second is the clipboard contents." - (if (eq system-type 'darwin) + (if (ha-running-on-macos?) (ha-get-mac-clipboard) (ha-get-linux-clipboard))) #+END_SRC