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).
This commit is contained in:
Howard Abrams 2021-12-13 10:45:32 -08:00
parent 40f30013b6
commit 7a3d95d70b
3 changed files with 24 additions and 12 deletions

View file

@ -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,13 +82,14 @@ 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

View file

@ -46,7 +46,7 @@ More settings:
And some Mac-specific settings:
#+BEGIN_SRC emacs-lisp
(when (equal system-type 'darwin)
(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))

View file

@ -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