Spacemacs Rocks Note Day 6
A series of notes that I learn Emacs hacking. Org-capture, org-pomodoro; file encoding with utf-8; batch rename files in dired mode, seach and replace with helm-ag; flycheck; snippets auto complete.
Use org-capture to take notes
- A module in org-mode. We can customize the template to make it easier to use.
- Configuration of the template.
'(("t" "Todo" entry (file+headline "D:/Dropbox/AGDA/Orz.org" "Agenda")
"* TODO [#B] %?\n %i\n"
C-c C-s to add timestamp to the TODO item. Enter a time to schedule.
C-a a to view the scheduled TODO list. Remember to set the location value of the
(setq org-agenda-files '("D:/Dropbox/AGDA"))
org-pomodoro: A package to track the time. Pomodoro Technique.
M-x org-pomodoro: Execute this command to start 25-min clock counter.
- Change the default buffer encoding. So that in case we type some Chinese characters, the coding of the buffer will becomes “UTF-8”. And we don’t need to bother again typing the encoding when we save that file.
- Insert current url of the first activate tab in Chrome (This is only achieved in Mac in the video). Try to implement that in Windows.
C-p instead of
M-p to select the candidates in company-mode:
(define-key company-active-map (kbd "M-n") nil)
(define-key company-active-map (kbd "M-p") nil)
(define-key company-active-map (kbd "C-n") #'company-select-next)
(define-key company-active-map (kbd "C-p") #'company-select-previous))
Batch rename files in dired mode
C-x C-q in dired mode. The major mode becomes
iedit to batch change files.
C-; to enter iedit mode. And then we can change the filename all together.
C-c C-c to save the buffer to confirm the changes.
Search and replace (Important)
brew install the_silver_searcher
apt-get install silversearcher-ag
- Search speed:
- Not quite convenient on Windows.
- Why not using
helm in Emacs?
helm loads slower than
helm-ag is an exception.
M-x helm-do-ag-project-root: find the occurence of certain keyword in the projoct directory.
- We can bind a key to it. (
C-c p s).
! to eliminate the undesired results.
- In the result buffer, press
C-c C-e enter editing mode.
- Use similar things in previous section (Batch rename) to change everything at once!
Use flycheck to highlight typos
- enable it globally:
M-x flycheck-verify-setup to show the candidate flychecker module available.
- Add more module to support more programming language.
- Option: Add hook to enable it only in programming mode instead of global mode.
- It can help us to enter some commonly used code snippets, such as
- For more details, find the
YASnippets menu on the top in programming mode.
~ to make the template. At that line, call
- At the new line, call
aya-expand, then we create a template that has multiple cursors marked at the previous
~ point. Type in the stuff you want and create a new sentence.