              (evernote-get-current-line-string)
              evernote-search-mode-formatted-name-displayed-name-alist))
       (kill-buffer (current-buffer))
-      (evernote-set-minibuffer-string displayed-name)
-      (exit-minibuffer))))
+      (if (active-minibuffer-window)
+          (progn
+            (evernote-set-minibuffer-string displayed-name)
+            (exit-minibuffer))))))
 
 
 (defun evernote-find-opened-buffer (guid)

      (ding)
      (evernote-minibuffer-tmp-message "[No Match]"))
     ((string= result word)
      (let (formatted-name-displayed-name-alist completion-buf)
        (setq formatted-name-displayed-name-alist
              (mapcar (lambda (displayed-name)
                        (cons
                         (evernote-assoc-cdr
                          displayed-name
                          evenote-note-displayed-name-formatted-name-alist)
                         displayed-name))
                      (all-completions
                       word
                       evenote-note-displayed-name-formatted-name-alist)))
        (setq completion-buf (get-buffer-create "*Evernote-Completions*"))
        (save-excursion
          (set-buffer completion-buf)
          (evernote-display-note-completion-list
           formatted-name-displayed-name-alist)
          (setq evernote-search-mode-formatted-name-displayed-name-alist
                formatted-name-displayed-name-alist)
          (evernote-search-mode))
        (display-buffer completion-buf)))
     (t (evernote-set-minibuffer-string result)
        (end-of-buffer)
        (if (eq t

   search-command-out))


(defun evernote-read-note-attr (note-command-out &optional display-completion)
  "Prompts a note name and returns a note attribute"
  (let ((name-num-hash (make-hash-table :test #'equal))
        evernote-note-displayed-name-attr-alist ; used in evernote-search-mode
