[ஞாயிறு ஜூலை 05, 2026] Ihor Radchenko wrote:

> Visuwesh <[email protected]> writes:
>
>> Please find attached patch.  There is still a small problem with it that
>> I'm not sure how to resolve.  Consider the following scenario:
>>
>>   1. Set Calc's language to Mathematica by doing C-x * * d M
>>   2. Then with the patch applied, go to an Org mode buffer and write out
>>      the following
>>      #+BEGIN_SRC calc :language mathematica
>>      B_12
>>      #+END_SRC
>>   3. Evaluate the source block and witness an error
>> ...
>> I could always set calc-language to normal regardless of the presence of
>> the :language parameter but that would be a breaking change.  I think
>> erroring out when an incorrect language value is given is the better
>> solution, WDYT?  Something like
>>
>>     Invalid language parameter; accepted values are c, pascal, ...
>
> Yes, it would make sense.
> I am not sure what would be breaking about this.

Forcing the input language to normal would be a breaking change because
currently, one could have calc's language set to Mathematica and have
the source block be in Mathematica.

However, if we are going to error out, I don't think we need to worry
too much.

>> +    ;; This is needed so that we can force Org to print the results as
>> +    ;; "raw" format.  If there's a colon in front, then C-c C-x C-l
>> +    ;; does not do the job anymore.
>> +    (when (equal "latex" (cdr (assq :language params)))
>> +      (cl-callf (lambda (v) (nconc v '("raw")))
>> +          (alist-get :result-params params)))))
>
> This is awkward. What about extending ob-core itself. There is already
> :results code, but it does not allow custom languages. We may extend that.

That would be better, I agree.  I will look into it.

>>  +(defun org-babel-calc--format-lang (result params old-lang old-lang-opt)
>>  +  "Return RESULT as per the Calc language given in PARAMS.
>>  +This resets the Calc language back to OLD-LANG, and the options to
>>  +OLD-LANG-OPT."
>>  +  (calc-set-language (org-babel-calc--valid-lang-p params))
>>  +  (prog1
>>  +      (if (eq calc-language 'latex)
>>  +          (concat "\\begin{equation*}\n"
>>  +                  (calc-eval result)
>>  +                  "\n\\end{equation*}")
>>  +        (calc-eval result))
>
> What about inline src blocks?

I don't use inline source blocks so I don't know how to handle them.  We
could go with \( \) or \[ \].  The former would be appropriate AFAICT.

Reply via email to