Skip to content

Instantly share code, notes, and snippets.

@twlz0ne
Last active February 27, 2018 17:05
Show Gist options
  • Save twlz0ne/38f9f972574abcb860ee06c33398ee97 to your computer and use it in GitHub Desktop.
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
;;; 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
@twlz0ne
Copy link
Author

twlz0ne commented Feb 27, 2018

> ls -1 ~/.emacs.d/test-lsp-mode-issue295/27.0.50/elpa/
archives/
dash-20180206.2124/
epl-20180205.1249/
flycheck-20180224.1046/
lsp-mode-20180224.246/
lsp-python-20171021.254/
pkg-info-20150517.443/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment