bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#16755: 24.3; customize-save-variable saves the wrong value


From: Sean Peters
Subject: bug#16755: 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

-- 





reply via email to

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