Function: reftex-figure-out-cite-format

reftex-figure-out-cite-format is a byte-compiled function defined in reftex-cite.el.gz.

Signature

(reftex-figure-out-cite-format ARG &optional NO-INSERT FORMAT-KEY)

Documentation

Check if there is already a cite command at point and change cite format in order to only add another reference in the same cite command.

Source Code

;; Defined in /usr/src/emacs/lisp/textmodes/reftex-cite.el.gz
(defun reftex-figure-out-cite-format (arg &optional no-insert format-key)
  "Check if there is already a cite command at point and change cite format
in order to only add another reference in the same cite command."
  (let ((macro (car (reftex-what-macro 1)))
        (cite-format-value (reftex-get-cite-format))
        key format)
    (cond
     (no-insert
      ;; Format does not really matter because nothing will be inserted.
      (setq format "%l"))

     ((and (stringp macro)
           ;; Match also commands from biblatex ending with `s'
           ;; (\parencites) or `*' (\parencite*) and `texts?'
           ;; (\footcitetext and \footcitetexts).
           (string-match "\\`\\\\cite\\|cite\\([s*]\\|texts?\\)?\\'" macro))
      ;; We are already inside a cite macro
      (if (or (not arg) (not (listp arg)))
          (setq format
                (concat
                 (if (member (preceding-char) '(?\{ ?,))
		     ""
		   reftex-cite-key-separator)
                 "%l"
                 (if (member (following-char) '(?\} ?,))
		     ""
		   reftex-cite-key-separator)))
        (setq format "%l")))
     (t
      ;; Figure out the correct format
      (setq format
            (if (and (symbolp cite-format-value)
                     (assq cite-format-value reftex-cite-format-builtin))
                (nth 2 (assq cite-format-value reftex-cite-format-builtin))
              cite-format-value))
      (when (listp format)
        (setq key
              (or format-key
                  (reftex-select-with-char
                   "" (concat "SELECT A CITATION FORMAT\n\n"
                              (mapconcat
                               (lambda (x)
                                 (format "[%c] %s  %s" (car x)
                                         (if (> (car x) 31) " " "")
                                         (cdr x)))
                               format "\n")))))
        (if (assq key format)
            (setq format (cdr (assq key format)))
          (error "No citation format associated with key `%c'" key)))))
    format))