A Little compatibility insurance.
authorSteve Youngs <steve@sxemacs.org>
Sun, 15 Oct 2017 00:40:15 +0000 (10:40 +1000)
committerSteve Youngs <steve@sxemacs.org>
Sun, 15 Oct 2017 00:40:15 +0000 (10:40 +1000)
The new account walking functions use some SXEmacs-only features, namely:
dllists and #'mapfam.  This changeset allows eMoney to be run and
byte-compiled on XEmacs

* emoney.el: Globally declare `dllist-car', `dllist-lrotate',
`dllist-rrotate', and `mapfam' so XEmacs can byte-compile.
(emoney-emacs-is-sexy-enough): New. Non-nil when super
sexy features are available such as dllists.
(emoney-walk-accounts-next): Use it.
(emoney-walk-accounts-previous): Ditto.
(emoney-mode-map): Ditto.

Signed-off-by: Steve Youngs <steve@sxemacs.org>
emoney.el

index 6cbadd3..0de6565 100644 (file)
--- a/emoney.el
+++ b/emoney.el
 ;;  changes.
 
 ;;; Code:
+;; A little compatibility insurance
+(globally-declare-fboundp 
+ '(mapfam dllist-car dllist-lrotate dllist-rrotate))
+
+(defvar emoney-emacs-is-sexy-enough (and (featurep 'dllist)
+                                        (fboundp #'mapfam))
+  "Non-nil when emacs has some needed extra features.
+
+Currently, that is support for dllists and #'mapfam.  Don't worry, if
+you're not sexy enough you can still use eMoney, you just won't be
+able to \"walk\" through accounts, but you can still switch to any
+account directly.
+
+See: `emoney-walk-accounts'.")
 
 ;; Drag in what we need.
 (eval-and-compile
@@ -593,12 +607,15 @@ in the current buffer."
 (defun emoney-walk-accounts-next ()
   "Switch to the 'next' account in the chart of accounts."
   (interactive)
-  (emoney-walk-accounts 'next))
+  (and emoney-emacs-is-sexy-enough
+       (emoney-walk-accounts 'next)))
+
 
 (defun emoney-walk-accounts-previous ()
   "Switch to the 'previous' account in the chart of accounts."
   (interactive)
-  (emoney-walk-accounts 'previous))
+  (and emoney-emacs-is-sexy-enough
+       (emoney-walk-accounts 'previous)))
 
 (defconst emoney-accounts-buffer-map
   (let* ((map (make-sparse-keymap 'emoney-accounts-buffer-map)))
@@ -754,8 +771,9 @@ transactions.")
     (define-key map [(control c) d]           #'emoney-goto-default-account)
     (define-key map [(control c) q]           #'emoney-quit)
     (define-key map [(control c) (control q)] #'emoney-recalc-and-exit)
-    (define-key map [(meta n)]                #'emoney-walk-accounts-next)
-    (define-key map [(meta p)]                #'emoney-walk-accounts-previous)
+    (when emoney-emacs-is-sexy-enough
+      (define-key map [(meta n)]              #'emoney-walk-accounts-next)
+      (define-key map [(meta p)]              #'emoney-walk-accounts-previous))
     map)
   "Keymap for emoney buffer.")