0

The guide I'm following for lsp-emacs wants me to set these options:

;; Enable scala-mode and sbt-mode (use-package scala-mode :mode "\\.s\\(cala\\|bt\\)$") (use-package sbt-mode :commands sbt-start sbt-command :config ;; WORKAROUND: https://github.com/ensime/emacs-sbt-mode/issues/31 ;; allows using SPACE when in the minibuffer (substitute-key-definition 'minibuffer-complete-word 'self-insert-command minibuffer-local-completion-map)) 

but MELPA (and most likely mirrors of MELPA) are blocked on my school's internet, so I've been trying to use load-file with Git Submodules:

;; Enable scala-mode and sbt-mode (load-file "~/.emacs.d/plugins/scala-mode/scala-mode.el" :mode "\\.s\\(cala\\|bt\\)$") (load-file "~/.emacs.d/plugins/sbt-mode/sbt-mode.el" :commands sbt-start sbt-command :config ;; WORKAROUND: https://github.com/ensime/emacs-sbt-mode/issues/31 ;; allows using SPACE when in the minibuffer (substitute-key-definition 'minibuffer-complete-word 'self-insert-command minibuffer-local-completion-map)) 

However, the :colon commands aren't allowed as options on load-file. How can I get these options to work?

1

1 Answer 1

2

TL;DR: install the package use-package, like you did with sbt-mode and scala-mode and be happy. ;)

You can not simply replace use-package with load-file. This are 2 completely different constructs. use-package is a macro, which changes the syntax of elisp, hence it can work with keywords like :mode, :config and so on. load-file is a simple function and has not the ability to change elisp's syntax.

use-package, when avaluated is expanded and its block is replaced by various lisp constructs.

:mode expands to stuff like:

 (add-to-list 'auto-mode-alist '("\\.s\\(cala\\|bt\\)$" . scala-mode))) 

:config expands to stuff like:

 (eval-after-load 'sbt-mode (progn .... )) 

:commands is replaced with stuff like:

 (autoload #'sbt-start "sbt-mode" nil t)) 

Your expanded use-package contructs look like this:

(progn (defvar use-package--warning81 #'(lambda (keyword err) (let ((msg (format "%s/%s: %s" 'scala-mode keyword (error-message-string err)))) (display-warning 'use-package msg :error)))) (condition-case-unless-debug err (progn (unless (fboundp 'scala-mode) (autoload #'scala-mode "scala-mode" nil t)) (add-to-list 'auto-mode-alist '("\\.s\\(cala\\|bt\\)$" . scala-mode))) (error (funcall use-package--warning81 :catch err)))) (progn (defvar use-package--warning82 #'(lambda (keyword err) (let ((msg (format "%s/%s: %s" 'sbt-mode keyword (error-message-string err)))) (display-warning 'use-package msg :error)))) (condition-case-unless-debug err (progn (unless (fboundp 'sbt-start) (autoload #'sbt-start "sbt-mode" nil t)) (unless (fboundp 'sbt-command) (autoload #'sbt-command "sbt-mode" nil t)) (eval-after-load 'sbt-mode '(condition-case-unless-debug err (progn (substitute-key-definition 'minibuffer-complete-word 'self-insert-command minibuffer-local-completion-map) t) (error (funcall use-package--warning82 :config err))))) (error (funcall use-package--warning82 :catch err)))) 

But you do not really need this, because it is used only to defer loading of a package.

You could just require the packages and set their options either with customize or setq.

2
  • So, once I add use-package as a git submodule like I did with the others, how do I load the other git submodules? Commented Apr 25, 2019 at 12:04
  • Ah, use-package just finds them if I disable ensure mode. Commented Apr 25, 2019 at 12:21

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.