emacs - 将当前缓冲区列表保存到文本文件 [英] emacs - save current buffer list to a text file

查看:120
本文介绍了emacs - 将当前缓冲区列表保存到文本文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我经常需要获取我当前打开的文件的简单文本。原因通常是:

Quite often I need to get a simple text copy of my currently opened files. The reasons are usually:


  • 我想将列表发送给同事

  • 我想记录我正在开展的工作(通常在组织文档中)

  • 我想对我当前打开的一个文件(在shell上)采取行动。我需要复制粘贴该路径名。

事实是,通常的缓冲区菜单 list-buffers 提供了一个方便的菜单来浏览打开的缓冲区,但是非常不便于将邮件复制粘贴到终端的名称文件,或执行上述任何操作。例如:我不能双击一行来选择完整的路径名,我不能使用 kill / yank emacs序列来复制路径名。

The fact is that the usual buffer-menu or list-buffers provide a convenient menu to navigate the opened buffers, but are very inconvenient to copy-paste to the the terminal the names of the opened files, or to perform any of the actions mentioned above. For example: I can not double-click in a line to select the full path-name, and I can not use the kill/yank emacs sequence to copy around the path-name.

总结:我想要一种导出到文本文件(或新的缓冲区)的方法,打开的文件列表,没有其他数据;没有文件大小,模式或任何其他emacs元数据。

Summary: I would like a way to export to a text file (or to a new buffer) the list of opened files, without other data; no file size, mode, or any other emacs metadata.

有没有一个命令?可以安装一个额外的包?

Is there a command for that? An extra package I can install?

添加Trey Jackson的解决方案,修改后提供一些反馈已经做了什么:

Adding solution by Trey Jackson, modified to provide some feedback of what has been done:

(defun copy-open-files ()
  "Add paths to all open files to kill ring"
  (interactive)
  (kill-new (mapconcat 'identity 
                       (delq nil (mapcar 'buffer-file-name (buffer-list))) 
                       "\n"))
  (message "List of files copied to kill ring"))


推荐答案

此命令将为您完成此工作:

This command will do the job for you:

(defun copy-open-files ()
  "Add paths to all open files to kill ring"
  (interactive)
  (kill-new (mapconcat 'identity 
                       (delq nil (mapcar 'buffer-file-name (buffer-list))) 
                       "\n")))

这篇关于emacs - 将当前缓冲区列表保存到文本文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