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.
1 2 3 4
(setq org-capture-templates '(("t" "Todo" entry (file+headline "D:/Dropbox/AGDA/Orz.org" "Agenda") "* TODO [#B] %?\n %i\n" :empty-line 1)))
C-c C-sto add timestamp to the TODO item. Enter a time to schedule.
C-a ato 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.
M-pto select the candidates in company-mode:
1 2 3 4 5
(with-eval-after-load 'company (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-qin dired mode. The major mode becomes
ieditto batch change files.
C-;to enter iedit mode. And then we can change the filename all together.
C-c C-cto 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
helmloads slower than
helm-agis 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-eenter 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-setupto 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
YASnippetsmenu 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.