summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBarry Warsaw <barry@python.org>1997-11-05 18:41:11 (GMT)
committerBarry Warsaw <barry@python.org>1997-11-05 18:41:11 (GMT)
commit5e21cb0bfb116658bc1c566fc284408c90dcbdad (patch)
treeebd314418c7147c702a23d42c1e7c007e0809b5f
parent2bd358c9fd0e3357f24d6d1232583a2436a8b10f (diff)
downloadcpython-5e21cb0bfb116658bc1c566fc284408c90dcbdad.zip
cpython-5e21cb0bfb116658bc1c566fc284408c90dcbdad.tar.gz
cpython-5e21cb0bfb116658bc1c566fc284408c90dcbdad.tar.bz2
(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.
-rw-r--r--Misc/python-mode.el30
1 files changed, 20 insertions, 10 deletions
diff --git a/Misc/python-mode.el b/Misc/python-mode.el
index 94dadf6..dc6e738 100644
--- a/Misc/python-mode.el
+++ b/Misc/python-mode.el
@@ -8,7 +8,7 @@
;; Created: Feb 1992
;; Keywords: python languages oop
-(defconst py-version "3.0"
+(defconst py-version "$Revision$"
"`python-mode' version number.")
;; This software is provided as-is, without express or implied
@@ -231,16 +231,19 @@ the Emacs bell is also rung as a warning."
;; ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
;; 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.
There are many flavors of Emacs out there, each with different
-features supporting those needed by CC Mode. Here's the current
-supported list, along with the values for this variable:
-
- XEmacs 19: ()
- XEmacs 20: ()
- Emacs 19: ()
-")
+features supporting those needed by CC Mode.")
(defvar python-font-lock-keywords
(let* ((keywords '("and" "assert" "break" "class"
@@ -1009,6 +1012,9 @@ filter."
(setq py-file-queue nil)
(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)
"Execute the the region in a Python interpreter.
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'."
(or (< start end)
(error "Region is empty"))
(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))
(outbuf "*Python Output*"))
(write-region start end file nil 'nomsg)