开发者

Long name aliases for file and directory paths in emacs

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 loa开发者_JS百科ding it in dired).

Thanks


See Bookmarks.


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.


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

bookmarksbookmark

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