diff options
| author | Lars Ingebrigtsen | 2020-12-11 14:40:20 +0100 |
|---|---|---|
| committer | Lars Ingebrigtsen | 2020-12-11 14:40:20 +0100 |
| commit | aa7e5ce651b1872180e8da94ac80fbc25e33eec0 (patch) | |
| tree | d7a50705c11b9257683743857ea479b2d0739d1c /src | |
| parent | 9d598ef93cbebe59f1d3a91f4fda35d3e00f36a9 (diff) | |
| download | emacs-aa7e5ce651b1872180e8da94ac80fbc25e33eec0.tar.gz emacs-aa7e5ce651b1872180e8da94ac80fbc25e33eec0.zip | |
Add new function `object-intervals'
* doc/lispref/text.texi (Examining Properties): Document it.
* src/fns.c (Fobject_intervals): New defun.
(collect_interval): New function.
Diffstat (limited to 'src')
| -rw-r--r-- | src/fns.c | 35 |
1 files changed, 35 insertions, 0 deletions
| @@ -5573,6 +5573,40 @@ Case is always significant and text properties are ignored. */) | |||
| 5573 | 5573 | ||
| 5574 | return make_int (string_byte_to_char (haystack, res - SSDATA (haystack))); | 5574 | return make_int (string_byte_to_char (haystack, res - SSDATA (haystack))); |
| 5575 | } | 5575 | } |
| 5576 | |||
| 5577 | static void | ||
| 5578 | collect_interval (INTERVAL interval, Lisp_Object collector) | ||
| 5579 | { | ||
| 5580 | nconc2 (collector, | ||
| 5581 | list1(list3 (make_fixnum (interval->position), | ||
| 5582 | make_fixnum (interval->position + LENGTH (interval)), | ||
| 5583 | interval->plist))); | ||
| 5584 | } | ||
| 5585 | |||
| 5586 | DEFUN ("object-intervals", Fobject_intervals, Sobject_intervals, 1, 1, 0, | ||
| 5587 | doc: /* Return a copy of the text properties of OBJECT. | ||
| 5588 | OBJECT must be a buffer or a string. | ||
| 5589 | |||
| 5590 | Altering this copy does not change the layout of the text properties | ||
| 5591 | in OBJECT. */) | ||
| 5592 | (register Lisp_Object object) | ||
| 5593 | { | ||
| 5594 | Lisp_Object collector = Fcons (Qnil, Qnil); | ||
| 5595 | INTERVAL intervals; | ||
| 5596 | |||
| 5597 | if (STRINGP (object)) | ||
| 5598 | intervals = string_intervals (object); | ||
| 5599 | else if (BUFFERP (object)) | ||
| 5600 | intervals = buffer_intervals (XBUFFER (object)); | ||
| 5601 | else | ||
| 5602 | wrong_type_argument (Qbuffer_or_string_p, object); | ||
| 5603 | |||
| 5604 | if (! intervals) | ||
| 5605 | return Qnil; | ||
| 5606 | |||
| 5607 | traverse_intervals (intervals, 0, collect_interval, collector); | ||
| 5608 | return CDR (collector); | ||
| 5609 | } | ||
| 5576 | 5610 | ||
| 5577 | 5611 | ||
| 5578 | void | 5612 | void |
| @@ -5614,6 +5648,7 @@ syms_of_fns (void) | |||
| 5614 | defsubr (&Smaphash); | 5648 | defsubr (&Smaphash); |
| 5615 | defsubr (&Sdefine_hash_table_test); | 5649 | defsubr (&Sdefine_hash_table_test); |
| 5616 | defsubr (&Sstring_search); | 5650 | defsubr (&Sstring_search); |
| 5651 | defsubr (&Sobject_intervals); | ||
| 5617 | 5652 | ||
| 5618 | /* Crypto and hashing stuff. */ | 5653 | /* Crypto and hashing stuff. */ |
| 5619 | DEFSYM (Qiv_auto, "iv-auto"); | 5654 | DEFSYM (Qiv_auto, "iv-auto"); |