by shigemk2

当面は技術的なことしか書かない

型変換

(string-to-number "100")		; => 100
;; N進数→数値
(string-to-number "100" 16)		; => 256
(string-to-number "1011" 2)		; => 11
(number-to-string 1000)			; => "1000"
(number-to-string 1000.01)		; => "1000.01"
(format "%s %s" 1000 1000.01)		; => "1000 1000.01"
(char-to-string ?a)			; => "a"
(format "%c" ?a)			; => "a"
?a					; => 97
;; 最初の1文字のみ処理される
(string-to-char "a")			; => 97
(string-to-char "abc")			; => 97
(float 10)				; => 10.0
(float 10.1)				; => 10.1
;; appendの最後の引数にnilを指定するとリストに変換
(append [1 2])				; => [1 2]
(append [1 2] nil)			; => (1 2)
(append [1 2] [3 4])			; => (1 2 . [3 4])
(append [1 2] [3 4] nil)		; => (1 2 3 4)
(buffer-name (current-buffer))		; => "12-155811.el"
(get-buffer "*scratch*")		; => #<buffer *scratch*>
(symbol-name 'i-love-emacs)		; => "i-love-emacs"
(intern "Emacs")			; => Emacs

P153

Emacs Lispテクニックバイブル

Emacs Lispテクニックバイブル