1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-15 10:30:25 -08:00

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.
This commit is contained in:
Glenn Morris 2014-05-13 23:35:36 -07:00
parent 692a1cc417
commit f0036ec2d2
2 changed files with 28 additions and 15 deletions

View file

@ -1,3 +1,8 @@
2014-05-14 Glenn Morris <rgm@gnu.org>
* printing.el (subst-char-in-string, make-temp-file, pr-get-symbol):
Optimize on Emacs, which has the relevant functions for ages.
2014-05-13 Stefan Monnier <monnier@iro.umontreal.ca>
* simple.el (undo-make-selective-list): Obey undo-no-redo.

View file

@ -1038,20 +1038,27 @@ Please send all bug fixes and enhancements to
;; To avoid compilation gripes
(or (fboundp 'subst-char-in-string) ; hacked from subr.el
(defun subst-char-in-string (fromchar tochar string &optional inplace)
"Replace FROMCHAR with TOCHAR in STRING each time it occurs.
;; Emacs has this since at least 21.1.
(when (featurep 'xemacs)
(or (fboundp 'subst-char-in-string) ; hacked from subr.el
(defun subst-char-in-string (fromchar tochar string &optional inplace)
"Replace FROMCHAR with TOCHAR in STRING each time it occurs.
Unless optional argument INPLACE is non-nil, return a new string."
(let ((i (length string))
(newstr (if inplace string (copy-sequence string))))
(while (> (setq i (1- i)) 0)
(if (eq (aref newstr i) fromchar)
(aset newstr i tochar)))
newstr)))
(let ((i (length string))
(newstr (if inplace string (copy-sequence string))))
(while (> (setq i (1- i)) 0)
(if (eq (aref newstr i) fromchar)
(aset newstr i tochar)))
newstr))))
(or (fboundp 'make-temp-file) ; hacked from subr.el
(defun make-temp-file (prefix &optional dir-flag suffix)
;; Emacs has this since at least 21.1, but the SUFFIX argument
;; (which this file uses) only since 22.1. So the fboundp test
;; wasn't even correct/adequate. Whatever, no-one is using
;; this file on older Emacs version, so it's irrelevant.
(when (featurep 'xemacs)
(or (fboundp 'make-temp-file) ; hacked from subr.el
(defun make-temp-file (prefix &optional dir-flag suffix)
"Create a temporary file.
The returned file name (created by appending some random characters at the end
of 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."
nil)
file)
;; Reset the umask.
(set-default-file-modes umask)))))
(set-default-file-modes umask))))))
(eval-when-compile
@ -3192,9 +3199,10 @@ See `pr-ps-printer-alist'.")
(defalias 'pr-get-symbol
(if (fboundp 'easy-menu-intern) ; hacked from easymenu.el
'easy-menu-intern
(lambda (s) (if (stringp s) (intern s) s))))
(if (featurep 'emacs) 'easy-menu-intern ; since 22.1
(if (fboundp 'easy-menu-intern) ; hacked from easymenu.el
'easy-menu-intern
(lambda (s) (if (stringp s) (intern s) s)))))
(defconst pr-menu-spec