refactor!: deprecate IS-* OS constants

BREAKING CHANGE: This deprecates the IS-(MAC|WINDOWS|LINUX|BSD) family
of global constants in favor of a native `featurep` check:

  IS-MAC      ->  (featurep :system 'macos)
  IS-WINDOWS  ->  (featurep :system 'windows)
  IS-LINUX    ->  (featurep :system 'linux)
  IS-BSD      ->  (featurep :system 'bsd)

The constants will stick around until the v3 release so folks can still
use it -- and there are still some modules that use it, but I'll phase
those uses out gradually.

Fix: #7479
This commit is contained in:
Henrik Lissner 2023-12-05 17:05:13 -05:00
parent d38787edf4
commit 659f7bfc71
No known key found for this signature in database
GPG key ID: B60957CA074D39A3
52 changed files with 150 additions and 120 deletions

View file

@ -17,7 +17,7 @@ This is ignored by ccls.")
`((c-mode . nil)
(c++-mode
. ,(list "-std=c++1z" ; use C++17 draft by default
(when IS-MAC
(when (featurep :system 'macos)
;; NOTE beware: you'll get abi-inconsistencies when passing
;; std-objects to libraries linked with libstdc++ (e.g. if you
;; use boost which wasn't compiled with libc++)
@ -286,7 +286,7 @@ If rtags or rdm aren't available, fail silently instead of throwing a breaking e
;; NOTE : This setting is untested yet
(after! eglot
(when IS-MAC
(when (featurep :system 'macos)
(add-to-list 'eglot-workspace-configuration
`((:ccls . ((:clang . ,(list :extraArgs ["-isystem/Library/Developer/CommandLineTools/usr/include/c++/v1"
"-isystem/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include"
@ -313,12 +313,12 @@ If rtags or rdm aren't available, fail silently instead of throwing a breaking e
(setq-hook! 'lsp-configure-hook
ccls-sem-highlight-method (if lsp-enable-semantic-highlighting
ccls-sem-highlight-method))
(when (or IS-MAC
IS-LINUX)
(when (or (featurep :system 'macos)
(featurep :system 'linux))
(setq ccls-initialization-options
`(:index (:trackDependency 1
:threads ,(max 1 (/ (doom-system-cpus) 2))))))
(when IS-MAC
(when (featurep :system 'macos)
(setq ccls-initialization-options
(append ccls-initialization-options
`(:clang ,(list :extraArgs ["-isystem/Library/Developer/CommandLineTools/usr/include/c++/v1"

View file

@ -9,7 +9,7 @@
(`skim
(when-let
(app-path
(and IS-MAC
(and (featurep :system 'macos)
(file-exists-p! (or "/Applications/Skim.app"
"~/Applications/Skim.app"))))
(add-to-list 'TeX-view-program-selection '(output-pdf "Skim"))
@ -18,7 +18,7 @@
app-path)))))
(`sumatrapdf
(when (and IS-WINDOWS
(when (and (featurep :system 'windows)
(executable-find "SumatraPDF"))
(add-to-list 'TeX-view-program-selection '(output-pdf "SumatraPDF"))))
@ -40,7 +40,7 @@
(`pdf-tools
(when (modulep! :tools pdf)
(add-to-list 'TeX-view-program-selection '(output-pdf "PDF Tools"))
(when IS-MAC
(when (featurep :system 'macos)
;; PDF Tools isn't in `TeX-view-program-list-builtin' on macs.
(add-to-list 'TeX-view-program-list '("PDF Tools" TeX-pdf-tools-sync-view)))
;; Update PDF buffers after successful LaTeX runs.

View file

@ -5,7 +5,7 @@
(format "%s %s"
(if (executable-find "love")
"love"
(if IS-MAC "open -a love.app"))
(if (featurep :system 'macos) "open -a love.app"))
(shell-quote-argument root))))
;;;###autoload

View file

@ -34,9 +34,9 @@ lua-language-server.")
;; is a function is to dynamically change when/if `+lua-lsp-dir' does
(list (or (executable-find "lua-language-server")
(doom-path +lua-lsp-dir
(cond (IS-MAC "bin/macOS")
(IS-LINUX "bin/Linux")
(IS-WINDOWS "bin/Windows"))
(cond ((featurep :system 'macos) "bin/macOS")
((featurep :system 'linux) "bin/Linux")
((featurep :system 'windows) "bin/Windows"))
"lua-language-server"))
"-E" "-e" "LANG=en"
(doom-path +lua-lsp-dir "main.lua")))

View file

@ -32,8 +32,8 @@ capture, the end position, and the output buffer.")
;; This is set to `nil' by default, which causes a wrong-type-arg error
;; when you use `markdown-open'. These are more sensible defaults.
markdown-open-command
(cond (IS-MAC "open")
(IS-LINUX "xdg-open"))
(cond ((featurep :system 'macos) "open")
((featurep :system 'linux) "xdg-open"))
;; A sensible and simple default preamble for markdown exports that
;; takes after the github asthetic (plus highlightjs syntax coloring).

View file

@ -14,7 +14,7 @@ nimsuggest isn't installed."
(set-formatter! 'nmfmt '("nimfmt" filepath) :modes '(nim-mode))
(when IS-WINDOWS
(when (featurep :system 'windows)
;; TODO File PR/report upstream (https://github.com/nim-lang/nim-mode)
(defadvice! +nim--suggest-get-temp-file-name-a (path)
"Removes invalid characters from the temp file path, including the unicode

View file

@ -15,12 +15,12 @@
(width . 70)
(height . 25)
(transient . t)
,@(when IS-LINUX
,@(when (featurep :system 'linux)
`((window-system . ,(if (boundp 'pgtk-initialized) 'pgtk 'x))
(display . ,(or (getenv "WAYLAND_DISPLAY")
(getenv "DISPLAY")
":0"))))
,(if IS-MAC '(menu-bar-lines . 1)))
,(if (featurep :system 'macos) '(menu-bar-lines . 1)))
"TODO")
;;;###autoload

View file

@ -3,13 +3,14 @@
(defun +org--yank-html-buffer (buffer)
(with-current-buffer buffer
(require 'ox-clip)
(cond ((or IS-WINDOWS IS-MAC)
(cond ((or (featurep :system 'windows)
(featurep :system 'macos))
(shell-command-on-region
(point-min)
(point-max)
(cond (IS-WINDOWS ox-clip-w32-cmd)
(IS-MAC ox-clip-osx-cmd))))
(IS-LINUX
(cond ((featurep :system 'windows) ox-clip-w32-cmd)
((featurep :system 'macos) ox-clip-osx-cmd))))
((featurep :system 'linux)
(let ((html (buffer-string)))
(with-temp-file (make-temp-file "ox-clip-md" nil ".html")
(insert html))

View file

@ -507,7 +507,7 @@ relative to `org-directory', unless it is an absolute path."
"file" :face (lambda (path)
(if (or (file-remote-p path)
;; filter out network shares on windows (slow)
(if IS-WINDOWS (string-prefix-p "\\\\" path))
(if (featurep :system 'windows) (string-prefix-p "\\\\" path))
(file-exists-p path))
'org-link
'(warning org-link))))
@ -931,7 +931,7 @@ between the two."
[C-return] #'+org/insert-item-below
[C-S-return] #'+org/insert-item-above
[C-M-return] #'org-insert-subheading
(:when IS-MAC
(:when (featurep :system 'macos)
[s-return] #'+org/insert-item-below
[s-S-return] #'+org/insert-item-above
[s-M-return] #'org-insert-subheading)
@ -1391,7 +1391,7 @@ between the two."
"Advise `server-visit-files' to load `org-protocol' lazily."
:around #'server-visit-files
(if (not (cl-loop with protocol =
(if IS-WINDOWS
(if (featurep :system 'windows)
;; On Windows, the file arguments for `emacsclient'
;; get funnelled through `expand-file-path' by
;; `server-process-filter'. This substitutes

View file

@ -26,8 +26,8 @@
(setq org-download-method 'attach
org-download-timestamp "_%Y%m%d_%H%M%S"
org-download-screenshot-method
(cond (IS-MAC "screencapture -i %s")
(IS-LINUX
(cond ((featurep :system 'macos) "screencapture -i %s")
((featurep :system 'linux)
(cond ((executable-find "maim") "maim -s %s")
((executable-find "scrot") "scrot -s %s")
((executable-find "gnome-screenshot") "gnome-screenshot -a -f %s"))))

View file

@ -33,7 +33,7 @@
(advice-add #'org-babel-ipython-initiate-session :override #'+org-ob-ipython-initiate-session-a)
;; retina resolution image hack
(when IS-MAC
(when (featurep :system 'macos)
(advice-add #'ob-ipython--write-base64-string :around #'+org-ob-ipython-write-base64-string-a))
;; ipython has its own async keyword, disable ipython in ob-async.

View file

@ -16,10 +16,10 @@ Migrate your notes to org-roam-v2 and switch to the +roam2 flag (see the module
(warn! "Couldn't find the dot executable (from graphviz). org-roam will not be able to generate graph visualizations.")))
(when (modulep! +dragndrop)
(when IS-MAC
(when (featurep :system 'macos)
(unless (executable-find "pngpaste")
(warn! "Couldn't find the pngpaste executable. org-download-clipboard will not work.")))
(when IS-LINUX
(when (featurep :system 'linux)
(unless (or (executable-find "maim") (executable-find "scrot") (executable-find "gnome-screenshot"))
(warn! "Couldn't find the maim, scrot or gnome-screenshot executable. org-download-clipboard will not work."))
(if (string= "wayland" (getenv "XDG_SESSION_TYPE"))
@ -27,6 +27,6 @@ Migrate your notes to org-roam-v2 and switch to the +roam2 flag (see the module
(warn! "Couldn't find the wl-paste executable (from wl-clipboard). org-download-clipboard will not work."))
(unless (executable-find "xclip")
(warn! "Couldn't find the xclip executable. org-download-clipboard will not work."))))
(when IS-WINDOWS
(when (featurep :system 'windows)
(unless (executable-find "convert")
(warn! "Couldn't find the convert program (from ImageMagick). org-download-clipboard will not work."))))

View file

@ -54,7 +54,7 @@
:type git
:repo "https://repo.or.cz/org-contacts.git")))
(when (and IS-MAC
(when (and (featurep :system 'macos)
(modulep! :os macos))
(package! org-mac-link :pin "e30171a6e98db90787ab8a23b3a7dc4fd13b10f9"))

View file

@ -83,7 +83,7 @@
(set-company-backend! 'sh-mode '(company-shell company-files))
(setq company-shell-delete-duplicates t
;; whatis lookups are exceptionally slow on macOS (#5860)
company-shell-dont-fetch-meta IS-MAC))
company-shell-dont-fetch-meta (featurep :system 'macos)))
(use-package! powershell