Emacs dired 模式和 Isearch

发布于 2024-10-08 06:53:48 字数 666 浏览 8 评论 0原文

我最近发现了 Emacs 的 dired 模式的一些强大功能和易用性。 但在 Krusader 中,我只是开始按文件夹/文件的第一个字母,然后按 Enter,所以我深入,然后搜索另一个文件夹,聚焦,按 Enter 直到找到我应该打开的文件。

我现在如何在 Dired 中执行此操作:

  • 按 Ctrl+S 进行 isearch
  • 按查找文件夹的字母
  • 按 Enter(或其他组合)一次以逃避 I-search
  • 按 Enter 输入文件夹或打开文件(用于打开文件我知道我有其他字母也是如此)

我真的需要让这变得更容易。 所以我想要的主要事情是当我按一次回车键时:

  • 转义Isearch
  • 输入文件夹(或打开文件)

当然第二个主要事情默认情况下是BE在某些带有 dired 的 isearch 模式下,只需通过键入进行导航,并且仅当按 ESC 时才处于单个字母具有命令含义的 dired 模式。我不确定这第二件主要事情是否容易实现或推荐用于 dired。 但是主要的事情我相信应该可以通过一些智能的 Lisp 行来完成,我不知道:)

谢谢你们,

Stefan

I recently discovered some of the power and easy of use of dired mode of Emacs.
But in Krusader, I just begin press first letter(s) of folder/file, and press enter, and so I go deep, then search for another folder, focus, press enter until I found the file I should open.

How I do it in dired now:

  • press Ctrl+S for isearch
  • press the letters for finding folder
  • press enter (or some other combination) once to escape I-search
  • press enter to enter folder or open file (for opening file I know I have other letters as well)

I really need to make this easier.
So the main thing I want is when I press enter once, to:

  • escape Isearch
  • enter folder (or open file)

Of course the second main thing would be to BE by default in some isearch mode with dired, to just navigate by typing, and only when press ESC to be in that dired mode where single letters have commands meanings. I'm not sure if this second main thing is easy possible or recommended for dired.
But the main thing I believe should be doable with a few smart Lisp lines, which I don't know :)

Thank you guys,

Stefan

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

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

发布评论

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

评论(3

梦魇绽荼蘼 2024-10-15 06:53:48

这是完成主要事情的一种方法:

(add-hook 'isearch-mode-end-hook 
  (lambda ()
    (when (and (eq major-mode 'dired-mode)
           (not isearch-mode-end-hook-quit))
      (dired-find-file))))

Here's one way to do the main thing:

(add-hook 'isearch-mode-end-hook 
  (lambda ()
    (when (and (eq major-mode 'dired-mode)
           (not isearch-mode-end-hook-quit))
      (dired-find-file))))
梦罢 2024-10-15 06:53:48

对于第二个主要事情:

(defadvice dired (after activate)
  (isearch-forward))

(ad-activate 'dired)


(defadvice dired-find-file (after activate)
  (isearch-forward))

(ad-activate 'dired-find-file)


(defadvice dired-up-directory (after activate)
   (isearch-forward))

(ad-activate 'dired-up-directory)

For the second main thing:

(defadvice dired (after activate)
  (isearch-forward))

(ad-activate 'dired)


(defadvice dired-find-file (after activate)
  (isearch-forward))

(ad-activate 'dired-find-file)


(defadvice dired-up-directory (after activate)
   (isearch-forward))

(ad-activate 'dired-up-directory)
笑叹一世浮沉 2024-10-15 06:53:48

借助 madalu 的答案,您可以通过将 isearches 串在一起来接近第二个主要内容:

(add-hook 'isearch-mode-end-hook 
  (lambda ()
    (when (and (eq major-mode 'dired-mode)
               (not isearch-mode-end-hook-quit))
      (dired-find-file)
      (isearch-forward-regexp))))

Piggy-backing on madalu's answer, you can get close to the second main thing by stringing isearches together:

(add-hook 'isearch-mode-end-hook 
  (lambda ()
    (when (and (eq major-mode 'dired-mode)
               (not isearch-mode-end-hook-quit))
      (dired-find-file)
      (isearch-forward-regexp))))
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文