My Avatar

LanternD's Castle

An electronics enthusiast - survive technically

Spacemacs Rocks Note Day 4

2017-10-25

A series of notes that I learn Emacs hacking. Package loading mechanism, auto-indentation, hippie-expand, dired-mode, basic about org-mode.

Spacemacs Rocks Note Day 4

More about require and load-file

Indent

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
(defun indent-whole-buffer()
  (interactive)
  (indent-region (point-min) (point-max))
  )

(defun indent-region-or-buffer()
  (interactive)
  (save-excursion 
    (if (region-active-p)
    (progn
      (indent-region (region-begin) (region-end))
      (message "Selected region is indented.")
     )
      (progn 
	(indent-whole-buffer)
	(message "The whole buffer is indented.")
       )
      )
    )
  )

(global-set-key (kbd "C-M-\\") 'indent-region-or-buffer)

More about auto-complete - hippie-expand

1
2
3
4
5
6
7
8
9
10
11
12
;; set the list for hippie-expand
(setq hippie-expand-try-functions-list '(try-expand-dabbrev
					 try-expand-dabbrev-all-buffers
					 try-expand-dabbrev-from-kill
					 try-complete-file-name-partially
					 try-complete-file-name
					 try-expand-all-abbrevs
					 try-expand-list
					 try-expand-line
					 try-complete-lisp-symbol-partially
					 try-complete-list-symbol))
(global-set-key (kbd "M-/") 'hippie-expand) ;; this is the default key set

About dired-mode

1
2
3
4
;; (require 'dired)
(with-eval-after-load 'dired)
(put 'dired-find-alternate-file 'disabled nil)
(define-key dired-mode-map (kbd "RET") 'dired-find-alternate-file)

Save-excursion

Use org-mode to organize the initialization files

1
2
3
(require 'org-install)
(require 'ob-tangle)
(org-babel-load-file (expand-file-name "lanternd_int.org" user-emacs-directory))


Disqus Comment 0