EMACS-DOCUMENT

=============>随便,谢谢

Org-mode features You May Not Know

When I meet fellow orgers, I occasionally use some of the features below and quite often, my interlocutor does not know some of them. Do you know them all?

If you think of a secret Org weapon that is not listed here, please send me an email, I will consider adding it to the list.

The features listed below are all available with Org 9.3 and later. Check your version with M-x org-version RET and please read Org's manual and browse Worg if you want to explore more.

...

You can discuss these features on reddit and on Hacker News.

Let's say you have harvested a dozen of links to various emacs buffers (emails, files, etc.)

C-c C-M-l will insert all the links as a list.

The related command is org-insert-all-links.

C-u C-c C-c on a list to make it a checklist

It will turn the list into a checkbox list.

Contextual capture templates

(setq org-capture-templates-contexts
 '(("r" ((in-mode . "gnus-summary-mode")
     (in-mode . "gnus-article-mode")
     (in-mode . "message-mode")))))

Here the capture template associated with the r key will only be displayed in gnus-summary-mode, gnus-article-mode and message-mode.

Use agenda* as a custom view to match appointments

Quoting the Org manual:

The agenda* view is the same as agenda except that it only considers appointments, i.e., scheduled and deadline items that have a time specification [h]h:mm in their time-stamps.

(setq org-agenda-custom-commands
 '(("%" "Appointments" agenda* "Today's appointments"
     ((org-agenda-span 1)
 (org-agenda-max-entries 3)))))

See the example above.

Very useful when defining agenda views dedicated to appointments.

C-h v org-agenda-max-entries RET

"Here is another neat trick. The sample code above also sets org-agenda-max-entries:

(setq org-agenda-custom-commands
 '(("%" "Appointments" agenda* "Today's appointments"
     ((org-agenda-span 1)
 (org-agenda-max-entries 3)))))

The use of org-agenda-max-entries will limit the agenda view to the first three entries of today's tasks.

C-h v org-agenda-max-entries RET to know more about this variable.

C-x C-w agenda.org RET in an agenda view

It will store the displayed list of tasks in a new agenda.org file.

Hit = in agenda views to filter by a regex

Very useful to (export and) share your current list of tasks with someone.

Hitting = in the agenda buffer will limit to headlines matching a regular expression.

You can remove all filters by hitting |.

. in a the calendar to jump to today

After C-c C-s on a headline scheduled in the past or the future, use . to jump to today's date.

After you hit C-c C-s on a headline to schedule it, enter e.g. +3d to plan in three days, or 10:00+1 to plan an meeting from 10am to 11am.

Use S-<up/down/left/right> to move a table cell

It will move the current cell up/down/left/right.

Use S-RET to copy and increment the cell at point

| Numbers | Dates |
|---------+-------------------|
| 1 | <2020-02-04 mar.> |
| 2 | <2020-02-05 mer.> |
| | |

Hitting S-RET here will create a new row and a cell with "3".

Hitting S-RET there will create a new row and a cell with "<2020-02-06 Thu>"

Summing durations in tables

Org tables are able to sum durations:

| 00:00:30 | 2:30 |
| 00:00:45 | 3:30 |
|----------+------|
| 00:01:15 | 6.00 |
#+TBLFM: @3$1=vsum(@1..@2);T::@3$2=vsum(@1..@-1);t

Hit s to (un)narrow to subtree

When org-use-speed-commands is set to t, hitting s at the beginning of a headline will narrow to the current subtree. Hitting s again will unnarrow the buffer.

Very useful when you need to hide the rest of your personal notes from your colleagues.

The related command is org-narrow-to-subtree.

Hit < to (de)activate restriction lock on current subtree

When org-use-speed-commands is set to t, hitting < at the beginning of a headline will activate the restriction lock on the current subtree. Hitting < again will deactivate it.

Very useful when you temporarily need to call agenda views while only considering tasks in the current subtree or when you need to undo things in the current subtree alone.

The related command is org-agenda-set-restriction-lock.

C-c C-^ to move to the root of the element

C-c C-^ (or C-c C-u) while move the cursor up one element.

C-c - and C-c * to toggle headlines and items

C-c - on a headline will convert it into a list item.

C-c * on a list item will convert it into a headline.

You can also try on multiple headlines and list items.

C-c C-x - to start a list with a timer

- 0:00:00 :: Now I can start taking some notes.
- 0:00:02 :: If I hit ~M-RET~, a new list item is created.
- 0:00:06 :: And so on.

C-c C-x - will start a timer and create a list item displaying the timer like the example above.

Schedule multiple headlines in the region

When org-loop-over-headlines-in-active-region is set to t and the region is active on multiple headline, you can use C-c C-s to schedule all the headlines one after another.

See the docstring of org-loop-over-headlines-in-active-region for more fun.

M-h for mark-paragraph and org-mark-element

M-h will mark (and highlight) the paragraph at point.

In org-mode, M-h will mark (and highlight) the element at point.

Hitting M-h several times successively will mark the next elements too.

M-<up/down> and S-M-<up/down> to move elements and lines

Just hit M-<up/down> in an Org buffer. It moves elements.

Now hit S-M-: it moves the current line up/down.

S-<left/right> in column mode to cycle through property values

If a property can have multiple predefined values and the column view is active, you can use S-<left/right> in column mode to cycle through possible property values.

I use something like this in my configuration:

(setq org-tag-alist
 '((:startgroup)
    ("Handson" . ?o) ;; The grouping tag
    (:grouptags)
    ("Write" . ?w) ("Code" . ?c) ("Mail" . ?@)
    (:endgroup)
    (:startgroup)
    ("Handsoff" . ?f) ;; The grouping tag
    (:grouptags)
    ("Read" . ?r) ("View" . ?v) ("Listen" . ?l)
    (:endgroup)
    ;; Off groups
    ("Print" . ?P) ("Buy" . ?B) ("Patch" . ?p) ("Bug" . ?b)))

Then M-x org-agenda RET m +Handsoff will list all headlines with a Read, View or Listen tag.

  • S-up/down on a timestamp in a CLOCK: line will adjust the timestamp.
  • C-S-up/down on a timestamp in a CLOCK: line will adjust both timestamp, the time you clocked in and the time you clocked out: the clock duration will not change.
  • M-S-up/down on a timestamp in a CLOCK: line will also adjust previous clocks timestamps, if any.

C-u C-u C-c c to jumb back to the last stored capture entry

C-u C-u C-c c will jump to the last captured note. The one you may actually want to update if you forgot something.

M-x org-toggle-archive-tag RET

This add an :ARCHIVE: tag to the current entry, making it unavailable for most commands like (un)folding, agenda views, etc. It is bound to C-c C-x a - less known than org-archive-subtree, but useful too.

M-x org-num-mode RET to prefix headlines with numbers

M-x org-num-mode RET will prefix headlines with a number.

...

Thanks!

Thanks to Karl Voit and Steven Shaw for their feedback and suggestions.