File 如何在emacs中快速打开文件?

File 如何在emacs中快速打开文件?,file,emacs,organization,File,Emacs,Organization,我有一个非常复杂和密集的文件夹和文件结构。我想在emacs中快速打开一个离家很远的文件 C-x C-f不够快,因为我必须编写可能很长的路径(例如:/very/long/and/boring/path/which/make/me/use/tab/for/autocompletion/too/much/and/writes/my/hands/with/repeative/drain/injuries/my\u file\u finally.tex) 那么,是否有另一种方式,比打开此类文件更快(比C-

我有一个非常复杂和密集的文件夹和文件结构。我想在emacs中快速打开一个离家很远的文件

C-x C-f
不够快,因为我必须编写可能很长的路径(例如:
/very/long/and/boring/path/which/make/me/use/tab/for/autocompletion/too/much/and/writes/my/hands/with/repeative/drain/injuries/my\u file\u finally.tex

那么,是否有另一种方式,比打开此类文件更快(比
C-x C-f
),如果没有,是否有办法为最常用的文件创建快捷方式

我不想移动文件(长路径对我来说意味着干净有序的计算机)

  • 注意几乎相同的问题。特别地,考虑使用(a)DigRead书签和其他项目相关书签在<强>书签+< /强>和(b)项目相关的AIDS在<强>冰柱< /强>

  • 您可以为长目录名创建缩写——请参见
    directory abbrev list

  • 选项#1——每个指定键一个功能:

    (global-set-key (kbd "<f6>") (lambda () (interactive)
      (find-file "/Users/HOME/.0.data/todo.org")
      (message "Opened:  %s" (buffer-name))))
    

    选项4——菜单栏下拉菜单:

    (require 'easymenu)
    
    (easy-menu-define lawlist-menu global-map "My own menu"
      '("lawlist"
        ["Next Line" next-line t]
        ["Previous Line" previous-line t]
        ["Dired Mode" dired t]
        ["--" my-function t]
        ("Favorites"
        ["Diary" (find-file "/Users/HOME/.0.data/diary.org")]
        ["--" diary]
        ["GTD" (find-file "/Users/HOME/.0.data/gtd.org")]
        ["--" gtd]
        ["Vocab" (find-file "/Users/HOME/.0.data/vocab.org")]
        ["--" vocab]
        ["Notes" (find-file "/Users/HOME/.0.data/notes.org")]
        ["--" notes]
        ["ToDo" (find-file "/Users/HOME/.0.data/todo.org")]
        )  ))
    

    除了以上的答案,可能是一个很好的解决你的问题。虽然它在复杂的模式匹配和创建/管理/保存复杂文件集方面做得不多,但helm做得既好又快(从击键角度和软件/延迟角度)。只需
    M-x软件包安装头盔
    ,就可以安装了

    首先,helm可以跟踪您最近使用过的文件列表。只需
    M-x helm recentf
    并键入与所需文件名匹配的字符串/regex,它将与您最近实时打开的文件名匹配。滚动并输入以选择一个

    但是等等!还有更多:(如果这听起来像广告,那就很抱歉)如果你在Linux上(我假设你在路径中使用斜杠,而且看起来是emacs+Linux>mac+Linux),你可以使用GNU locate,这是一个查找系统中任何位置文件的工具,只要locate守护进程以前见过它,如果文件已经存在了一段时间,那么它可能已经存在了一段时间(请参阅下面的内容,了解它没有存在的时间)。这几乎是实时的。定位过程很快,helm会实时流式显示结果。该命令是
    M-x helm locate

    现在,如果您想在git/mercurial/bazaar/等项目中查找文件,该怎么办?您可以使用“项目交互库”。使用头盔投射物(您将需要以与头盔本身相同的方式安装投射物和头盔投射物)。它将文件/目录名和其他任何内容流式传输到helm中。再一次您只需键入一个匹配任何位置的子字符串,helm就会为您找到它<代码>M-x头盔投射物

    Github自述说“helm有很多能力”。还有很多很多事情要做。试一试舵手摩克、舵手确认(外部软件包)、舵手伊梅努、舵手浏览代码、舵手跟踪器搜索、舵手达布列夫等

    最后:为什么要选择一个呢?helm做得很好的一件事是创建您自己的命令。下面是一个搜索上述所有内容的函数

    ;; you'll need to require helm-config and helm-projectile somewhere above
    (defun my-helm-omni (&rest arg) 
      ;; just in case someone decides to pass an argument, helm-omni won't fail.
      (interactive)
      (helm-other-buffer
        (append '(helm-c-source-buffers-list ;; list of all open buffers
                   helm-c-source-recentf)    ;; all recent files
    
          ;; projectile errors out if you're not in a project 
          (if (projectile-project-p) ;; so look before you leap
            '(helm-source-projectile-files-list
               helm-source-projectile-recentf-list
               helm-source-projectile-buffers-list)
            '())
    
          '(
             helm-c-source-files-in-current-dir ;; files in current directory
             helm-c-source-locate               ;; file anywhere
             helm-c-source-bookmarks            ;; bookmarks too
             helm-c-source-buffer-not-found     ;; ask to create a buffer otherwise
             ))
        "*helm-omni*"))
    

    我将此绑定到
    C-co
    我还将提到
    filecache.el
    。它基本上提供了一个专门的完成(您可以绑定到一个键,以便在输入文件名时使用),它首先在“filenames,而不管目录”上完成,一旦完成,循环浏览找到此类文件的几个目录。

    您可以使用以更快地打开文件和/或键入文件路径。您可以创建指向更深层目录的符号链接。虽然我对它没有太多了解,查看
    ICICICLES
    ,它声称可以让你更有效地使用迷你缓冲区。我有一个类似的问题。在我的公司里,我有一些标准的文件夹,我会不时访问它们。为了快速访问这些文件夹,我在启动(.emacs)时打开了一个组织文件。在该组织文件中,有一个指向标准位置的链接列表。单击打开dired。从那里,您还可以使用鼠标访问特定的子文件夹。组织文件很好,因为即使使用regexp to goto to,您也可以向文件添加注释或链接。这并不能回答问题。若要评论或要求作者澄清,请在其帖子下方留下评论。当然可以。您是否费心检查了
    filecache.el
    ?“答案”不符合SO标准。它是一行,没有添加上下文。即使这是OP的答案,对社区也没有什么用处。看,所以你的“评论”真的想说我的回答太简洁了。我现在已经扩展了,说得对。评论是由审阅队列机制自动生成的。您的答案被标记为低质量,并最终进入我的审阅队列。也许我应该在[D]ired前面加上一个自定义注释,这样会更清楚。只是好奇的问题:在选项2中,如果我在[D]ired前面去掉“c”,我就有一个错误。这需要“c”是什么意思?它们被称为
    交互代码
    :这一精彩答案的另一个问题:
    (require 'easymenu)
    
    (easy-menu-define lawlist-menu global-map "My own menu"
      '("lawlist"
        ["Next Line" next-line t]
        ["Previous Line" previous-line t]
        ["Dired Mode" dired t]
        ["--" my-function t]
        ("Favorites"
        ["Diary" (find-file "/Users/HOME/.0.data/diary.org")]
        ["--" diary]
        ["GTD" (find-file "/Users/HOME/.0.data/gtd.org")]
        ["--" gtd]
        ["Vocab" (find-file "/Users/HOME/.0.data/vocab.org")]
        ["--" vocab]
        ["Notes" (find-file "/Users/HOME/.0.data/notes.org")]
        ["--" notes]
        ["ToDo" (find-file "/Users/HOME/.0.data/todo.org")]
        )  ))
    
    ;; you'll need to require helm-config and helm-projectile somewhere above
    (defun my-helm-omni (&rest arg) 
      ;; just in case someone decides to pass an argument, helm-omni won't fail.
      (interactive)
      (helm-other-buffer
        (append '(helm-c-source-buffers-list ;; list of all open buffers
                   helm-c-source-recentf)    ;; all recent files
    
          ;; projectile errors out if you're not in a project 
          (if (projectile-project-p) ;; so look before you leap
            '(helm-source-projectile-files-list
               helm-source-projectile-recentf-list
               helm-source-projectile-buffers-list)
            '())
    
          '(
             helm-c-source-files-in-current-dir ;; files in current directory
             helm-c-source-locate               ;; file anywhere
             helm-c-source-bookmarks            ;; bookmarks too
             helm-c-source-buffer-not-found     ;; ask to create a buffer otherwise
             ))
        "*helm-omni*"))