Orgmode and Emacs Diary

Date

November 23, 2020

1 Agenda view

  • (org-agenda) activate Agenda view

    • C-u 2 1 C-c a a show the next 21 days schedule. Different number works of course.

  • S / M / C display Sunrise/Sunset times, show lunar phases and to convert to other calendars

  • c switch back and forth between calendar and agenda

  • org-agenda-to-appt add the appointments of your agenda files. This also reads a ‘APPT_WARNTIME’ property which will then override the value of ‘appt-message-warning-time’.

1.1 Variables

  • org-agenda-files The information to be shown is normally collected from the files listed in this variable. If a directory is part of this list, all files with the extension \*.org in this directory will be included.

    • orgmode offers functions org-agenda-file-to-front and org-remove-file to add/remove such files from the variable list, but the list will be managed manually in .emacs file (so I’ll remove the keyboard bindings C-c [ and C-c ]).

  • (setq org-agenda-include-diary t) include entries from the Emacs diary into Org mode’s agenda; all diary entries including holidays, anniversaries, etc., will be included in the agenda buffer created by Org mode

  • org-agenda-start-on-weekday set the first day of a week. 0 denotes Sunday, 1 Monday, …

  • org-agenda-include-diary include entries from the Emacs diary into Org mode’s agenda

2 Sunrise/sunset

  • sunrise-sunset Display times of sunrise and sunset for today’s date.

  • C-u M-x sunrise-sunset Display times of sunrise and sunset for a specified date.

  • C-u C-u M-x sunrise-sunset display the times of sunrise and sunset for any location and any date

  • calendar-sunrise-sunset-month Display times of sunrise and sunset for the selected month.

2.1 Variables

  • calendar-latitude 40.1 / calendar-longitude -88.2 / calendar-location-name "Urbana, IL"

3 Code block

#+NAME: <name>
#+BEGIN_SRC <language> <switches> <header arguments>
  <body>
#+END_SRC

3.1 TODO state options, +n, -n, numbering, -r, -l

4 Example/Verse/Quote/Center blocks

#+BEGIN_<block name>
...
#+END_<block name>

where <block name> can be one of the following:

  • VERSE (preserves line breaks, indentation and blank lines, but otherwise uses normal formatting, i.e., poetry block)

  • QUOTE (for quoting a passage—a paragraph that is indented on both the left and the right margin)

  • CENTER (to center some text)

  • EXAMPLE (for ‘verbatim’ text—literal examples that should not be subjected to markup)

  • SRC (for quoting source codes; see the dedicated section §”Code block”)

5 Export options

  • #+TITLE: the title to be shown

  • #+AUTHOR: the author (default taken from user-full-name)

  • #+DATE: a date, fixed, or an Org timestamp

  • #+EMAIL: his/her email address (default from user-mail-address)

  • #+LANGUAGE: language, e.g. ‘en’ (org-export-default-language)

  • #+OPTIONS: H:2 num:t toc:t \n:nil ::t |:t ^:t f:t tex:t ...

6 Exporting

6.1 HTML export command

  • C-c C-e h h (org-html-export-to-html) Export as HTML file with a ‘.html’ extension.

7 Font

  • \*bold*, /italic/, _underlined_, =verbatim=, ~code~, +strike-through+, /~italic code~/

8 Footnote

  • [fn:1] footnote definition when at column 0

  • C-c C-x f switch footnote definition / (first) reference or create a new footnote

  • C-c C-c Jump between definition and reference.

9 Images

  • ./img/cat.jpg

  • #+CAPTION: the caption for the next figure link (or table) / #+NAME: fig:SED-HR4049 [[./img/a.jpg]]

