Skip to content

My notes about starting Emacs org-mode in WSL (August 2021)

Notifications You must be signed in to change notification settings

nerding-it/learn-orgmode

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

40 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Learning Emacs Org-Mode

In this file I add new things I learn about Emacs and orgmode. QUESTION and #FIXME mark section where help is needed.

Starting Emacs

Options to run Emacs

Pure Windows - Windows executable (not WSL, just from shell):

  • emacs.exe starts GUI (Russian font ok, preferred option)
  • emacs.exe -nw for text mode
  • runemacs.exe (runs GUI, has issue with bad Russian font spacing)

WSL:

  • WSL in terminal (cmder) with bash (Ubuntu)
  • XServ graphics (X410) - pipeline to start a bit complex

VSCode extension:

  • syntax highlighing and some commands
  • no agenda view

Mobile:

  • Android + Termux + Emacs (You will probably need something like Hacker’s Keyboard to input the shortcuts effectively)
  • Orgzly
Console vs teminal vs shell.

Basic pipeline

  • Install emacs on WSL with sudo apt-get install emacs
  • Launch emacs with emacs -nw <FILENAME.org> command
  • Open a file with F10 - File menu
  • Edit file
  • Save file C-x C-s
  • Exit Emacs C-x C-c

Improvements and changes

Configure terminal to avoid key conflicts

Must configure terminal to resolve key binding conflicts like Ctrl-C.

Set org-support-shift-select

  • Selection with Shift is already built-in part of Emacs, but not org-mode
  • Start with ‘M-x customize’ to find options about Shift selection

Set CUA option in F10 menu

  • Set CUA (Ctrl-Z/X/C/V) as part of F10 menu with Enter
  • Save options

Where is the config?

Use just one, any of them:

  • ~/.emacs is a config file
  • ~/.emacs.d is a directory with init.el config file

Using X410 video system

Change keyboard layout in X410

  • Selecting a Keyboard Layout
  • This page details the use of the setxkbmap command to set X410 keyboard layout. By example, to set keyboard layout to Russian, the command is setxkbmap ru.

Avoid screen with tutorial

Kill it with C-x 1 or try (setq inhibit-splash-screen t).

Using Emacs

Make a selection, copy and paste selection

You can configure orgmode to use Shift-arrows for selection with org-support-shift-select.

[C] Finding and replacing text

Unsure how it works on emacs, is it C-s? What about replace? Please recommend some tutorial on this?

[C] Working with windows

I currently use <Remove other windows> from File menu. Maybe I can do better.

How to select a vertical block of text?

Run bash

M-X shell

How to move across buffers?

  • C-x o move to the other window
  • C-x 1 maximixe current buffer
  • C-x 2 split current window vertically
  • C-x 3 split current window horizontally
  • C-x b ask for the name of a buffer and display it in current window
  • C-x B split current window and show a buffer list in the other window
  • C-x B split current window and show a buffer list in the other window
  • C-x k kills buffer

[B] How to run some command from a command line?

Imagine I needed something like

~emacs README.md –run “C-c C-e h h”

How would it do it? Using emacs lisp?

Refresh file from disk

The command is M-x revert-buffer (details).

Is there somethign similar to prettier or black code formatter for org files?

M-x revert-buffer

Using orgmode

<TAB> is all you need

  • TAB shows/hides headers (quite powerful!)
  • Shift-TAB opens all headers

Getting around headers

  • Alt + left or right changes header level
  • Alt + up or down moves lines around
  • Shift - arrow:
    • changes list numbering style
    • cycles TODO-DONE in header
    • selects in CUA mode

Move line across headers beyond own section

Create a hyperlink

Use timestamps

As guide suggests:

  • C-c . for active date-only timestamp (Active = it creates an entry on Org agenda)
  • C-c ! for inactive date-only timestamp (Inactive = it doesn’t create entries on Org agenda)
  • S-arrow for change

[A] How to put a timestamp with time, not just date?

  • C-u C-c . and C-u C-c ! for timestamp including date and time, active and inactive respectively

Checkboxes

  • You must type [0/0] or [0%] for checkbox
  • Only X counts for completion, not `x` or `+`
  • C-c C-c toggles and recalculates
  • QUESTION: what can recalculate on its own?
  • Check Rainer König video OrgMode E01S05: Checklists

Sample checkbox list [2/3], [66%]:

  • [X] Item 1
  • [X] Item 2
  • [ ] Item 3

Agenda

  • Use F10 and menu for agenda view

C-c a

