From: Noam Postavsky Date: Wed, 28 Feb 2018 00:44:35 +0000 (-0500) Subject: Fix python.el for Emacs 24, bump ELPA version to 0.26.1 (Bug#30633) X-Git-Tag: emacs-27.0.90~5604 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=2291d9ae888961ce7e4f22675244f535db54df56;p=emacs.git Fix python.el for Emacs 24, bump ELPA version to 0.26.1 (Bug#30633) Since python.el is distributed via GNU ELPA, it should be functional in earlier Emacs versions. Also fix some compile warnings. * lisp/progmodes/python.el: Bump version to 0.26.1. Define `prog-first-column' and `file-local-name' also at compile time, as needed. (inferior-python-mode-hook): Declare for the benefit of Emacs 24.3. (python-nav-end-of-statement): Fix format string for assertion error. (python-shell-tramp-refresh-process-environment): Don't `function' quote a symbol which might not be fbound. (python-mode): Only use prettify-symbols settings if they're bound. --- diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index 530eb2fb95e..142e6eb3f3c 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el @@ -4,7 +4,7 @@ ;; Author: Fabián E. Gallina ;; URL: https://github.com/fgallina/python.el -;; Version: 0.26 +;; Version: 0.26.1 ;; Package-Requires: ((emacs "24.1") (cl-lib "1.0")) ;; Maintainer: emacs-devel@gnu.org ;; Created: Jul 2010 @@ -287,9 +287,20 @@ ;;; 24.x Compat -(unless (fboundp 'prog-first-column) - (defun prog-first-column () - 0)) +(eval-and-compile + (unless (fboundp 'prog-first-column) + (defun prog-first-column () + 0)) + (unless (fboundp 'file-local-name) + (defun file-local-name (file) + "Return the local name component of FILE. +It returns a file name which can be used directly as argument of +`process-file', `start-file-process', or `shell-command'." + (or (file-remote-p file 'localname) file)))) + +;; In Emacs 24.3 and earlier, `define-derived-mode' does not define +;; the hook variable, it only puts documentation on the symbol. +(defvar inferior-python-mode-hook) ;;; Bindings @@ -1509,7 +1520,8 @@ of the statement." ;; narrowing. (cl-assert (> string-start last-string-end) :show-args - "Overlapping strings detected") + " +Overlapping strings detected (start=%d, last-end=%d)") (goto-char string-start) (if (python-syntax-context 'paren) ;; Ended up inside a paren, roll again. @@ -2148,7 +2160,7 @@ of `exec-path'." (defun python-shell-tramp-refresh-process-environment (vec env) "Update VEC's process environment with ENV." ;; Stolen from `tramp-open-connection-setup-interactive-shell'. - (let ((env (append (when (fboundp #'tramp-get-remote-locale) + (let ((env (append (when (fboundp 'tramp-get-remote-locale) ;; Emacs<24.4 compat. (list (tramp-get-remote-locale vec))) (copy-sequence env))) @@ -5381,8 +5393,10 @@ REPORT-FN is Flymake's callback function." "`outline-level' function for Python mode." (1+ (/ (current-indentation) python-indent-offset)))) - (set (make-local-variable 'prettify-symbols-alist) - python--prettify-symbols-alist) + (when (and (boundp 'prettify-symbols-alist) + (boundp 'python--prettify-symbols-alist)) + (set (make-local-variable 'prettify-symbols-alist) + python--prettify-symbols-alist)) (python-skeleton-add-menu-items)