aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGlenn Morris2014-05-13 23:35:36 -0700
committerGlenn Morris2014-05-13 23:35:36 -0700
commitf0036ec2d210796144fb41381a0841130734e13a (patch)
tree2a871b70acdbf1f7a0dcd9b19a1766359ca8d832
parent692a1cc41786d43f61a3dd8e0024dcd602ef06b8 (diff)
downloademacs-f0036ec2d210796144fb41381a0841130734e13a.tar.gz
emacs-f0036ec2d210796144fb41381a0841130734e13a.zip
Optimize away some compat-cruft in printing.el
* lisp/printing.el (subst-char-in-string, make-temp-file, pr-get-symbol): Optimize on Emacs, which has the relevant functions for ages.
-rw-r--r--lisp/ChangeLog5
-rw-r--r--lisp/printing.el42
2 files changed, 30 insertions, 17 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index cd2ce4e8749..0b257444662 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,8 @@
12014-05-14 Glenn Morris <rgm@gnu.org>
2
3 * printing.el (subst-char-in-string, make-temp-file, pr-get-symbol):
4 Optimize on Emacs, which has the relevant functions for ages.
5
12014-05-13 Stefan Monnier <monnier@iro.umontreal.ca> 62014-05-13 Stefan Monnier <monnier@iro.umontreal.ca>
2 7
3 * simple.el (undo-make-selective-list): Obey undo-no-redo. 8 * simple.el (undo-make-selective-list): Obey undo-no-redo.
diff --git a/lisp/printing.el b/lisp/printing.el
index 0393746f8a5..de7958ea0e6 100644
--- a/lisp/printing.el
+++ b/lisp/printing.el
@@ -1038,20 +1038,27 @@ Please send all bug fixes and enhancements to
1038;; To avoid compilation gripes 1038;; To avoid compilation gripes
1039 1039
1040 1040
1041(or (fboundp 'subst-char-in-string) ; hacked from subr.el 1041;; Emacs has this since at least 21.1.
1042 (defun subst-char-in-string (fromchar tochar string &optional inplace) 1042(when (featurep 'xemacs)
1043 "Replace FROMCHAR with TOCHAR in STRING each time it occurs. 1043 (or (fboundp 'subst-char-in-string) ; hacked from subr.el
1044 (defun subst-char-in-string (fromchar tochar string &optional inplace)
1045 "Replace FROMCHAR with TOCHAR in STRING each time it occurs.
1044Unless optional argument INPLACE is non-nil, return a new string." 1046Unless optional argument INPLACE is non-nil, return a new string."
1045 (let ((i (length string)) 1047 (let ((i (length string))
1046 (newstr (if inplace string (copy-sequence string)))) 1048 (newstr (if inplace string (copy-sequence string))))
1047 (while (> (setq i (1- i)) 0) 1049 (while (> (setq i (1- i)) 0)
1048 (if (eq (aref newstr i) fromchar) 1050 (if (eq (aref newstr i) fromchar)
1049 (aset newstr i tochar))) 1051 (aset newstr i tochar)))
1050 newstr))) 1052 newstr))))
1051 1053
1052 1054
1053(or (fboundp 'make-temp-file) ; hacked from subr.el 1055;; Emacs has this since at least 21.1, but the SUFFIX argument
1054 (defun make-temp-file (prefix &optional dir-flag suffix) 1056;; (which this file uses) only since 22.1. So the fboundp test
1057;; wasn't even correct/adequate. Whatever, no-one is using
1058;; this file on older Emacs version, so it's irrelevant.
1059(when (featurep 'xemacs)
1060 (or (fboundp 'make-temp-file) ; hacked from subr.el
1061 (defun make-temp-file (prefix &optional dir-flag suffix)
1055 "Create a temporary file. 1062 "Create a temporary file.
1056The returned file name (created by appending some random characters at the end 1063The returned file name (created by appending some random characters at the end
1057of PREFIX, and expanding against `temporary-file-directory' if necessary), 1064of PREFIX, and expanding against `temporary-file-directory' if necessary),
@@ -1086,7 +1093,7 @@ If SUFFIX is non-nil, add that at the end of the file name."
1086 nil) 1093 nil)
1087 file) 1094 file)
1088 ;; Reset the umask. 1095 ;; Reset the umask.
1089 (set-default-file-modes umask))))) 1096 (set-default-file-modes umask))))))
1090 1097
1091 1098
1092(eval-when-compile 1099(eval-when-compile
@@ -3192,9 +3199,10 @@ See `pr-ps-printer-alist'.")
3192 3199
3193 3200
3194(defalias 'pr-get-symbol 3201(defalias 'pr-get-symbol
3195 (if (fboundp 'easy-menu-intern) ; hacked from easymenu.el 3202 (if (featurep 'emacs) 'easy-menu-intern ; since 22.1
3196 'easy-menu-intern 3203 (if (fboundp 'easy-menu-intern) ; hacked from easymenu.el
3197 (lambda (s) (if (stringp s) (intern s) s)))) 3204 'easy-menu-intern
3205 (lambda (s) (if (stringp s) (intern s) s)))))
3198 3206
3199 3207
3200(defconst pr-menu-spec 3208(defconst pr-menu-spec