diff --git a/core/core-modules.el b/core/core-modules.el index 917393412..8f29d0bf4 100644 --- a/core/core-modules.el +++ b/core/core-modules.el @@ -39,7 +39,8 @@ run before `doom-init-modules-hook'. Relevant to `doom-module-init-file'.") (vterm (:term vterm)) (password-store (:tools pass)) (flycheck (:checkers syntax)) - (flyspell (:checkers spell))) + (flyspell (:checkers spell)) + (macos (:os macos))) (:emacs (electric-indent (:emacs electric)) (hideshow (:editor fold)) (eshell (:term eshell)) diff --git a/docs/modules.org b/docs/modules.org index c3ed648d7..0e14b5de1 100644 --- a/docs/modules.org +++ b/docs/modules.org @@ -154,6 +154,7 @@ Modules that bring support for a language or group of languages to Emacs. * :os Modules to improve integration into your OS, system, or devices. ++ [[file:/mnt/projects/conf/doom-emacs/modules/os/macos/README.org][macos]] - Improve Emacs' compatibility with macOS + tty =+osc= - Improves the terminal Emacs experience. * :term @@ -178,7 +179,6 @@ Small modules that give Emacs access to external tools & services. + [[file:../modules/tools/lookup/README.org][lookup]] =+dictionary +docsets +offline= - Universal jump-to & documentation lookup backend + [[file:../modules/tools/lsp/README.org][lsp]] =+peek +eglot= - Installation and configuration of language server protocol client (lsp-mode or eglot) -+ macos - TODO + [[file:../modules/tools/magit/README.org][magit]] =+forge= - TODO + make - TODO + pass =+auth= - TODO diff --git a/init.example.el b/init.example.el index 01d9f7594..269185186 100644 --- a/init.example.el +++ b/init.example.el @@ -93,7 +93,6 @@ ;;gist ; interacting with github gists lookup ; navigate your code and its documentation ;;lsp - ;;macos ; MacOS-specific commands magit ; a git porcelain for Emacs ;;make ; run make tasks from Emacs ;;pass ; password manager for nerds @@ -106,6 +105,7 @@ ;;upload ; map local to remote projects via ssh/ftp :os + (:if IS-MAC macos) ; improve compatibility with macOS ;;tty ; improve the terminal Emacs experience :lang diff --git a/modules/os/macos/README.org b/modules/os/macos/README.org new file mode 100644 index 000000000..bbe296e57 --- /dev/null +++ b/modules/os/macos/README.org @@ -0,0 +1,42 @@ +#+TITLE: os/macos +#+DATE: February 19, 2017 +#+SINCE: v1.3 +#+STARTUP: inlineimages nofold + +* Table of Contents :TOC_3:noexport: +- [[#description][Description]] + - [[#module-flags][Module Flags]] + - [[#maintainers][Maintainers]] + - [[#plugins][Plugins]] +- [[#features][Features]] + - [[#open-with-x]["Open with X"]] + +* Description +This module provides extra functionality for macOS. + +** Module Flags +This module provides no flags. + +** Maintainers +This module has no dedicated maintainers + +** Plugins ++ [[https://github.com/emacsorphanage/osx-trash][osx-trash]] ++ [[https://github.com/purcell/ns-auto-titlebar][ns-auto-titlebar]] + +* Features +** "Open with X" +This module adds various macOS-specific launchers under the =SPC o= prefix (=C-c +o= for users with Evil disabled). + +It also enables Keychain integration for =auth-source=. This is used by our [[file:../../../modules/app/irc/README.org][irc]] +and [[file:../../../modules/tools/magit/README.org][magit]]-forge modules, for instance. + +To support GitHub Forge add an internet password like this to your keychain: +| Field | Value | +|----------+-------------------------| +| Name | api.github.com | +| Kind | Internet password | +| Account | ^forge | +| Where | https://api.github.com/ | +| Password | | diff --git a/modules/tools/macos/autoload.el b/modules/os/macos/autoload.el similarity index 67% rename from modules/tools/macos/autoload.el rename to modules/os/macos/autoload.el index 6aa1f006c..ffd12cae9 100644 --- a/modules/tools/macos/autoload.el +++ b/modules/os/macos/autoload.el @@ -1,7 +1,4 @@ -;;; tools/macos/autoload.el -*- lexical-binding: t; -*- - -;;;###autoload -(setq locate-command "mdfind") +;;; os/macos/autoload.el -*- lexical-binding: t; -*- ;;;###autoload (defun +macos-open-with (&optional app-name path) @@ -27,28 +24,28 @@ (interactive) (+macos-open-with ,app ,dir))) -;;;###autoload (autoload '+macos/open-in-default-program "tools/macos/autoload" nil t) +;;;###autoload (autoload '+macos/open-in-default-program "os/macos/autoload" nil t) (+macos--open-with open-in-default-program) -;;;###autoload (autoload '+macos/reveal-in-finder "tools/macos/autoload" nil t) +;;;###autoload (autoload '+macos/reveal-in-finder "os/macos/autoload" nil t) (+macos--open-with reveal-in-finder "Finder" default-directory) -;;;###autoload (autoload '+macos/reveal-project-in-finder "tools/macos/autoload" nil t) +;;;###autoload (autoload '+macos/reveal-project-in-finder "os/macos/autoload" nil t) (+macos--open-with reveal-project-in-finder "Finder" (or (doom-project-root) default-directory)) -;;;###autoload (autoload '+macos/send-to-transmit "tools/macos/autoload" nil t) +;;;###autoload (autoload '+macos/send-to-transmit "os/macos/autoload" nil t) (+macos--open-with send-to-transmit "Transmit") -;;;###autoload (autoload '+macos/send-cwd-to-transmit "tools/macos/autoload" nil t) +;;;###autoload (autoload '+macos/send-cwd-to-transmit "os/macos/autoload" nil t) (+macos--open-with send-cwd-to-transmit "Transmit" default-directory) -;;;###autoload (autoload '+macos/send-to-launchbar "tools/macos/autoload" nil t) +;;;###autoload (autoload '+macos/send-to-launchbar "os/macos/autoload" nil t) (+macos--open-with send-to-launchbar "LaunchBar") -;;;###autoload (autoload '+macos/send-project-to-launchbar "tools/macos/autoload" nil t) +;;;###autoload (autoload '+macos/send-project-to-launchbar "os/macos/autoload" nil t) (+macos--open-with send-project-to-launchbar "LaunchBar" (or (doom-project-root) default-directory)) -;;;###autoload (autoload '+macos/open-in-iterm "tools/macos/autoload" nil t) +;;;###autoload (autoload '+macos/open-in-iterm "os/macos/autoload" nil t) (+macos--open-with open-in-iterm "iTerm" default-directory) diff --git a/modules/os/macos/config.el b/modules/os/macos/config.el new file mode 100644 index 000000000..df70ef5c7 --- /dev/null +++ b/modules/os/macos/config.el @@ -0,0 +1,62 @@ +;;; os/macos/config.el -*- lexical-binding: t; -*- + +;; +;;; Reasonable defaults for macOS + +;; Use spotlight search backend as a default for M-x locate (and helm/ivy +;; variants thereof), since it requires no additional setup. +(setq locate-command "mdfind") + + +;; +;;; Compatibilty fixes + +;; Curse Lion and its sudden but inevitable fullscreen mode! +;; NOTE Meaningless to railwaycat's emacs-mac build +(setq ns-use-native-fullscreen nil) + +;; Visit files opened outside of Emacs in existing frame, not a new one +(setq ns-pop-up-frames nil) + +;; sane trackpad/mouse scroll settings +(setq mac-redisplay-dont-reset-vscroll t + mac-mouse-wheel-smooth-scroll nil) + +;; Sets `ns-transparent-titlebar' and `ns-appearance' frame parameters so window +;; borders will match the enabled theme. +(and (or (daemonp) + (display-graphic-p)) + (require 'ns-auto-titlebar nil t) + (ns-auto-titlebar-mode +1)) + +;; HACK On MacOS, disabling the menu bar makes MacOS treat Emacs as a +;; non-application window -- which means it doesn't automatically capture +;; focus when it is started, among other things. We enable menu-bar-lines +;; there, but we still want it disabled in terminal frames because there it +;; activates an ugly menu bar. +(add-hook! '(window-setup-hook after-make-frame-functions) + (defun doom-init-menu-bar-in-gui-frames-h (&optional frame) + "Re-enable menu-bar-lines in GUI frames." + (when-let (frame (or frame (selected-frame))) + (when (display-graphic-p frame) + (set-frame-parameter frame 'menu-bar-lines 1))))) + +;; Integrate with Keychain +(after! auth-source + (pushnew! auth-sources 'macos-keychain-internet 'macos-keychain-generic)) + + +;; +;;; Packages + +(use-package! osx-trash + :commands osx-trash-move-file-to-trash + :init + ;; Delete files to trash on macOS, as an extra layer of precaution against + ;; accidentally deleting wanted files. + (setq delete-by-moving-to-trash t) + + ;; Lazy load `osx-trash' + (and IS-MAC + (not (fboundp 'system-move-file-to-trash)) + (defalias #'system-move-file-to-trash #'osx-trash-move-file-to-trash))) diff --git a/modules/tools/macos/README.org b/modules/tools/macos/README.org deleted file mode 100644 index a755ab277..000000000 --- a/modules/tools/macos/README.org +++ /dev/null @@ -1,31 +0,0 @@ -#+TITLE: tools/macos -#+DATE: February 19, 2017 -#+SINCE: v1.3 -#+STARTUP: inlineimages nofold - -* Table of Contents :TOC_3:noexport: -- [[#description][Description]] - - [[#maintainers][Maintainers]] -- [[#features][Features]] - -* Description -This module provides extra functionality for macOS. - -** Maintainers -This module has no dedicated maintainers - -* Features - -This module adds various macOS specific launchers under the SPC o shortcuts. - -It also enables keychain as an auth-source. This is used by apps like [[file:../../../modules/app/irc/README.org][irc]] and -[[file:../../../modules/tools/magit/README.org][magit]]'s forge module. For instance, to support GitHub Forge add an internet -password like this to your keychain: - - | Field | Value | - |----------+-------------------------| - | Name | api.github.com | - | Kind | Internet password | - | Account | ^forge | - | Where | https://api.github.com/ | - | Password | | diff --git a/modules/tools/macos/config.el b/modules/tools/macos/config.el deleted file mode 100644 index e3fa1a587..000000000 --- a/modules/tools/macos/config.el +++ /dev/null @@ -1,5 +0,0 @@ -;;; tools/macos/config.el -*- lexical-binding: t; -*- - -(after! auth-source - (when IS-MAC - (pushnew! auth-sources 'macos-keychain-internet 'macos-keychain-generic)))