lisp-slashify, prin1-to-string, and supported emacs versions
Bob Rogers <[email protected]>
| Newsgroups | gmane.lisp.ilisp.devel |
|---|---|
| Message-ID | <[email protected]> |
From: Bob Rogers <[email protected]> Date: Mon, 16 Sep 2002 09:55:47 -0400 . . . In fact, speaking of %s vs. %S, it occurs to me that lisp-slashify is entirely equivalent to the following . . . Perhaps lisp-slashify is a historical artifact, a product of older emacsen that didn't support %S? Is it still desirable to support these older versions? If so, I probably shouldn't be using %S at all . . . According to the first item in the "New Features for Printing And Formatting Output" section of the etc/LNEWS file (/usr/share/emacs/20.7/etc/LNEWS in my version of emacs), the %S directive was added in emacs 19, but the next item implies that a one-arg version of prin1-to-string was present in prior versions. Because of that, I feel it is safe to commit the simplification to lisp-slashify shown below, even though ilisp still claims to support emacs 18. But I'm curious how important emacs 18 support really is, as that determines how hard I have to work to avoid making use of nice features like match-string and %S. Does emacs 18 really work? When was the last time anybody tried to run ilisp under emacs 18? -- Bob Rogers http://rgrjr.dyndns.org/ ------------------------------------------------------------------------ Index: ilisp-utl.el =================================================================== RCS file: /cvsroot/ilisp/ILISP/ilisp-utl.el,v retrieving revision 1.2 diff -u -r1.2 ilisp-utl.el --- ilisp-utl.el 12 May 2001 22:10:53 -0000 1.2 +++ ilisp-utl.el 21 Sep 2002 20:15:52 -0000 @@ -27,20 +27,16 @@ "Put string in the *ilisp-send* buffer, backslashifying troublesome chars. I.e. put backslashes before quotes and backslashes and return the resulting string." - (save-excursion - (lisp-show-send string) - (set-buffer "*ilisp-send*") - (goto-char (point-min)) - (while (search-forward "\\" nil t) - (delete-char -1) - (insert "\\\\")) - (goto-char (point-min)) - (while (search-forward "\"" nil t) - (backward-char) - (insert ?\\) - (forward-char)) - (buffer-substring (point-min) (point-max)))) - + ;; The quoting is now all done by prin1-to-string, since elisp and Common Lisp + ;; string quoting syntax is identical. + (or (stringp string) + (error "ilisp bug: argument to %s is %s, which is not a string." + 'lisp-slashify string)) + (let* ((string (prin1-to-string string)) + ;; strip off surrounding quotes. + (result (substring string 1 (1- (length string))))) + (lisp-show-send result) ;; for side effect. + result)) ;;;%%String (defun lisp-prefix-p (s1 s2) ------------------------------------------------------- This sf.net email is sponsored by:ThinkGeek Welcome to geek heaven. http://thinkgeek.com/sf