Open write mode for flock(fh, LOCK_EX) for portability

We should open file with write intent for using flock(fh, LOCK_EX) for portability. Because flock(fh, LOCK_EX) is failed without write intent on some platforms(such as Solaris) and platforms which does not provide flock. (In this case Perl emulates flock with other API).

On Linux or some BSD(include MacOSX), flock(fh, LOCK_EX) successes without write intent. However if you want to work your module on many platforms, you should open with write intent.

perldoc -f flock says

Note that the fcntl(2) emulation of flock(3) requires that FILEHANDLE be open with read intent to use LOCK_SH and requires that it be open with write intent to use LOCK_EX.

See also

Macで flyspell-modeを使うための設定

スペルチェックはもっぱら flyspell-mode, flyspell-bufferなので, Macでもそれを使うための設定.

ispellのインストール

% brew install ispell

昔は ~/.aspell.confの設定が必須だったような気がするのだが, なくても動作した. デフォルトの言語を設定を英語にしているということが関係しているのか, そもそも不要になったのかはよくわかっていない.

faceの設定

GUIだとデフォルトが波線ですごく見づらい. emacs -nwなら真っ直ぐな下線なのでよいのだが... 見やすければなんでもいいので以下のような設定にしてみた.

(set-face-attribute 'flyspell-duplicate nil
                    :foreground "white"
                    :background "orange" :box t :underline nil)


(set-face-attribute 'flyspell-incorrect nil
                    :foreground "white"
                    :background "red" :box t :underline nil)

こんな感じになります.

f:id:syohex:20150820004813p:plain

Tips

ドキュメントを書くときは, flyspell-modeを有効にしているだけですが, まとめてチェックしたい場合は以下のように設定して開くファイルすべてに対してスペルチェックをかけるというようなことをしています.

(add-hook 'find-file-hook 'flyspell-mode)
(add-hook 'find-file-hook 'flyspell-buffer)

auto-complete for Elixir programming

I recommend you to use company-mode for auto completion of Elixir programming.

I created ac-alchemist which is auto-complete source of alchemist. Because alchemist provides only company-mode completion.

alchemist often changes its API frequently. So it may break ac-alchemist. Please report me if ac-alchemist does not work with latest alchemist via github issues.

Repository

https://github.com/syohex/emacs-ac-alchemist

Image

ac-alchemist

See also

neotree with vc-mode

neotree can work with vc-mode. So it works like Atom.io. However its feature is disabled as default. Please add following configuration to your init.el for enabling it. You also enable vc-mode.

(custom-set-variables
 '(neo-vc-integration '(face)))

Screenshot is here. Modified files are highlighted in magenta.

f:id:syohex:20150805194909p:plain

neotree supports showing vc information by face and char. We can also enable both of them as below.

(custom-set-variables
 '(neo-vc-integration '(face char)))

This version screenshot is here. There are E(means edited) characters at Modified files.

f:id:syohex:20150805195322p:plain

Customize

Face names of neotree vc information are neo-vc-*-face(Ex neo-vc-edited-face). And characters of it is neo-vc-state-char-alist. You can custom as you like. Please read documentation or source code in more detail.

f:id:syohex:20150805200033p:plain

enjoy hacking neotree.

Release Mouse v2.4.4

https://metacpan.org/release/SYOHEX/Mouse-v2.4.4

Mouse with threads did not work on Perl 5.22.0 or higher version. This makes Text::Xslate test failure for a long time. This version fixed the issue and works with threads. Please upgrade for newer perl users.

Example

We expects $foo->syntax is "Kolon" but $foo->syntax is undef with older Mouse on Perl 5.22.0 or higher. This test is passed with Mouse v2.4.4.

#!perl
package Foo;
use Mouse;

has syntax => (
    is      => 'rw',
    isa     => 'Str',
    default => 'Kolon',
);

package main;
use strict;
use warnings;
use threads;

use Test::More;

my $foo = Foo->new;
is $foo->syntax, "Kolon";

threads->create(sub{
    is $foo->syntax, "Kolon";
})->join();

done_testing;

evil-textobj-line

evil-textobj-line is Emacs port of @kana1's vim-textobj-line. evil-text-obj-line provides functions which select portion of current line.

Repository

https://github.com/syohex/evil-textobj-line

Demo a line("val")

a-line selects whole current line

f:id:syohex:20150731140024g:plain

Demo inner line("vil")

inner-line selects current line excepts both leading spaces and trailing spaces.

f:id:syohex:20150731140054g:plain

atomを起動できない問題の workaround

atomを使ってみようと, Ubuntu 15.04に公式 debパッケージを使って, インストールして起動しようとしてみたが以下のエラーが出て起動しない.

line 98:  8076 Aborted                 (core dumped) nohup "$ATOM_PATH" --executed-from="$(pwd)" --pid=$$ "$@" > "$ATOM_HOME/nohup.out" 2>&1
[8076:0727/230141:ERROR:browser_main_loop.cc(170)] Running without the SUID sandbox! See https://code.google.com/p/chromium/wiki/LinuxSUIDSandboxDevelopment for more information on developing with the sandbox on.
ATTENTION: default value of option force_s3tc_enable overridden by environment.
[libprotobuf FATAL ../../third_party/protobuf/src/google/protobuf/stubs/common.cc:61] This program requires version 2.6.0 of the Protocol Buffer runtime library, but the installed version is 2.5.0.  Please update your library.  If you compiled the program yourself, make sure that your headers are from the same version of Protocol Buffers as your link-time library.  (Version verification failed in "gen/proto_out/session/candidates.pb.cc".)
Failed to get crash dump id.
Report Id:

Ubuntu 14.04ではなんともなかったのだが, 起動さえもできなくなってしまった. Protocol Bufferライブラリのバージョンについて怒られているが, インストールしているバージョンは 2.6台でそこに問題はない(はず).

Workaround

環境変数 GTK_IM_MODULE(KDE等の Qt環境では QT_IM_MODULE)と XMODIFIERSを無効にして起動すれば問題ないことがわかった.( 参考). 以下のようなスクリプトを /usr/binより優先される PATHに置き, 実行すればとりあえず起動できることはわかった. インプットメソッドは起動できないので日本語は打てないが, 必要ないのでとりあえずいいでしょう.

#!/bin/sh

set -e

unset GTK_IM_MODULE
unset XMODIFIERS
/usr/bin/atom $@