     (anything-other-buffer 'anything-c-source-minibuffer-history
                            "*anything minibuffer-history*")))
 
+;; In Emacs 23.1.50, minibuffer-local-must-match-filename-map was renamed to
+;; minibuffer-local-filename-must-match-map.
+(defvar minibuffer-local-filename-must-match-map (make-sparse-keymap)) ;; Emacs 23.1.+
+(defvar minibuffer-local-must-match-filename-map (make-sparse-keymap)) ;; Older Emacsen
 (dolist (map (list minibuffer-local-filename-completion-map
                    minibuffer-local-completion-map
                    minibuffer-local-must-match-filename-map
+                   minibuffer-local-filename-must-match-map
                    minibuffer-local-map
                    minibuffer-local-isearch-map
                    minibuffer-local-must-match-map

(anything-document-attribute 'subexp "Headline plug-in"
  "Display (match-string-no-properties subexp).")

(defun anything-headline-get-candidates (regexp subexp)
  (save-excursion
    (set-buffer anything-current-buffer)
    (save-excursion
      (goto-char (point-min))
      (if (functionp regexp) (setq regexp (funcall regexp)))
      (let (hierarchy curhead)
        (flet ((matched ()
                        (if (numberp subexp)
                            (cons (match-string-no-properties subexp) (match-beginning subexp))
                          (cons (buffer-substring (point-at-bol) (point-at-eol))
                                (point-at-bol))))
               (hierarchies (headlines)
                            (1+ (loop for (_ . hierarchy) in headlines
                                      maximize hierarchy)))
               (vector-0-n (v n)
                           (loop for i from 0 to hierarchy
                                 collecting (aref curhead i)))
               (arrange (headlines)
                        (loop with curhead = (make-vector (hierarchies headlines) "")
                              for ((str . pt) . hierarchy) in headlines
                              do (aset curhead hierarchy str)
                              collecting
                              (cons
                               (mapconcat 'identity (vector-0-n curhead hierarchy) " / ")
                               pt))))
          (if (listp regexp)
              (arrange
               (sort
                (loop for re in regexp
                      for hierarchy from 0
                      do (goto-char (point-min))
                      appending
                      (loop
                       while (re-search-forward re nil t)
                       collect (cons (matched) hierarchy)))
                (lambda (a b) (> (cdar b) (cdar a)))))
            (loop while (re-search-forward regexp nil t)
                  collect (matched))))))))

(defun anything-headline-make-candidate-buffer (regexp subexp)
  (with-current-buffer (anything-candidate-buffer 'local)

;; (anything 'anything-c-source-calculation-result)

;;; Google Suggestions
(defun anything-c-google-suggest-fetch (input)
  "Fetch suggestions for INPUT.
Return an alist with elements like (data . number_results)."
  (let (result-alist)
    (with-current-buffer (url-retrieve-synchronously
                          (concat anything-c-google-suggest-url
                                  (url-hexify-string input)))
      (setq result-alist (xml-get-children
                       (car (xml-parse-region (point-min) (point-max)))
                       'CompleteSuggestion)))
    (loop
       for i in result-alist
       for data = (cdr (caadr (assoc 'suggestion i)))
       for nqueries = (cdr (caadr (assoc 'num_queries i)))
       collect (cons data nqueries) into cont
       finally return cont)))

(defun anything-c-google-suggest-set-candidates ()
  "Set candidates with result and number of google results found."
  (let ((suggestions (anything-c-google-suggest-fetch anything-input)))
    (setq suggestions (loop for i in suggestions
                         collect (concat (car i) " (" (cdr i) "results)")))
    (if (some (lambda (data)
                (equal (car (split-string data)) anything-input))
              suggestions)
        suggestions
        ;; if there is no suggestion exactly matching the input then
        ;; prepend a Search on Google item to the list
        (append (list (cons (concat "Search for "
                                    "'" anything-input "'"
                                    " on Google")
                            anything-input))
                suggestions))))
    
(defun anything-c-google-suggest-action (candidate)
  "Default action to jump to a google suggested candidate."
  (let ((elm (car (split-string candidate))))
    (browse-url (concat anything-c-google-suggest-search-url
                        (url-hexify-string elm)))))


(defvar anything-c-source-google-suggest
  '((name . "Google Suggest")
    (candidates . anything-c-google-suggest-set-candidates)
    (action . (("Google Search" . anything-c-google-suggest-action)))
    (volatile)
    (requires-pattern . 3)
    (delayed)))
;; (anything 'anything-c-source-google-suggest)


;;; Surfraw
;;; Need external program surfraw.
