- (concat "There is this problem with the existing index table:\n\n " reason "\n\nThis assistant will guide you to create a new one.\n\nDo you want to proceed ?") \r

- (concat "The existing index table contains this error:\n\n " reason "\n\nYou need to correct this error manually before proceeding. However, this assistant will help you to create an new initial index table with detailed comments, so that you may fix the errors in your existing table more easily.\n\nDo you want to proceed ?")))\r

- \r

- (unless (y-or-n-p prompt) \r

- (message "Cannot proceed without a valid index table: %s" reason)\r

- ;; show existing index\r

- (when (and org-index--buffer\r

- org-index--point)\r

- (org-pop-to-buffer-same-window org-index--buffer)\r

- (goto-char org-index--point)\r

- (org-show-context)\r

- (show-subtree)\r

- (recenter 1)\r

- (delete-other-windows))\r

- (throw 'created-new-index nil))\r

- \r

- (setq buffer-name (org-completing-read "Please choose the buffer, where the new node for the index table should be created; the new node will be inserted at its end.\n\nBuffer: " (mapcar 'buffer-name (org-buffer-list)) nil nil))\r

-\r

- (setq title (read-from-minibuffer "Please enter the title of the index node: "))\r

-\r

- (while (progn\r

- (setq firstref (read-from-minibuffer "Please enter your first reference-number. This is a number preceeded by some non-digit chars and optionally followed by some more non-digit chars, e.g. 'R1', '-1-' or '#1#' (and your initial number does not need to be '1'). The format of your reference-numbers only needs to make sense for yourself, so that you can spot it easily in your texts or write it on a piece of paper; it should however not already appear to frequently within your existing notes, to avoid too many false hits when searching.\n\nPlease choose: "))\r

- ;; we had an error with the existing table, so present old and new one\r

- (progn\r

- ;; show existing index\r

- (org-pop-to-buffer-same-window org-index--buffer)\r

- (goto-char org-index--point)\r

- (org-show-context)\r

- (show-subtree)\r

- (recenter 1)\r

- (delete-other-windows)\r

- ;; show new index\r

- (select-window (split-window-vertically))\r

- (org-pop-to-buffer-same-window buffer-name)\r

- (org-id-goto id)\r

- (org-show-context) \r

- (show-subtree)\r

- (recenter 1)\r

- (message "Please compare your existing index (upper window) and a temporary new one (lower window) to correct the previous error (\"%s\"); the explanations following the new index table should help." reason))\r

-\r

- ;; Only show the new index\r

- (org-pop-to-buffer-same-window buffer-name)\r

- (delete-other-windows)\r

- (org-id-goto id)\r

- (org-show-context) \r

- (show-subtree)\r

- (recenter 1)\r

- (setq org-index-id id)\r

- (if (y-or-n-p "This is your new index table; Do you want to save its id to make it permanent ? ")\r