LoginSignup
4
6

More than 5 years have passed since last update.

simplenote.elの設定でsimplenote-emailとsimplenote-passwordをべた書きせずに済むようにする

Last updated at Posted at 2013-11-29

simplenote.elを使うようになりました。

simplenote.elのREADMEによるとsimplenote-emailとsimplenote-passwordを生で指定するように書かれているのですが、Githubに自分の.emacs.dをうっかり公開している人がそのままREADMEの通りにしてしまうと自分のSimplenoteがすべて見られてしまいます(苦笑)。

そこで、Emacsのnetrcライブラリを使い、Simplenoteのsimplenote-emailとsimplenote-passwordをなんとか隠蔽してみました。netrcライブラリがない場合は何もしません(といってもnetrcライブラリはEmacs19で取り込まれたようなのでいまどきの環境で「ない場合」はそうそうないでしょうけれど)。

~/.emacs.d/user-start.d/simplenote.el
;;; -*- mode: emacs-lisp; coding: utf-8-emacs; -*-

(if (locate-library "simplenote")
    (progn
      (require 'simplenote)
      (if (locate-library "netrc")
          (progn
            (require 'netrc)
            (let* ((credentials (netrc-credentials "app.simplenote.com"))
                   (login (nth 0 credentials))
                   (password (nth 1 credentials)))
              (setq simplenote-email login)
              (setq simplenote-password password))
            (simplenote-setup)
            (setq simplenote-notes-mode 'markdown-mode)))))

なお、Emacsのnetrcライブラリはデフォルトで~/.authinfoを使うようになっていますので、必要であればnetrc-fileを~/.netrcに設定しなおします。

また、~/.authinfo・~/.netrcは1行1エントリで書かないと、Emacsのnetrcライブラリはきちんと認識できないようですので、気をつける必要があります(余談ですが、Pythonのnetrcモジュールはmachineエントリが複数行にまたがっていてもきちんと認識します)。

~/.authinfo
machine app.simplenote.com login h12o@example.com password Th!s1sMyPassw0rd
4
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
6