Function: vc-bzr-revision-completion-table

vc-bzr-revision-completion-table is a byte-compiled function defined in vc-bzr.el.gz.

Signature

(vc-bzr-revision-completion-table FILES)

Source Code

;; Defined in /usr/src/emacs/lisp/vc/vc-bzr.el.gz
(defun vc-bzr-revision-completion-table (files)
  ;; What about using `files'?!?  --Stef
  (lambda (string pred action)
    (cond
     ((string-match "\\`\\(ancestor\\|branch\\|\\(revno:\\)?[-0-9]+:\\):"
                    string)
      (completion-table-with-context (substring string 0 (match-end 0))
                                     (apply-partially
                                      'completion-table-with-predicate
                                      'completion-file-name-table
                                      'file-directory-p t)
                                     (substring string (match-end 0))
                                     pred
                                     action))
     ((string-match "\\`\\(before\\):" string)
      (completion-table-with-context (substring string 0 (match-end 0))
                                     (vc-bzr-revision-completion-table files)
                                     (substring string (match-end 0))
                                     pred
                                     action))
     ((string-match "\\`\\(tag\\):" string)
      (let ((prefix (substring string 0 (match-end 0)))
            (tag (substring string (match-end 0)))
            (table nil)
            process-file-side-effects)
        (with-temp-buffer
          ;; "bzr-1.2 tags" is much faster with --show-ids.
          (process-file vc-bzr-program nil '(t) nil "tags" "--show-ids")
          ;; The output is ambiguous, unless we assume that revids do not
          ;; contain spaces.
          (goto-char (point-min))
          (while (re-search-forward "^\\(.*[^ \n]\\) +[^ \n]*$" nil t)
            (push (match-string-no-properties 1) table)))
        (completion-table-with-context prefix table tag pred action)))

     ((string-match "\\`annotate:" string)
      (completion-table-with-context
       (substring string 0 (match-end 0))
       (apply-partially #'completion-table-with-terminator
                        (cons ":" regexp-unmatchable)
                        #'completion-file-name-table)
       (substring string (match-end 0)) pred action))

     ((string-match "\\`date:" string)
      (completion-table-with-context
       (substring string 0 (match-end 0))
       '("yesterday" "today" "tomorrow")
       (substring string (match-end 0)) pred action))

     ((string-match "\\`\\([a-z]+\\):" string)
      ;; no actual completion for the remaining keywords.
      (completion-table-with-context (substring string 0 (match-end 0))
                                     (if (member (match-string 1 string)
                                                 vc-bzr-revision-keywords)
                                         ;; If it's a valid keyword,
                                         ;; use a non-empty table to
                                         ;; indicate it.
                                         '("") nil)
                                     (substring string (match-end 0))
                                     pred
                                     action))
     (t
      ;; Could use completion-table-with-terminator, except that it
      ;; currently doesn't work right w.r.t pcm and doesn't give
      ;; the *Completions* output we want.
      (complete-with-action action (eval-when-compile
                                     (mapcar (lambda (s) (concat s ":"))
                                             vc-bzr-revision-keywords))
                            string pred)))))