1

I am using my emacs configuration in macOS and linux.

Exact configuration,always crash on macos but does not in linux. Hence I want to add following line only for macOS but not linux:

(setq debug-on-error t)

Can we apply an if condition like in bash into lisp?

Example approach in bash:

uname_out="$(uname -s)"
case "${uname_out}" in
    Darwin*) # UNIX
        # (setq debug-on-error t)
        ;;
    *) # LINUX
        ;;
esac
1
  • There are multiple duplicates and near duplicates of this question. Someone (TM) could maybe create a generic Community question for this, replacing some of the existing Qs.
    – Drew
    Commented May 31, 2023 at 13:14

1 Answer 1

2

You can use system-type to identify OS.

(when (eq system-type 'darwin)
  (setq debug-on-error t))

from M-x describe-variable system-type, the possible values are:

The value is a symbol indicating the type of operating system you are using.
Special values:
  ‘gnu’          compiled for a GNU Hurd system.
  ‘gnu/linux’    compiled for a GNU/Linux system.
  ‘gnu/kfreebsd’ compiled for a GNU system with a FreeBSD kernel.
  ‘darwin’       compiled for Darwin (GNU-Darwin, macOS, ...).
  ‘ms-dos’       compiled as an MS-DOS application.
  ‘windows-nt’   compiled as a native W32 application.
  ‘cygwin’       compiled using the Cygwin library.
Anything else (in Emacs 26, the possibilities are: aix, berkeley-unix,
hpux, usg-unix-v) indicates some sort of Unix system.

Not the answer you're looking for? Browse other questions tagged or ask your own question.