Last active
February 27, 2018 17:05
-
-
Save twlz0ne/38f9f972574abcb860ee06c33398ee97 to your computer and use it in GitHub Desktop.
Example code to reproduce the issue https://github.com/emacs-lsp/lsp-mode/issues/295
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;; Reproduce the issue https://github.com/emacs-lsp/lsp-mode/issues/295 | |
;;; Usage: /path/to/emacs -nw -Q -l /path/to/test-lsp-mode-issue295.el | |
;;; Date: 2018-02-27_23.24.41 | |
(toggle-debug-on-error) | |
;; ------------------------------------------------------------------ | |
(setq user-emacs-directory (format "~/.emacs.d/%s/%s/" (file-name-base load-file-name) emacs-version)) | |
(setq package-user-dir (concat user-emacs-directory "elpa/")) | |
(unless (load (concat "~/.emacs.d/elpa.el") t) | |
(setq package-archives | |
'(("gnu" . "https://elpa.gnu.org/packages/") | |
("melpa" . "https://melpa.org/packages/")))) | |
(package-initialize) | |
(defun require-packages (&rest packages) | |
(dolist (pkg packages) | |
(unless (package-installed-p pkg) | |
(package-refresh-contents) | |
(package-install pkg)) | |
(require pkg))) | |
;; ------------------------------------------------------------------ | |
(require-packages | |
'lsp-mode | |
'lsp-python) | |
(defun make-test-file () | |
(let ((test-file (concat (make-temp-file "test-lsp-mode-issue295--" 'dir "/") "main.py"))) | |
(with-temp-buffer | |
(insert | |
(format | |
"\"\"\"Generated at %s.\"\"\"" (format-time-string "%Y-%m-%d %H:%M"))) | |
(write-region (point-min) (point-max) test-file)) | |
test-file)) | |
(add-hook 'prog-major-mode 'lsp-prog-major-mode-enable) | |
(add-hook 'python-mode-hook 'lsp-python-enable) | |
(add-to-list 'auto-mode-alist '("\\.py\\'" . python-mode)) | |
(add-hook 'after-init-hook | |
(lambda () | |
(find-file (make-test-file)) | |
)) | |
(run-hooks 'after-init-hook) | |
;;; test-lsp-mode-issue295.el ends here |
Author
twlz0ne
commented
Feb 27, 2018
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment