Wed 09 Mar 2016 — Mon 05 Jun 2017

Help about Help

apropos searches in command descriptions

C-h ? shows some ways to get help about help.

Read the status bar as you type.

C-h F thing for command help C-h K keys for command help based on a key sequence

C-h i go to the info reader. C-h r go to the manual.

C-h t tutorial.

FAQ

Look and Feel

customize-themes

Look at 'Using Customize'

Text Processing

dired-do-query-replace-regexp

Repeat Commands

C-x z repeats last command.

M-5 sends the argument 5 to the next command. M-5 0 sends the argument 50 to the next command.

C-x ( and C-x ) make macros. C-x e executes them.

C-u arg command passes arguments to a command.

Indentation

For C-style languages

cc-mode does indentation

C-c C-o to fix some indentation you don't like.

C-c C-q to reinden

Picture-Mode

Lets you move your cursor freely. Removes trailing whitespace.

There's also Artist Mode which gives you some more drawing tools (including mouse drawing).

Parens

(show-parent-mode 1)

C-M-f and C-M-b move parent-wise.

Auto-mode-alist

(add-to-list 'auto-mode-alist '("\\.thing\\'" whatever-mode))

Debugging

Use emacs -debug-init

Org-mode

See Babel Intro

C-c C-c executes a code block.

Tangle means get the code, weave means make a document.

Results

:results value captures the last return value. :results output captures text from stdout.

Session

:session name-of-session lets your persist things from one code block to another.

(Otherwise they are self-contained.)

Calling functions

We can use Babel as a meta-programming language, glueing several others together.

Give code blocks names using #+name: my-function.

Declare their parameters with #+header: :var x=0.

Call them with #+call: my-function(x=5).

Multiple Files

org-babel-lob-ingest (C-c C-v i) allows us to load code blocks from other files.

Tangling

org-babel-tangle

Specify :tangle filename to output a code block to file.

Turn on :noweb yes and then Use to specify a depedendency on some other block.

Languages

Python

The default Python support isn't that good yet. Its output has prompts all over the place, and it can't handle empty lines inside function definitions.

To get around this, we can use the IPython kernel for Jupyter instead.

Include the Jupyter package in your installed Python command. For example, I use something like:

pkgs.python36.withPackages(ps: with ps; [matplotlib tabulate numpy jupyter])

This install will put in assorted Jupyter command line tools for you. For example, you should now be able to run jupyter kernelspec list and see your Python 3 kernel.

Remember to also include (ipython . t) inside the org-babel-load-languages variable.

Unfortunately, ob-ipython has its own difficulty. Mainly, the table export (which works very nicely with normal Python) is broken, and the first listed in their Github readme is out of date.

I'll look at this again next year.

Org-TaskJuggler

Install TaskJuggler

It's a ruby project

sudo aptitude install ruby
mkdir ~/taskjuggler
gem install --install-dir ~/taskjuggler taskjuggler

Making some tasks

  1. Define an effort property and column
  2. Add a taskjugglertag to the top of your tree.
  3. M-x org-export-as-taskjuggler-and-open

Adding dependencies

  • ORDERED property
  • BLOCKER property says what we depend on ('previous-sibling', or a task id)

People

Make a separate tree for people.

Give each person a resourceid property

Give your tasks allocate properties, saying who they depend on.

Org-Mode

TODO Tags

Properties

Each entry in an org-mode outline can have properties. They go inside a PROPERTIES…END block. Each properties is a key-value pair which is written on one line.

* My-Heading
:PROPERTIES:
:Title: Whatever
:END:

C-c C-x p sets a property.

S-left and S-right switch between allowed values for a property.

C-c C-c D kill a property out of the whole file.

Properties may be searched like tags.

There's an API for controlling properties using elisp.

  • Inheritance

    org-use-property-inheritance exists. Probably don't use it.

  • Column View

    Define columns on a file level, or for a particular sub-tree:

    #+COLUMNS: %THIS %THAT %TOTHER
    

    You can also control the width of a column (and some other things):

    #+COLUMNS: %10FIXEDWIDTH
    

    C-c C-x C-c toggles column view. org-columns-quit exits column view.

Todo Status

Todo status is implemented as a special property.

C-c C-t toggles the todo status of the current branch.

Archiving

C-c C-x a org-toggle-archive-tag

C-u C-c C-x a tag archive children without TODO entries

C-c C-x A org-archive-to-archive-sibling puts it in a parallel subtree

C-C C-x C-s or C-c $ org-archive-subtree

C-u C-c C-x C-s children to subtree

There's also a timestamp one, which I won't bother with.

Sparse-Tree

Let you filter based on dates, regex, properties or TODO.

Collapse most of the tree, so you can only see those things you asked for.

TODO Read This

http://doc.norang.ca/org-mode.html

This looks like the thing.

Includes

Link is C-c l

You can link to another org file using my-file.html

You can include another file using INCLUDE:

#+INCLUDE: "my-file.org" org

Timestamps

