Kaydet (Commit) 5e21cb0b authored tarafından Barry Warsaw's avatar Barry Warsaw

(py-emacs-features): Test for working make-temp-name, which is broken

on NTEmacs 19.34.6.

(py-serial-number): New variable.

(py-execute-region): If make-temp-name is broken, simply append a
serial number to the string "python-" to get a temporary file name.
It's possible concurrent NTEmacs can step on each others toes, but it
makes no sense to further coddle a busted NTEmacs.
üst 2bd358c9
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
;; Created: Feb 1992 ;; Created: Feb 1992
;; Keywords: python languages oop ;; Keywords: python languages oop
(defconst py-version "3.0" (defconst py-version "$Revision$"
"`python-mode' version number.") "`python-mode' version number.")
;; This software is provided as-is, without express or implied ;; This software is provided as-is, without express or implied
...@@ -231,16 +231,19 @@ the Emacs bell is also rung as a warning." ...@@ -231,16 +231,19 @@ the Emacs bell is also rung as a warning."
;; ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ;; ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
;; NO USER DEFINABLE VARIABLES BEYOND THIS POINT ;; NO USER DEFINABLE VARIABLES BEYOND THIS POINT
(defconst py-emacs-features () (defconst py-emacs-features
(let (features)
;; NTEmacs 19.34.6 has a broken make-temp-name; it always returns
;; the same string.
(let ((tmp1 (make-temp-name ""))
(tmp2 (make-temp-name "")))
(if (string-equal tmp1 tmp2)
(push 'broken-temp-names features)))
;; return the features
features)
"A list of features extant in the Emacs you are using. "A list of features extant in the Emacs you are using.
There are many flavors of Emacs out there, each with different There are many flavors of Emacs out there, each with different
features supporting those needed by CC Mode. Here's the current features supporting those needed by CC Mode.")
supported list, along with the values for this variable:
XEmacs 19: ()
XEmacs 20: ()
Emacs 19: ()
")
(defvar python-font-lock-keywords (defvar python-font-lock-keywords
(let* ((keywords '("and" "assert" "break" "class" (let* ((keywords '("and" "assert" "break" "class"
...@@ -1009,6 +1012,9 @@ filter." ...@@ -1009,6 +1012,9 @@ filter."
(setq py-file-queue nil) (setq py-file-queue nil)
(message "%d pending files de-queued." n))) (message "%d pending files de-queued." n)))
;; only used when (memq 'broken-temp-names py-emacs-features)
(defvar py-serial-number 0)
(defun py-execute-region (start end &optional async) (defun py-execute-region (start end &optional async)
"Execute the the region in a Python interpreter. "Execute the the region in a Python interpreter.
The region is first copied into a temporary file (in the directory The region is first copied into a temporary file (in the directory
...@@ -1032,7 +1038,11 @@ is inserted at the end. See also the command `py-clear-queue'." ...@@ -1032,7 +1038,11 @@ is inserted at the end. See also the command `py-clear-queue'."
(or (< start end) (or (< start end)
(error "Region is empty")) (error "Region is empty"))
(let* ((proc (get-process "Python")) (let* ((proc (get-process "Python"))
(temp (make-temp-name "python")) (temp (if (memq 'broken-temp-names py-emacs-features)
(prog1
(format "python-%d" py-serial-number)
(setq py-serial-number (1+ py-serial-number)))
(make-temp-name "python")))
(file (concat (file-name-as-directory py-temp-directory) temp)) (file (concat (file-name-as-directory py-temp-directory) temp))
(outbuf "*Python Output*")) (outbuf "*Python Output*"))
(write-region start end file nil 'nomsg) (write-region start end file nil 'nomsg)
......
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