From 8e1d449754f952175e651c953212b314cf603d11 Mon Sep 17 00:00:00 2001 From: Muneeb Shaikh Date: Sat, 27 Aug 2016 20:58:27 +0530 Subject: [PATCH] osx: add osx-dictionary and make it default for OS X --- layers/+os/osx/README.org | 11 +++++++++++ layers/+os/osx/config.el | 3 +++ layers/+os/osx/packages.el | 15 +++++++++++++++ layers/+spacemacs/spacemacs-language/packages.el | 2 +- 4 files changed, 30 insertions(+), 1 deletion(-) diff --git a/layers/+os/osx/README.org b/layers/+os/osx/README.org index ced8f0181..1fb6eff5b 100644 --- a/layers/+os/osx/README.org +++ b/layers/+os/osx/README.org @@ -8,6 +8,7 @@ - [[#install][Install]] - [[#layer][Layer]] - [[#use-with-non-us-keyboard-layouts][Use with non-US keyboard layouts]] + - [[#define-words-using-os-x-dictionary][Define words using OS X Dictionary]] - [[#coreutils][Coreutils]] - [[#key-bindings][Key Bindings]] - [[#future-work][Future Work]] @@ -50,6 +51,16 @@ key. (setq-default mac-right-option-modifier nil) #+END_SRC +*** Define words using OS X Dictionary + +This layer by default enables defining words under point ~SPC x w d~ using OS X Dictionary. +You can disable it by setting =osx-use-dictionary-app= variable to =nil=: + +#+BEGIN_SRC emacs-lisp + (setq-default dotspacemacs-configuration-layers '( + (osx :variables osx-use-dictionary-app nil))) +#+END_SRC + ** Coreutils To get =gls= install coreutils homebrew: diff --git a/layers/+os/osx/config.el b/layers/+os/osx/config.el index 33a1fc2a1..f87e88e22 100644 --- a/layers/+os/osx/config.el +++ b/layers/+os/osx/config.el @@ -2,6 +2,9 @@ "If non nil the option key is mapped to meta. Set to `nil` if you need the option key to type common characters.") +(defvar osx-use-dictionary-app t + "If non nil use osx dictionary app instead of wordnet") + ;; Use the OS X Emoji font for Emoticons (when (fboundp 'set-fontset-font) (set-fontset-font "fontset-default" diff --git a/layers/+os/osx/packages.el b/layers/+os/osx/packages.el index 870fbb1ac..03ba2560d 100644 --- a/layers/+os/osx/packages.el +++ b/layers/+os/osx/packages.el @@ -3,6 +3,7 @@ exec-path-from-shell helm launchctl + (osx-dictionary :toggle osx-use-dictionary-app) osx-trash pbcopy reveal-in-osx-finder @@ -68,6 +69,20 @@ (kbd "#") 'launchctl-unsetenv (kbd "h") 'launchctl-help)))) +(defun osx/init-osx-dictionary () + (use-package osx-dictionary + :if osx-use-dictionary-app + :init (spacemacs/set-leader-keys "xwd" 'osx-dictionary-search-pointer) + :config + (progn + (evilified-state-evilify-map osx-dictionary-mode-map + :mode osx-dictionary-mode + :bindings + "q" 'osx-dictionary-quit + "r" 'osx-dictionary-read-word + "s" 'osx-dictionary-search-input + "o" 'osx-dictionary-open-dictionary.app)))) + (defun osx/init-osx-trash () (use-package osx-trash :if (and (spacemacs/system-is-mac) diff --git a/layers/+spacemacs/spacemacs-language/packages.el b/layers/+spacemacs/spacemacs-language/packages.el index ea18ffe36..e83102729 100644 --- a/layers/+spacemacs/spacemacs-language/packages.el +++ b/layers/+spacemacs/spacemacs-language/packages.el @@ -10,7 +10,7 @@ ;;; License: GPLv3 (setq spacemacs-language-packages - '(define-word + '(define-word :toggle (not osx-use-dictionary-app) google-translate)) (defun spacemacs-language/init-define-word ()