Created
February 27, 2020 19:09
-
-
Save bsnux/3db7438cea4b2d0f85d95e4e7f5c0509 to your computer and use it in GitHub Desktop.
Learning Emacs LISP
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
;;; package --- Testing script from emacs | |
;;; Commentary: | |
;;; Code: | |
;; $ emacs --script test.el | |
(message "Hello World!") | |
(defun mytest2() | |
(message "hi!")) | |
(defun sayHello() | |
"Simple say hi!." | |
(message "hi") | |
) | |
(sayHello) | |
(defun mytest () | |
"Learning how to write functions." | |
(message "I'm a func!")) | |
(defun myparams (x y) | |
"Just sum x and y numbers." | |
(+ x y)) | |
(message "Hello World!") | |
(message (format "%d" (length "this is a long string test"))) | |
(list-system-processes) | |
(mytest) | |
(message (number-to-string (myparams 1 2))) | |
(message (shell-command-to-string "ls")) | |
(setq list-of-names '("Sarah" "Chloe" "Mathilde")) | |
(print list-of-names) | |
(defun multiply-by-seven (number) | |
"Multiply NUMBER by seven." | |
(* 7 number)) | |
(multiply-by-seven 4) | |
(setq counter 5) | |
(setq counter (+ counter 4)) | |
(message (format "%d" counter)) | |
(defun localvars () | |
"Testing local vars: `let` is that it is like a setq that is temporary and local." | |
(message "global counter: %d" counter) | |
(let ((counter 1)) | |
(message "local counter: %d" counter))) | |
(localvars) | |
(if (> 5 4) | |
(message "inside if!")) | |
(if (> 8 6) | |
; more than one statement requires `progn`: special form that causes each of | |
; its arguments to be evaluated in sequence and then returns the value of the last one. | |
(progn | |
(message "inside if!") | |
(message "8 is greater than 6!"))) | |
(if (> 2 3) | |
(message "2 is not greater than 3") | |
; else condition here | |
(message "3 is greater than 2")) | |
(defun get-json (uri) | |
(setq buffer (url-retrieve-synchronously uri)) | |
(with-current-buffer buffer | |
(message (buffer-string)))) | |
(get-json "https://jsonplaceholder.typicode.com/todos/") | |
(get-json "https://jsonplaceholder.typicode.com/todos/1") | |
(get-json "https://jsonplaceholder.typicode.com/todos/2") | |
;;; test-run.el ends here |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment