In org-mode 9.6.6 when not in a LaTeX fragment, inserting \ and invoking completion-at-point produces a multitude of LaTeX completions.

Doing the same thing when in a LaTeX fragment, I would like the same completions to be available, but they are not.

What I have figured out so far

completion-at-point-functions contains (pcomplete-completions-at-point t), and the definition of completion-at-point is as follows:

(defun completion-at-point ()
  "Perform completion on the text around point.
The completion method is determined by `completion-at-point-functions'."
  (let ((res (run-hook-wrapped 'completion-at-point-functions
                               #'completion--capf-wrapper 'all)))
    (pcase res
      (`(,_ . ,(and (pred functionp) f)) (funcall f))
      (`(,hookfun . (,start ,end ,collection . ,plist))
       (unless (markerp start) (setq start (copy-marker start)))
       (let* ((completion-extra-properties plist)
               (lambda ()
                 ;; We're still in the same completion field.
                 (let ((newstart (car-safe (funcall hookfun))))
                   (and newstart (= newstart start))))))
         (completion-in-region start end collection
                               (plist-get plist :predicate))))
      ;; Maybe completion already happened and the function returned t.
       (when (cdr res)
         (message "Warning: %S failed to return valid completion data!"
                  (car res)))
       (cdr res)))))

When not in a LaTeX fragment, res is being bound to the same value as the result of (pcomplete-completions-at-point); when in a LaTeX fragment, res is bound to nil, even though (pcomplete-completions-at-point) returns the same value as before.

  • I can not reproduce it here. Are you sure you are trying to complete equal 'patterns'? If so, could you add examples? Feb 6 at 21:39
  • 1
    It works in a \begin{math}...\end{math} environment, but not in $...$ or \(...\) or \[...\]. If I run completion-at-point with point immediately after the second of the three backslashes in the following text: \(\\), it says No Match. If I do it like this \( \ \) it says cl--assertion-failed: Assertion failed: (<= start (point)). This is all done in /tmp/x.org after emacs -Q while using emacs-mac
    – user615536
    Feb 7 at 0:53
  • 1
    Please report your findings with M-x org-submit-bug-report. I can reproduce the assertion failures. You should also add the Org mode version you are using to your question.
    – NickD
    Feb 7 at 1:46


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.