Skip to content

Instantly share code, notes, and snippets.

@weaming
Created May 25, 2020 06:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save weaming/361be26e9473a60ae2df2eeccece91a9 to your computer and use it in GitHub Desktop.
Save weaming/361be26e9473a60ae2df2eeccece91a9 to your computer and use it in GitHub Desktop.
(+ 1 (+ 3 4))
(setq name "weaming")
(defun hello (name) (insert "Hello, " name))
(hello "weaming")
(switch-to-buffer-other-window "*test*")
(progn
(switch-to-buffer-other-window "*test*")
(erase-buffer)
(hello "you")
(other-window 1)
)
(let ((local-name "Garden"))
(switch-to-buffer-other-window "*test*")
(erase-buffer)
(greeting local-name)
(other-window 1)
)
(defun greeting (from-name)
(let ((your-name (read-from-minibuffer "Enter your name: ")))
(insert (format "Hello, %s!\n\nI am %s." your-name from-name ))
))
;; list
(setq list-of-names '("A" "B" "C"))
(greeting (car list-of-names))
(insert (cdr list-of-names))
(push "D" list-of-names)
(push "E" list-of-names)
(mapcar 'hello list-of-names)
(defun greeting ()
(switch-to-buffer-other-window "*test*")
(erase-buffer)
(mapcar 'hello list-of-names)
(other-window 1))
(greeting)
(defun replace-hello-by-bonjour ()
(switch-to-buffer-other-window "*test*")
(goto-char (point-min))
(while (search-forward "Hello")
(replace-match "Bonjour"))
(other-window 1))
(replace-hello-by-bonjour)
(defun replace-text (from to)
(switch-to-buffer-other-window "*test*")
(goto-char (point-min))
(while (search-forward from)
(replace-match to))
(other-window 1))
(replace-text "Bonjour" "Hello")
(replace-text "Hello" "Bonjour")
(defun boldify-text ()
(switch-to-buffer-other-window "*test*")
(goto-char (point-min))
(while (re-search-forward "Bonjour \\(.+\\)!" nil t)
(add-text-properties (match-beginning 1)
(match-end 1)
(list 'face 'bold)))
(other-window 1))
(boldify-text)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment