3

我想知道 Dired 缓冲区中的“东西”是什么。

例如 Debug 是一个“目录”:

drwxrwxrwx 0 10-08-2009 17:50 调试

Makefile 是一个“文件”:

-rw-rw-rw- 15k 6-03-2009 13:02 生成文件

这是一个“标题”

d:/foo/bar/调试:

找到一个东西的一种方法是看点是什么脸。还有另一种方法吗?如何确定事物的边界?

标准 (thing-at-point 'filename) 不处理文件名中的空格。

4

4 回答 4

6

这些功能可能有助于炮制您想要的东西:

  • 目录获取文件名
  • 目录移动到文件名
  • 目录移动到文件名末尾
  • 文件目录-p 和朋友
于 2009-08-11T21:49:39.620 回答
1

There is never (almost never?) a single thing at point. There are thing-at-point functions that can retrieve some text at or near point that is a thing of a particular type. So you have a fundamental misconception here.

In Dired, as elsewhere, depending on where point is, you can retrieve a symbol name at point, a file name at point, and several other kinds of things -- all from the same position.

Others have answered how to determine whether a given line is for an ordinary file or a directory.

If you use Dired+, then you can use C-h RET (command diredp-describe-file) to get information about the file or directory on the current line -- its type, attributes, etc.

If you want to get a thing at or near point programmatically, see Thing At Point+.

于 2011-09-05T00:13:28.540 回答
1

列表的第一个字符是 d 表示目录,l 表示链接,- 表示普通文件。有代表字符和块设备、进程等的字符。您还想知道什么?(我从未见过你的“标题”类型。你是如何产生的?)

于 2009-08-11T16:10:30.693 回答
1

您可以使用叠加层突出显示文本。以下是您可以添加到 .emacs 文件中的几个函数来执行此操作。关键是我们将所有以这种方式创建的叠加层命名为“my-highlights”,以便我们以后可以仅删除这些叠加层。

(defun highlight-thing-at-point ()
  (interactive)
  (let* ((my-thing (bounds-of-thing-at-point 'sexp))
         (my-overlay (make-overlay (first my-thing) (rest my-thing))))
    (overlay-put my-overlay 'name 'my-highlights)
    (overlay-put my-overlay 'face 'highlight)))

(defun unhighlight-all-of-mine ()
  (interactive)
  (remove-overlays nil nil 'my-highlights))

编辑:

您可以添加一个自定义函数,用于在其中包含空格的点处返回文件名的边界。有关示例,请参阅此 EmacsWiki 文章。因此,如果您编写一个名为 my-bounds-of-filename-at-point 的函数,您可以将其设置为 (bounds-of-thing-at-point 'filename) 和 (thing-at-point 'filename) 的默认值,例如这个:

(put 'filename 'bounds-of-thing-at-point 'my-bounds-of-filename-at-point)
于 2009-08-11T07:01:17.307 回答