Subject: bug#56655: 29.0.50; symbol's function definition is void: reftex-all-used-citation-keys

From: Arash Esbati <[email-masked]>
Date: Fri, 22 Jul 2022 15:41:19 +0200

Melody Y <[email-masked]> writes:

> When I cite after an escaping symbol, the following citation item can
> not be extracted with `reftex-all-used-citation-keys`. For example,
> \%\cite{gaoEfficientKnowledgeGraph2019}, the key
> `gaoEfficientKnowledgeGraph2019` can't be exported. But if i make
> \cite{gaoEfficientKnowledgeGraph2019} to a new line, the export will
> work. Is it possible to solve this bug?

Thanks for the report.  Can you please elaborate what you mean with
"after an escaping symbol"?  Does your description above apply only to
\% or also to other control symbols in TeX?  The way I understand the
regexp in `reftex-all-used-citation-keys' it should only apply to \%.

Can you please try this version of the function and report back if it
works?  In order to use is, you need to:

 • Copy the code into into scratch buffer

 • Load your .tex file and hit 'C-c [' to make sure that reftex-cite.el
   is loaded

 • Switch to scratch buffer and eval the function, i.e., put cursor
   after the last parenthesis and hit 'C-x C-e'

 • Switch to your .tex file again and run
   `reftex-all-used-citation-keys'.

--8<---------------cut here---------------start------------->8---
(defun reftex-all-used-citation-keys ()
  (reftex-access-scan-info)
  (let ((files (reftex-all-document-files)) file keys kk k)
    (save-current-buffer
      (while (setq file (pop files))
        (set-buffer (reftex-get-file-buffer-force file 'mark))
        (save-excursion
          (save-restriction
            (widen)
            (goto-char (point-min))
            (while (re-search-forward
                    (concat "\\(?:^\\|\\=\\)"
                            "\\(?:[^%\n\r]*?\\(?:\\\\%\\)?[^%\n\r]*?\\)"
                            "\\\\\\(bibentry\\|[a-zA-Z]*cite[a-zA-Z]*\\)"
                            "\\(\\[[^]]*\\]\\)?{\\([^}]+\\)}")
                    nil t)
              (setq kk (match-string-no-properties 3))
              (while (string-match "%.*\n?" kk)
                (setq kk (replace-match "" t t kk)))
              (setq kk (split-string kk "[, \t\r\n]+"))
              (while (setq k (pop kk))
                (or (member k keys)
                    (setq keys (cons k keys)))))))))
    (reftex-kill-temporary-buffers)
    keys))
--8<---------------cut here---------------end--------------->8---

TIA.  Best, Arash