Cambiar configuración de python
This commit is contained in:
parent
ae71bb8ca8
commit
c107341a41
|
@ -27,9 +27,7 @@
|
|||
- [[No truncar líneas][No truncar líneas]]
|
||||
- [[Programación][Programación]]
|
||||
- [[Auto identación][Auto identación]]
|
||||
- [[Auto completado][Auto completado]]
|
||||
- [[Magit][Magit]]
|
||||
- [[Aviso de errores con flycheck][Aviso de errores con flycheck]]
|
||||
- [[Insertar licencia][Insertar licencia]]
|
||||
- [[Borrar espacios sobrantes][Borrar espacios sobrantes]]
|
||||
- [[Usar ssh con tramp][Usar ssh con tramp]]
|
||||
|
@ -464,25 +462,6 @@ No está activo.
|
|||
#+BEGIN_SRC emacs-lisp
|
||||
(global-set-key (kbd "RET") 'newline-and-indent)
|
||||
#+END_SRC
|
||||
*** Auto completado
|
||||
:PROPERTIES:
|
||||
:CUSTOM_ID: Auto completado
|
||||
:END:
|
||||
Tiene como dependencia popup.
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
(use-package auto-complete
|
||||
:init
|
||||
(use-package auto-complete-config
|
||||
:init
|
||||
(use-package popup
|
||||
:ensure t
|
||||
)
|
||||
)
|
||||
:config
|
||||
(ac-config-default)
|
||||
:ensure t
|
||||
)
|
||||
#+END_SRC
|
||||
*** Magit
|
||||
:PROPERTIES:
|
||||
:CUSTOM_ID: Magit
|
||||
|
@ -510,41 +489,6 @@ cat `which tgit`
|
|||
torify git "$@"
|
||||
#+END_SRC
|
||||
|
||||
*** Aviso de errores con flycheck
|
||||
:PROPERTIES:
|
||||
:CUSTOM_ID: Aviso de errores con flycheck
|
||||
:END:
|
||||
Solo me interesa para python-mode.
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
(use-package flycheck
|
||||
:config
|
||||
(setq flycheck-global-modes '(python-mode))
|
||||
(global-flycheck-mode)
|
||||
:diminish flycheck-mode
|
||||
:ensure t
|
||||
)
|
||||
#+END_SRC
|
||||
|
||||
Necesita pylint para funcionar mejor, por lo que hay que configurarlo minimamente.
|
||||
#+BEGIN_SRC sh :tangle no
|
||||
# Lo instalamos
|
||||
sudo pip install pylint
|
||||
# Creamos archivo de configuración
|
||||
pylint --generate-rcfile > ~/.pylintrc
|
||||
#+END_SRC
|
||||
|
||||
Si no se quiere que aparezcan ciertos errores, se busca el código de estos en [[http://pylint-messages.wikidot.com/all-codes][esta web]] y se añade a la variable =disabled= del archivo de configuración.
|
||||
|
||||
Los que yo he desactivado son los siguientes:
|
||||
|
||||
#+BEGIN_SRC sh :results code :export results
|
||||
grep "^disable=" ~/.pylintrc
|
||||
#+END_SRC
|
||||
|
||||
#+RESULTS:
|
||||
#+BEGIN_SRC sh
|
||||
disable=setslice-method,delslice-method,nonzero-method,long-builtin,coerce-method,old-division,reload-builtin,filter-builtin-not-iterating,oct-method,old-ne-operator,parameter-unpacking,execfile-builtin,import-star-module-level,no-absolute-import,standarderror-builtin,round-builtin,unicode-builtin,getslice-method,apply-builtin,reduce-builtin,cmp-method,buffer-builtin,metaclass-assignment,file-builtin,indexing-exception,suppressed-message,backtick,dict-view-method,map-builtin-not-iterating,unpacking-in-except,old-octal-literal,using-cmp-argument,raw_input-builtin,coerce-builtin,input-builtin,old-raise-syntax,long-suffix,dict-iter-method,intern-builtin,print-statement,useless-suppression,hex-method,raising-string,cmp-builtin,range-builtin-not-iterating,unichr-builtin,basestring-builtin,xrange-builtin,zip-builtin-not-iterating,next-method-called,C0111,W0702,R0201,W0223,R0913,R0914,C0103,R0902,W0703,R0912
|
||||
#+END_SRC
|
||||
*** Insertar licencia
|
||||
:PROPERTIES:
|
||||
:CUSTOM_ID: Insertar licencia
|
||||
|
@ -605,7 +549,7 @@ Gestiona las ventanas abiertas modificando el tamaño para hacerlo aceptable. Ig
|
|||
;; 'init/no-golden-ratio)
|
||||
|
||||
(golden-ratio-mode t)
|
||||
(setq golden-ratio-exclude-buffer-regexp '("undo-tree" "help" "diff" "calendar" "messages" "Org Agenda" "Agenda Commands" "Org Select" "magit:"))
|
||||
(setq golden-ratio-exclude-buffer-regexp '("undo-tree" "help" "diff" "calendar" "messages" "Org Agenda" "Agenda Commands" "Org Select" "magit:" "Calendar"))
|
||||
:diminish golden-ratio-mode
|
||||
:ensure t
|
||||
)
|
||||
|
@ -1214,28 +1158,21 @@ Cargar =markdown-mode=, usar utf-8 al exportar y asociar el modo a las extension
|
|||
:PROPERTIES:
|
||||
:CUSTOM_ID: python
|
||||
:END:
|
||||
Carga el modo =python-mode.el=, que no es el que trae emacs por defecto, activa la identación inteligente y establece la version de python 3.
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
(unless (require 'ivy nil 'noerror)
|
||||
(sleep-for 5))
|
||||
|
||||
(use-package python-mode
|
||||
La configuración de elpy:
|
||||
#+name: elpy
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
(use-package elpy
|
||||
:init
|
||||
(setq py-smart-indentation t)
|
||||
(setq py-shell-name "/usr/local/bin/python3")
|
||||
(setq py-python-command "python3")
|
||||
(setq elpy-modules '(elpy-module-sane-defaults elpy-module-company elpy-module-eldoc elpy-module-pyvenv))
|
||||
(add-hook 'python-mode-hook 'flycheck-mode)
|
||||
:config (elpy-enable)
|
||||
:ensure t
|
||||
)
|
||||
#+END_SRC
|
||||
|
||||
Carga el pep8. Se ejecuta con =M-x pep8=. Hay que instalar el paquete =pep8= mediante =pip=.
|
||||
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
(use-package pep8
|
||||
:ensure t)
|
||||
)
|
||||
#+END_SRC
|
||||
|
||||
Este paquete muestra una ralla que marca los 79 carácteres, para cumplir con el pep8.
|
||||
#+name: fill-column
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
(use-package fill-column-indicator
|
||||
:init
|
||||
|
@ -1246,17 +1183,31 @@ Este paquete muestra una ralla que marca los 79 carácteres, para cumplir con el
|
|||
)
|
||||
#+END_SRC
|
||||
|
||||
Configura el =virtualenv= y el =virtualenvwrapper=.
|
||||
Corrección con flycheck, mejor que flymake:
|
||||
#+name: flycheck
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
(use-package flycheck
|
||||
:config
|
||||
(setq flycheck-global-modes '(python-mode))
|
||||
(global-flycheck-mode)
|
||||
:diminish flycheck-mode
|
||||
:ensure t
|
||||
)
|
||||
#+END_SRC
|
||||
|
||||
Configura virtualenvwrapper para eshell, lo que habilita la orden =workon= y demás.
|
||||
#+name: virtualenvwrapper
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
(use-package virtualenvwrapper
|
||||
:init
|
||||
(setq venv-location "~/.env/")
|
||||
(setq venv-location "~/.virtualenvs/")
|
||||
(venv-initialize-eshell)
|
||||
(venv-initialize-interactive-shells)
|
||||
:ensure t
|
||||
)
|
||||
#+END_SRC
|
||||
|
||||
|
||||
|
||||
** web-mode
|
||||
:PROPERTIES:
|
||||
:CUSTOM_ID: web-mode
|
||||
|
@ -1337,10 +1288,10 @@ No está activo.
|
|||
)
|
||||
#+END_SRC
|
||||
** po-mode
|
||||
|
||||
:PROPERTIES:
|
||||
:CUSTOM_ID: po-mode
|
||||
:END:
|
||||
|
||||
#+name: po-mode
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
(use-package po-mode
|
||||
|
@ -1675,34 +1626,34 @@ Las funciones cutres son mías.
|
|||
(setq org2nikola-output-root-directory "~/Documentos/blog/")
|
||||
(setq org2nikola-use-verbose-metadata t)
|
||||
|
||||
(defun blog/build ()
|
||||
(defun org2nikola/build ()
|
||||
"Construye la web."
|
||||
(interactive)
|
||||
(compile (concat "source ~/.env/blog/bin/activate; cd " org2nikola-output-root-directory "; bash scripts/construir.sh; deactivate")))
|
||||
(compile (concat "source ~/.virtualenvs/blog/bin/activate; cd " org2nikola-output-root-directory "; bash scripts/construir.sh; deactivate")))
|
||||
|
||||
(defun blog/serve ()
|
||||
(defun org2nikola/serve ()
|
||||
"Sirve la web en un servidor web interno."
|
||||
(interactive)
|
||||
(compile (concat "source ~/.env/blog/bin/activate; cd " org2nikola-output-root-directory "; qutebrowser --target tab-bg-silent http://localhost:8000 2> /dev/null &; nikola serve; deactivate;")))
|
||||
(compile (concat "source ~/.virtualenvs/blog/bin/activate; cd " org2nikola-output-root-directory "; qutebrowser --target tab-bg-silent http://localhost:8000 2> /dev/null &; nikola serve; deactivate;")))
|
||||
|
||||
(defun blog/clean ()
|
||||
(defun org2nikola/clean ()
|
||||
"Borra la carpeta output para empezar de cero."
|
||||
(interactive)
|
||||
(compile (concat "source ~/.env/blog/bin/activate; cd " org2nikola-output-root-directory "; nikola clean; deactivate")))
|
||||
(compile (concat "source ~/.virtualenvs/blog/bin/activate; cd " org2nikola-output-root-directory "; nikola clean; deactivate")))
|
||||
|
||||
(defun blog/deploy ()
|
||||
(defun org2nikola/deploy ()
|
||||
"Despliega la web al momento preguntando por el nombre del commit."
|
||||
(interactive)
|
||||
(compile (concat "source ~/.env/blog/bin/activate; cd " org2nikola-output-root-directory "; nikola deploy; deactivate;")))
|
||||
(compile (concat "source ~/.virtualenvs/blog/bin/activate; cd " org2nikola-output-root-directory "; nikola deploy; deactivate;")))
|
||||
|
||||
(defun blog/autodeploy ()
|
||||
(defun org2nikola/autodeploy ()
|
||||
"Despliega la web automáticamente el día designado."
|
||||
(interactive)
|
||||
(insert
|
||||
(compile (concat "/usr/local/bin/programa-post " (org-read-date)))))
|
||||
|
||||
;; Las dos siguientes funciones probablemente no sirvan a nadie
|
||||
(defun blog/url-post ()
|
||||
(defun org2nikola/url-post ()
|
||||
"Devuelve el enlace del articulo en el que esté el cursor."
|
||||
(interactive)
|
||||
(setq url (concat "https://daemons.cf/posts/"
|
||||
|
@ -1711,7 +1662,7 @@ Las funciones cutres son mías.
|
|||
(kill-new url)
|
||||
)
|
||||
|
||||
(defun blog/url-config ()
|
||||
(defun org2nikola/url-config ()
|
||||
"Devuelve el enlace de la parte de la configuración en la que esté el cursor."
|
||||
(interactive)
|
||||
(setq url (concat "https://daemons.cf/stories/mi-configuracin-de-emacs/#"
|
||||
|
@ -1842,14 +1793,17 @@ A diferencia de la función de writequit, esta establece el título como custom\
|
|||
("b" "Idea per article" entry (file+headline "~/Documentos/blog/Articulos/articulos.org" "Ideas")
|
||||
"** TODO %?\n:PROPERTIES:\n:CREATED: %u\n:END:\n")
|
||||
("p" "Personal" entry (file+headline "~/Documentos/org/index.org" "Personal")
|
||||
"* TODO %? \n:PROPERTIES:\n:CREATED: %u\n:END:\nSCHEDULED: %(org-insert-time-stamp (org-read-date nil t \"+0d\"))\n")
|
||||
"** TODO %? \n:PROPERTIES:\n:CREATED: %u\n:END:\nSCHEDULED: %(org-insert-time-stamp (org-read-date nil t \"+0d\"))\n")
|
||||
("t" "Treball" entry (file+headline "~/Documentos/org/index.org" "Treball")
|
||||
"* TODO %? \n:PROPERTIES:\n:CREATED: %u\n:END:\nSCHEDULED: %(org-insert-time-stamp (org-read-date nil t \"+0d\"))\n")
|
||||
"** TODO %? \n:PROPERTIES:\n:CREATED: %u\n:END:\nSCHEDULED: %(org-insert-time-stamp (org-read-date nil t \"+0d\"))\n")
|
||||
("w" "Marcadors" entry (file "~/Documentos/org/web.org")
|
||||
"* %x\n %U\n %c"
|
||||
:empty-lines 1)
|
||||
("v" "Relacionat amb els VPS / chustaserver" entry (file+headline "~/Documentos/org/index.org" "VPS")
|
||||
"* TODO %?\n:PROPERTIES:\n:CREATED: %u\n:END:\n")
|
||||
("e" "Coses a fer amb emacs" entry (file+headline "~/Documentos/org/index.org" "Emacs")
|
||||
"** TODO %? \n:PROPERTIES:\n:CREATED: %u\n:END:\nSCHEDULED: %(org-insert-time-stamp (org-read-date nil t \"+0d\"))\n")
|
||||
|
||||
))
|
||||
|
||||
(setq org-capture-templates
|
||||
|
@ -1878,6 +1832,8 @@ A diferencia de la función de writequit, esta establece el título como custom\
|
|||
'(("b" . "Blog")
|
||||
("bi" "Idees per article" ((todo "TODO|IN-PROGRESS" ((org-agenda-files '("~/Documentos/blog/Articulos/articulos.org"))))))
|
||||
("bp" "Articles llestos per a publicar" ((todo "READY|PROGRAMMED" ((org-agenda-files '("~/Documentos/blog/Articulos/articulos.org"))))))
|
||||
("bc" "Articles cancel·lats" ((todo "CANCELLED" ((org-agenda-files '("~/Documentos/blog/Articulos/articulos.org"))))))
|
||||
("bf" "Articles publicats" ((todo "DONE" ((org-agenda-files '("~/Documentos/blog/Articulos/articulos.org"))))))
|
||||
("p" . "Projectes Personals")
|
||||
("pp" "Projectes Personals" tags-todo "projectes")
|
||||
("pg" "General" tags-todo "general")
|
||||
|
|
Loading…
Reference in New Issue