0

elpy と yasnippet を使用して、emacs を Python エディターにします。

次に、yasnipprt を使用してクラス オブジェクトを作成しますが、崇高なテキストのように、二重の "return" 内でフィールドを終了できないことがわかりました。つまり、タブまたはキーボードを使用する行の先頭にカーソルを1つずつ移動して、クラスオブジェクトの最後に新しいコードを入力する必要があることを意味し、yasnippetがサポートするクラスフィールドを終了できます。

出口フィールドについて同じ混乱を起こした人はいますか?

以下の init.el コードをプッシュします。yasnippet のフィールドを終了するキーは何ですか?

(require 'package)
(add-to-list 'package-archives
       '("melpa" . "http://melpa.milkbox.net/packages/") t)

;;;(add-to-list 'package-archives
;;;      '("elpy" . "http://jorgenschaefer.github.io/packages/"))

(package-initialize)
(elpy-enable)

(add-to-list 'load-path
       "~/.emacs.d/yasnippet")
(require 'yasnippet)
(yas-global-mode 1)

(c-add-style
"python-new"
'((indent-tabs-mode . 4)
(fill-column      . 78)
(c-basic-offset   . 4)
(c-offsets-alist  . ((substatement-open . 0)
         (inextern-lang . 0)
         (arglist-intro . +)
         (knr-argdecl-intro . +)))
(c-hanging-braces-alist . ((brace-list-open)
                 (brace-list-intro)
                 (brace-list-close)
                 (brace-entry-open)
                 (substatement-open after)
                 (block-close . c-snug-do-while)))
(c-block-comment-prefix . "* "))
)

;; This is a very crude hook that auto-selects the C style depending on
;; whether it finds a line starting with tab in the first 3000 characters
;; in the file
(defun c-select-style ()
(save-excursion
    (if (re-search-forward "^\t" 3000 t)
   (c-set-style "python")
    (c-set-style "python-new"))))
(add-hook 'c-mode-hook 'c-select-style)
4

1 に答える 1