aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBoris Goldowsky1995-03-27 16:02:44 +0000
committerBoris Goldowsky1995-03-27 16:02:44 +0000
commitbe9d483dd96918b591a8545d79459a04ea7017d7 (patch)
tree544c423436ae52dba69a2edc8645d009346e1552 /src
parentef6fe31be94ddc463b022aecc9fa8a0f32a4481a (diff)
downloademacs-be9d483dd96918b591a8545d79459a04ea7017d7.tar.gz
emacs-be9d483dd96918b591a8545d79459a04ea7017d7.zip
(Fplist_put, Fplist_get): New fns.
(Fget): Use Fplist_get to do the work. (Fput): Use Fplist_put to do the work.
Diffstat (limited to 'src')
-rw-r--r--src/fns.c65
1 files changed, 49 insertions, 16 deletions
diff --git a/src/fns.c b/src/fns.c
index 3aeae4532a5..0fcf8766751 100644
--- a/src/fns.c
+++ b/src/fns.c
@@ -828,15 +828,19 @@ merge (org_l1, org_l2, pred)
828 } 828 }
829} 829}
830 830
831DEFUN ("get", Fget, Sget, 2, 2, 0, 831
832 "Return the value of SYMBOL's PROPNAME property.\n\ 832DEFUN ("plist-get", Fplist_get, Splist_get, 2, 2, 0,
833This is the last VALUE stored with `(put SYMBOL PROPNAME VALUE)'.") 833 "Extract a value from a property list.\n\
834 (sym, prop) 834PLIST is a property list, which is a list of the form\n\
835 Lisp_Object sym; 835(PROP1 VALUE1 PROP2 VALUE2...). This function returns the value\n\
836corresponding to the given PROP, or nil if PROP is not\n\
837one of the properties on the list.")
838 (val, prop)
839 Lisp_Object val;
836 register Lisp_Object prop; 840 register Lisp_Object prop;
837{ 841{
838 register Lisp_Object tail; 842 register Lisp_Object tail;
839 for (tail = Fsymbol_plist (sym); !NILP (tail); tail = Fcdr (Fcdr (tail))) 843 for (tail = val; !NILP (tail); tail = Fcdr (Fcdr (tail)))
840 { 844 {
841 register Lisp_Object tem; 845 register Lisp_Object tem;
842 tem = Fcar (tail); 846 tem = Fcar (tail);
@@ -846,30 +850,57 @@ This is the last VALUE stored with `(put SYMBOL PROPNAME VALUE)'.")
846 return Qnil; 850 return Qnil;
847} 851}
848 852
849DEFUN ("put", Fput, Sput, 3, 3, 0, 853DEFUN ("get", Fget, Sget, 2, 2, 0,
850 "Store SYMBOL's PROPNAME property with value VALUE.\n\ 854 "Return the value of SYMBOL's PROPNAME property.\n\
851It can be retrieved with `(get SYMBOL PROPNAME)'.") 855This is the last VALUE stored with `(put SYMBOL PROPNAME VALUE)'.")
852 (sym, prop, val) 856 (sym, prop)
853 Lisp_Object sym; 857 Lisp_Object sym, prop;
854 register Lisp_Object prop; 858{
855 Lisp_Object val; 859 return Fplist_get (Fsymbol_plist (sym), prop);
860}
861
862DEFUN ("plist-put", Fplist_put, Splist_put, 3, 3, 0,
863 "Change value in PLIST of PROP to VAL.\n\
864PLIST is a property list, which is a list of the form\n\
865(PROP1 VALUE1 PROP2 VALUE2 ...). PROP is a symbol and VAL is any object.\n\
866If PROP is already a property on the list, its value is set to VAL,\n\
867otherwise the new PROP VAL pair is added. The new plist is returned;
868use `(setq x (plist-put x prop val))' to be sure to use the new value.\n\
869The PLIST is modified by side effects.")
870 (plist, prop, val)
871 Lisp_Object plist;
872 register Lisp_Object prop;
873 Lisp_Object val;
856{ 874{
857 register Lisp_Object tail, prev; 875 register Lisp_Object tail, prev;
858 Lisp_Object newcell; 876 Lisp_Object newcell;
859 prev = Qnil; 877 prev = Qnil;
860 for (tail = Fsymbol_plist (sym); !NILP (tail); tail = Fcdr (Fcdr (tail))) 878 for (tail = plist; !NILP (tail); tail = Fcdr (Fcdr (tail)))
861 { 879 {
862 register Lisp_Object tem; 880 register Lisp_Object tem;
863 tem = Fcar (tail); 881 tem = Fcar (tail);
864 if (EQ (prop, tem)) 882 if (EQ (prop, tem))
865 return Fsetcar (Fcdr (tail), val); 883 {
884 Fsetcar (Fcdr (tail), val);
885 return plist;
886 }
866 prev = tail; 887 prev = tail;
867 } 888 }
868 newcell = Fcons (prop, Fcons (val, Qnil)); 889 newcell = Fcons (prop, Fcons (val, Qnil));
869 if (NILP (prev)) 890 if (NILP (prev))
870 Fsetplist (sym, newcell); 891 return newcell;
871 else 892 else
872 Fsetcdr (Fcdr (prev), newcell); 893 Fsetcdr (Fcdr (prev), newcell);
894 return plist;
895}
896
897DEFUN ("put", Fput, Sput, 3, 3, 0,
898 "Store SYMBOL's PROPNAME property with value VALUE.\n\
899It can be retrieved with `(get SYMBOL PROPNAME)'.")
900 (sym, prop, val)
901 Lisp_Object sym, prop, val;
902{
903 Fsetplist (sym, Fplist_put (Fsymbol_plist (sym), prop, val));
873 return val; 904 return val;
874} 905}
875 906
@@ -1490,7 +1521,9 @@ Used by `featurep' and `require', and altered by `provide'.");
1490 defsubr (&Snreverse); 1521 defsubr (&Snreverse);
1491 defsubr (&Sreverse); 1522 defsubr (&Sreverse);
1492 defsubr (&Ssort); 1523 defsubr (&Ssort);
1524 defsubr (&Splist_get);
1493 defsubr (&Sget); 1525 defsubr (&Sget);
1526 defsubr (&Splist_put);
1494 defsubr (&Sput); 1527 defsubr (&Sput);
1495 defsubr (&Sequal); 1528 defsubr (&Sequal);
1496 defsubr (&Sfillarray); 1529 defsubr (&Sfillarray);