|
55 | 55 | 'display-line-numbers-mode
|
56 | 56 | 'linum-mode))
|
57 | 57 |
|
| 58 | +(defun executables-missing (&rest commands) |
| 59 | + "Check if any of COMMANDS are missing." |
| 60 | + (let ((result nil)) |
| 61 | + (dolist (command commands result) |
| 62 | + (unless (executable-find command) |
| 63 | + (message "Necessary executable '%s' is not found on exec-path" command) |
| 64 | + (setq result t))) |
| 65 | + result)) |
| 66 | + |
58 | 67 | (use-package exec-path-from-shell
|
59 | 68 | :if (memq window-system '(mac ns x))
|
60 | 69 | :config
|
|
371 | 380 | (js2r-add-keybindings-with-prefix "C-c C-r"))
|
372 | 381 |
|
373 | 382 | (use-package xref-js2
|
| 383 | + :unless (executables-missing "ag") |
374 | 384 | :after (js2-mode)
|
375 |
| - :init |
376 |
| - (defun init-js2-xref-backend () |
377 |
| - "Initialises JS2 Xref backend via hook" |
378 |
| - (cond |
379 |
| - ((not (executable-find "ag")) |
380 |
| - (message "Necessary executable `ag' is not found on `exec-path'")) |
381 |
| - (t (message "Registered JS2 Xref backend") |
382 |
| - (add-hook 'xref-backend-functions 'xref-js2-xref-backend)))) |
383 | 385 | :hook
|
384 |
| - (js2-mode . init-js2-xref-backend)) |
| 386 | + (xref-backend-functions |
| 387 | + xref-js2-xref-backend)) |
385 | 388 |
|
386 | 389 | (use-package company-tern
|
| 390 | + :unless (executables-missing "tern") |
387 | 391 | :after (company js2-mode)
|
388 |
| - :init |
389 |
| - (defun enable-company-tern () |
390 |
| - "Initialises Tern company backend" |
391 |
| - (cond |
392 |
| - ((not (executable-find "tern")) |
393 |
| - (message "Necessary executable `tern' is not found on `exec-path'")) |
394 |
| - (t (message "Turning on company-mode using Tern") |
395 |
| - (company-mode) |
396 |
| - (tern-mode)))) |
397 | 392 | :hook
|
398 |
| - (js2-mode . enable-company-tern) |
| 393 | + (js2-mode . company-mode) |
| 394 | + (js2-mode . tern-mode) |
399 | 395 | :config
|
400 | 396 | (add-to-list 'company-backends 'company-tern)
|
401 | 397 | (unbind-key "M-." tern-mode-keymap)
|
|
430 | 426 | (use-package systemd)
|
431 | 427 |
|
432 | 428 | (use-package markdown-mode
|
433 |
| - :init |
434 |
| - (when (not (executable-find "markdown")) |
435 |
| - (message "Necessary executable `markdown' is not found on `exec-path'")) |
| 429 | + :unless (executables-missing "markdown") |
436 | 430 | :hook
|
437 | 431 | (markdown-mode . markdown-live-preview-mode)
|
438 | 432 | (markdown-mode . visual-line-mode)
|
|
0 commit comments