Skip to content

Latest commit

 

History

History
373 lines (240 loc) · 8.8 KB

File metadata and controls

373 lines (240 loc) · 8.8 KB

Emacs :emacs:

Install Emacs

install

emacs.app

brew cask install emacs
git clone https://github.com/syl20bnr/spacemacs ~/.emacs.d

but it does create the path for command line. Tips for emacs setup on OS X.

develop branch

git checkout develop #use the master version

org-indent-mode

(setq org-startup-indented t)

Timestamp :cheatsheet:

, d t:

active timestamp: <2020-02-09 23:00 Sun>

, d T:

inactive timestamp [2020-02-09 Sun]

info:org#Timestamps

Tags :cheatsheet:

, i t: add tags to headline

SPC a o m: open a org-tags-view

Tree :cheatsheet:

, s a: add archive tag

, s n: narrow to the subtree

, s N: widen

Search :cheatsheet:

SPC s s: search in current buffer

SPC s f: fuzzy search for files

SPC s d: ag search in current dir

SPC s r f: rg search in files

SPC a o m: search with tags in agenda files

SPC a o r: full text search in agenda files

SPC a o s: search with keywords in agenda files

Custom Commands:

SPC o s: helm-org-agenda-files-heading search headings in agenda files. Bind this to a shortcut.

How to bind keys

Todo keywords [2/2]

  • Add more keywords

    (setq org-todo-keywords '((sequence "iTODO(t)i" "PROGRESS(p)" "|" "DONE(d)" "CANCELLED(c)")))

    org-todo-keywords

  • Add the highlights of the keywords

    (custom-set-variables 
     '(org-todo-keyword-faces
       (quote
        (("TODO" . "#dc752f")
         ("PROGRESS" . "#4f97d7")
         ("DONE" . "#86dc2f"))))
     )

    org-todo-keyword-faces

    If the effects are not taken, use org-mode-restart to clear the caches in Emacs.

Org-mode

The Org Manual Org Mode - Organize Your Life In Plain Text

Org-Babel :cheatsheet:

C-c, C-, or , i b: open code block templates

C-c, C-,: open code block templates

C-c, C-': edit code block in separate window

C-c, C-C: edit code block in separate window

C-c, C-v, t: tangle code block in buffer

SPC u, C-c, C-v, t: tangle current code block

python

print "This Is A python code"
print "hahaha"
>>>

java

import edu.princeton.cs.algs4.StdIn;
class Test {
    private String pat;

    public Test(String pat) {
        this.pat = pat;
    }

    public static void main(String[] args) {
        System.out.println("Hello World!");
    }
}

how to tangle a block

print("this")

Org-agenda :cheatsheet:

C-c a: trigger org-agenda menu

(setq org-agenda-files (quote
                        ("~/OneDrive/org/notes.org"
                         "~/OneDrive/org/gtd.org")))

org-agenda-files

  • In agenda view

    C-c C-s: to schedule item

Org-capture :cheatsheet:

C-c c: trigger org-capture

org-capture-templates

  • Add template for org-capture.
(setq org-capture-templates
      '(("n" "Notes" entry (file+headline "~/OneDrive/org/notes.org" "Notes"))
        ("t" "ToDo" entry (file+headline "~/OneDrive/org/gtd.org" "Tasks")
         "* TODO %?\n  %i\n  %a")
        ))

Org-habit :cheatsheet:

  1. configuration in org-modules

    (defun dotspacemacs/user-config ()
      "Configuration for user code:
    This function is called at the very end of Spacemacs startup, after layer
    configuration.
    Put your configuration code here, except for variables that should be set
    before packages are loaded."
      (setq org-modules (quote (org-habit)))
      (setq org-agenda-files '("~/OneDrive/org/gtd.org"))
      )
  2. add a schedule to a TODO task.

  3. add :STYLE: habit to the task.

C-k toggle habit in agenda view

Org-refile :cheatsheet:

Problem after installation of the develop branch.

# org-refile does not work. org-copy-subtree: Invalid function: org-preserve-local-variables
cd ~/.emacs.d && git pull --rebase; find ~/.emacs.d/elpa/2*/develop/org-plus-contrib* -name '*.elc' -delete

Reference

, s r: open refile window

(setq org-refile-targets '((org-agenda-files :maxlevel . 3)))
(setq org-refile-use-outline-path 'file)
(setq org-outline-path-complete-in-steps nil)

file:///Users/alfmunny/.spacemacs

Export :cheatsheet:

SPC m e e open export menu

Archive tasks :cheatsheet:

Options:

  • :Archive: tag, , s a

    Maybe suitable for some project

  • Archive to C-c C-x A (org-archive-to-archive-sibling)

    For major categories, like this one Tasks

  • Use org-refile, refile it to a structured notes, , s r

    Important notes, which has to be taken into notes

  • Archive to *archive, , s A

    Not needed anymore

    Reference: info:org#Archiving

Binding keys

(spacemacs/declare-prefix "o" "custom")
(spacemacs/set-leader-keys "os" 'helm-org-agenda-files-headings)

binding-keys

(global-set-key (kbd "C-c n l") 'org-roam)
(global-set-key (kbd "C-c n f") 'org-roam-find-file)
(global-set-key (kbd "C-c n g") 'org-roam-graph)
(global-set-key (kbd "C-c n i") 'org-roam-insert)
(global-set-key (kbd "C-c n I") 'org-roam-insert-immediate)

https://develop.spacemacs.org/doc/DOCUMENTATION.html#binding-keys

Multi-line editing :cheatsheet:

g-r-A multi editing using visual selection

g-r-q quit register

Clock :cheatsheet:

, C i: clock in

, C o: clock out

, C R: clock report

:LOGBOOK:
CLOCK: [2020-02-13 Thu 17:04]--[2020-02-13 Thu 17:06] =>  0:02
:END:

Python mode :cheatsheet:

SPC m s b: send buffer SPC m s B: send buffer and switch to REPL SPC m s f: send function and switch to REPL SPC m s i: start the inferior REPL process SPC m c c: execute current file in a comint shell

Diary-date :cheatsheet:

visual-line-mode

setq visual-line-mode t

To navigate under visual line mode:

M-x spacemacs/toggle-visual-line-navigation-on

Line number

SPC t n a absolute line number

SPC t n r relative line number

SPC t n v visual line number

Spell Checking

SPC t S toggle spell checking

(setq spell-checking-enable-by-default nil)

Current Time Stamp

C-u C-c . insert current active time with prompt

C-u C-u C-c . insert current active time without prompt

C-u C-c ! insert current inactive time with prompt C-u C-u C-c ! insert current inactive time without prompt

Enable Writeroom Mode

M-x writeroom-mode Writeroom Mode

asm mode :emacs:

mov ax, 1000H