emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Unmentioned "stringify" aspect in docu buffer-substring-no-propertie


From: Andreas Roehler
Subject: Re: Unmentioned "stringify" aspect in docu buffer-substring-no-properties
Date: Fri, 23 Jun 2006 08:38:43 +0200
User-agent: Thunderbird 1.5.0.4 (X11/20060516)

David Kastrup schrieb:
Andreas Roehler <address@hidden> writes:

Richard Stallman schrieb:
Would people please check those files for accuracy one more time?
They are the files listed in FOR-RELEASE with just one name.
text.texi
IMO:
Unmentioned "stringify" aspect in
`buffer-substring-no-properties'; also concerns
`buffer-substring'

AFAIU there are two different meanings of string, which
are mixed up in naming and function of

`buffer-substring-no-properties':

1) it takes a portion of the buffer, but not necessary
 of a type `string', so `substring' might mislead
 here (nonetheless, would not ask for changing this
 name for compatiblity reasons)

Uh what?  Of course the type is `string'.

2) it stringifies these portion, changes the type of it

It does nothing of the sort.

;;; check the following examples in a buffer starting
  with it, in order to have the Start-End-Entries
  set as given

(defun foo ()
" "
(interactive "*")
)

(buffer-substring-no-properties 34 37)"e \""

There is no "stringification" done by buffer-substring-no-properties.
The Lisp reader prints the result of the evaluation in string syntax,
that is all.

It happened to be a discussion in de.comp.editoren,
concerning a stringify function

The (still disputed) result exploits just the
mentioned quality.

It doesn't.

(defun region2string (start end)
"Make a string from the chars of a region.
Doublequotes inside will be quoted therefor.

baz --> \"baz\"

baz \"bar\" --> \"baz \\\"bar\\\"\""
(interactive "r*")
(goto-char end)
(prin1 (buffer-substring-no-properties start end) (current-buffer))
(delete-region start end))

The string quotes get added by prin1, not by
buffer-substring-no-properties.  You should really try reading up some
basics in the Emacs Lisp tutorial.

Please look at the example given above

(setq baz (buffer-substring-no-properties 34 37))

baz"e \""

there was no prin1 between, AFAIS.

The behavior of prin1 BTW was not the item.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]