Last active
November 14, 2016 10:40
-
-
Save ypetya/e4ec61ac87acb96a950e59809ab8c28a to your computer and use it in GitHub Desktop.
First lisp steps. elisp examples. http://ergoemacs.org/emacs/elisp_basics.html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(;; my block | |
(let ( | |
(str "string!") | |
(local_list (list 1 2 3))) | |
(message "This is a string %s" str) ;; prints to *Message* buffer | |
(message "This is a list %S" local_list) | |
nil | |
) ;; => returns nil | |
;; from emacs 24 eslip simulates lexical scoping though it has | |
;; dynamic scoping | |
;; that is a difference to common lisp, which has lexical scoping by default | |
;; avoid macro usage it brings in dynamic scoping |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun parseDate (dateStr) | |
"Parses the date from YYYY.mm.DD | |
(parseDate "2016.03.12") -> (2015 3 12)" | |
;(interactive) | |
(string-match "^\\([0-9]+\\)\.\\([0-9]+\\)\.\\([0-9]+\\).*" dateStr) | |
(mapcar 'string-to-number (list | |
(match-string 1 dateStr) | |
(match-string 2 dateStr) | |
(match-string 3 dateStr)))) | |
(provide 'parseDate) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun read-lines (filePath) | |
"Return a list of lines of a file at filePath." | |
(with-temp-buffer | |
(insert-file-contents filePath) | |
(split-string (buffer-string) "\n" t))) | |
(provide 'read-lines) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment