Org Wiki

Main Programming Platforms Projects Emacs Russian Quotes Old


Table of Contents

1 Emacs Notes

1.1 Handy keys

1.1.1 Windows and buffers

C-x b <filename> Select buffer by filename; with autocompletion
C-x C-f 'Find file' - open a file
C-x C-s Save buffer
C-x s Save all buffers; prompts per changed buffer
C-x s ! Save all buffers; no prompting
C-x C-v <RET> Reload current buffer; useful for resetting R/W
C-x k <enter> Kill current buffer without closing window
C-x o Go to next window
C-x 0 Close current window without killing buffer
C-x 2 Split current window vertical
C-x 3 Split current window horizontal

1.1.2 Other essential keys

Keys Action Comment
C-s Search forward  
C-s M-c Search case sensitive M-c is a toggle
C-r Search back Use after C-s
C-s (C-w)* Select (expanding) word under cursor Use after C-s
C-M-s Search by regex NB: \{ \}
C-x C-e run elisp function Place cursor at end brace
C-h f get elisp function doc Set cursor on name
TAB Outline: cycle visibility i.e. open/close outlines
<shift>-<insert> Paste  
C-<shift>-<backspace> Delete line  
M-1 M-! shell-cmd run shell command  
C-h v var-name Show variable  
C-c C-l Create/edit external link  
C-c C-o Open link under cursor in new window  
C-x 8 C-h Help page for accented char's  
C-x 8 ' e Accents; given combination: é Should work for all emacs modes
C-c C-f Toggle folding of block For modes that support it
C-x 8 RET #x20AC RET Euro sign €  
M-x sort-lines sort lines in current selection  
M-x *-mode <tab> List all interactive commands ending in '-mode' Prefix: just hit Tab, no *
<shift>-left click Adjust font size menu Click in text area

1.1.3 Useful commands

Prefix these with M-x. Notably, major modes can be set here.

load-file <RET> <RET> reload current file - handy for .emacs
customize-option <name> use emacs option screen for changing settings
set-variable RET tab-width RET 4 RET Change tab width for local buffer

Lisp functions: use C-x C-e at end to run (eg in scratch buffer)

(dired "/wim@quinte:~") Show dir listing on remote machine
  - Leaving out user works
  - Refresh with single key 'g'
  - '/' required

Byte-compile everything in .emacs.d/elpa

To avoid warnings when uploading wiki

Source

> C-u 0 M-x byte-recompile-directory
> Directory: ~/.emacs.d/elpa

1.1.4 Major/minor modes

Major modes. Others work analogously; useful for eg. syntax highlighting.

c++-mode
markdown-mode
ruby-mode

Useful minor modes

hs-minor-mode enable folding in current buffer

1.1.5 Vim rehash

Following useful vim-keys also work in evil-mode:

NOTES

  • emacs folding binded to C-c s, C-c h in .emacs.
  • In vim, lower case does action on current level, upper case on all lower levels as well. Evil mode does not implement this well.
  • Works better if cursor is on a brace, or within (c++)
za toggle current fold current level
zR, zM open, close all folds
zo, zc open, close current fold

1.1.6 Evil mode

C-z Toggle evil mode - conflicts with undo!

1.1.7 Make source block runnable inline

E.g. for shell:

(org-babel-do-load-languages
 'org-babel-load-languages '((sh . t)))

1.2 Org mode

NOTE: Stuff here works only in org-mode files

1.2.1 Issue "Wrong type argument: org-export-backend…"

Following occurs during export to html:

Wrong type argument: org-export-backend, [cl-struct-org-export-backend nil html ((footnote-reference . ignore) (link lambda (object c i) c) (radio-target lambda (object c i) c) (target . ignore)) nil nil nil nil]

Source

Solution: delete all .elc files in org package. Date postfix will differ

cd ~/.emacs.d/elpa/org-
cd org-20181008/ cd org-ac-20170401.1307/ cd org-ref-20181010.2343/
rm -r *.elc

1.2.2 essential keys

Keys Action Comment
C-c C-c Export commands  
C-c C-e Publish org file  
" " h h Publish to html  
C-c C-c p markdown preview bare display in browser

1.2.3 essential commands (images)

