From: Christoph Egger Date: Sat, 17 Sep 2016 08:31:27 +0000 (+0000) Subject: Conditionalize emacs startup snippets X-Git-Url: https://git.siccegge.de//index.cgi?a=commitdiff_plain;h=a1e4bd5a5a8b698adfe9552ef565bf39dac74a41;p=dotfiles%2Femacs.git Conditionalize emacs startup snippets --- diff --git a/config/general.el b/config/general.el index c8c406e..76eba1a 100644 --- a/config/general.el +++ b/config/general.el @@ -1,6 +1,7 @@ (message "General emacs setup") -(tool-bar-mode -1) +(if window-system + (tool-bar-mode -1)) (setq inhibit-startup-message t) ;; Indentation @@ -17,9 +18,11 @@ (require 'uniquify) (setq uniquify-buffer-name-style 'post-forward) -(require 'auto-complete) +(if (locate-library "auto-complete") + (require 'auto-complete)) -(require 'magit) +(if (locate-library "auto-complete") + (require 'magit)) ;; Ido mode (require 'ido) @@ -56,5 +59,8 @@ (global-set-key (kbd "") 'paste-x-selection) (global-set-key (kbd "C-S-") 'paste-x-selection) -(require 'dired-narrow) -(define-key dired-mode-map "/" 'dired-narrow) + +(if (locate-library "dired-narrow") + (progn + (require 'dired-narrow) + (define-key dired-mode-map "/" 'dired-narrow))) diff --git a/config/irony.el b/config/irony.el index 95b6c48..c00ab45 100644 --- a/config/irony.el +++ b/config/irony.el @@ -1,13 +1,15 @@ -(require 'irony) -(add-hook 'c++-mode-hook 'irony-mode) -(add-hook 'c-mode-hook 'irony-mode) -(add-hook 'objc-mode-hook 'irony-mode) +(if (locate-library "irony") + (progn + (require 'irony) + (add-hook 'c++-mode-hook 'irony-mode) + (add-hook 'c-mode-hook 'irony-mode) + (add-hook 'objc-mode-hook 'irony-mode) -;; replace the `completion-at-point' and `complete-symbol' bindings in -;; irony-mode's buffers by irony-mode's function -(defun my-irony-mode-hook () - (define-key irony-mode-map [remap completion-at-point] - 'irony-completion-at-point-async) - (define-key irony-mode-map [remap complete-symbol] - 'irony-completion-at-point-async)) -(add-hook 'irony-mode-hook 'my-irony-mode-hook) + ;; replace the `completion-at-point' and `complete-symbol' bindings in + ;; irony-mode's buffers by irony-mode's function + (defun my-irony-mode-hook () + (define-key irony-mode-map [remap completion-at-point] + 'irony-completion-at-point-async) + (define-key irony-mode-map [remap complete-symbol] + 'irony-completion-at-point-async)) + (add-hook 'irony-mode-hook 'my-irony-mode-hook))) diff --git a/config/whitespace.el b/config/whitespace.el index 1c1ad0c..3009628 100644 --- a/config/whitespace.el +++ b/config/whitespace.el @@ -1,3 +1,5 @@ ;; Show whitespaces by default -(require 'show-wspace) -(global-font-lock-mode 1) +(if (locate-library "show-wspace") + (progn + (require 'show-wspace) + (global-font-lock-mode 1))) diff --git a/config/yas.el b/config/yas.el index 2eb1e1f..78bb421 100644 --- a/config/yas.el +++ b/config/yas.el @@ -1,6 +1,6 @@ -(require 'yasnippet) - -(setq yas-snippet-dirs '("~/proj/snippets")) - -(yas-global-mode 1) +(if (locate-library "yasnippet") + (progn + (require 'yasnippet) + (setq yas-snippet-dirs '("~/proj/snippets")) + (yas-global-mode 1)))