从 Emacs 21.2 升级时,迷你缓冲区中的动态扩展不再起作用

发布于 2024-09-14 17:41:50 字数 273 浏览 8 评论 0原文

继续我的迁移最新版本的过程最伟大的 Emacs 23.2,我遇到了另一个令人不快的惊喜:动态扩展在迷你缓冲区不再起作用!

我所说的“迷你缓冲区中的动态扩展”是指让您盲目地按空格键来完成文件名、变量等的功能。

我还调用了“Emacs -Q”(以排除任何 .emacs 工件),问题不仅存在在 Windows XP 上使用 Emacs 23.2,甚至在 Ubuntu 上使用 Emacs 22.1。

Emacs 的默认行为发生了一些变化,但它是什么呢?

Continuing my process of migrating the latest & greatest Emacs 23.2, I hit another unpleasant surprise: dynamic expansion in minibuffer no longer works!

By "dynamic expansion in the minibuffer" I mean the feature that lets you blindly hit the spacebar to complete filenames, variables, etc.

I also invoked 'Emacs -Q' (to rule out any .emacs artifacts) and the problem exists not only with Emacs 23.2 on Windows XP, but even with Emacs 22.1 on Ubuntu.

Something has changed in Emacs' default behavior, but what is it?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

〆一缕阳光ご 2024-09-21 17:41:50

来自 (22.1) 新闻文件:

** When Emacs prompts for file names, SPC no longer completes the file name.
This is so filenames with embedded spaces could be input without the
need to quote the space with a C-q.  The underlying changes in the
keymaps that are active in the minibuffer are described below under
"New keymaps for typing file names".

If you want the old behavior back, add these two key bindings to your
~/.emacs init file:

  (define-key minibuffer-local-filename-completion-map
         " " 'minibuffer-complete-word)
  (define-key minibuffer-local-must-match-filename-map
         " " 'minibuffer-complete-word)

From the (22.1) NEWS file:

** When Emacs prompts for file names, SPC no longer completes the file name.
This is so filenames with embedded spaces could be input without the
need to quote the space with a C-q.  The underlying changes in the
keymaps that are active in the minibuffer are described below under
"New keymaps for typing file names".

If you want the old behavior back, add these two key bindings to your
~/.emacs init file:

  (define-key minibuffer-local-filename-completion-map
         " " 'minibuffer-complete-word)
  (define-key minibuffer-local-must-match-filename-map
         " " 'minibuffer-complete-word)
走走停停 2024-09-21 17:41:50

发布的解决方案有效,但一旦我们使用 Emacs v24 及更高版本,就会崩溃。我建议您将 define-key 调用与新地图的存在联系起来,如下所示:

(if (boundp 'minibuffer-local-filename-completion-map) 
   (define-key minibuffer-local-filename-completion-map " " 'minibuffer-complete-word))

(if (boundp 'minibuffer-local-must-match-filename-map)
   (define-key minibuffer-local-must-match-filename-map " " 'minibuffer-complete-word))

这应该适用于所有 Emacs 版本。

The posted solution works, but will break once we get to Emacs v24 and later. I would recommend instead tying your define-key calls to the presence of the new maps, as so:

(if (boundp 'minibuffer-local-filename-completion-map) 
   (define-key minibuffer-local-filename-completion-map " " 'minibuffer-complete-word))

(if (boundp 'minibuffer-local-must-match-filename-map)
   (define-key minibuffer-local-must-match-filename-map " " 'minibuffer-complete-word))

This should work correctly for all Emacs versions.

是你 2024-09-21 17:41:50

回答我的第二个问题(在评论中):

(defmacro GNUEmacs23 (&rest body)
  (list 'if (string-match "GNU Emacs 23" (version))
        (cons 'progn body)))

(defmacro GNUEmacs22 (&rest body)
  (list 'if (string-match "GNU Emacs 22" (version))
        (cons 'progn body)))

(GNUEmacs22
  (define-key minibuffer-local-filename-completion-map " " 'minibuffer-complete-word)
  (define-key minibuffer-local-must-match-filename-map " " 'minibuffer-complete-word)
)

(GNUEmacs23
  (define-key minibuffer-local-filename-completion-map " " 'minibuffer-complete-word)
  (define-key minibuffer-local-must-match-filename-map " " 'minibuffer-complete-word)
)

如果您想出一个更优雅的解决方案,那就太好了,但上述内容对我有用(目前)。

Answering my 2nd question (in the comment):

(defmacro GNUEmacs23 (&rest body)
  (list 'if (string-match "GNU Emacs 23" (version))
        (cons 'progn body)))

(defmacro GNUEmacs22 (&rest body)
  (list 'if (string-match "GNU Emacs 22" (version))
        (cons 'progn body)))

(GNUEmacs22
  (define-key minibuffer-local-filename-completion-map " " 'minibuffer-complete-word)
  (define-key minibuffer-local-must-match-filename-map " " 'minibuffer-complete-word)
)

(GNUEmacs23
  (define-key minibuffer-local-filename-completion-map " " 'minibuffer-complete-word)
  (define-key minibuffer-local-must-match-filename-map " " 'minibuffer-complete-word)
)

If you come up with a more elegant solution, that would be great, but the above works for me (for now).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文