unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: "Sean Peters" <sean.a.peters@googlemail.com>
To: 16755@debbugs.gnu.org
Subject: bug#16755: 24.3; customize-save-variable saves the wrong value
Date: Fri, 14 Feb 2014 15:23:52 +0000	[thread overview]
Message-ID: <21246.13576.276212.697702@eddie.wibble.net> (raw)


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	other threads:[~2014-02-14 15:23 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-14 15:23 Sean Peters [this message]
2014-02-14 18:23 ` bug#16755: 24.3; customize-save-variable saves the wrong value Stefan Monnier
2014-03-18 23:32   ` Juanma Barranquero

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=21246.13576.276212.697702@eddie.wibble.net \
    --to=sean.a.peters@googlemail.com \
    --cc=16755@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).