My Avatar

LanternD's Castle

An electronics enthusiast - survive technically

Spacemacs Rocks Note Day 8 & 9

2017-11-07

A series of notes that I learn Emacs hacking. Cask and pallet package for multi-version Emacs collaboration; Macro in emacs-lisp; use-package package introduction.

Prologue: Not too much for day 8. Previous video is 1 hour’s long, the author decrease the length of each video to 30 min for better performance. Therefore I put the content in two days’ video into single post.

Day 8

There are not too many in this video.

Visit Melpa from China

cask, a package for project monitoring

pallet package

1
2
3
4
(require 'cask "~/.cask/cask.el")
(cask-initialize)
(require 'pallet)
(pallet-mode t)

mwe-log-command package


Day 9

Macro

1
2
(defmacro inc (var)
  (list 'setq var (list '1+ var)))
1
2
3
(setq my-var 1)
(inc my-var)
(macroexpand '(inc my-var))
1
(sp-local-pair 'emacs-lisp-mode "`" nil :actions nil)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
(defun my-print (number)
  (message "%d" number))
(my-print 2)

(my-print (+ 2 3))

(defmacro my-print-2 (number)
`(message "%d" ,number))
(my-print-2 2)
(my-print-2 (+ 2 3))

(defmacro inc (var)
(list 'setq var (list '1+ var)))

(setq my-var-2)
(inc my-var)

(defmacro inc2 (var1 var2 )
(list 'progn (list 'inc var1) (list 'inc var2)))
(macroexpand '(inc2 my-var my-var)) ;; this will expand only one layer.
(macroexpand-all '(inc2 my-var my-var))

use-package package

1
2
3
4
5
6
7
(use-package xxx
  :init 
  (progn
    (setq var1 1)
    (setq var2 "s"))
  :config 
  (setq var3 5))			
1
2
3
4
(use-package xxx
  :commands
  (global-company-mode)
  :defer t
1
2
3
4
5
6
7
8
9
10
11
(use-package color-moccur
  :commands (isearch-moccur iseach-all)
  :bind (("M-s O" . moccur)
	 :map isearch-mode-map
	 ("M-o" . isearch-moccur)
	 ("M-O" . isearch-moccur-all))
  :init 
  (setq isearch-lazy-highlight t)
  :config 
  (use-package moccur-edit)
  )


Disqus Comment 0