M-x org-display-inline-images show linked images
M-x org-remove-inline-images hide linked images

1.2.4 font modifiers

  • # Comment (start of line, one space)
  • bold
  • `*backticks override*`
  • italic
  • underlined
  • verbatim
  • code
  • strike-through
  • super^script
  • sub_script
  • Text with a new-style footnote 1

Source: see link under 'links'


Source

Note: ': ' prefix must me at start of line, space after

* This Is A Heading
 ** This Is A Sub-Heading
 *** And A Sub-Sub-Heading

horizontal rule (at least 5 dashes)
-----

 Paragraphs are separated by at least one empty line.

 *bold* /italic/ _underlined_ +strikethrough+ =monospaced=
 [[http://Karl-Voit.at][Link description]]
 http://Karl-Voit.at → link without description

 : Simple pre-formatted text such as for source code.
 : This also respects the line breaks. *bold* is not bold here.

 - list item
 - another item
   - sub-item
     1. also enumerated
     2. if you like
 - [ ] yet to be done
 - [X] item which is done   

1.2.6 Outline/todo keys

C-c C-t Cycle state todo->done->nothing  
M-<right/left> Lower/raise current outline item Select first!
M-S-<right/left> Lower/raise outline item + children First attempt usually fails, just redo
C-c C-e Export, opens help screen  
C-c C-x C-v Toggle inline images  

1.2.7 Disable warnings when running src blocks on export

(setq org-confirm-babel-evaluate nil)

1.2.8 The difference between `BEGIN_HTML` and `BEGIN_EXPORT html`

`BEGIN_HTML` uses the html raw in the page:

Welcome back to the 90's

`BEGIN_EXPORT html` formats the html so that the tags are visible:

<b>Welcome back to the 90's</b>

1.2.9 Using src blocks to generate html

This is the first attempt that actually worked:

WTF

Welcome back to the 90's!
poepkat, is this really going to work??

WTF

Welcome back to the 90's!
Little piggy, is this really going to work??

1.3 Blog

1.3.1 Jekyll server mode

For local network:

> cd ~/project/blog/jekyll-simple
> jekyll serve --host 192.168.1.16

In serve mode, changes in posts get picked up automatically.

1.3.2 Publish from org to jekyll

> C-c C-e P x wim

1.4 Daemon mode

  • Start in running emacs: `M-x server-start`
  • Login from other machine: `ssh -XYC olivia`
  • Start in graphics mode: `emacsclient -c` # -t for text mode

NOTE: When server started this way, main emacs (in server mode) hangs from time to time.

1.5 Install new package

Following assumes you're installing package 'evil'

M-x list-packages
C-s evil to find evil
i  - select for install
x  - execute install

1.6 Notes

1.6.1 Set encoding in file to utf-8,

on first line:

-*- coding: utf-8 -*-

… limited success with org-mode export

1.6.2 Specify org-mode within file

Tutorial said to put this at the top of an org-mode file:

MY PROJECT -*- mode: org -*-

However, emacs picks up org-mode up from the extension. Also, given line is interpreted as the document title on export to HTML.

1.7 Task Log

27-06-2016 Did David O'Toole org tutorial. 27-09-2016 Upgraded org mode using this HOWTO.

1.7.1 01-10-2016 Installed package 'capt-of'

> sudo zypper in texlive-capt-of

Due to error during pdf generation

1.9 Try

1.9.1 Test: run shell commands within org-mode document

uname -a

1.9.2 Try spreadsheet

Source - skipped using lisp functions

  • C-c ? for references
  • C-c } for inline ref's
  • C-c C-c on formula for recalc
  • C-u C-c * on table for full recalc
  • C-c = in cell; edit column formula in minibuffer
  • C-u C-c = in cell; edit column formula in minibuffer
  • functions used come from Calc. Doc, Function index.
  • := for field formula, = for column formula

Formula's

  • 'this row' is default
Student Maths Physics Mean
Bertrand 13 19 16
Henri 15 14 14.5
Arnold 17 13 15
Means 15 15.333333 15.166667

Footnotes:

1

New-style requires the fn:-prefix within the brackets. For this one, double empty line is required, otherwise following text is added to footnote as well.

Author: Wim Rijnders

Created: 2021-09-26 Sun 06:41

Validate