組み込みです。roundです。小数点の精度の問題で、きちんと丸まらない可能性はあります。
Return number rounded to ndigits precision after the decimal point. If ndigits is omitted or is None, it returns the nearest integer to its input.
組み込みです。roundです。小数点の精度の問題で、きちんと丸まらない可能性はあります。
Return number rounded to ndigits precision after the decimal point. If ndigits is omitted or is None, it returns the nearest integer to its input.
# test # ## test ## #### test #### ##### test #####
C-c C-t 1
とかやると呼び出される関数
markdown-mode/markdown-mode.el at master · jrblevin/markdown-mode · GitHub
markdown-insert-header-atx
系関数を呼び出すと実行される関数
markdown-mode/markdown-mode.el at master · jrblevin/markdown-mode · GitHub
test test ここでmarkdown-insert-header-atx系関数を呼び出すと改行が挟まるのはよくわからない test
ec2
: Update ec2 command to latest versionEmacsでmarkdownのメモ書きをしているから自分はmarkdown-modeのヘビーユーザーだけど、テーブルをいちから作るコマンドがなかったのでmarkdown-modeにパッチを投げた。 パッチを投げて明くる日にはコメントが来ていたので、そのうち取り込まれると思う。
行数、列数、表寄せ、ヘッダーの中身を指定したらmarkdownなテーブルが自動で作られるようなコマンド markdown-insert-table
を作成している。
行数5 列数4 表寄せ中央で作成したテーブルの例
|id|name|alpha|beta| |---|---|---|---| | | | | | | | | | | | | | | | | | | | | | | | | |
各種パラメータの指定方法はこちらを参考にしており、実装自体は指定した行数列数ぶんだけ |
と改行を繰り返すだけの簡単なもの。再帰はしてない。
CONTRIBUTING.mdにertでテストを書けよ、と言われていたのである程度ちゃんとテストは書いたつもり。なお、interactiveな関数をertでテストを書く方法については公式ドキュを読んでも分からなかったので、調べに調べてたどり着いた件についてはこちらを参考のこと。
read-stringの結果をconcatしてさらにconcatすることは可能らしい。
(setq header (concat header (read-string (concat "header " (number-to-string header-counter) ": ")) "|"))
interactiveな関数をertでテストしたい
Useful Techniques - Emacs Lisp Regression Testing
ertでテストするときに、引数を指定する系の関数だったらサンプルよろしくこんなふうに書けばいいけど、interactiveな関数で引数を ミニバッファとかで指定する系の関数はどうやってテストしたらいいんだろうって調べていた。
(ert-deftest ert-test-mismatch () (should (eql (cl-mismatch "" "") nil)) (should (eql (cl-mismatch "" "a") 0)) (should (eql (cl-mismatch "a" "a") nil)) (should (eql (cl-mismatch "ab" "a") 1)) (should (eql (cl-mismatch "Aa" "aA") 0)) (should (eql (cl-mismatch '(a b c) '(a b d)) 2)))
execute-kbd-macroとread-kbd-macroのコンボを使う。
こんな感じで。
(ert-deftest test-markdown-insertion/create-table-with-left-align () "Insert table with left align." (markdown-test-string "" (execute-kbd-macro (read-kbd-macro "M-x markdown-insert-table RET 2 RET 2 RET left RET id RET name RET")) (should (string-equal (buffer-string) "|id|name| |:--|:--| | | | | | | "))))
(setq desired-number-one 10) (setq desired-number-two 10) (setq count-one 1) (while (<= count-one desired-number) (setq count-two 1) (while (<= count-two desired-number) (message "message in-loop: %d" count-two) (setq count-two (1+ count-two))) (message "message out-loop: %d" count-one) (setq count-one (1+ count-one)))
厳密にはLispじゃないけど、応用はできるとおもう(cl-loopを使ってもいいけど) 11. Lisp(for Common Lisp)とフローチャート
(setq desired-number 10) (setq count 1) (while (<= count desired-number) (message "message: %d" count) (setq count (1+ count)))
Programming in Emacs Lisp: Loops & Recursion message - Programming in Emacs Lisp
公式をみたら、テーブルを作る機能はないらしい
|id|name| |:---|:---|
|id|name| |:---|:---| ←ここでmarkdown-table-insert-rowを実行しても行は増えない
| id | name | | test | test |
| id | name | | ←ここでタブを押すと行がふえる
workspaces
: Update workspaces command to latest versionssm
: Update ssm command to latest versionmedialive
: Update medialive command to latest versionappstream
: Update appstream command to latest versionroute53
: Update route53 command to latest version