bongo-patches
[Top][All Lists]
Advanced

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

[bongo-patches] Add new file `bongo-emacs21.el' [...]


From: Daniel Brockman
Subject: [bongo-patches] Add new file `bongo-emacs21.el' [...]
Date: Fri, 29 Dec 2006 10:37:11 +0100
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux)

Wed Dec 27 10:25:31 CET 2006  Daniel Brockman <address@hidden>

  * Add new file `bongo-emacs21.el' and add compatibility
    wrappers `bongo-customize-mark-as-set' and
    `bongo-custom-reevaluate-setting'.

diff -rN -u old-bongo/bongo.el new-bongo/bongo.el
--- old-bongo/bongo.el  2006-12-29 10:36:17.000000000 +0100
+++ new-bongo/bongo.el  2006-12-29 10:36:18.000000000 +0100
@@ -81,6 +81,13 @@
 ;; whether to enable Bongo Last.fm mode by default.
 (require 'lastfm-submit nil 'no-error)
 
+(if (<= emacs-major-version 21)
+    (require 'bongo-emacs21)
+  (defalias 'bongo-customize-mark-as-set
+    'customize-mark-as-set)
+  (defalias 'bongo-custom-reevaluate-setting
+    'custom-reevaluate-setting))
+
 (eval-when-compile
   (require 'cl)
   (require 'rx))
@@ -215,7 +222,7 @@
                  (with-current-buffer buffer
                    (bongo-update-enabled-backends-list))))))
     :group 'bongo)
-  (custom-reevaluate-setting 'bongo-enabled-backends)
+  (bongo-custom-reevaluate-setting 'bongo-enabled-backends)
 
   (custom-declare-variable 'bongo-custom-backend-matchers nil
     "List of custom Bongo player backend matchers.
@@ -683,7 +690,7 @@
             (not bongo-header-line-mode)
           (> (prefix-numeric-value argument) 0)))
   (when (called-interactively-p)
-    (customize-mark-as-set 'bongo-header-line-mode))
+    (bongo-customize-mark-as-set 'bongo-header-line-mode))
   (if bongo-header-line-mode
       (progn
         (add-hook 'bongo-player-started-functions
@@ -1297,7 +1304,7 @@
             (not bongo-mode-line-indicator-mode)
           (> (prefix-numeric-value argument) 0)))
   (when (called-interactively-p)
-    (customize-mark-as-set 'bongo-mode-line-indicator-mode))
+    (bongo-customize-mark-as-set 'bongo-mode-line-indicator-mode))
   (when bongo-mode-line-indicator-parent
     (if (not bongo-mode-line-indicator-mode)
         (set bongo-mode-line-indicator-parent
@@ -7523,9 +7530,9 @@
   (unless (bongo-buffer-p)
     (switch-to-buffer (bongo-buffer))))
 
-(custom-reevaluate-setting 'bongo-header-line-mode)
-(custom-reevaluate-setting 'bongo-mode-line-indicator-mode)
-(custom-reevaluate-setting 'bongo-global-lastfm-mode)
+(bongo-custom-reevaluate-setting 'bongo-header-line-mode)
+(bongo-custom-reevaluate-setting 'bongo-mode-line-indicator-mode)
+(bongo-custom-reevaluate-setting 'bongo-global-lastfm-mode)
 
 ;; For backwards compatibility.
 (provide 'bongo-lastfm)
diff -rN -u old-bongo/bongo-emacs21.el new-bongo/bongo-emacs21.el
--- old-bongo/bongo-emacs21.el  1970-01-01 01:00:00.000000000 +0100
+++ new-bongo/bongo-emacs21.el  2006-12-29 10:36:18.000000000 +0100
@@ -0,0 +1,90 @@
+;;; bongo-emacs21.el --- compatibility functions for Emacs 21
+;; Copyright (C) 2006  Daniel Brockman
+;; Copyright (C) 1996, 1997, 1999, 2001, 2002, 2003, 2004,
+;;   2005, 2006  Free Software Foundation, Inc.
+
+;; Author: Daniel Brockman <address@hidden>
+;; URL: http://www.brockman.se/software/bongo/
+;; Created: December 27, 2006
+;; Updated: December 27, 2006
+
+;; This file is free software; you can redistribute it and/or
+;; modify it under the terms of the GNU General Public License as
+;; published by the Free Software Foundation; either version 2 of
+;; the License, or (at your option) any later version.
+
+;; This file is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty
+;; of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+;; See the GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public
+;; License along with this program (see the file `COPYING');
+;; if not, write to the Free Software Foundation, 51 Franklin
+;; Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+;;; Commentary:
+
+;; This file contains functions that are necessary for Bongo
+;; to work with Emacs 21.  Most definitions were simply
+;; copied from Emacs 22 and then backported to Emacs 21.
+
+;;; Code:
+
+(require 'custom)
+
+;;; The following definitions were copied from `custom.el'
+;;; and modified to work with Emacs 21.
+
+(defun bongo-customize-mark-as-set (symbol)
+  "Mark current value of SYMBOL as being set from customize.
+
+If the default value of SYMBOL is different from the saved value if any,
+or else if it is different from the standard value, set the
+`customized-value' property to a list whose car evaluates to the
+default value.  Otherwise, set it to nil.
+
+Return non-nil iff the `customized-value' property actually changed."
+
+;;; Not available in Emacs 21.
+;;;   (custom-load-symbol symbol)
+
+  (let* ((get (or (get symbol 'custom-get) 'default-value))
+         (value (funcall get symbol))
+         (customized (get symbol 'customized-value))
+         (old (or (get symbol 'saved-value) (get symbol 'standard-value))))
+    ;; Mark default value as set iff different from old value.
+    (if (not (and old
+                  (equal value (condition-case nil
+                                   (eval (car old))
+                                 (error nil)))))
+        (progn (put symbol 'customized-value (list (custom-quote value)))
+               
+;;; Not available in Emacs 21.
+;;;                (custom-push-theme 'theme-value symbol 'user 'set
+;;;                                   (custom-quote value))
+               
+               )
+      (put symbol 'customized-value nil))
+    ;; Changed?
+    (not (equal customized (get symbol 'customized-value)))))
+
+(defun bongo-custom-reevaluate-setting (symbol)
+  "Reset the value of SYMBOL by re-evaluating its saved or standard value.
+Use the :set function to do so.  This is useful for customizable options
+that are defined before their standard value can really be computed."
+  (funcall (or (get symbol 'custom-set) 'set-default)
+           symbol
+           (eval (car (or (get symbol 'saved-value)
+                          (get symbol 'standard-value))))))
+
+;;; Local Variables:
+;;; coding: utf-8
+;;; time-stamp-format: "%:b %:d, %:y"
+;;; time-stamp-start: ";; Updated: "
+;;; time-stamp-end: "$"
+;;; time-stamp-line-limit: 20
+;;; End:
+
+(provide 'bongo-emacs21)
+;;; bongo-emacs21.el ends here.
-- 
Daniel Brockman <address@hidden>

reply via email to

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