书签的完成选择来自Emacs迷你缓冲区

时间:2013-10-15 09:58:41

标签: emacs

我设置了几个书签以跳转到dired个缓冲区。之前Emacs会在点击C-x r b以回忆书签之后在迷你缓冲区中为我提供一些(内联)候选人列表,但在对我的.emacs文件进行一些黑客攻击后将其拆分为模块列表候选人已经失踪。

我认为我无意中更改了与idoautocomplete相关的一些设置,我使用了这两个设置,但我无法弄清楚它是什么。有人可以提出解决方案吗? [编辑:书签仍然存在,如果我输入书签的名称,我可以跳转到它们,但没有提示列表。如果我按TAB,我会得到一个带有完成候选者的缓冲区,但我不会将它们放入迷你缓冲区。]

minibuffer

以前我会得到这个:

minibuffer2

我认为这与我从Scott Frazer复制的以下一系列功能有关。

(require 'bookmark)

(defun my-ido-bookmark-jump ()
  "Jump to bookmark using ido"
  (interactive)
  (let ((dir (my-ido-get-bookmark-dir)))
    (when dir
      (find-alternate-file dir))))

(defun my-ido-get-bookmark-dir ()
  "Get the directory of a bookmark."
  (let* ((name (ido-completing-read "Use dir of bookmark: " (bookmark-all-names) nil t))
         (bmk (bookmark-get-bookmark name)))
    (when bmk
      (setq bookmark-alist (delete bmk bookmark-alist))
      (push bmk bookmark-alist)
      (let ((filename (bookmark-get-filename bmk)))
        (if (file-directory-p filename)
            filename
          (file-name-directory filename))))))

(defun my-ido-dired-mode-hook ()
  (define-key dired-mode-map "$" 'my-ido-bookmark-jump))

(add-hook 'dired-mode-hook 'my-ido-dired-mode-hook)


(defun my-ido-use-bookmark-dir ()
  "Get directory of bookmark"
  (interactive)
  (let* ((enable-recursive-minibuffers t)
         (dir (my-ido-get-bookmark-dir)))
    (when dir
      (ido-set-current-directory dir)
      (setq ido-exit 'refresh)
      (exit-minibuffer))))

;;define-key ido-file-dir-completion-map (kbd "$") 'my-ido-use-bookmark-dir)

(add-hook 'ido-setup-hook 'ido-my-keys)
(defun ido-my-keys ()
"Add my keybindings for ido."
(define-key ido-file-dir-completion-map (kbd "$") 'my-ido-use-bookmark-dir))

1 个答案:

答案 0 :(得分:4)

试试这个

(global-set-key (kbd "C-x r b")
    (lambda ()
      (interactive)
      (bookmark-jump
       (ido-completing-read "Jump to bookmark: " (bookmark-all-names)))))