Compare commits
3 commits
f3a55fca68
...
d36c62080b
Author | SHA1 | Date | |
---|---|---|---|
d36c62080b | |||
20eba0d77d | |||
54c44551e8 |
2 changed files with 39 additions and 1 deletions
39
config.org
39
config.org
|
@ -229,6 +229,19 @@
|
|||
'org-babel-load-languages
|
||||
'((restclient . t)))
|
||||
#+end_src
|
||||
* 宏
|
||||
** cond-let
|
||||
终于知道为什么没人想写这个宏了,括号是真得多啊。
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
(defmacro cond-let (forms)
|
||||
(declare (debug t))
|
||||
(if forms
|
||||
`(let* ,(setq varlist (internal--build-bindings (caar forms)))
|
||||
(if-let ,(car (last varlist))
|
||||
,(cadar forms)
|
||||
(cond-let ,(cdr forms))))))
|
||||
#+end_src
|
||||
|
||||
* 杂项
|
||||
=cnfonts= 是一个可以分别设置中英文字体的 bk ,方便对其表格。
|
||||
|
@ -577,3 +590,29 @@
|
|||
(add-hook 'emacs-lisp-mode-hook 'enable-paredit-mode)
|
||||
(add-hook 'cider-repl-mode-hook 'enable-paredit-mode))
|
||||
#+end_src
|
||||
|
||||
* Python
|
||||
自动切换虚拟环境, poetry 包可能在处理远端机器的项目可能会有问题所以从那边抠出来放到这里。
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
(defvar poetry-venv-list '()
|
||||
"List of known poetry virtualenvs.")
|
||||
|
||||
(defun my/track-python-virtualenv (&optional _)
|
||||
(interactive)
|
||||
(when (and buffer-file-name
|
||||
(string= nil (file-remote-p default-directory)))
|
||||
(cond ((locate-dominating-file default-directory "pyproject.toml")
|
||||
(if-let ((poetry-current-project-venv (cdr (assq '(locate-dominating-file default-directory "pyproject.toml") poetry-venv-list))))
|
||||
(when (not (equal python-shell-virtualenv-path poetry-current-project-venv))
|
||||
(pyvenv-activate poetry-current-project-venv))
|
||||
(let ((poetry-project-path (locate-dominating-file default-directory "pyproject.toml"))
|
||||
(poetry-venv-path (s-trim (shell-command-to-string "env -u VIRTUAL_ENV poetry env info -p"))))
|
||||
(pyvenv-activate poetry-venv-path)
|
||||
(add-to-list 'poetry-venv-list (cons poetry-project-path poetry-venv-path)))))
|
||||
((locate-dominating-file default-directory ".venv")
|
||||
(pyvenv-activate (concat (locate-dominating-file default-directory ".venv") ".venv")))
|
||||
(t (pyvenv-deactivate)))))
|
||||
|
||||
(add-to-list 'window-buffer-change-functions 'my/track-python-virtualenv)
|
||||
#+end_src
|
||||
|
|
1
init.el
1
init.el
|
@ -169,7 +169,6 @@
|
|||
(python
|
||||
+lsp
|
||||
+pyright
|
||||
+poetry
|
||||
+tree-sitter) ; beautiful is better than ugly
|
||||
;;qt ; the 'cutest' gui framework ever
|
||||
;;racket ; a DSL for DSLs
|
||||
|
|
Loading…
Reference in a new issue