Why is C-c a undefined? Shoud I define it?

Seems to be undefined by default, but this page of the Org mode guide says that with (global-set-key (kbd "C-c a") 'org-agenda) can be set. If the keyboard shortcut isn’t activated, you can activate the agenda view manually with M-x org-agenda.

How to sort agenda by priority?

This Emacs Stackexchange question shows Emacs-Lisp code to make sorting by priority the default in agenda view

	(defun hw-org-agenda-sort-habits (a b)
	  "Sort habits first by user priority, then by schedule+deadline+consistency."
	  (let ((ha (get-text-property 1 'org-habit-p a))
		(hb (get-text-property 1 'org-habit-p b)))
	    (when (and ha hb)
	      (let ((pa (org-get-priority a))
		    (pb (org-get-priority b)))
		(cond ((> pa pb) +1)
		      ((< pa pb) -1)
		      ((= pa pb) (org-cmp-values a b 'priority)))))))
	(setq org-agenda-cmp-user-defined 'hw-org-agenda-sort-habits
	      org-agenda-sorting-strategy '((agenda time-up user-defined-down habit-down)
					    (todo priority-down category-keep)
					    (tags priority-down category-keep)
										(search category-keep)))

How to close agenda buffer?

In Emacs you close a buffer with C-x k

Clocking

*** Clock this!

  • Start: C-c C-x C-i
  • End: C-c C-x C-o

It is easy to “clock-in” to a particular task by positioning point within an item and typing C-c C-x C-i and clocking out with C-c C-x C-o.

https://www.adventuresinwhy.com/post/org-mode-timekeeping/

What are useful habit with clocking? Does pomodoro help?

SJ: In the same way the body cannot sustain exercise indefinitely, but needs to rest after a period of sustained effort, so does the brain. So pomodoro is a good practice, but you need to tailor the focus and rest periods to your personal optimum./

Table

  • Start table from menu
  • C-c C-c to format

Calendar

How to view calendar (it was popping up accidantally when I hit something wrong).

Other actions

  • Sort this list is C-c ^
  • Add cycling todo tags #+SEQ_TODO:
  • Archive tasks through Org menu
  • Defintion list with :: separator
  • Github search for org files with [[https://github.com/search?o=asc&q=language%3Aorg&s=indexed&type=Code][language:org]]
  • C-k C-y can move lines

Useful scenarios

What are productive scenarios for using org-mode?

- @Trevoke via reddit:

The best advice I’ve heard for using org-mode in some sort of GTD system was not to try and set up categories when you start. Start with just a bunch of TODOs, and slowly grow the system as you feel the need to.

SJ:

  • As a general notebook for brainstorming and keeping interesting ideas at hand.
  • Org mode can execute code in several programming languages, so it can also be used to automate tasks that require collections of scripts.
  • It can even be used as database client for SQL databases, and the result of SQL queries can be shown in Org tables.
  • To measure your productivity by tabulating hourly, weekly, daily views on your clock-ins and clock-outs.
  • Alongside existing productivity methodologies like GTD

Reference

Concepts

buffer
a screen that represents a file or Emacs own output
frame
is a new window for the whole program
modeline
a line at the bottom of a screen with something like -UUU(DOS)**--F1
window
is a windows inside editor

Notation

  • * is a header
  • drawer box has :NAME: and :END:

Links

Videos

New:

Essential:

Extension:

Academic:

Blogs and success stories

[C] add images from sachachua.com

[C] redraw mindmap to simplify

Orgfiles on github

Out of scope

I try to avoid more complicated topics:

  • packages and complex configuration
  • programming in lisp
  • spacemacs, emacs-doom and similar
  • org-roam
  • org-capture
  • email with gnus
  • git with magit
  • export to latex and beamer

Appendix.

Key binding cheatsheet

CommandAction
M-x <command>Run command by name
M-x shellRun Shell
F10Upper menu
C-sAdvanced search
C-c C-cToggle or recalculate
C-k C-yKill and undo line
C-c C-e h hCreate HTML
C-x 1Remove window
Way out
C-gKill, stop or exit
ESC-ESC-ESCExit (hopefully)
qExit (sometimes)
Not Emacs:
Fn-EscLock Fn key (Lenovo)

Emacs commands

M-x:

  • revert-buffer (in File menu)
  • customize
  • shell
  • query-replace-regexp (asks for a regular expression, replaces it, it is very powerful to automate editing tasks)

About

My notes about starting Emacs org-mode in WSL (August 2021)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published