查看“Emacs python”的源代码
←
Emacs python
跳到导航
跳到搜索
因为以下原因,您没有权限编辑本页:
您所请求的操作仅限于该用户组的用户使用:
用户
您可以查看与复制此页面的源代码。
=good Jedi.el - Python auto-completion for Emacs= ==安装el-get插件管理器== <pre> 手动把插件下载下来安装插件的过程费时费力,所以使用el-get来管理和安装插件,就像使用Debian/Ubuntu时使用的apt一样,安装软件省时省力。 编辑~/.emacs文件,加入如下内容: (add-to-list 'load-path "~/.emacs.d/el-get/el-get") (unless (require 'el-get nil 'noerror) (with-current-buffer (url-retrieve-synchronously "https://raw.github.com/dimitri/el-get/master/el-get-install.el") (goto-char (point-max)) (eval-print-last-sexp))) (el-get 'sync) (add-hook 'python-mode-hook 'jedi:setup) (setq jedi:complete-on-dot t) ;; 保存,随后启动Emacs,它会自动安装el-get;这个过程可能会比较长,不过我在公司试了 不算慢 毕竟 上了github.com的 </pre> === trouble === <pre> emacs --debug-init Debugger entered--Lisp error: (error "Could not create connection to raw.github.com:443") 解决办法 在另外一台可以的机器全同步就行啦 rsync -avz .emacs evan@192.168.0.186:/home/evan/ rsync -avz .emacs.d/ evan@192.168.0.186:/home/evan/.emacs.d/ </pre> ==安装jedi == <pre> 按照官网说法,jedi是一个用于IDE和调试器的Python静态分析工具;之前我们安装了el-get,因此安装jedi就轻松许多,在Emacs下键入(其中『RET』表示回车): 也就是要回车两次 第一次回车后出现 Install package: 输入 软件名 jedi 再回车 M-x el-get-install RET jedi RET 如果el-get 不然 就用 M-x package-install RET jedi RET or 如果没有安装virtualenv,请在终端中使用pip安装: pip install virtualenv 最后在Emacs中键入: M-x jedi:install-server </pre> ==基本配置加强== <pre> ; place on ~/.emacs (defun my-python-mode-config () (setq python-indent-offset 4 python-indent 4 indent-tabs-mode nil default-tab-width 4 ;; 设置 run-python 的参数 python-shell-interpreter "ipython" python-shell-interpreter-args "-i" python-shell-prompt-regexp "In \\[[0-9]+\\]: " python-shell-prompt-output-regexp "Out\\[[0-9]+\\]: " python-shell-completion-setup-code "from IPython.core.completerlib import module_completion" python-shell-completion-module-string-code "';'.join(module_completion('''%s'''))\n" python-shell-completion-string-code "';'.join(get_ipython().Completer.all_completions('''%s'''))\n") (add-to-list 'auto-mode-alist '("\\.py\\'" . python-mode)) (hs-minor-mode t) ;开启 hs-minor-mode 以支持代码折叠 (auto-fill-mode 0) ;关闭 auto-fill-mode,拒绝自动折行 ;(whitespace-mode t) ;开启 whitespace-mode 对制表符和行为空格高亮 ;(hl-line-mode t) ;开启 hl-line-mode 对当前行进行高亮 (pretty-symbols-mode t) ;开启 pretty-symbols-mode 将 lambda 显示成希腊字符 λ (set (make-local-variable 'electric-indent-mode) nil)) ; 建议不要关闭, 关闭自动缩进 ) (add-hook 'python-mode-hook 'my-python-mode-config) ;jq </pre> ==trouble == Can’t guess python-indent-offset, using defaults: 4 https://segmentfault.com/q/1010000000266278 https://www.cnblogs.com/wangxiaole/articles/7643029.html 在家里如下 这可以用package普通方法安装 Warning (initialization): An error occurred while loading ‘/home/evan/.emacs’: error: Could not create connection to raw.github.com:443 看来要ss == see also== [https://my.oschina.net/u/1453148/blog/552056 为Emacs配置Python开发环境] [http://tkf.github.io/emacs-jedi/latest/ Jedi.el - Python auto-completion for Emacs] [http://www.zmonster.me/2017/09/16/emacs-python-configuration.html 加强 Emacs 的 Python3 开发环境配置] =00用这个= <pre> Usage 回车是 自动补 ctrl+n 才是另起一个新行 没格式关联的 #notice 这个有个问题 第一个func 和第二个func时 会多出4个空格 为什么 呢 https://github.com/gabrielelanaro/emacs-for-python 最省力的安装是,直接安装别人整合好的一个配置emacs-for-python cd ~/.emacs.d/ git clone https://github.com/gabrielelanaro/emacs-for-python.git 直接下载下来,并在.emacs文件中添加: (load-file "~/.emacs.d/emacs-for-python/epy-init.el") ;;配置代码错误检测,添加: (epy-setup-checker "pyflakes %f") vim ~/.emacs.d/emacs-for-python/epy-init.el ;; 添加显示行号 试过 这个一定有效果 (global-linum-mode 1) 哈哈 不过我觉得还是自己一个个安装比较好,不然哪天来个emacs-for-clojure,后天在来个emacs-for-ruby之类的难保里面的package没有重复冲突的 </pre> =11= <pre> touch .emacs.d/init.el cat .emacs.d/init.el ;; init.el --- Emacs configuration ;; Set OSX function key as Meta ;; INSTALL PACKAGES ;; -------------------------------------- (require 'package) (add-to-list 'package-archives '("elpy" . "http://jorgenschaefer.github.io/packages/")) (add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t) ;; activate all packages (package-initialize) ;; fetch the list of packages available (unless package-archive-contents (package-refresh-contents)) ;; define list of packages to install (defvar myPackages '(better-defaults material-theme exec-path-from-shell elpy pyenv-mode)) ;; install all packages in list (mapc #'(lambda (package) (unless (package-installed-p package) (package-install package))) myPackages) ;; BASIC CUSTOMIZATION ;; -------------------------------------- (setq inhibit-startup-message t) ;; hide the startup message (load-theme 'material t) ;; load material theme (global-linum-mode t) ;; enable line numbers globally (setq linum-format "%4d \u2502 ") ;; format line number spacing ;; Allow hash to be entered (global-set-key (kbd "M-3") '(lambda () (interactive) (insert "#"))) ;; Use shell's $PATH (exec-path-from-shell-copy-env "PATH") ;; define list of packages to install (defvar myPackages '(better-defaults material-theme elpy)) (elpy-enable) (pyenv-mode) (setq python-shell-interpreter "ipython" python-shell-interpreter-args "-i --simple-prompt") ;; init.el ends here (custom-set-variables ;; custom-set-variables was added by Custom. ;; If you edit it by hand, you could mess it up, so be careful. ;; Your init file should contain only one such instance. ;; If there is more than one, they won't work right. '(package-selected-packages (quote (pyenv-mode elpy exec-path-from-shell material-theme better-defaults)))) (custom-set-faces ;; custom-set-faces was added by Custom. ;; If you edit it by hand, you could mess it up, so be careful. ;; Your init file should contain only one such instance. ;; If there is more than one, they won't work right. ) </pre> =see also= ==要看的py== [https://my.oschina.net/alphajay/blog/70965 Emacs中打造强大的Python IDE] [http://codingpy.com/article/emacs-the-best-python-editor/ Emacs:最好的Python编辑器] [https://realpython.com/emacs-the-best-python-editor/ Emacs – The Best Python Editor] http://matrixlyb.is-programmer.com/posts/100431.html https://github.com/redguardtoo/emacs.d https://www.cnblogs.com/kunyuanjushi/p/5951405.html [http://wiki.linuxchina.net/index.php?title=Emacs%E5%85%A5%E9%97%A8#package linuxchina package] [https://gist.github.com/widdowquinn/987164746810f4e8b88402628b387d39 Turning emacs into a Python IDE] [https://www.emacswiki.org/emacs/PythonProgrammingInEmacs PythonProgrammingInEmacs] [http://clojure.iteye.com/blog/1724910 Emacs配置Python IDE] [http://matrixlyb.is-programmer.com/posts/100431.html 赋闲在家的TO DO LIST Emacs入门指南及配置Python开发IDE] [[category:emacs]]
返回至
Emacs python
。
导航菜单
个人工具
登录
名字空间
页面
讨论
变种
视图
阅读
查看源代码
查看历史
更多
搜索
导航
首页
我的导航
关于我
shell
python
ops
linuxchina.net
blog.linuxchina
最近更改
随机页面
帮助
工具
链入页面
相关更改
特殊页面
页面信息