
私は C プログラミングに emacs を使用してきましたが、アセンブリ コードをいくつか記述したいのですが、Tab キーを押すと、emacs はスペースを挿入するだけです。Tab キーで現在の行を強制的に識別するにはどうすればよいでしょうか。
答え1
試すガスモード組み込みの asm モードの代わりに。
答え2
使用el-patch
:
(el-patch-defun asm-calculate-indentation ()
(or
;; Flush labels to the left margin.
(and (looking-at "\\(\\sw\\|\\s_\\)+:") 0)
;; Same thing for `;;;' comments.
(and (looking-at "\\s<\\s<\\s<") 0)
(el-patch-remove
;; Simple `;' comments go to the comment-column.
(and (looking-at "\\s<\\(\\S<\\|\\'\\)") comment-column))
;; The rest goes at the first tab stop.
(or (indent-next-tab-stop 0))))
(defun my--indent-asm-setup ()
"Set up indentation variables.
Indent with tabs, and make the TAB key behave like it's supposed
to."
(setq-local indent-tabs-mode t)
(setq-local tab-always-indent (default-value 'tab-always-indent)))
(add-hook 'asm-mode-hook #'my--indent-asm-setup)
答え3
このままにしておいてください。ほとんどのエディターには、タブをスペースに変換するオプションがあります。エディターでタブをスペースに変換するのはなぜでしょうか? コード (保存したファイル形式またはクリップボードにコピーしたもの) を任意のエディターで使用すれば、見た目は同じになります。強制的にタブを使用するようにして、ここに貼り付けたり、エディターで開いたりすると、タブが特定のサイズに設定されている可能性があるため、見た目が悪くなる可能性が高くなります。
スペースの代わりにタブをどうしても使用する必要がある場合は、ここに投稿したり他の人に渡す前に、タブをスペースに変換してください。