Skip to content

Instantly share code, notes, and snippets.

@ypetya
Last active November 14, 2016 10:40
Show Gist options
  • Save ypetya/e4ec61ac87acb96a950e59809ab8c28a to your computer and use it in GitHub Desktop.
Save ypetya/e4ec61ac87acb96a950e59809ab8c28a to your computer and use it in GitHub Desktop.
First lisp steps. elisp examples. http://ergoemacs.org/emacs/elisp_basics.html
(;; 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
(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)
(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