0
Debugger entered--Lisp error: (scan-error "Unbalanced parentheses" 1 1)
  scan-lists(41 -1 -1)
  down-list(-1)
  edebug-step-out()
  edebug-forward-sexp(1)
  funcall-interactively(edebug-forward-sexp 1)
  command-execute(edebug-forward-sexp record)
  execute-extended-command(nil "edebug-forward-sexp" nil)
  funcall-interactively(execute-extended-command nil "edebug-forward-sexp" nil)
  command-execute(execute-extended-command)
  recursive-edit()
  debug(debug)
  debug--implement-debug-on-entry()
  apply(debug--implement-debug-on-entry nil)
* find_last_ontology_file()
  (progn (find_last_ontology_file))

When I try to step forward from the entrypoint find_last_ontology_file using debug-on-entry, I get the above error. But where exactly would I have mismatched parentheses? The code works without throwing parentheses-related errors when I'm not debugging. The code is below, if it helps.

(defmacro dowhile (body condition)
  (cons 'progn  body)
  (list 'while condition (cons 'progn body)))

     
(defun file-exists-in-buffer-directory (filename)
 (let* ((buffer-directory (file-name-directory buffer-file-name))
        (full-path (concat (file-name-as-directory buffer-directory) filename)))
   (file-exists-p full-path)))

    

(defun find_last_ontology_file ()
  (let ((current_file (car (split-string buffer-file-name "\\.")))
        (index 1)
        (last_found_ont_file nil)
        (keep_looping t))

       (dowhile
        ((let ((filename_to_check (concat current_file "_" (number-to-string index) ".pu")))
          (if (file-exists-in-buffer-directory filename_to_check)
          (progn (setq index (1+ index))
                 (setq last_found_ont_file filename_to_check))
          
          (setq keep_looping nil))))
          keep_looping)

        (if last_found_ont_file
            last_found_ont_file
            nil)))
(find_last_ontology_file)
3
  • Start by formatting your code better, please. And start by getting rid of the extra code in your macro - it does nothing.
    – Drew
    Dec 10, 2023 at 5:19
  • @Drew sorry, did a bit of reformating. Would you happen to know if there are any Elisp linters for formatting? (Also: the macro is invoked once)
    – shintuku
    Dec 10, 2023 at 5:33
  • C-h k C-M-q for indentation. show-paren-mode for parenthesis matching.
    – Drew
    Dec 10, 2023 at 21:59

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.