Subject: [PATCH] [Calc] Fix saving user-defined compositions

From: Jack Coughlin <[email-masked]>
Date: Thu, 18 Jul 2019 08:32:48 -0700

When saving a user-defined formula by specifying its ~z-~ key, or the
~M-x~ command name, its compositions are not saved correctly. The
attached patch fixes this behavior.

--- notes on the code change ---

~func~ is the calcFunc- symbol representing the formula.
~cmd~ is either the calc- symbol representing the command, or, if we
are saving just the formula, the calcFunc- symbol.

We always want to associate the composition forms to the calcFunc-
version. Observe for example that two lines below, this is the symbol
that we pull them from to save.

>From c65e573fbdff716b91d3a93cb4b79a8ee506adc1 Mon Sep 17 00:00:00 2001
From: Jack Coughlin <[email-masked]>
Date: Thu, 18 Jul 2019 08:16:50 -0700
Subject: [PATCH] Fix bug when saving user-defined commands with compositions

This fixes a bug where saving user-defined formulas with compositions
would fail to save the compositions when the user specified their
formula by its command name or key.
---
 lisp/calc/calc-prog.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lisp/calc/calc-prog.el b/lisp/calc/calc-prog.el
index ba8efd43b8..01b39478c9 100644
--- a/lisp/calc/calc-prog.el
+++ b/lisp/calc/calc-prog.el
@@ -1097,7 +1097,7 @@ Redefine the corresponding command."
        (or func (setq func (and cmd (symbolp cmd) (fboundp cmd) cmd)))
        (if (get func 'math-compose-forms)
 	   (let ((pt (point)))
-	     (insert "(put '" (symbol-name cmd)
+	     (insert "(put '" (symbol-name func)
 		     " 'math-compose-forms '"
 		     (prin1-to-string (get func 'math-compose-forms))
 		     ")\n")
-- 
2.14.3 (Apple Git-98)