Commit 046428d3 authored by Fabián Ezequiel Gallina's avatar Fabián Ezequiel Gallina Committed by Fabián Ezequiel Gallina

Added ffap support

parent 1066882c
......@@ -88,8 +88,6 @@
;; (Perhaps) python-check
;; (Perhaps) ffap support
;; (Perhaps) some skeletons (I never use them because of yasnippet)
;;; Code:
......@@ -1430,6 +1428,62 @@ Optional argument JUSTIFY defines if the paragraph should be justified."
(goto-char (line-end-position)))) t)
(t t))))
;;; FFAP
(defvar python-ffap-setup-code
"def __FFAP_get_module_path(module):
import os
path = __import__(module).__file__
if path[-4:] == '.pyc' and os.path.exists(path[0:-1]):
path = path[:-1]
return path
return ''"
"Python code to get a module path.")
(defvar python-ffap-string-code
"Python code used to get a string with the path of a module.")
(defun python-ffap-setup ()
"Send `python-ffap-setup-code' to inferior Python process.
It is specially designed to be added to the
(when python-ffap-setup-code
(let ((temp-file (make-temp-file "py")))
(with-temp-file temp-file
(insert python-ffap-setup-code)
(goto-char (point-min)))
(python-shell-send-file temp-file (get-buffer-process (current-buffer)))
(message (format "FFAP setup code sent.")))))
(defun python-ffap-module-path (module)
"Function for `ffap-alist' to return path for MODULE."
(let ((process (or
(and (eq major-mode 'inferior-python-mode)
(get-buffer-process (current-buffer)))
(if (not process)
(let ((module-file
(format python-ffap-string-code module) process)))
(when module-file
(substring-no-properties module-file 1 -1)
nil nil))))))
(eval-after-load "ffap"
(push '(python-mode . python-ffap-module-path) ffap-alist)
(push '(inferior-python-mode . python-ffap-module-path) ffap-alist)))
(add-hook 'inferior-python-mode-hook
;;; Eldoc
......@@ -1463,7 +1517,7 @@ It is specially designed to be added to the
(goto-char (point-min)))
(python-shell-send-file temp-file (get-buffer-process (current-buffer)))
(message (format "Completion setup code sent.")))))
(message (format "Eldoc setup code sent.")))))
(defun python-eldoc-function ()
"`eldoc-documentation-function' for Python.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment