0

Here's some emacs-lisp code in a babel block:

#+begin_src emacs-lisp
(defun factor (number)
  (labels
      ((*factor (divisor number)
        (if (> (* divisor divisor) number)
            (list number)
          (if (= (mod number divisor) 0)
              (cons divisor (*factor divisor (/ number divisor)))
            (*factor (+ divisor 1) number)))))
    (*factor 2 number)))
#+end_src

So in the org buffer I get a parentheses matching problem, i.e., that very last ) at the bottom is flagged as one too many. It flashes red and check-parens flags it as well. Trouble is, this is not an error, i.e., the same code in scratch is perfectly paren-matched, likewise when I bring it up in the Org Source C-c ' window. BTW, this code compiles and runs giving good output. Any ideas what org-mode is doing here? I've got (show-paren-mode 1). When I turn it off, obviously, no problem because no highlighting matching parens.

  • can't replicate.... more config detalis? – manandearth Apr 29 at 16:05
  • I don't think this block is the problem. It's evidence of some other syntax problem in your org file. I'd suggest identifying what section of your org file provokes this error. Do this by removing parts of your org file until this matching problem does not occur and adding back what you removed one by one until the error returns. – Aquaactress Apr 29 at 16:29
  • I've got this problem in a totally naked file, i.e., just the code block, no headers, saved with an .org suffix. I'm on Emacs 26.2 and Org mode version 9.2.3 (9.2.3-11-g42abf5-elpaplus @ /.../.emacs.d/elpa/org-plus-contrib-20190429/) – 147pm Apr 29 at 19:17
  • I can run check-parens and get the problem. Go into C-c ' problem disappears. – 147pm Apr 29 at 20:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.