如何防止面部流到缓冲区周围?


20

问:如何org-mode避免链接面渗入...折叠页眉末尾的选择性显示字符中?

这是一个视觉上的滴答声,使我有点生气。在中org-mode,当链接是一行中的最后一个内容时,链接面会渗入到...,表示标头已折叠。例如,如果链接后有空白空间,则不存在出血。

我发布的屏幕快照演示了该问题。第三行是有问题的行,在链接的末尾和行尾之间没有字符,而第四行则显示了一个链接,后跟一个空格:

怪异的链接面行为

首先,为什么会这样?其次,更重要的是,如何使它停止?

更新1:根据评论,下面是缓冲区的屏幕截图,其中标题已关闭且已打开。我已经打开了没有初始化文件(即emacs -Q),required org模式的Emacs ,并打开了此示例文件。因此:在我的设置中,它似乎并不奇怪。

所有标题已关闭: 怪异的链接脸封闭

所有标题均打开: 怪异的链接脸开

尽管在使用solarized主题以及默认主题(如新的屏幕截图)时遇到了相同的问题,但我上面一直使用的主题是墨水瓶。

Emacs版本是24.3.1。使用组织版本7.9.3f(即与该Emacs版本捆绑在一起的版本)以及8.3beta时,我得到相同的结果。

更新2:这是响应评论请求的最小工作示例:

* here's a header with a [[~/somefile.txt][link at the end]]

  - This one's a problem
  - Interesting note:
    + put the cursor immediately *after* the *d* in "end" with the
      header closed/folded
      * the face no longer bleeds over into the dots
    + move the cursor anywhere else
      * the face bleeds over into the dots again

* here's another [[~/someotherfile.txt][go at it]]
  DEADLINE: <2014-10-26 Sun>

  - This one's also a problem

* here's another header with a [[~/anotherfile.txt][link followed by a space]] 

  - No bleed-over onto the dots with this one

1
我很难在Emacs 24.3.1及其随附的组织模式下进行复制。即使您提到了复制步骤。您可以显示原始的组织模式缓冲区吗?(也就是说,我认为这是组织模式下的错误。添加额外的换行符有帮助吗?)
aerique

与@aerique一样,我在这里看不到。因此,这可能取决于Emacs版本或组织模式缓冲区的某些细节。
Stefan 2014年

@Dan,出于好奇,您在使用什么主题?
2014年

1
@Dan您能否提供示例组织文件的源进行测试?
Wilfred Hughes 2014年

2
@Dan我可以使用您提供的文件在Emacs 24.4上重现此内容。
rekado 2014年

Answers:


10

这看起来像是由org-modeorg-activate-bracket-links函数触发的错误。

该函数的外观如下:

(defun org-activate-bracket-links (limit)
  "Run through the buffer and add overlays to bracketed links."
  (if (and (re-search-forward org-bracket-link-regexp limit t)
       (not (org-in-src-block-p)))
      (let* ((hl (org-match-string-no-properties 1))
         (help (concat "LINK: " (save-match-data (org-link-unescape hl))))
         (ip (org-maybe-intangible
          (list 'invisible 'org-link
            'keymap org-mouse-map 'mouse-face 'highlight
            'font-lock-multiline t 'help-echo help
            'htmlize-link `(:uri ,hl))))
         (Vp (list 'keymap org-mouse-map 'mouse-face 'highlight
               'font-lock-multiline t 'help-echo help
               'htmlize-link `(:uri ,hl))))
    ;; We need to remove the invisible property here.  Table narrowing
    ;; may have made some of this invisible.
    (org-remove-flyspell-overlays-in (match-beginning 0) (match-end 0))
    (remove-text-properties (match-beginning 0) (match-end 0)
                '(invisible nil))
    (if (match-end 3)
        (progn
          (add-text-properties (match-beginning 0) (match-beginning 3) ip)
          (org-rear-nonsticky-at (match-beginning 3))
          (add-text-properties (match-beginning 3) (match-end 3) vp)
          (org-rear-nonsticky-at (match-end 3))
          (add-text-properties (match-end 3) (match-end 0) ip)
          (org-rear-nonsticky-at (match-end 0)))
      (add-text-properties (match-beginning 0) (match-beginning 1) ip)
      (org-rear-nonsticky-at (match-beginning 1))
      (add-text-properties (match-beginning 1) (match-end 1) vp)
      (org-rear-nonsticky-at (match-end 1))
      (add-text-properties (match-end 1) (match-end 0) ip)
      (org-rear-nonsticky-at (match-end 0)))
    t)))

它搜索的匹配一个括号链路(例如[[target][label]],隐藏了[[target][通过添加部分ip到文本属性,然后将linkifies label通过添加vp到文本属性,以及最后去除尾部]]通过将ip再次到文本属性。

这一切看起来都不错。 org-rear-nonsticky-at应注意财产流血。

此行为由触发(add-text-properties (match-end 3) (match-end 0) ip),它隐藏了尾随]]。只有该'invisible 'org-link属性触发此行为,其他属性似乎是无辜的。

您可以覆盖org-activate-bracket-links,从而ip不再设置,'invisible'display ""效果相同:

(defun org-activate-bracket-links (limit)
  "Run through the buffer and add overlays to bracketed links."
  (if (and (re-search-forward org-bracket-link-regexp limit t)
       (not (org-in-src-block-p)))
      (let* ((hl (org-match-string-no-properties 1))
         (help (concat "LINK: " (save-match-data (org-link-unescape hl))))
         (ip (org-maybe-intangible
          (list 'display ""
            'keymap org-mouse-map 'mouse-face 'highlight
            'font-lock-multiline t 'help-echo help
            'htmlize-link `(:uri ,hl))))
         (Vp (list 'keymap org-mouse-map 'mouse-face 'highlight
               'font-lock-multiline t 'help-echo help
               'htmlize-link `(:uri ,hl))))
    ;; We need to remove the invisible property here.  Table narrowing
    ;; may have made some of this invisible.
    (org-remove-flyspell-overlays-in (match-beginning 0) (match-end 0))
    (remove-text-properties (match-beginning 0) (match-end 0)
                '(invisible nil))
    (if (match-end 3)
        (progn
          (add-text-properties (match-beginning 0) (match-beginning 3) ip)
          (org-rear-nonsticky-at (match-beginning 3))
          (add-text-properties (match-beginning 3) (match-end 3) vp)
          (org-rear-nonsticky-at (match-end 3))
          (add-text-properties (match-end 3) (match-end 0) ip)
          (org-rear-nonsticky-at (match-end 0)))
      (add-text-properties (match-beginning 0) (match-beginning 1) ip)
      (org-rear-nonsticky-at (match-beginning 1))
      (add-text-properties (match-beginning 1) (match-end 1) vp)
      (org-rear-nonsticky-at (match-end 1))
      (add-text-properties (match-end 1) (match-end 0) ip)
      (org-rear-nonsticky-at (match-end 0)))
    t)))

显然,这是一个丑陋的hack。但这对我有用,也许对您有用。我仍然建议提交错误报告。


感谢您的努力(为此+1!),但是此解决方案不适用于我。而不是propertizing [[~/somefile.txt][link label]]link label(其中斜体表示标准面的链接),它成为link label]](用面没有变化)。我将提交错误报告。

嗯,很奇怪。我对的定义唯一的变化org-activate-bracket-links是替换'invisible non-nil'display "",因此它仍应像以前一样应用链接面。它肯定在Emacs 24.4中对我有用,但是我认为精力最好花在Bug报告上,而不是试图使我的黑客工作起来... :)
rekado 2014年
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.