代码之家  ›  专栏  ›  技术社区  ›  justinhj

Emacs函数向我使用的python函数发送消息

  •  10
  • justinhj  · 技术社区  · 17 年前

    我正在编辑一些带有相当长函数的Python代码,并决定在不向上滚动的情况下快速获取函数名会很有用。我把这段代码放在一起做这件事。emacs是否有内置的东西,或者特别是标准python模式,我可以使用它来代替?

    (defun python-show-function-name()
      "Message the name of the function the point is in"
      (interactive)
      (save-excursion
        (beginning-of-defun)
        (message (format "%s" (thing-at-point 'line)))))
    
    3 回复  |  直到 17 年前
        1
  •  21
  •   Blair Conrad    17 年前

    你可能会发现与你的关系不错的结果 which-function-mode :

    显示当前函数的 模式行中的名称,将其更新为 你可以在缓冲区里走动。

    要启用或禁用 全球的它适用于所有缓冲区, 既有也有尚待解决的问题 创建。然而,它只起作用 在哪个func模式的值中。如果 这个值是t,那么是哪个函数 模式适用于以下所有主要模式: 知道如何支持它换句话说, 支持的所有主要模式 伊梅努。

        2
  •  2
  •   Community Mohan Dere    9 年前

    你试过了吗 py-beginning-of-def-or-class

    (defun python-show-function-name()
      "Message the name of the function the point is in"
      (interactive)
      (save-excursion
        (py-beginning-of-def-or-class)
        (message (format "%s" (thing-at-point 'line)))))
    

    beginning-of-defun ,但如果这不是你的问题,那么也许我只是看到了另一个导致你的怪癖的症状 my other answer

        3
  •  0
  •   Jarret Hardie    17 年前

    C-C-u(py goto block up)可能就是你想要的。