emacs 中文件和目录路径的长名称别名

发布于 2024-10-07 19:39:21 字数 713 浏览 4 评论 0原文

我在Emacs 文档中阅读了Emacs支持的将文件名存储在寄存器中,允许用户通过命令Cx rj r快速检索它们,其中r是寄存器的名称。然而,这显然仅限于单字符寄存器名称。

例如,以下示例有效:

(set-register ?c '(file . "/gd/gnu/emacs/19.0/src/ChangeLog"))

即它允许我只需输入 Cx rj z 即可访问上面的文件 ChageLog。

但是,如果我尝试将上述文件的路径存储在具有较长名称的寄存器中,如下所示:

(set-register ?clog '(file . "/gd/gnu/emacs/19.0/src/ChangeLog"))

我从 Lisp 解释器中收到以下错误消息:

无效的读取语法:“?”

我的问题是:是否有一种(简单)方法可以使用长名称别名在 emacs 中存储文件名(和目录路径),以便我可以快速访问它们? (用于编辑文件,或将其加载到dired中)。

谢谢

I read in the Emacs documentation that Emacs supports storing file names in registers that allows a user to quickly retrieve them via the command C-x r j r, where r is the name of the register. However, this is apparently limited to single character register names.

E.g. The following example works:

(set-register ?c '(file . "/gd/gnu/emacs/19.0/src/ChangeLog"))

i.e. it allows me to visit the file ChageLog above by just typing C-x r j z.

However, if I try to store the path to the above file in a register with a longer name, as in:

(set-register ?clog '(file . "/gd/gnu/emacs/19.0/src/ChangeLog"))

I get the following error message from he Lisp interpreter:

Invalid read syntax: "?"

My question then is: Is there a (easy) way of storing file names (and directory paths) in emacs using long name aliases, so that I can quickly visit them? (for editing a file, or loading it in dired).

Thanks

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

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

发布评论

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

评论(3

暖风昔人 2024-10-14 19:39:21

请参阅书签

谁许谁一生繁华 2024-10-14 19:39:21

Emacs 中的寄存器被设计为通过单键按键来访问,因此它们以字符命名。 ?x 语法是字符语法。您可以将路径保存在普通变量中,或者使用哈希表来避免污染变量名称空间,但我不知道现有的包可以执行此操作,并且只能执行此操作。

我相信更常见的用例是保持您想要快速/经常访问的文件打开,并坚持 会话状态。使用 iswitch 之类的东西可以使缓冲区之间的切换更加方便。

我也不明白为什么 书签 不适合您用例。如果您确实想手动输入路径 (add-to-list 'bookmark-alist '(bookmarkname (filename . "/path/to/your/file"))) 似乎可行,尽管访问文件一次并保存书签更简单。

Registers in Emacs are designed to be accessed with single key presses, so they are named by characters. The ?x syntax is a character syntax. You could save paths in normal variables, or use a hash-table to avoid polluting the variable namespace, but I do not know a preexisting package to do this and only this.

I believe that the more common use case is to just keep files you want to access quickly/often open, and persist the session state. Switching between buffers can be made more convenient with something like iswitch.

I also do not see why Bookmarks do not fit your use case. If you really want to type the path by hand (add-to-list 'bookmark-alist '(bookmarkname (filename . "/path/to/your/file"))) appears to work, although visiting the file once and saving a bookmark is simpler.

時窥 2024-10-14 19:39:21

您可以为文件添加书签,而无需实际访问它。听起来这就是您所要求的:一种指定绝对文件名并为其添加书签的方法(这样您就可以使用较短的书签名称)。

Bookmark+ 是您想要的:

http://www.emacswiki.org/ emacs/BookmarkPlus#BookmarkingWithoutVisiting

< a href="/questions/tagged/bookmark" class="post-tag" title="显示标记为“书签”的问题" rel="tag">书签

You can bookmark a file without actually visiting it. Sounds like that's what you're asking for: a way to specify the absolute file name and get a bookmark to it (so you can use the shorter, bookmark name).

Bookmark+ is what you want:

http://www.emacswiki.org/emacs/BookmarkPlus#BookmarkingWithoutVisiting

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