10 Insert entries

  • M-<RET> (org-meta-return) Insert a new item of the same level as the current one.

  • C-<RET> (org-insert-heading-respect-content) Insert a new heading at the end of the current subtree.

  • <TAB>-<RET> new list item at a new level

  • <M>-<RIGHT> make current item one level lower (Promoting/Demoting headings)

  • <M>-<LEFT> make current item one level higher (Promoting/Demoting headings)

  • <TAB> (org-cycle) The first <TAB> demotes the entry to become a child of the previous one. The next <TAB> makes it a parent, and so on, all the way to top level. Yet another <TAB>, and you are back to the initial level.

11 Latex preview

  • org-compile-file: File "/tmp/orgtex5473MjV.dvi" wasn’t produced. Please adjust ’dvipng’ part of ‘org-preview-latex-process-alist’. a log is generated, /tmp/orgtex9997XKu.log. Something interesting is in this log: LaTeX Error: File `wrapfig.sty' not found. Then a quick search tells me texlive-latex-extra package is missing.

  • C-c C-x C-l toggle latex preview

12 Motion

  • C-c C-n (org-next-visible-heading) next heading

  • C-c C-p (org-previous-visible-heading) previous heading

  • C-c C-u (outline-up-heading) backward to higher level heading

13 Moving subtrees up/down

  • M-<UP> (org-move-subtree-up) Move subtree up.

  • M-<DOWN> (org-move-subtree-down) Move subtree down.

14 Paragraphs

  • #+BEGIN_VERSE / #+END_VERSE

  • #+BEGIN_QUOTE / #+END_QUOTE

  • #+BEGIN_CENTER / #+END_CENTER

15 Promoting/Demoting headings

  • M-<LEFT> (org-do-promote) Promote current heading by one level.

  • M-<RIGHT> (org-do-demote) Demote current heading by one level.

  • M-S-<LEFT> (org-promote-subtree) Promote the current subtree by one level.

  • M-S-<RIGHT> (org-demote-subtree) Demote the current subtree by one level.

16 Repeated tasks

  • yearly/monthly/weekly/daily corresponds to y/w/m/d/h letters

  • <2005-10-01 Sat +1m> repeat every (one) month starting from the time

  • <2005-10-01 Sat +1m -3d> a warning period

  • C-- 1 C-c C-t mark a task with a repeater as DONE; a timestamp will be added under the data, to keep a record

  • <2008-02-10 Sun ++1w> Marking this DONE will shift the date by at least one week, but also by as many weeks as it takes to get this date into the future. However, it stays on a Sunday even if this is marked DONE on Saturday.

  • <2008-02-08 Fri 20:00 ++1d> Marking this DONE will shift the date by at least one day, and also by as many days as it takes to get the timestamp into the future. Since there is a time in the timestamp, the next deadline in the future will be on today’s date if you complete the task before 20:00.

  • <2005-11-01 Tue .+1m> Marking this DONE will shift the date to one month after today. (1 month after completion)

  • C-c C-x c (org-clone-subtree-with-time-shift) Clone a subtree by making a number of sibling copies of it. You will be prompted for the number of copies to make, and you can also specify if any timestamps in the entry should be shifted. This can be useful, for example, to create a number of tasks related to a series of lectures to prepare.

17 Sort

  • C-c ^ Sort the plain list. Prompt for the sorting method: numerically, alphabetically, by time, or by custom function.

18 Special symbols

  • \ and maybe a few letters, then M-TAB to see possible completions of special symbols. If you need such a symbol inside a word, terminate it with a pair of curly brackets for eg. \pi{}d.

  • command org-entities-help a command to browse the complete list from a dedicated buffer

  • org-entities-user define own symbols

  • C-c C-x \ (org-toggle-pretty-entities) Toggle display of entities as UTF-8 characters. This does not change the buffer content which remains plain ASCII, but it overlays the UTF-8 character for display purposes only.

19 Superscript and subscript

  • ^ and _ are used to indicate super- and subscripts. We may surround multi-character sub- and superscripts with curly braces.

  • org-use-sub-superscripts a variable that determines whether to interprete _ as a subscript or not. Eg. setting this variable to {}, ‘a_b’ is not interpreted as a subscript, but ‘a_{b} is.

  • C-c C-x \ (org-toggle-pretty-entities) formats sub- and superscripts in a WYSIWYM way.

20 time stamp

  • C-c . (org-time-stamp) Prompt for a date and insert a corresponding timestamp. When the cursor is at an existing timestamp in the buffer, the command is used to modify this timestamp instead of inserting a new one. When this command is used twice in succession, a time range is inserted.

  • C-c ! (org-time-stamp-inactive) Like C-c ., but insert an inactive timestamp that will not cause an agenda entry.

  • C-u C-c . / C-u C-c ! Like C-c . and C-c !, but use the alternative format which contains date and time. The default time can be rounded to multiples of 5 minutes, see the option org-time-stamp-rounding-minutes.

  • The description of org-time-stamp-inactive says that it inserts an inactive time-stamp without prompting if two universal prefixes are provided interactively. This corresponds to the following code:

    (defun org-time-stamp-inactive-without-prompt ()
      (interactive)
      (require 'org)
      (let ((current-prefix-arg '(16)))
        (call-interactively 'org-time-stamp-inactive)))
    

    When we run this function at the previous time-stamp, it updates it without adding a new one. To see why '(16), run the following—try C-u 1, C-u 2, …, C-u C-u, etc., to see what corresponds to which value:

    (progn
      (interactive )
      (message "%s" current-prefix-arg))
    

20.1 automatic time-stamping

# -*- time-stamp-start: "DATE:\\s-"; time-stamp-end: "$"; time-stamp-format "%:b %02d, %:y" -*-
#+DATE:

This will automatically update the timestamp on DATE whenever saving any change. The function time-stamp-toggle-active will switch time-stamping on/off, the option time-stamp-active will set the mode on/off.

20.2 variables

  • org-hide-emphasis-markers

20.3 time stamp in TODO

See TODO section

21 TODO

  • S-M-RET (org-insert-todo-heading) Insert a new TODO entry below the current one.

  • C-c C-t (org-todo) Cycles “TODO” -> “DONE” -> (unmarked). We can customize this: eg.

    (setq org-todo-keywords
          '((sequence "TODO" "FEEDBACK" "VERIFY" "|" "DONE" "DELEGATED")))
    

    The vertical bar separates the TODO keywords (states that need action) from the DONE states (which need no further action). If you do not provide the separator bar, the last state is used as the DONE state.

  • C-c C-q (org-set-tags-command) Enter new tags for the current headline. (“tags” replaces the obsolete “types of action items”.)

  • (setq org-log-done 'time)

    • Then each time you turn an entry from a TODO (not-done) state into any of the DONE states, a line ‘CLOSED: [timestamp]’ is inserted just after the headline.

    • If you turn the entry back into a TODO item through further state cycling, that line is removed again.

      • Setting org-closed-keep-when-no-todo to non-nil, that line is not removed when turning the entry back to a non-TODO state

  • C-c , (org-priority) Set the priority of the current headline. The command prompts for a priority character ‘A’, ‘B’ or ‘C’. When you press SPC instead, the priority cookie, if one is set, is removed from the headline. The priorities can also be changed “remotely” from the agenda buffer with the , command (see Agenda Commands).

    • priority characters can be customized with variables #+PRIORITIES: A C B or #+PRIORITIES: 1 10 5

  • S-UP (org-priority-up) / S-DOWN (org-priority-down)

21.1 Time stamp

  • C-c . (org-time-stamp) Prompt for a date and insert a corresponding timestamp. We can put date and time as jan 1 2020 10:45pm-11:45pm.

  • C-c ! (org-time-stamp-inactive) Like C-c ., insert an inactive timestamp that will not cause an agenda entry.

  • C-u C-c . / C-u C-c ! insert current day/time accordingly (active/inactive)

22 Visibility cycling

  • <TAB> (org-cycle) Subtree cycling