http://orgmode.org/manual/Creating-timestamps.html#Creating-timestamps

  • Can repeat
  • Can have ranges
  • Can be generated by an SEXP

C-c . org-time-stamp

C-u C-c . date and time

C-c < org-date-from-calendar today's date

C-C > org-goto-calendar

C-c C-o org-open-at-point open an agenda at that date

Shift + cursor keys change the date

C-c C-y org-evaluate-time-range compute difference between dates

  • Repeat tasks

    Set a repeater interval using + and the keywords y/m/w/d/h for year/month/week/day/hour. For example:

    <2005-10-01 Sat +1m>
    

    Setting a repeat task to done will shift the timestamp. It'll also store an extra timestamp to let you know when you did it.

  • Special Tags

    DEADLINE and SCHEDULED tags take a timestamp as an argument. Schedule means when you intend to start working on a thing.

    There are commands to show passed deadlines etc.

  • Clock

    C-c C-x C-i clock in, C-c C-x C-o clock out.

    There is a special clock table to look at these.

    It can be set up to warn you about idle time, and allow you to resolve/adjust the clock.

  • Timers

    Not quite the same as clocks.

    There is org-timer-start and org-timer-set-timer.

  • Estimates

    C-C C-x e lets you set an estimate.

Agendas

http://orgmode.org/manual/Agenda-views.html#Agenda-views

C-c a opens the agenda menu. Then you choose which agenda view you want.

You can filter the agenda in various ways:

  • / for tags
  • < for category
  • = for regex
  • ^ nearby things
  • | clear filters
  • space to go to the place where this item came from.
  • F (follow) to display items as you move through the agenda.
  • C-k delete item
  • t toggle todo status
  • C-c schedule it
  • C-d deadline it
  • S-left S-right move the timestamp
  • m mark item
  • B bulk action
  • x exit and clear out opened buffers
  • C-x w write agenda to file
  • C-x C-c C-x toggle columns mode
  • Date View
    • f go forward in time
    • b go backward in time
    • . today
    • j jump to a day
  • Files

    Agendas need to know which files to look at.

    Use C-c [ to add and C-c ] to remove a file. Use C-, and C-. to cycle those files.

    C-C C-x < says read my agenda from this subtree. C-c C-x > undoes it.

    It doesn't follow includes or links.

    You can set up a regex or a directory or whatever.

    Org items will get a category based on what file they came from.

Interleave

The Interleave Package is a way to take notes on a PDF side-by-side with an org-mode buffer.

org-capture

You have a notes file, and a key combination.

Press the key combination, type your note, it gets put in the file.

You can do this from anywhere in Emacs.

Export

C-c e

This is obviously excellent.

Consider these headers for latex export:

#+AUTHOR:
#+TITLE:
#+OPTIONS: toc:nil num:0
#+LATEX_HEADER: \usepackage{fullpage, parskip}

TODO Emacs Calendar/Diary Integration

Org can just work out things like %%(org-anniversary). Do that.

%%(org-calendar-holiday)

Batch

https://www.emacswiki.org/emacs/BatchMode

#!/usr/bin/emacs --script"

The –script flag is shorthand for –batch -l, where -l means "load this file".

You can also use –eval to eval some elisp.

Marks

Marks are used for highlighting.

Shifted movements make this happen.

Alternatively, type C-<space>

There is a mark ring, which keeps a short history.

C-u <space> moves to the previous mark.

C-x C-x pushes us into history, then marks the previous mark.

Registers

Registers have a name. It may be a character (case sensitive) or number.

General form of commands is: C-x r <thing> <name>

Type Get Set
Position and buffer C-x r j <name> C-x r <SPC> <NAME>
File C-x r j <name> (set-register <name> '(file . NAME))
Macros C-x r j <name> C-x C-k x <name>
Text C-x r i <name> C-x r s <name>
Rectangle C-x r i <name> C-x r r <name>
Number C-x r i <name> C-x r n <name>
Bookmark C-x r b <name> C-x r m <nane>

If you explicitly put in numbers, you can use increment-register. You use C-u <N> as a prefix to tell it what number you want to set.

There are also append-to-register and prepend-to-register commands. You can use the register-separator variable to separate things added like this.

Bookmarks

These are persistent registers with long names.

C-x r l to list bookmarks.

Customization

Use M-x customize to get the top-level customize thing.

Variables are arranged in groups.

Use M-x customize-apropros if you don't know what you're looking for.

Use C-h v some-variable to get the help for a variable.

Saved customizations go into the Emacs config file. We can use (setq_custom_file "some-file") and (load custom-file) to separate this out.

Hooks

Hooks are a special kind of variable which contain a list of functions.

Those functions are run in order under particular situations.

Locals

Individual buffers can have local copies of variables with their own values.

This is how modes work.

File Locals

A file can have some variables that are set when it is loaded.

See M-x add-file-local-variable and M-x add-file-local-variable-prop-line.

Windows

Windows in Emacs are called Frames.

C-x 5 2 create frame C-x 5 0 delete frame