子龙山人Learn Emacs in 21 Days: day 6 学习笔记

子龙山人Learn Emacs in 21 Days: day 6 学习笔记
Youtube
youku

1. org-mode

建立模板

init-org.el中加入

(setq org-capture-templates
      '(("t" "Todo" entry (file+headline "~/.emacs.d/gtd.org" "工作安排")
     "* TODO [#B] %?\n  %i\n"
     :empty-lines 1)))

可以新建模板

M-x org-capture
后按t可以建立org模板

模板会保存在~/.emacs.d/gtd.org

设置快捷键打开模板

(global-set-key (kbd "C-c r") 'org-capture)

org-pomodora

安装

(require 'org-pomodoro)

custumize-group中可以设置long break和short break,具体也不知道有什么用- -

C-a a
打开org后
M-x org-pomodoro
可以启用番茄工作时间

获取chrome当前链接


(defun sandwich/insert-chrome-current-tab-url()
  "Get the URL of the active tab of the first window"
  (interactive)
  (insert (sandwich/retrieve-chrome-current-tab-url)))

(defun sandwich/retrieve-chrome-current-tab-url()
  "Get the URL of the active tab of the first window"
  (interactive)
  (let ((result (do-applescript (concat "set frontmostApplication to path to frontmost application\n" "tell application \"Google Chrome\"\n" " set theUrl to get URL of active tab of first window\n" " set theResult to (get theUrl) \n" "end tell\n" "activate application (frontmostApplication as text)\n" "set links to {}\n" "copy theResult to the end of links\n" "return links as string\n"))))
    (format "%s" (s-chop-suffix "\"" (s-chop-prefix "\"" result)))))

(setq org-capture-templates
      '(("t" "Todo" entry (file+headline "~/.emacs.d/gtd.org" "工作安排")
     "* TODO [#B] %?\n  %i\n"
     :empty-lines 1)
    ("c" "Chrome" entry (file+headline "~/.emacs.d/gtd.org" "Quick notes")
               "* TODO [#C] %?\n %(sandwich/retrieve-chrome-current-tab-url)\n %i\n %U"
               :empty-lines 1)
    ))
C-c r c
可以创建chrome相关的模板 

2. others

company中可以通过C-n C-p选择补全选项

stackexchange

(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))

dir rename

C-x C-q

3. ag

ag > pt > ack > grep

install

brew install the_silver_searcher

install package helm-ag

(global-set-key (kbd "C-c p s") 'helm-do-ag-project-root)

编辑ag的搜索结果

“`
C-c C-e
打开搜索buffer

C-c C-c
保存结果

C-c C-k
取消
“`

4. flycheck & snippet

python中使用flycheck

install pip

wget https://bootstrap.pypa.io/get-pip.py
sudo python get-pip.py

pip install

pip install pylint

other

M-x flycheck-verify-setup

yasnippet & anto-yasnippet

(require 'yasnippet)
(yas-reload-all)
(add-hook 'prog-mode-hook #'yas-minor-mode)

你可能感兴趣的:(emacs)