diff options
| author | Andrea Corallo | 2021-04-21 14:22:11 +0200 |
|---|---|---|
| committer | Andrea Corallo | 2021-04-21 17:36:59 +0200 |
| commit | 0eee48af9de308ef57a065ecd8b2c2c7b59012a0 (patch) | |
| tree | 2f8a382f7dc51222438e856ecab5343e5f22184a | |
| parent | b5c76530fab4b99e76249bfb9a105b30bef4ce67 (diff) | |
| download | emacs-0eee48af9de308ef57a065ecd8b2c2c7b59012a0.tar.gz emacs-0eee48af9de308ef57a065ecd8b2c2c7b59012a0.zip | |
Introduce `sxhash-equal-including-properties'.
* src/fns.c (collect_interval): Move it upwards.
(Fsxhash_equal_including_properties): New function.
(syms_of_fns): Register `sxhash-equal-including-properties'.
* etc/NEWS: Add 'sxhash-equal-including-properties'.
| -rw-r--r-- | etc/NEWS | 5 | ||||
| -rw-r--r-- | src/fns.c | 43 |
2 files changed, 39 insertions, 9 deletions
| @@ -2580,6 +2580,11 @@ the Emacs Lisp reference manual for background. | |||
| 2580 | * Lisp Changes in Emacs 28.1 | 2580 | * Lisp Changes in Emacs 28.1 |
| 2581 | 2581 | ||
| 2582 | +++ | 2582 | +++ |
| 2583 | ** New function 'sxhash-equal-including-properties'. | ||
| 2584 | This is identical to 'sxhash-equal' but accounting also for string | ||
| 2585 | properties. | ||
| 2586 | |||
| 2587 | +++ | ||
| 2583 | ** 'unlock-buffer' displays warnings instead of signaling. | 2588 | ** 'unlock-buffer' displays warnings instead of signaling. |
| 2584 | Instead of signaling 'file-error' conditions for file system level | 2589 | Instead of signaling 'file-error' conditions for file system level |
| 2585 | errors, the function now calls 'display-warning' and continues as if | 2590 | errors, the function now calls 'display-warning' and continues as if |
| @@ -4492,6 +4492,15 @@ check_mutable_hash_table (Lisp_Object obj, struct Lisp_Hash_Table *h) | |||
| 4492 | eassert (!PURE_P (h)); | 4492 | eassert (!PURE_P (h)); |
| 4493 | } | 4493 | } |
| 4494 | 4494 | ||
| 4495 | static void | ||
| 4496 | collect_interval (INTERVAL interval, Lisp_Object collector) | ||
| 4497 | { | ||
| 4498 | nconc2 (collector, | ||
| 4499 | list1(list3 (make_fixnum (interval->position), | ||
| 4500 | make_fixnum (interval->position + LENGTH (interval)), | ||
| 4501 | interval->plist))); | ||
| 4502 | } | ||
| 4503 | |||
| 4495 | /* Put an entry into hash table H that associates KEY with VALUE. | 4504 | /* Put an entry into hash table H that associates KEY with VALUE. |
| 4496 | HASH is a previously computed hash code of KEY. | 4505 | HASH is a previously computed hash code of KEY. |
| 4497 | Value is the index of the entry in H matching KEY. */ | 4506 | Value is the index of the entry in H matching KEY. */ |
| @@ -4949,6 +4958,30 @@ Hash codes are not guaranteed to be preserved across Emacs sessions. */) | |||
| 4949 | return hashfn_equal (obj, NULL); | 4958 | return hashfn_equal (obj, NULL); |
| 4950 | } | 4959 | } |
| 4951 | 4960 | ||
| 4961 | DEFUN ("sxhash-equal-including-properties", Fsxhash_equal_including_properties, | ||
| 4962 | Ssxhash_equal_including_properties, 1, 1, 0, | ||
| 4963 | doc: /* Return an integer hash code for OBJ suitable for | ||
| 4964 | `equal-including-properties'. | ||
| 4965 | If (sxhash-equal-including-properties A B), then | ||
| 4966 | (= (sxhash-equal-including-properties A) (sxhash-equal-including-properties B)). | ||
| 4967 | |||
| 4968 | Hash codes are not guaranteed to be preserved across Emacs sessions. */) | ||
| 4969 | (Lisp_Object obj) | ||
| 4970 | { | ||
| 4971 | if (STRINGP (obj)) | ||
| 4972 | { | ||
| 4973 | Lisp_Object collector = Fcons (Qnil, Qnil); | ||
| 4974 | traverse_intervals (string_intervals (obj), 0, collect_interval, | ||
| 4975 | collector); | ||
| 4976 | return | ||
| 4977 | make_ufixnum ( | ||
| 4978 | SXHASH_REDUCE (sxhash_combine (sxhash (obj), | ||
| 4979 | sxhash (CDR (collector))))); | ||
| 4980 | } | ||
| 4981 | |||
| 4982 | return hashfn_equal (obj, NULL); | ||
| 4983 | } | ||
| 4984 | |||
| 4952 | DEFUN ("make-hash-table", Fmake_hash_table, Smake_hash_table, 0, MANY, 0, | 4985 | DEFUN ("make-hash-table", Fmake_hash_table, Smake_hash_table, 0, MANY, 0, |
| 4953 | doc: /* Create and return a new hash table. | 4986 | doc: /* Create and return a new hash table. |
| 4954 | 4987 | ||
| @@ -5832,15 +5865,6 @@ Case is always significant and text properties are ignored. */) | |||
| 5832 | return make_int (string_byte_to_char (haystack, res - SSDATA (haystack))); | 5865 | return make_int (string_byte_to_char (haystack, res - SSDATA (haystack))); |
| 5833 | } | 5866 | } |
| 5834 | 5867 | ||
| 5835 | static void | ||
| 5836 | collect_interval (INTERVAL interval, Lisp_Object collector) | ||
| 5837 | { | ||
| 5838 | nconc2 (collector, | ||
| 5839 | list1(list3 (make_fixnum (interval->position), | ||
| 5840 | make_fixnum (interval->position + LENGTH (interval)), | ||
| 5841 | interval->plist))); | ||
| 5842 | } | ||
| 5843 | |||
| 5844 | DEFUN ("object-intervals", Fobject_intervals, Sobject_intervals, 1, 1, 0, | 5868 | DEFUN ("object-intervals", Fobject_intervals, Sobject_intervals, 1, 1, 0, |
| 5845 | doc: /* Return a copy of the text properties of OBJECT. | 5869 | doc: /* Return a copy of the text properties of OBJECT. |
| 5846 | OBJECT must be a buffer or a string. | 5870 | OBJECT must be a buffer or a string. |
| @@ -5922,6 +5946,7 @@ syms_of_fns (void) | |||
| 5922 | defsubr (&Ssxhash_eq); | 5946 | defsubr (&Ssxhash_eq); |
| 5923 | defsubr (&Ssxhash_eql); | 5947 | defsubr (&Ssxhash_eql); |
| 5924 | defsubr (&Ssxhash_equal); | 5948 | defsubr (&Ssxhash_equal); |
| 5949 | defsubr (&Ssxhash_equal_including_properties); | ||
| 5925 | defsubr (&Smake_hash_table); | 5950 | defsubr (&Smake_hash_table); |
| 5926 | defsubr (&Scopy_hash_table); | 5951 | defsubr (&Scopy_hash_table); |
| 5927 | defsubr (&Shash_table_count); | 5952 | defsubr (&Shash_table_count); |