--- Begin Message ---
Subject: |
24.3; customize-save-variable saves the wrong value |
Date: |
Fri, 14 Feb 2014 15:23:52 +0000 |
Bug:
customize-save-variable saves the wrong value if custom-set changes
the value.
Example:
(defcustom emacspeak-feeds
'(
("Wired News" "http://www.wired.com/news_drop/netcenter/netcenter.rdf" rss)
("BBC Podcast Directory" "http://www.bbc.co.uk/podcasts.opml" opml)
("BBC News"
"http://www.bbc.co.uk/syndication/feeds/news/ukfs_news/front_page/rss091.xml"
rss)
("CNet Tech News" "http://feeds.feedburner.com/cnet/tcoc" rss)
)
"Table of RSS feeds."
:type '(repeat
(list :tag "Feed"
(string :tag "Title")
(string :tag "URI")
(choice :tag "Type"
(const :tag "RSS" rss)
(const :tag "opml" opml)
(const :tag "Atom" atom))))
:initialize 'custom-initialize-reset
:set
#'(lambda (sym val)
(set-default
sym
(sort val #'(lambda (a b)
(string-lessp (first a) (first b))))))
:group 'emacspeak-feeds)
(customize-save-variable 'emacspeak-feeds (push '("z" "z" 'rss)
emacspeak-feeds))
The value that gets saved is just '("z" "z" (quote rss)) instead of
the existing list with this on the end.
Cause:
These two lines from customize-save-variable show the problem:
(funcall (or (get variable 'custom-set) 'set-default) variable value)
(put variable 'saved-value (list (custom-quote value)))
During the call of custom-set, value gets destructively sorted. So
when value is used for setting saved-value it is missing the part of
the sorted list of settings before the newly added feed.
Fix:
I think customize-save-variable should use (default-value variable)
instead of value in all the places it currently uses value after the
call to custom-set.
Also, customize-set-variable may have a similar problem.
Sean
--
--- End Message ---
--- Begin Message ---
Subject: |
Re: bug#16755: 24.3; customize-save-variable saves the wrong value |
Date: |
Wed, 19 Mar 2014 00:32:38 +0100 |
On Fri, Feb 14, 2014 at 7:23 PM, Stefan Monnier
<address@hidden> wrote:
> So I think the better course is to document that the ":set" function should
> not modify its `val' argument destructively.
Done.
--- End Message ---