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

在视觉模式下自动输入Beg End参数

  •  1
  • Aquaactress  · 技术社区  · 9 年前

    我看过这些函数的“evil commands.el”中的源代码,但它们的“beg”和“end”参数似乎不知从何而来。有些(比如下面的一个)甚至没有互动性。

    为什么会这样?我如何用自己的方法做同样的事情?

    ;; Defined in ~/.emacs.d/elpa/evil-20170712.2350/evil-commands.el
    (evil-define-operator evil-invert-char (beg end type)
      "Invert case of character."
      :motion evil-forward-char
      (if (eq type 'block)
          (evil-apply-on-block #'evil-invert-case beg end nil)
        (evil-invert-case beg end)
        (when evil-this-motion
          (goto-char end)
          (when (and evil-cross-lines
                     evil-move-cursor-back
                     (not evil-move-beyond-eol)
                     (not (evil-visual-state-p))
                     (not (evil-operator-state-p))
                     (eolp) (not (eobp)) (not (bolp)))
            (forward-char)))))
    
    1 回复  |  直到 9 年前
        1
  •  1
  •   Arnot    9 年前

    evil-invert-char 未使用正则表达式定义 defun ,但使用宏 evil-define-operator evil-macros.el .使用 M-x describe-function RET evil-define-operator RET

    evil-define-operator is a Lisp macro in ‘evil-macros.el’.
    
    (evil-define-operator OPERATOR (BEG END ARGS...) DOC [[KEY VALUE]...] BODY...)
    
    Define an operator command OPERATOR.
    

    你可以使用优秀的 macrostep 模式(绑定到 , d m 在我的Spacemacs中 emacs-lisp-mode 邪恶定义运算符 邪恶定义运算符 -宏转换为 evil-define-command interactive BEG 和 END 宏插入的调用。

    推荐文章