;;;;;;;;;;;; ;; Python ;; ;;;;;;;;;;;; (setq py-python-command "/usr/bin/python") (setq auto-mode-alist (cons '("\\.py$" . python-mode) auto-mode-alist)) (setq interpreter-mode-alist (cons '("python" . python-mode) interpreter-mode-alist)) (autoload 'python-mode "python-mode" "Python editing mode." t) ;; show pydoc ;; http://www.emacswiki.org/cgi-bin/wiki/PythonMode (defun my-python-documentation (w) "Launch PyDOC on the Word at Point" (interactive (list (let* ((word (thing-at-point 'word)) (input (read-string (format "pydoc entry%s: " (if (not word) "" (format " (default %s)" word)))))) (if (string= input "") (if (not word) (error "No pydoc args given") word) ;sinon word input)))) ;sinon input (shell-command (concat py-python-command " -c \"from pydoc import help;help(\'" w "\')\"") "*PYDOCS*") (view-buffer-other-window "*PYDOCS*" t 'kill-buffer-and-window)) ;;to show the pydoc help on the word at point (add-hook 'python-mode-hook (function (lambda () (local-set-key [(control f1)] 'my-python-documentation) ))) ;;para indentar o completar con tab (add-hook 'python-mode-hook (function (lambda () (local-set-key (kbd "") 'indent-or-complete) ))) (add-hook 'python-mode-hook (function (lambda () (local-set-key (kbd "C-x #") 'comment-or-uncomment-region) ))) ;;pdb setup, note the python version (setq pdb-path '/usr/bin/pdb gud-pdb-command-name (symbol-name pdb-path)) (defadvice pdb (before gud-query-cmdline activate) "Provide a better default command line when called interactively." (interactive (list (gud-query-cmdline pdb-path (file-name-nondirectory buffer-file-name))))) ;; para usar pdb con F8 (add-hook 'python-mode-hook (function (lambda () (local-set-key (kbd "") 'pdb) ))) ;; para usar pydoc (add-hook 'python-mode-hook '(lambda () (eldoc-mode 1)) t) ;;show tab in python mode (add-hook 'python-mode-hook (lambda () (font-lock-add-keywords nil my-extra-keywords))) ;; para mostrar el trailing whitespace (add-hook 'python-mode-hook (lambda () (setq show-trailing-whitespace t))) ;; usar pylint (when (load "flymake" t) (defun flymake-pylint-init () (let* ((temp-file (flymake-init-create-temp-buffer-copy 'flymake-create-temp-inplace)) (local-file (file-relative-name temp-file (file-name-directory buffer-file-name)))) (list "epylint" (list local-file)))) (add-to-list 'flymake-allowed-file-name-masks '("\\.py\\'" flymake-pylint-init))) ;; (require 'pymacs) ;; (require 'pycomplete) ;; (autoload 'pymacs-load "ropemacs" "rope-") ;; (autoload 'pymacs-load "pymacs" nil t) ;; (autoload 'pymacs-eval "pymacs" nil t) ;; (autoload 'pymacs-apply "pymacs") ;; (autoload 'pymacs-call "pymacs") ;;(rope-init) ;; para autocompletar los cierres de parentesis o de string ;;(add-hook 'python-mode-hook ;; (lambda () ;; (define-key python-mode-map "\"" 'electric-pair) ;; (define-key python-mode-map "\'" 'electric-pair) ;; (define-key python-mode-map "(" 'electric-pair) ;; (define-key python-mode-map "[" 'electric-pair) ;; (define-key python-mode-map "{" 'electric-pair))) ;;(defun electric-pair () ;; "Insert character pair without sournding spaces" ;; (interactive) ;; (let (parens-require-spaces) ;; (insert-pair)))