Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
2
Help us understand the problem. What is going on with this article?
@tnoda_

gofmt のあとに kill-region が動かなくなる問題

More than 5 years have passed since last update.

go-mode.el についてくる gofmt コマンドを実行すると,kill-region が壊れる可能性があります.これは,kill-regiondefadvice されている場合に起こります.

私の場合は sense-region.el が kill-region を advise していてハマりました.kill-region に advice が無ければこの事象は発生しないので,gofmt の間だけ advice を外すことにしました.設定変更はこんな感じ↓です.

--- a/tnoda.org
+++ b/tnoda.org
@@ -2553,8 +2553,16 @@ would be done by the following steps:

   (el-get 'sync 'go-autocomplete)

+  (defun tnoda/gofmt-before-save ()
+    "The original version of go-fmt may break the kill-region function,
+  if it has an advised version."
+    (interactive)
+    (when (eq major-mode 'go-mode)
+      (sense-region-off)
+      (gofmt)
+      (sense-region-on)))

-  (add-hook 'before-save-hook 'gofmt-before-save)
+  (add-hook 'before-save-hook 'tnoda/gofmt-before-save)
   (add-hook 'go-mode-hook 'rainbow-delimiters-mode)
   (add-hook 'go-mode-hook 'turn-on-smartparens-strict-mode)

gofmtdefadvice するかどうかで迷ったのですが,自前の gofmt-before-save を作って様子をみることにしました.

参考

  • https://github.com/dominikh/go-mode.el/issues/53
    • ここでは volatile-highlights.el が kill-region を advise していたようです.
    • ちなみに,go-mode.el の作者の人は,fletcl-flet に置き換えるつもりが無いようです.
2
Help us understand the problem. What is going on with this article?
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
tnoda_
Scala ときどき Clojure

Comments

No comments
Sign up for free and join this conversation.
Sign Up
If you already have a Qiita account Login
2
Help us understand the problem. What is going on with this article?