简体   繁体   English

为什么Emacs中的按钮锁定模式不能与python模式一起使用?

[英]Why doesn't button-lock-mode work with python-mode in Emacs?

I'd like to have clickable links to JIRA tickets in my Python code from within Emacs. 我想从Emacs的Python代码中获得指向JIRA票证的可单击链接。

For example, I use doxygen docstrings in my integration test code, which links a ticket number: 例如,我在集成测试代码中使用了doxygen文档字符串,该字符串链接了故障单编号:

def test_user_type_isolation(self):
    """
    Ensure UDT cannot be used from another keyspace
    @jira_ticket CASSANDRA-9409
    @since 2.2
    """
    ....

I'd like to be able to click the CASSANDRA-9409 and have it go directly to the JIRA ticket it's referencing. 我希望能够单击CASSANDRA-9409,并将其直接转到它所引用的JIRA票证 I found button-lock-mode and it works great! 我发现了按钮锁定模式 ,效果很好! However, this elisp works in every mode except for python-mode: 但是,此elisp可以在 python-mode 之外的所有模式下工作:

(require 'button-lock)
(global-button-lock-mode 1)

(setq cassandra-jira-button
      (button-lock-set-button "CASSANDRA-[0-9]+"
        #'(lambda ()
            (interactive)
            (browse-url (concat "https://issues.apache.org/jira/browse/"
                         (thing-at-point 'symbol)))
        )
    :face 'link :face-policy 'prepend))

It's not just my code though, none of the examples included in button-lock.el work in python-mode either. 不过,这不仅是我的代码,button-lock.el中包含的所有示例都无法在python模式下工作。 So, does anyone know what might be causing the conflict? 那么,有人知道造成冲突的原因吗?

I don't know anything about button-lock-mode , but Emacs comes with bug-reference-mode , and the very useful sub-mode bug-reference-prog-mode . 我对button-lock-mode一无所知,但是Emacs带有bug-reference-mode和非常有用的sub-mode bug-reference-prog-mode I would suggest using those instead. 我建议改用那些。 For your use you would want to configure this via bug-reference-bug-regexp and bug-reference-url-format . 供您使用时,您需要通过bug-reference-bug-regexpbug-reference-url-format

bug-reference-prog-mode is handy because it limits its buttonizing behavior to comments and strings -- perfect for programming modes. bug-reference-prog-mode很方便,因为它将按钮化行为限制为注释和字符串-非常适合编程模式。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM