Indent like python-mode in coffee-mode

f:id:syohex:20151010173847g:plain

https://github.com/defunkt/coffee-mode/pull/323

I have implemented indentation like python-mode in coffee-mode. You can enable this feature by setting coffee-indent-like-python-mode to non-nil.

(custom-set-variables
 '(coffee-indent-like-python-mode t))

If you don't like default coffee-mode indent-command, please try this. And I suppose this is useful for Evil users. o and O commands works well as you expect with this indentation mode.

migemo対応の helm sourceを書く(helm-migemo不要)

昔 helmは migemo対応していたのですが(anything時代から), それが除去され, migemo機能を有効にする helm-migemoというパッケージが作成されさました. しかし最近 helmが再度 migemo対応しました. これにより helmだけで migemo対応の sourceが書けるようになりました. その手順を示します(作者の方が主導的に行われたので再度外される可能性はないとはいえませんが, 高くはないと思います).

バージョン

1.7.9以上を使う必要があります.

事前準備

migemoの設定を行い(以下は cmigemo), helm-modeを有効にします. (NOTE helm-migemo-modeは autoloadできないので, 事前に helmをロードしています)

(require 'migemo)
(setq migemo-command "migemo")
(setq migemo-options '("-q" "--emacs"))

;; Set your installed path
(setq migemo-dictionary
      (expand-file-name "/usr/local/share/migemo/utf-8/migemo-dict"))

(setq migemo-user-dictionary nil)
(setq migemo-regex-dictionary nil)
(setq migemo-coding-system 'utf-8-unix)
(migemo-init)

(require 'helm)
(helm-migemo-mode +1)

サンプル

source作成マクロで migemo属性を non-nilに設定します.

(defvar sample-source
  (helm-build-sync-source "Sample helm-migemo"
    :candidates '("りんご" "みかん" "メロン")
    :action 'message
    :migemo t))

(defun sample-helm-migemo ()
  (interactive)
  (helm :sources '(sample-source) :buffer "*helm-sample*"))

イメージ

上記の実行結果(M-x sample-helm-migemo)は以下のようになります.

f:id:syohex:20151010171556g:plain

hcl-mode 0.01 released

hcl-mode 0.01 is out. hcl-mode provides major mode of HCL(Hashicorp Configuration Language). Currently hcl-mode provide indentation, highlighting, some cursor moving commands. If you have any issues or suggestions, please report me via github issues, I'll try to implement/fix as possible.

Repository

https://github.com/syohex/emacs-hcl-mode

Installation

You can install hcl-mode from MELPA with package.el.

Screenshot

f:id:syohex:20151006082112p:plain

Codic Web APIのサポート

codic.el から Codic Web APIを使えるようにしました.

リポジトリ

https://github.com/syohex/emacs-codic/

使い方

M-x codic-translateで使えます. 使用するには APIトークンの設定が必要になります. codic.jpから APIトークンを取得し, codic-api-tokenに設定します.

(custom-set-variables
 '(codic-api-token "YOUR_API_TOKEN"))

イメージ

f:id:syohex:20150926204602g:plain

おわりに

問題, 意見等ありましたら, github issuesまでお願いします.

集中線GIFメーカー in Golang

http://hitode909.hatenablog.com/entry/2015/09/13/205925

I wrote @hitode909's 集中線GIFメーカー(Awesome Web application) in Golang. This is command line application and you can use this as below.

Repository

https://github.com/syohex/speedline

Sample Output

f:id:syohex:20150915200436g:plain

f:id:syohex:20150915200446g:plain

Code

package main

import (
    "flag"
    "fmt"
    "math"
    "math/rand"

    "github.com/gographics/imagick/imagick"
)

var (
    output = flag.String("o", "output.gif", "output filename")
    color  = flag.String("color", "black", "background color")
)

func speedLine(mw *imagick.MagickWand, aw *imagick.MagickWand) error {
    cols, rows := mw.GetImageHeight(), mw.GetImageWidth()

    dw := imagick.NewDrawingWand()
    defer dw.Destroy()
    cw := imagick.NewPixelWand()
    cw.SetColor(*color)
    dw.SetFillColor(cw)

    center := []float64{float64(cols) / 2.0, float64(rows) / 2.0}
    const radiusCenter float64 = 0.75
    const step float64 = 0.02
    const bold float64 = 1.0
    var theeta float64

    for theeta < math.Pi*2 {
        stepNoise := rand.Float64() + 0.5
        theeta += step * stepNoise
        radiusCenterNoise := rand.Float64()*0.3 + 1.0
        boldNoise := rand.Float64() + 0.7 + 0.3

        point0 := imagick.PointInfo{
            X: math.Sin(theeta)*center[0]*radiusCenter*radiusCenterNoise + center[0],
            Y: math.Cos(theeta)*center[1]*radiusCenter*radiusCenterNoise + center[1],
        }
        point1 := imagick.PointInfo{
            X: math.Sin(theeta)*center[0]*2 + center[0],
            Y: math.Cos(theeta)*center[1]*2 + center[1],
        }
        point2 := imagick.PointInfo{
            X: math.Sin(theeta+step*bold*boldNoise)*center[0]*2 + center[0],
            Y: math.Cos(theeta+step*bold*boldNoise)*center[1]*2 + center[1],
        }

        dw.Polygon([]imagick.PointInfo{point0, point1, point2})
    }

    if err := aw.DrawImage(dw); err != nil {
        return err
    }

    return nil
}

func main() {
    flag.Parse()

    imagick.Initialize()
    defer imagick.Terminate()

    mw := imagick.NewMagickWand()
    defer mw.Destroy()
    aw := imagick.NewMagickWand()
    defer aw.Destroy()

    if err := mw.ReadImage(flag.Arg(0)); err != nil {
        panic(err)
    }

    if int(mw.GetNumberImages()) == 1 {
        mw.SetIteratorIndex(0)
        first := mw.GetImage()
        mw.ResetIterator()
        for i := 0; i < 3; i++ {
            mw.AddImage(first.Clone())
        }
    }

    for i := 0; i < int(mw.GetNumberImages()); i++ {
        mw.SetIteratorIndex(i)
        tw := mw.GetImage()
        aw.AddImage(tw)
        if err := speedLine(tw, aw); err != nil {
            fmt.Println(err)
            return
        }
        tw.Destroy()
    }
    mw.ResetIterator()

    aw.SetOption("loop", "0")
    if err := aw.WriteImages(*output, true); err != nil {
        panic(err)
    }
}