Move defuns out of top level macro in order to simplify debugging. Follow
consistent naming convention.
--- a/.emacs-my Mon Jun 20 21:32:48 2016 +0300
+++ b/.emacs-my Tue Aug 02 23:42:10 2016 +0300
@@ -2709,7 +2709,7 @@
(setq python-indent 4)
-(defvar my/python-eldoc-setup-code
+(defvar my-python/eldoc-setup-code
"def __PYDOC_get_full_help(obj):
try:
import inspect
@@ -2741,125 +2741,127 @@
return doc"
"Python code to setup documentation retrieval.")
-(defvar my/python-eldoc-string-code "__PYDOC_get_full_help('''%s''')"
+(defvar my-python/eldoc-string-code "__PYDOC_get_full_help('''%s''')"
+ "Python code used to get a string with the documentation of an object.")
+
+(defun my-python/eldoc-at-point (&optional symbol)
+ "Show full docs for symbol at point."
+ (interactive
+ (let ((symbol (python-info-current-symbol t))
+ (enable-recursive-minibuffers t))
+ (list (read-string (if symbol
+ (format "Describe symbol (default %s): " symbol)
+ "Describe symbol: ")
+ nil nil symbol))))
+ (let ( (python-eldoc-string-code my-python/eldoc-string-code)
+ (python-eldoc-setup-code my-python/eldoc-setup-code) )
+ (switch-to-buffer (get-buffer-create "*Python-doc*"))
+ (read-only-mode -1)
+ (buffer-disable-undo)
+ (erase-buffer)
+ (insert (python-eldoc--get-doc-at-point symbol))
+ (goto-char (point-min))
+ (when (re-search-forward "^u?['\"]" (line-end-position) t)
+ (replace-match ""))
+ (while (re-search-forward "\\\\n" nil t)
+ (replace-match "\n"))
+ (goto-char (point-min))
+ (while (re-search-forward "\\\\'" nil t)
+ (replace-match "['\"]"))
+ (goto-char (point-max))
+ (when (eq ?' (char-before))
+ (delete-char -1))
+ (read-only-mode 1)
+ (goto-char (point-min))))
+
+(defvar my-python/eldoc-string-code2 "help(%s); pass"
"Python code used to get a string with the documentation of an object.")
-(defvar my/python-eldoc-string-code2 "help(%s); pass"
- "Python code used to get a string with the documentation of an object.")
+(defun my-python/eldoc-at-point2 (&optional symbol)
+ "Show full docs for symbol at point."
+ (interactive
+ (let ((symbol (python-info-current-symbol t))
+ (enable-recursive-minibuffers t))
+ (list (read-string (if symbol
+ (format "Describe symbol (default %s): " symbol)
+ "Describe symbol: ")
+ nil nil symbol))))
+ (let ( )
+ (switch-to-buffer (get-buffer-create "*Python-doc*"))
+ (read-only-mode -1)
+ (buffer-disable-undo)
+ (erase-buffer)
+ (insert (python-shell-send-string-no-output (format my-python/eldoc-string-code2 symbol) (python-shell-get-process)))
+ (goto-char (point-min))
+ (when (re-search-forward "^u?'" (line-end-position) t)
+ (replace-match ""))
+ (while (re-search-forward "\\\\n" nil t)
+ (replace-match "\n"))
+ (goto-char (point-min))
+ (while (re-search-forward "\\\\'" nil t)
+ (replace-match "'"))
+ (goto-char (point-max))
+ (when (eq ?' (char-before))
+ (delete-char -1))
+ (read-only-mode 1)
+ (goto-char (point-min))))
+
+(defun my-python/send-paragraph ()
+ (interactive)
+ (save-excursion
+ (mark-paragraph)
+ (python-shell-send-region (point) (mark))))
;; For built-in python.el
(my--eval-after-load python
- (add-to-list 'python-shell-setup-codes 'my/python-eldoc-setup-code) ; Used inside (python-shell-send-setup-code)
- (defun my/python-eldoc-at-point (&optional symbol)
- "Show full docs for symbol at point."
- (interactive
- (let ((symbol (python-info-current-symbol t))
- (enable-recursive-minibuffers t))
- (list (read-string (if symbol
- (format "Describe symbol (default %s): " symbol)
- "Describe symbol: ")
- nil nil symbol))))
- (let ( (python-eldoc-string-code my/python-eldoc-string-code)
- (python-eldoc-setup-code my/python-eldoc-setup-code) )
- (switch-to-buffer (get-buffer-create "*Python-doc*"))
- (read-only-mode -1)
- (buffer-disable-undo)
- (erase-buffer)
- (insert (python-eldoc--get-doc-at-point symbol))
- (goto-char (point-min))
- (when (re-search-forward "^u?['\"]" (line-end-position) t)
- (replace-match ""))
- (while (re-search-forward "\\\\n" nil t)
- (replace-match "\n"))
- (goto-char (point-min))
- (while (re-search-forward "\\\\'" nil t)
- (replace-match "['\"]"))
- (goto-char (point-max))
- (when (eq ?' (char-before))
- (delete-char -1))
- (read-only-mode 1)
- (goto-char (point-min))))
- (define-key python-mode-map "\C-c\C-d" 'my/python-eldoc-at-point)
- (defun my/python-eldoc-at-point2 (&optional symbol)
- "Show full docs for symbol at point."
- (interactive
- (let ((symbol (python-info-current-symbol t))
- (enable-recursive-minibuffers t))
- (list (read-string (if symbol
- (format "Describe symbol (default %s): " symbol)
- "Describe symbol: ")
- nil nil symbol))))
- (let ( )
- (switch-to-buffer (get-buffer-create "*Python-doc*"))
- (read-only-mode -1)
- (buffer-disable-undo)
- (erase-buffer)
- (insert (python-shell-send-string-no-output (format my/python-eldoc-string-code2 symbol) (python-shell-get-process)))
- (goto-char (point-min))
- (when (re-search-forward "^u?'" (line-end-position) t)
- (replace-match ""))
- (while (re-search-forward "\\\\n" nil t)
- (replace-match "\n"))
- (goto-char (point-min))
- (while (re-search-forward "\\\\'" nil t)
- (replace-match "'"))
- (goto-char (point-max))
- (when (eq ?' (char-before))
- (delete-char -1))
- (read-only-mode 1)
- (goto-char (point-min))))
- (define-key python-mode-map "\C-c\C-g" 'my/python-eldoc-at-point2)
-
- (defun my-python/send-paragraph ()
- (interactive)
- (save-excursion
- (mark-paragraph)
- (python-shell-send-region (point) (mark))))
+ (add-to-list 'python-shell-setup-codes 'my-python/eldoc-setup-code) ; Used inside (python-shell-send-setup-code)
+ (define-key python-mode-map "\C-c\C-d" 'my-python/eldoc-at-point)
+ (define-key python-mode-map "\C-c\C-g" 'my-python/eldoc-at-point2)
(define-key python-mode-map [?\C-c ?\C-h] 'my-python/send-paragraph))
(defgroup my/python nil
"My Python extentions in Emacs."
:group 'python)
-(defvar my/python-pylint-command "pylint"
+(defvar my-python/pylint-command "pylint"
"Command to run pylint executable.")
-(defvar my/python-pylint-args "-f parseable"
+(defvar my-python/pylint-args "-f parseable"
"Arguments to pass to pylint executable.")
-(defvar my/python-pep8-command "pep8"
+(defvar my-python/pep8-command "pep8"
"Command to run pep8 executable.")
-(defvar my/python-pep8-args ""
+(defvar my-python/pep8-args ""
"Arguments to pass to pep8 executable.")
-(defvar my/python-pyflakes-command "pyflakes"
+(defvar my-python/pyflakes-command "pyflakes"
"Command to run pyflakes executable.")
-(defvar my/python-pyflakes-args ""
+(defvar my-python/pyflakes-args ""
"Arguments to pass to pyflakes executable.")
-(defvar my/python-checker-alist
- '((pylint . (my/python-pylint-command my/python-pylint-args))
- (pep8 . (my/python-pep8-command my/python-pep8-args))
- (pyflakes . (my/python-pyflakes-command my/python-pyflakes-args)))
+(defvar my-python/checker-alist
+ '((pylint . (my-python/pylint-command my-python/pylint-args))
+ (pep8 . (my-python/pep8-command my-python/pep8-args))
+ (pyflakes . (my-python/pyflakes-command my-python/pyflakes-args)))
"Known Python source code checkers.")
-(defcustom my/python-default-checker 'pyflakes
- "Default Python source code checker. See `my/python-checker-alist' for full alist."
+(defcustom my-python/default-checker 'pyflakes
+ "Default Python source code checker. See `my-python/checker-alist' for full alist."
:group 'my/python
- :type (cons 'choice (mapcar (lambda (e) (cons 'const e)) my/python-checker-alist)))
-
-(defvar my/python-check-history nil)
-
-(defun my/python-check (&optional checker)
+ :type (cons 'choice (mapcar (lambda (e) (cons 'const e)) my-python/checker-alist)))
+
+(defvar my-python/check-history nil)
+
+(defun my-python/check (&optional checker)
(interactive
(list
- (completing-read "Select cheker: " (mapcar (lambda (e) (car e)) my/python-checker-alist) nil t (symbol-name my/python-default-checker) 'my/python-check-history)))
+ (completing-read "Select cheker: " (mapcar (lambda (e) (car e)) my-python/checker-alist) nil t (symbol-name my-python/default-checker) 'my-python/check-history)))
(let ( entry )
- (unless (setq entry (cdr (assoc (intern-soft checker) my/python-checker-alist)))
+ (unless (setq entry (cdr (assoc (intern-soft checker) my-python/checker-alist)))
(error "Unknown checker..."))
(compilation-start (format "%s %s %s" (symbol-value (car entry)) (symbol-value (cadr entry)) (shell-quote-argument (buffer-file-name))))))
(my--eval-after-load python
- (define-key python-mode-map [?\C-c ?\C-v] #'my/python-check))
+ (define-key python-mode-map [?\C-c ?\C-v] #'my-python/check))
;; For 3rd party python-mode.el.
(my--eval-after-load python-mode