文本编辑器和基于文本文件的超链接

发布于 2024-08-17 09:05:35 字数 1153 浏览 2 评论 0原文

背景:

一些文本编辑器和 IDE 的功能似乎开始变得更加“类似于浏览器”。具体来说,这样的功能之一就是能够将打开的文本缓冲区中的普通文本视为另一个文件、资源甚至可运行命令的超链接。

将其编程为编辑器插件或宏

由于这似乎是一个好主意,我已经开始编写一些脚本和编辑器插件来完成这种事情,以便文本编辑器的用户可以打开或对以下样式的链接进行操作:

href="c:/files/foobar.txt"                   (click to open file)
href="c:/files/foobar.txt" jumpto="34"       (jump to a line number)
href="c:/files/foobar.txt" find="Lorem"      (jump to 1st line containing word)
href="find_in_files://c:/files" find="Lorem" (show all matching lines)
[[find_in_files://find=Lorem;exten=*.htm*]]  (alternate syntax option)
href="redir://c:/files/feebar.txt"           (replace current edit buffer)
href="run://c:/files/foobar.jpg"             (open in default image editor)
[[run://c:/files/foobar.jpg;runwith=foo.exe]] (alternate syntax option)

问题:

  1. 是否有任何类型的新兴约定用于形成基于文本的超链接?
  2. 如果有此类事情的约定,是否有已发布的规范?
  3. 您最喜欢的编辑器/IDE 中有这个想法的实现吗?
  4. 对于这个想法,是否有一种不使用超链接的替代现有方法?
  5. “祖父”编辑器如何处理此功能? (Vim,Emacs)

更新:

看起来这个问题可以得到澄清,但事实证明 Emacs Org 模式是我正在寻找的一个具体示例,可以回答我的所有问题。

Background:

It seems that some text editors and IDEs are starting to get more "browser-like" in their features. Specifically, one such feature is the ability to treat ordinary text in an open text buffer as a hyperlink to another file, resource, or even a runnable command.

Programming this as an editor plugin or macro

Since this seems like a good idea, I have started programming some scripts and editor addons to do this very kind of thing, so that the user of a text editor can open or operate on links of the following style:

href="c:/files/foobar.txt"                   (click to open file)
href="c:/files/foobar.txt" jumpto="34"       (jump to a line number)
href="c:/files/foobar.txt" find="Lorem"      (jump to 1st line containing word)
href="find_in_files://c:/files" find="Lorem" (show all matching lines)
[[find_in_files://find=Lorem;exten=*.htm*]]  (alternate syntax option)
href="redir://c:/files/feebar.txt"           (replace current edit buffer)
href="run://c:/files/foobar.jpg"             (open in default image editor)
[[run://c:/files/foobar.jpg;runwith=foo.exe]] (alternate syntax option)

Questions:

  1. Is there any kind of emerging convention for forming text-based hyperlinks?
  2. If there is a convention for this kind of thing, is there a published specification?
  3. Is there an implementation of this idea in your favorite editor/IDE?
  4. Is there an alternate pre-existing approach for this idea that does not use hyperlinks?
  5. How is this feature handled in the "grand-daddy" editors? (Vim, Emacs)

Update:

It looks like the question could have been clarified, but it turns out that Emacs Org mode is one specific example of what I was looking for that answers all of my questions.

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

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

发布评论

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

评论(6

混浊又暗下来 2024-08-24 09:05:35

Emacs 的 Org-Mode 支持各种超链接

Emacs' Org-Mode has support for all kinds of Hyperlinks.

活泼老夫 2024-08-24 09:05:35

Vim 有几个添加超链接和标记的脚本。其中最受欢迎的一个是 Viki

There are several script for Vim that add hyperlinks and markup. One of the most popular is Viki.

怼怹恏 2024-08-24 09:05:35
  1. URL,例如 http://example.com/ (请注意,SO 自动链接该链接),有时是“www ”。前缀,只是因为它很常见。电子邮件地址是另一个常见的例子。
    • 但不是您拥有的这种准 xml 属性的东西。
  2. 当然不是;一旦你尝试让纯文本遵循某种约定,你就不再拥有纯文本。
  3. 是的,请参阅#5。
  4. 是的,请参阅#5。
  5. 对于编辑器(尤其是程序员的编辑器)来说,拥有脚本、宏、工具或任何他们想要称呼的东西是非常常见的。通常这些不是由文件中的文本直接控制的,而是可能使用文件、文件名、选择、光标位置、当前文件的目录等。我希望许多优秀的程序员使用这些功能而不再考虑它们。

大多数情况下,听起来你正在尝试解决一个不存在的问题。

  1. URLs, such as http://example.com/ (notice SO automatically links that), and sometimes a "www." prefix, just because it's so common. Email addresses are another example commonly recognized.
    • But not this quasi-xml-attribute stuff you have.
  2. Of course not; once you try and make plain text follow some convention, you no longer have plain text.
  3. Yes, see #5.
  4. Yes, see #5.
  5. It's extremely common for editors, especially programmers' editors, to have scripts, macros, tools, or whatever-they-want-to-call-it. Usually these are not controlled directly by the text in the file, but may use the file, filename, selection, cursor position, directory of the current file, etc. I expect many good programmers use such features without thinking about them anymore.

Mostly it sounds like you're trying to solve a problem that doesn't exist.

白首有我共你 2024-08-24 09:05:35

jumpto="34"find="Lorem" 肯定可以替换为网络浏览器风格的 #吗?< /code> 标记。

所以你的第二个和第三个例子看起来像这样:

href="c:/files/foobar.txt#34"       (jump to a line number)
href="c:/files/foobar.txt?Lorem"    (jump to 1st line containing word)

尽管,正如罗杰·佩特上面所说,听起来你正在解决一个不存在的问题。

Surely the jumpto="34" and find="Lorem" could be replaced with web-browser-style # and ? marks.

So your second and third example would look like so:

href="c:/files/foobar.txt#34"       (jump to a line number)
href="c:/files/foobar.txt?Lorem"    (jump to 1st line containing word)

Although, as Roger Pate says above, it does sound like you're solving a problem that doesn't exist.

顾北清歌寒 2024-08-24 09:05:35

Emacs 还具有“find-file-at-point”功能,您可以使用 Mx ffap 调用它

Emacs also has "find-file-at-point", which you can invoke with M-x ffap

千纸鹤带着心事 2024-08-24 09:05:35

另请参阅 LinkD。没有什么比 Org 更花哨的了。简单,小。

See also LinkD. Nothing fancy like Org. Simple, small.

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