\maketitle
Scimax is an Emacs starterkit designed for people interested in reproducible research and publishing. Scimax is just Emacs that has been configured extensively to make it act like we need it to for research documentation and publication. The notes below document some features we have built into scimax.
Note: The org-mode version of this manual is the preferred version for reading; it is the most functional version, and the most up to date. The info:scimax version is also useful though, and you might prefer that one.
scimax provides a lot of customization of org-mode. Here are some of the more important ones.
scimax defines some shortcuts for org-mode markup. You can select text and type the shortcut to wrap the region in the markup, or if on a word, type the shortcut to wrap the word, or type the short cut to create the markup with the cursor inside it to keep typing.
Note these modifier keys:
S | shift |
M | alt/meta |
C | Ctrl |
s | super |
H | hyper |
Notation like s-b means press super and b together.
super and Hyper aren’t common on all keyboards, and using them is platform dependent. One good resource for configuring them is http://ergoemacs.org/emacs/emacs_hyper_super_keys.html.
For Mac, I use:
(setq mac-right-command-modifier 'hyper)
(setq mac-right-option-modifier 'super)
For Windows you can use:
(setq w32-pass-lwindow-to-system nil)
(setq w32-lwindow-modifier 'super) ; Left Windows key
(setq w32-pass-rwindow-to-system nil)
(setq w32-rwindow-modifier 'super) ; Right Windows key
(setq w32-pass-apps-to-system nil)
(setq w32-apps-modifier 'hyper) ; Menu/App key
It was suggested here that you can also make some seldom used keys like <pause>
and <scroll>
act like these extra modifiers. Here is a snippet that will do that.
(define-key function-key-map (kbd "<pause>") 'event-apply-super-modifier)
(define-key function-key-map (kbd "<scroll>") 'event-apply-hyper-modifier)
This does not work for all key combination with the Windows key because Windows intercepts some keys. The intercepted keys depend on the Windows version:
Key | Windows 7 | Windows 10 |
---|---|---|
A | + | w |
B | w | w |
C | ||
D | w | w |
E | w | w |
F | w | w |
G | + | w |
H | w | |
I | + | w |
J | + | |
K | + | w |
L | w | w |
M | w | w |
N | + | + |
O | + | |
P | w | w |
Q | + | w |
R | w | w |
S | + | w |
T | w | w |
U | w | w |
V | ||
W | + | w |
X | + | w |
Y | + | + |
Z | + | |
0 … 9 | w | w |
+ | w | w |
- | + | + |
_ | + | + |
. | + | |
, | + | |
# | + | |
* | + | + |
- +
- Key is available for Emacs
- w
- Key is intercepted by Windows
- empty
- No reaction from Emacs or Windows
The following keyboard shortcuts are defined:
markup | keyshortcut | emacs-command |
---|---|---|
Bold | s-b | `org-bold-region-or-point’ |
italics | s-i | `org-italics-region-or-point’ |
verbatim |
s-v | `org-verbatim-region-or-point’ |
code |
s-c | `org-code-region-or-point’ |
underline | s-u | `org-underline-region-or-point’ |
s-+ | `org-strikethrough-region-or-point’ | |
subscript | s– | `org-subscript-region-or-point’ |
superscript | s-= | `org-superscript-region-or-point’ |
\(equation\) | s-4 | `org-latex-math-region-or-point’ |
C-u s-4 | ||
@@latex:snippet@@ | C-u C-u 4 | |
° | s-e | `ivy-insert-org-entity’ |
“ | s-” | `org-double-quote-region-or-point’ |
‘ | s-’ | `org-single-quote-region-or-point’ |
These commands try to do what you mean:
- If your cursor is on a space, insert balanced markers with cursor between them
- If you have highlighted a region, add markers around it
- If you are on a word, add markers around the word, unless you are sub/superscripting, and then do that on the character at point
- If the cursor is right after the end of a markup, you can press the key again to slurp the next word into the markup.
Use `ivy-insert-org-entity’ (s-e) for all accented characters.
The following examples show some of the shortcuts defined in scimax for expansion. Put your cursor after the shortcut and press tab to expand them. These are done with yasnippets (defined in ./snippets/).
<jp <ip <p <el <sh ti #+title: ok org-keywords with completions #+ARCHIVE: lh #+latex_header: lhp latex header with completion on usepackage #+latex_header: \usepackage{12many} lc #+latex_class: lco #+latex_class_options: ao #+attr_org: :width 300 al #+attr_latex: :placement [H] :width 300 ca #+caption: ncf #+name: ${1:name} #+caption: ${2:caption} [[${3:}]] $0 #+name: name #+caption: caption [[...]] nct #+name: name #+caption: caption | | n #+name: o #+options: oo (org-mode options with completion, use in an #+options line) toc: nw noweb with completion <<nil>> Here are some convenient table expansions. t | | tt | | | ttt | | | | tttt | | | | | tn (enter number of columns) | | | | | | | | |
There are some specific snippets to
- emacs-lisp ./snippets/emacs-lisp-mode/
- python ./snippets/python-mode/
and in org-mode:
- ./snippets/org-mode/
- ./snippets/org-mode/org-ref/ (bibliography, biliographystyle, cites and ref links)
- ./snippets/org-mode/src-blocks/ (src blocks)
- ./snippets/org-mode/blocks/ (quotes, verses, etc.)
For numbered LaTeX equations, scimax will make sure that the overlays have correct numbers on them. If you run `org-latex-preview’ you should see (1) and (2) on these overlays.
\begin{equation} f(x) = e^x \end{equation}
\begin{equation} f(x) = 2 e^x \end{equation}
Here is a list of installed latex classes.
(mapcar 'car org-latex-classes)
cmu-memo | gMOS2e | nature | elsarticle | svjour3 | revtex4-1 | achemso | article-nodefaults | article-no-defaults | article-1 | article | report | book |
Image rescaling in org-mode/Emacs used to require an Emacs with imagemagick support compiled in. This is a problem on Windows. Scimax support image rescaling with an external imagemagick program called mogrify. You can rescale the appearance of an image in org-mode by adding an attribute like this above the figure.
where resize-option is one of:
N% | to scale the image by a percentage. |
N | to set the width, keeping the aspect ratio constant. |
xN | to set the height, keeping the aspect ratio constant. |
NxM! | to set the width and height, ignoring the aspect ratio. |
Note that you have to have a line like this in your init file for this to work. This is the default in scimax, and if you set it to t, then scaling will not work (since this variable when set to t says to use the actual image width).
(setq org-image-actual-width nil)
Here are some examples.
scimax defines these new speed commands that are active when the cursor is on the first character of a headline.
m | Mark the subtree |
S | widen |
k | kill the subtree |
q | jump to a headline with avy |
T | org-teleport (move headline) |
The best way to see other speed commands is to put your cursor at the beginning of a headline and press ?. You can also run `org-speed-command-help’ to see a full list of speed commands.
`ox-clip-formatted-copy’ provides a way to copy org-mode with formatting so it can be pasted into other programs like MS Word and web browsers. It does this by copying the selected text to the HTML clipboard.
scimax provides a lot of features on top of org-mode to work with src blocks. The usual stuff should work fine, e.g. C-c C-c to run a block.
`scimax-ob-src-keymap-mode’ adds minor mode keymaps to your src blocks. See `scimax-ob-src-block-keymaps’ for a way to add your own custom maps.
- C-<return> is an alternative to C-c C-c to run a block
- S-<return> will run a block and move to the next block or create one if needed
- M-<return> will run a block and insert a new block after it
- M-S-<return> runs all the blocks to the current point
See `scimax-ob-insert-src-block’.
See `scimax-ob-split-src-block’ which splits a block at the point with cursor in the upper block. Use a prefix arg to put cursor in the lower block.
- `scimax-ob-jump-to-visible-block’
- use avy to jump to a visible block.
- `scimax-ob-jump-to-block’
- use ivy to jump to a block in the buffer
- `scimax-ob-jump-to-inline-src’
- use ivy to jump to an inline src
- `scimax-ob-jump-to-header’
- move cursor to the header
- `scimax-ob-jump-to-end’
- jump to the end
You can clone, copy, kill and merge blocks now.
`scimax-ob-clone-block’ `scimax-ob-copy-block-and-results’ `scimax-ob-kill-block-and-results’ `scimax-ob-merge-blocks’
It is also possible to move blocks up and down.
`scimax-ob-move-src-block-up’ `scimax-ob-move-src-block-down’
`scimax-ob-edit-header’ `scimax-ob-avy-jump-to-header’ `scimax-ob-replace-header-item-with-completion’
- `scimax-ob-toggle-line-numbers’
- show line numbers in a block
`scimax-ob-clear-all-results’
It is hard to remember all those commands and/or keybindings. Use this convenient hydra instead!
This should be bound to something convenient `scimax-ob/body’.
scimax is configured with flyspell and flycheck on. When you misspell a word it will be underlined in red, and you will see a message in the minibuffer that tells you how to fix it (C-;). Type that, and you will be able to fix the word spelling without losing your place! Not only that, but the correction will be saved as an abbreviation so it will auto correct every time you make the mistake again! Note this only works for single word corrections (i.e. the correction cannot be a two word correction).
If the word is correct, you can type M-o s to save the word in your dictionary so you will not see it as misspelled again.
Note: you need to have hunspell installed for this to work. On Windows, this should get installed into the scimax root directory in the emacs-win directory. For Mac and Linux, you need to install it using your package manager.
Scimax will auto-format several things for you.
- Ordinal numbers, e.g. 1st to 1st.
- Fractions: 1/4 to ¼
- Some superscripts, e.g. cm2 to cm2
- Transposed cAps, e.g. tHe to The
These are controlled by the following variables you can customize (they default to t):
- `scimax-autoformat-ordinals’
- `scimax-autoformat-fractions’
- `scimax-autoformat-sentence-capitalization’
- `scimax-autoformat-superscripts’
- `scimax-autoformat-transposed-caps’
To get the autoformatting you have to enable `scimax-autoformat-mode’. If you want it on all the time, add something like this to your init files:
(add-hook 'org-mode-hook 'scimax-autoformat-mode)
scimax also defines some abbreviations that you can toggle on and off. The abbreviations are defined in these variables:
- Auto-capitalization of weekdays and months, e.g. Monday and June.
- `scimax-month-abbreviations’
- `scimax-weekday-abbreviations’
- Contraction expansion: cant to can not and can’t to can not
- `scimax-contraction-abbreviations’
- Commonly transposed letters in words: the to the
- `scimax-transposition-abbreviations’
- Some common chemicals like co2 to CO2
- `scimax-chemical-formula-abbreviations’
- Some convenience symbols like degC to °C and Ang to Å, and some names like norskov to Nørskov.
- `scimax-misc-abbreviations’
You should be able to undo any expansion with C-/. Alternatively you can prevent the expansion by typing C-q after the abbreviation before the next character is typed.
These are not on by default. You have to enable them with commands like the one below in your init file. Use +1 to enable the abbrevs, and -1 to disable the abbrevs that are defined in the variable.
(scimax-toggle-abbrevs 'scimax-month-abbreviations +1)
`scimax-toggle-abbrevs’ is an interactive command you can use to toggle the abbreviations on and off. If you run that command it will toggle the state of the abbrevs. With a single prefix arg it will turn them on, and with a double prefix arg turn them off.
You can see the abbreviations defined with this command elisp:edit-abbrevs.
Scimax provides some support for track changes and edit marks in org-mode through the new ./scimax-editmarks.org project.
{>+Add this text.+<}{>-Delete this-<} {>~ @jk Here is a comment~<}
This is a {>$tpyo$<}
There are persistent highlights also.
{g>Green highlight<g} {b>blue highlight<b} {y>yellow<y} {p>pink<p}
There is a hydra menu bound to H-m that provides access to easily insert these markups.
There is limited support to convert these editmarks to LaTeX and html, and to generate these editmarks from git diffs or diffs with the copy on disk.
There is also an experimental feature for track-change mode.
Note: This library replaces several older attempts at this which are no longer maintained by me (you can find them still in ./deprecated/.
- ov-highlight
- org-editmarks.el
- cm-mods.el
org-ref is the answer to citations and bibliographies in scientific writing. Run `org-ref-help’ and read it.
The key-binding C-c C-e j should enter the ox-manuscript export menu. This process differs from the regular export process in a number of ways. It will detect if bibtex, makeindex, or makeglossary, and if minted is used, -shell-escape will automatically be used with pdflatex. The function `ox-manuscript-latex-pdf-process’ handles all of that.
Additionally, you can generate different outputs of an org-file:
- `ox-manuscript-build-submission-manuscript-and-open’
- creates a standalone tex file with embedded bibliography, and image extensions stripped, and the pdf file.
- `ox-manuscript-make-submission-archive’
- creates a directory containing all the files you normally need for submission.
- `ox-manuscript-toggle-interactive-build’
- if you are having trouble building a PDF, this will show you what happens at each step.
- `ox-manuscript-nobibliography’
- `ox-manuscript-texcount’
- Estimate how many words are in your manuscript. For when you are limited to a fixed number of words.
We have templates prepared for the following manuscripts, proposals and documents.
(mapcar (lambda (x) (list (plist-get x :template))) (ox-manuscript-candidates))
ACS Applied Materials and Interfaces |
ACS Catalysis |
ACS -Industrial & Engineering Chemistry Research |
ACS - Journal of Physical Chemistry C |
ACS J. Physical Chemistry Letters |
AIP - J. Chemical Physics |
Annual student review |
Physical Review B |
Physical Review Letters |
CMU ChemE Written Proposal |
CMU ChemE Written Qualifier |
CMU ChemE Written Qualifier |
Int. J. Greenhouse Gas Control - Elsevier |
Cover letter for manuscript submission |
Nature |
NSF Proposal - Biographical sketch |
NSF Proposal - Checklist |
NSF Proposal - Current and pending |
NSF Proposal - data management plan |
NSF Proposal - Facilities, Equipment, and other Resources |
NSF Proposal - postdoctoral mentoring plan |
NSF Proposal - Project description |
NSF Proposal - Project summary |
NSF Proposal - Statement of work |
Response to reviewers |
Surface Science - Elsevier |
Taylor & Francis Molecular Simulation |
Weekly progress report |
Wiley - Int. J. Quantum Chemistry |
- `ox-manuscript-new-ivy’
Bibliographies in scimax are stored in bibtex files. A bibtex file is a plain text file containing bibtex entries. Each entry describes an item. Here is a typical example.
@article{kitchin-2015-examp,f author = {Kitchin, John R.}, title = {Examples of Effective Data Sharing in Scientific Publishing}, journal = {ACS Catalysis}, volume = {5}, number = {6}, pages = {3894-3899}, year = 2015, doi = {10.1021/acscatal.5b00538}, url = { http://dx.doi.org/10.1021/acscatal.5b00538 }, keywords = {DESC0004031, early-career, orgmode, Data sharing }, eprint = { http://dx.doi.org/10.1021/acscatal.5b00538 }, }
This entry identifies the item as an article, labels it with a key (kitchin-2015-examp), and describes the details of the item in a series of key = {value} lines. You can learn more about bibtex here http://www.bibtex.org.
If you know the DOI I recommend you use `doi-add-bibtex-entry’ as much as possible to add bibtex entries to your bibliography files. This will add properly formatted and cleaned entries and download the pdf if it knows how. You may also find `crossref-add-bibtex-entry’ useful if you have a freeform citation and want to search for it.
In a bibtex file, `org-ref-bibtex-hydra/body’ will give you a menu of options to do things on an entry including:
- Search pubmed, WebOfScience (wos), wos-citing, wos-related, crossref, and google scholar using the DOI or title of the entry.
- Clean the entry, replace non-ascii characters, sort the entry fields, or change the case of the title.
- Update the entry or fields using the doi.
- Open the notes, pdf, or url associated with the entry.
- Email the entry to someone
- Copy or cut the entry to paste somewhere
- Copy a formatted bibliography entry
- Add tags to an entry
- Add a new entry
`org-ref-bibtex-file/body’ provides menu access to bibtex file functions:
- `bibtex-validate’ - Checks if the file is syntactically valid, and for duplicate keys.
- `bibtex-sort-buffer’
- `bibtex-reformat’
- `bibtex-count-entries’
- `org-ref-build-full-bibliography’
See `org-ref-help’ for information on using org-ref to insert citations.
Here are the bibtex entry types and fields you should use. You can add extra fields like keywords, doi, url, notes, etc… to each entry. Usually they will be ignored by bibtex, but they are useful for you. Note that biblatex is considered a more powerful bibliography formatting tool, but we use bibtex because that is what most of the publishers we use support.
(loop for (type doc required crossref optional) in bibtex-BibTeX-entry-alist
do
(princ (format "\n*** %s (%s)\n" type doc))
(princ "\n**** Required fields\n\n")
(loop for field in required
do
(princ (format "- %s" (car field)))
(message "%s" field)
(if (>= (length field) 2)
(princ (format " :: %s\n" (nth 1 field)))
(princ "\n")))
(princ "\n**** Optional if Crossref present but otherwise required fields\n\n")
(loop for field in crossref
do
(princ (format "- %s" (car field)))
(if (>= (length field) 2)
(princ (format " :: %s\n" (nth 1 field)))
(princ "\n")))
(princ "\n**** Optional fields\n\n")
(loop for field in optional
do
(princ (format "- %s" (car field)))
(if (>= (length field) 2)
(princ (format " :: %s\n" (nth 1 field)))
(princ "\n"))))
- author
- title
- Title of the article (BibTeX converts it to lowercase)
- journal
- year
- volume
- Volume of the journal
- number
- Number of the journal (only allowed if entry contains volume)
- pages
- Pages in the journal
- month
- note
- author
- title
- Title of the article in proceedings (BibTeX converts it to lowercase)
- booktitle
- Name of the conference proceedings
- year
- editor
- volume
- Volume of the conference proceedings in the series
- number
- Number of the conference proceedings in a small series (overwritten by volume)
- series
- Series in which the conference proceedings appeared
- pages
- Pages in the conference proceedings
- month
- address
- organization
- Sponsoring organization of the conference
- publisher
- Publishing company, its location
- note
- author
- title
- Title of the article in book (BibTeX converts it to lowercase)
- booktitle
- Name of the book
- publisher
- year
- editor
- volume
- Volume of the book in the series
- number
- Number of the book in a small series (overwritten by volume)
- series
- Series in which the book appeared
- type
- Word to use instead of “chapter”
- chapter
- Chapter in the book
- pages
- Pages in the book
- edition
- Edition of the book as a capitalized English word
- month
- address
- note
- author
- nil
- editor
- nil
- title
- Title of the book
- chapter
- Chapter in the book
- publisher
- year
- volume
- Volume of the book in the series
- number
- Number of the book in a small series (overwritten by volume)
- series
- Series in which the book appeared
- type
- Word to use instead of “chapter”
- address
- edition
- Edition of the book as a capitalized English word
- month
- pages
- Pages in the book
- note
- title
- Title of the conference proceedings
- year
- booktitle
- Title of the proceedings for cross references
- editor
- volume
- Volume of the conference proceedings in the series
- number
- Number of the conference proceedings in a small series (overwritten by volume)
- series
- Series in which the conference proceedings appeared
- address
- month
- organization
- Sponsoring organization of the conference
- publisher
- Publishing company, its location
- note
- author
- nil
- editor
- nil
- title
- Title of the book
- publisher
- year
- volume
- Volume of the book in the series
- number
- Number of the book in a small series (overwritten by volume)
- series
- Series in which the book appeared
- address
- edition
- Edition of the book as a capitalized English word
- month
- note
- title
- Title of the booklet (BibTeX converts it to lowercase)
- author
- howpublished
- The way in which the booklet was published
- address
- month
- year
- note
- author
- title
- Title of the PhD. thesis
- school
- School where the PhD. thesis was written
- year
- type
- Type of the PhD. thesis
- address
- Address of the school (if not part of field “school”) or country
- month
- note
- author
- title
- Title of the master’s thesis (BibTeX converts it to lowercase)
- school
- School where the master’s thesis was written
- year
- type
- Type of the master’s thesis (if other than “Master’s thesis”)
- address
- Address of the school (if not part of field “school”) or country
- month
- note
- author
- title
- Title of the technical report (BibTeX converts it to lowercase)
- institution
- Sponsoring institution of the report
- year
- type
- Type of the report (if other than “technical report”)
- number
- Number of the technical report
- address
- month
- note
- title
- Title of the manual
- author
- organization
- Publishing organization of the manual
- address
- edition
- Edition of the manual as a capitalized English word
- month
- year
- note
- author
- title
- Title of the unpublished work (BibTeX converts it to lowercase)
- note
- month
- year
- author
- title
- Title of the work (BibTeX converts it to lowercase)
- howpublished
- The way in which the work was published
- month
- year
- note
Scimax provides hotkeys for when your cursor is on the @ at the beginning of an entry. Here are the currently defined hotkeys.
(require 'bibtex-hotkeys)
(cl-loop for (key . desc) in bibtex-hotkeys collect (list key desc))
y | Paste last entry |
U | Update entry |
w | Move entry down |
T | Title-case article |
S | Sentence-case title |
s | Move entry up |
q | Jump to field with avy |
? | Show hotkeys |
p | Jump to previous entry |
n | Jump to next entry |
I | Inspect |
l | Clean entry |
k | Kill the entry |
f | Copy formatted |
e | Email entry |
c | Copy entry |
b | Open in browser |
- `email-buffer’
- email the whole buffer
- `email-region’
- emails selected region
- `email-heading’
- email the current heading, including properties, deadlines, etc…
- `email-heading-body’
- email just the body of the current heading
- `email-bibtex-entry’
- email the bibtex entry at point
You can send html email from org-mode.
From an org-file run `org-mime’. You will be prompted for the scope to send, which is either the whole buffer, the heading you are in, or the selected region. Then you will select how to make the email: html will export the text to html and put it in an email, and htmlize will use the htmlize library to generate the html.
Alternatively, you may want to type org-mode directly in an email buffer. Use `org-mime-compose-mail’ to do that.
scimax provides some tools to do a mail merge in org-mode. The idea is to run `mail-merge-make-headings’ with a template and data-source to generate a series of org-mode headings that are the messages. You can inspect these, edit them if needed, and then run `mail-merge’ to actually send them. Each heading will be tagged as sent, and marked DONE.
scimax defines its own contact management in org-mode. It is compatible with org-contacts, in the sense that it defines a contact as a headline with an :EMAIL: property. It also defines a contact link that integrates with `org-db’.
The principle idea is that `org-db’ has all your contact information in it, where you put it. The contacts can be distributed. You use the command `scimax-contacts’ to search them, and choose what to do with the one you select. The default action is to insert “name” <email> at point. You can also do these actions:
- open the contact heading
- insert a contact link
- assign the contact to a heading task
- Email a contact
you can mark multiple entries with C-spc, and some commands support acting on the marked entries. Type C-s to see which candidates are marked. Press Enter to select an action on the marked candidates.
You can insert functional contact links. They use an email as the path, although you can also use an org-id for backward compatibility.
Here is an example contact link: Kitchin, John Robert
If you click on a link you get a menu of options. On opening, if there is only one heading with that email it will open. If there are many candidates you will be prompted to choose which one to open.
You can also enter a contact link with completion, e.g. type C-x C-l and select contact.
We also define several org heading speed commands for contacts.
(cl-loop for (key . cmd) in scimax-contacts-speed-commands
collect (list key (documentation cmd)))
b | If contact has a URL open it in a browser. |
c | Copy the email address to the clipboard. |
e | Send an email to the contact. |
l | Store and copy a link to the contact. |
m | Copy “name<email>” |
? | Print contacts speed key help. |
It can be tedious to enter contacts by hand. You can use `scimax-message-get-emails’ to extract contacts into a user file defined in `scimax-message-org-contacts-file’.
If you have mu4e installed, the capture function will automatically capture emails when you reply to them. Also in a message you can type C-c-] to insert a contact.
google-this is installed in scimax. You can use these commands to search for things from Emacs:
C-c / SPC `google-this-region’ C-c / a `google-this-ray’ C-c / c `google-this-translate-query-or-region’ C-c / e `google-this-error’ C-c / f `google-this-forecast’ C-c / g `google-this-lucky-search’ C-c / i `google-this-lucky-and-insert-url’ C-c / l `google-this-line’ C-c / m `google-maps’ C-c / n `google-this-noconfirm’ C-c / r `google-this-cpp-reference’ C-c / s `google-this-symbol’ C-c / t `google-this’ C-c / w `google-this-word’ C-c / <return> `google-this-search’
Magit is a front-end for git version control. There is a good manual here: info:magit#Top
info:magit#Repository setup You can create a git repo with M-x magit-init. This will create a git-repo in the current directory.
(magit-init)
help:magit-init
info:magit#Repository setup
M-x magit-clone
This will prompt you for a repo, which is either a url, or a path, and a path to clone it to.
help:magit-clone
info:magit#Status buffer
Run M-x magit-status to see the status of your repo.
Press “g” in the window to refresh it.
press “n” (next) or “p” (previous) to navigate in this window.
help:magit-status
info:magit#Staging and unstaging
In the magit-status window, put your cursor on an unstaged file and press “s”.
If you press TAB on the file, it will expand to show the changes that are unstaged. Deletions show in red, and additions in green. The changes are in “hunks”.
You can unstage a file with “u”
info:magit#Initiating a commit
info:magit#Editing commit messages
In the magit-status window with some files that are staged, press “c”, review the options, and probably press “c” again. Enter a commit message and type “C-c C-c” to commit it, or “C-c C-k” to cancel it.
info:magit#Diffing
From the magit-status window, press “d” then “d” to see what has changed.
info:magit#Logging
In the magit-status window press “l”, review the options, and press “l” again.
If you want to see only the commits that affected a file, in the magit-status window press “l” then “=f”, enter the filename, and then press “l” again.
info:magit#Pushing
In the magit-status window press “P” then “p”.
Note that tags don’t normally get pushed, but there are options (“T” to push a tag, and “t” to push all tags).
info:magit#Pulling In the magit-status window press “F” then “p”.
info:magit#Running Git manually In the magit-status window, type “!” to get the popup and choose what you want to do (e.g. where to run the command, etc… You do not need to type “git” in the command. Note you can also run a shell command from this interface.
Press “$”
info:magit#Keystroke Index
Use M-x magit-checkout-file select the branch, or enter a revision, and then choose a file.
help:magit-checkout-file
help:magit-find-file help:magit-find-file-other-window
In a magit-status window press “l =g” enter a pattern to grep for, and then press “l”.
info:magit#Reverting
Got to the log, select the commit and type “V” then “V”.
info:magit#Tagging
press “t” in the magit-status window. You can then create a tag, annotate it, delete tags, and prune them.
info:magit#The branch popup
In the magit-status window press “b” then “b” and choose the branch.
To checkout a new branch, in the magit-status window press “b” then “c”. Choose the branch to start from then a name for the new branch.
info:magit#Merging
In the magit-status window press “m”, then “m” and select the branch to merge into the current one.
info:magit#Resolving conflicts
You will probably also want to get familiar with info:ediff#Top.
On a file in a magit-status window, press “e” to enter the 3-window ediff view. The A window is the version at HEAD, the B window is what is in the index, and the C window is the current version.
info:magit#Fetching
In the magit-status window press “f”.
info:magit#Remotes
M-x magit-remote-add then enter an alias, and the url.
info:magit#Stashing
Press “z” in the magit-status window
In an open file run M-x git-blame
, then press b to see commits that add lines. You press q to exit the blame mode.
info:magit#Resetting
info:magit#Rebasing
Open the log, select the oldest commit you want to rebase on then press “r” and then “i”. Use M-p and M-n to move commits around. Press “s” on any commits you want to squash into the commit above it. C-c C-c will start the commands.
From the magit-status on unpushed commits, you can also press “r” to get the rebase popup.
“r w” allows you to reword the commit message.
info:magit#Creating and sending patches
In magit-status window, press “W”
“W p” creates patches “W r” makes a pull request. This just creates an email with information in it. It is not a GitHUB request, and it is only useful if there is a public, external copy of the repo.
info:magit#Cherry picking
Press “A”
info:magit#Applying patches
info:magit#Notes
Press “T” to attach a note.
A typical use of notes is to supplement a commit message without changing the commit itself. Notes can be shown by git log along with the original commit message. To distinguish these notes from the message stored in the commit object, the notes are indented like the message, after an unindented line saying “Notes (<refname>):” (or “Notes:” for refs/notes/commits).
info:magit#Cherry picking
https://github.com/bbatsov/projectile for project management. A project is basically a directory under version control, e.g. git.
Projectile makes it easy to jump to projects, find files in projects, search projects, etc…
Scimax uses `counsel-projectile’ integration as much as possible.
keybinding | action |
---|---|
C-c p p | Switch to a project |
C-c p n | Switch project by name |
C-c p b | Switch to project buffer |
C-c p k | Kill project buffers |
C-c p f | Switch to project file |
C-c p d | Switch to project dir |
C-c p a | Search project with ag |
C-c p g | Search project with grep |
C-c p r | Search project with ripgrep |
You can see all the key bindings with C-c p C-h.
While in a project, you may want to try:
`counsel-git-grep’ to search all project files for a phrase.
scimax no longer supports ob-ipython. The old scimax enhancements are now in ./deprecated/. You should be able to use whatever org-mode provides. We have transitioned to emacs-jupyter now.
See ./scimax-jupyter.org for things you can do with emacs-jupyter in scimax.
- `lispy-mode’ is just amazing.
- `scimax-org-eldoc’ will generate documentation on elisp libraries in an org-mode format. It is a library you have to require.
It is a major challenge to keep up with the scientific literature. `elfeed’ is the package we use in scimax for that. It aggregates RSS feeds and provides a pretty easy way to consume them, capture them in to org-mode, search them, and do things with them. scimax preconfigures elfeed with some python, and emacs feeds, and you can easily add new feeds:
The scimax customizations of elfeed are not loaded by default. If you want them, you have to add this to your init files.:
(require 'scimax-elfeed)
(add-to-list 'elfeed-feeds "http://feeds.feedburner.com/acs/accacs")
or if you want entries from a feed to be automatically tagged, e.g. anything from Nature magazine could be tagged with nature:
(add-to-list 'elfeed-feeds '("http://feeds.nature.com/nchem/rss/current" nature))
Elfeed is configured to run every half hour after Emacs is started.
On an entry you can type:
e | email entry to someone |
c | capture the entry to org-mode |
d | add bibtex entry |
In the list of entries you can type:
f,j | marks entry as read |
o | open the entry |
b | open browser to entry url |
s | start a search query (see https://github.com/skeeto/elfeed#filter-syntax) |
`bash’ will open an external bash terminal in the current working directory.
`explorer’ and `finder’ will open a Windows Explorer or Mac Finder window in the current working directory.
Try out `words-hydra/body’ on a selection or word. I bound it to \[words-hydra/body].
This command: `ore’ tells you about the org-element your point is on. It gives some hints on commands you can use on the element, and provides a way for you to write your own notes.
This is a simple library to make simple presentations in org-mode. See `org-show-help’ for an example use.
These are external packages that are included in scimax and might be useful for you.
avy lets you jump to things in Emacs. See https://github.com/abo-abo/avy
There are a lot of avy commands. Click this to see them: elisp:(apropos-command “^avy”)
We use a lot of them in Navigation - navy.
This is for completing stuff. See http://oremacs.com/2015/04/09/counsel-completion/
In particular, scimax sets these keybindings:
(“M-x” . counsel-M-x) (“C-x b” . ivy-switch-buffer) (“C-x C-f” . counsel-find-file) (“C-h f” . counsel-describe-function) (“C-h v” . counsel-describe-variable) (“C-h i” . counsel-info-lookup-symbol) (“H-c r” . ivy-resume) (“H-c l” . counsel-load-library) (“H-c g” . counsel-git-grep) (“H-c a” . counsel-ag) (“H-c p” . counsel-pt)
This is a powerful search tool in Emacs. See https://github.com/abo-abo/swiper
C-s is bound to `counsel-grep-or-swiper’ for searching. Try H-s to run `swiper-all’.
There are a few undo features:
C-/ | undo the last action |
C-x u | use the undo-tree (q to quit) |
C-? | redo |
scimax provides a scientific notebook capability. Each “notebook” is actually collection of org-files in a “project”. A project is the set of files in a directory that is under git version control. Each project should have a master file (the default is README.org, but you can customize `nb-master-file’ to change this). The master file contains what ever you want, but typically it links to other documents in the project and provides an overview of the project.
You are basically free to structure the notebook however you want. You have all the freedom of org-mode at your fingers to document your work.
We leverage projectile for project management in the notebook. We use magit for version control.
Use `nb-new’ to create a new project. You will be prompted for a name, which must be a valid directory name. The directory will be created in `nb-notebook-directory’. Note that all git repos will be considered projects, so it is not necessary to use `nb-new’ to make a new notebook. It just automates a few things for you.
Use `nb-open’ to open a project. This will open the project to your master file. Previously visited projects are remembered by projectile and should be shown in an ivy completion minibuffer for selection.
Probably you will keep your projects separate from your agenda files, but you still would like to see what tasks the project has? Use `nb-agenda’ while in your project, and it will show you all the tasks in the org-files associated with the project.
Here are some other interesting commands you may want to use.
- `counsel-git-grep’
- grep for a string in the project
- `projectile-find-file’
- jump to a file in the project
- `projectile-switch-to-buffer’
- switch to a project buffer
- `projectile-kill-buffers’
- kill all the buffers associated with the project
These commands help you navigate to a headline at different scopes (e.g. file, directory or project).
- `ivy-org-jump-to-heading’
- in the current file
- `ivy-org-jump-to-heading-in-directory’
- in the current directory
- `ivy-org-jump-to-project-headline’
- in the project
- `counsel-org-tag’
- add/remove tags on a headline
You can manage the version control with Magit. There are also keyboard shortcuts for version control. Type C-x v C-h to see them.
- `vc-next-action’ will do the next logical thing for vc, e.g. add or commit.
- `vc-diff’ will show you what has changed in the buffer since the last commit.
- `vc-print-log’ will show you the vc log.
scimax defines these additional key bindings:
C-x v p | git push |
C-x v P | git pull |
Sometimes you may want a zip file of your notebook. You can use the `nb-archive’ command to create a zip file of the current state of your notebook. This can be useful to back up versions of your project, send copies to collaborators who don’t use git, or to create archives for data sharing and supporting information.
Note that only files under version control are archived, and only the current committed state is archived. So, uncommitted files and changes will not be included.
scimax currently uses ivy extensively for completion, and enables `ivy-mode’ and `counsel-mode’. The default matching behavior is `ivy–regex-ignore-order’.
When you get an ivy minibuffer, start typing to select what you want, and when it is highlighted, press enter.
There are a couple of nuances though.
- To eliminate matches use ! pattern, but you can only use one of these, and it comes last.
I have extended the `ivy-minibuffer-map’ to enable the following:
- M-spc will show the actions, and spc to resume the selection process.
- C-RET to perform the action and move to the next candidate, and C-u C-RET to perform the action and move to the previous candidate.
- M-RET will perform the default action on every candidate from the current selection to the end of the candidates. C-u M-RET does that from the current candidate to the beginning.
- s-RET quits the selection buffer with no action.
- ? shows you the keymap.
In the ivy selection buffer you can use these commands:
keybinding | action |
---|---|
M-spc | Show the actions |
spc | resume |
RET | Default action and exit |
C-RET | Default action and move to next line |
C-u C-RET | Default action and move to previous line |
M-RET | Default action on each candidate from current to end |
C-u M-RET | Default action on each candidate from current to beginning |
C-u C-u M-RET | Default action on all candidates |
s-RET | quit with no action |
? | show keymap help |
I use Hyper-c as a prefix map for these commands.
keybinding | action |
---|---|
H-c r | `ivy-resume’ |
H-c l | `counsel-load-library’ |
H-c a | `counsel-ag’ |
Here are some additional actions we define for `counsel-find-file’.
keybinding | action |
---|---|
a | attach to email |
c | copy relative path |
4 | Open in new window |
5/f | Open in new frame |
C | Copy absolute path |
d | open in dired |
D | Delete file |
e | open in external app |
p | insert relative path |
P | insert absolute path |
l | relative org link |
L | absolute org link |
r | rename file |
b | open in bash |
F | open in Finder |
Scimax uses a central hydra to launch a key-driven menu of commonly used commands.
(describe-function 'scimax/body)
scimax/body is an interactive autoloaded Lisp closure in `scimax-hydra.el'. It is bound to <f12>. (scimax/body) For more information check the manuals. Call the body in the "scimax" hydra. The heads for the associated hydra are: "a": ‘(scimax-open-hydra scimax-applications/body)’, "b": ‘(scimax-open-hydra scimax-buffers/body)’, "e": ‘(scimax-open-hydra scimax-errors/body)’, "f": ‘(scimax-open-hydra scimax-files/body)’, "g": ‘(scimax-open-hydra scimax-google/body)’, "h": ‘(scimax-open-hydra scimax-help/body)’, "i": ‘(scimax-open-hydra scimax-insert/body)’, "j": ‘(scimax-open-hydra scimax-jump/body)’, "k": ‘(scimax-open-hydra scimax-bookmarks/body)’, "l": ‘(scimax-open-hydra scimax-lisp/body)’, "m": ‘(scimax-open-hydra scimax-minor-modes/body)’, "M": ‘(scimax-open-hydra scimax-smerge/body)’, "s-m": ‘scimax-dispatch-mode-hydra’, "n": ‘(scimax-open-hydra scimax-navigation/body)’, "o": ‘(scimax-open-hydra scimax-org/body)’, "p": ‘(scimax-open-hydra hydra-projectile/body)’, "r": ‘(scimax-open-hydra scimax-registers/body)’, "s": ‘(scimax-open-hydra scimax-search/body)’, "t": ‘(scimax-open-hydra scimax-text/body)’, "v": ‘(scimax-open-hydra scimax-version-control/body)’, "w": ‘(scimax-open-hydra scimax-windows/body)’, "z": ‘(scimax-open-hydra scimax-customize/body)’, ",": ‘scimax-hydra-pop’, "x": ‘counsel-M-x’, "C-s": ‘save-buffer’, "/": ‘undo-tree-undo’, "\": ‘undo-tree-redo’, "8": ‘(switch-to-buffer "*scratch*")’, "?": ‘scimax-hydra-help’, ".": ‘scimax-dispatch-mode-hydra’, "u": ‘(hydra--universal-argument current-prefix-arg)’, "q": ‘nil’ The body can be accessed via ‘scimax/body’.
So, instead of C-x C-f to open a file (which still works by the way) you can simply type: f12 ff. Or instead of C-x C-s to save the file, type f12 RET. Each hydra will show you a hint in the minibuffer on which keys do what.
Search is a complicated thing because you often have to balance speed, completeness and accuracy. For example, for completeness you would search your whole hard drive, but that would be slow. Scimax offers several ways to search with different scopes.
You also have to consider what to do with the results you find. This is somewhat related to navigation, with the subtle difference being you use a search criteria before you jump to that location.
You are not likely to remember all these. You can access a lot of them from `scimax-search/body’.
Use `counsel-grep-or-swiper’ to search the current buffer. You start typing the pattern you are looking for, and when you see it, press enter to jump to that position.
Use `swiper-all’ to search all open buffers. You start typing the pattern you are looking for, and when you see it, press enter to jump to that position.
These functions provide ivy search interfaces to find headings in org-files with different scopes.
- `ivy-org-jump-to-heading’
- Jump to heading in the current buffer
- `ivy-org-jump-to-heading-in-directory’
- Search headings of org-files in current directory
- `ivy-org-jump-to-recent-headline’
- Jump to org heading in recently opened files
- `ivy-org-jump-to-agenda-heading’
- Jump to a heading in your agenda files
- `ivy-org-jump-to-project-headline’
- Jump to a heading in your current project
We use a variety of tools to search files for a pattern. These are full text searches of files
- `ag’
- Use ag to search
- `lgrep’
- Search for pattern in matching files in dir
- `rgrep’
- Recursive search for pattern in matching files in dir
- `counsel-git-grep’
- search for a string in the current git repo
- `counsel-pt’
- Search current directory using pt
- `counsel-ag’
- Search current directory using ag
- `counsel-rg’
- Search current directory using ripgrep
- `counsel-projectile-pt’
- Search current project using pt
- `counsel-projectile-ag’
- Search current project using ag
- `counsel-projectile-rg’
- Search current project using ripgrep
- `projectile-grep’
- Run rgrep in a project
- `projectile-ripgrep’
- Run ripgrep in a project
- `projectile-ag’
- Run ag in a project
scimax-notebook
provides some additional search tools. It is not super clear these are better than the options above.
- `nb-search’
- like grep, search for pattern in files matching a pattern
- `nb-search-all’
- search all notebook files
- `nb-search-title’
- Search org-files by title, author, date or filename
`scimax-journal’ provides some ways to limit the search of journal entries by date. There are `swiper’ commands. These will open the journal entries and use swiper to search them. The implied range here is the last week, month or year from today.
- `scimax-journal-swiper-range’
- `scimax-journal-swiper-last-week’
- `scimax-journal-swiper-last-month’
- `scimax-journal-swiper-last-year’
There are also grep based commands
- `scimax-journal-grep’
- `scimax-journal-find-regexp-last-week’
- `scimax-journal-find-regexp-last-month’
- `scimax-journal-find-regexp-last-year’
`org-db’ is an org-mode database. When it is active every org-mode file you visit will be indexed into a sqlite database. In each file, each headline with its title, tags and properties are stored, and every link in each file is stored.
`org-db’ should be loaded by default in scimax.
This becomes useful because you can then search all of your org-files and jump to different locations.
- `org-db-headings’
- Jump to a heading
- `org-db-contacts’
- jump to a heading with an email property
- `org-db-files’
- open a file in the db
- `org-db-recent-files’
- open a list of recent files from the db
- `org-db-locations’
- open a heading with an address property
- `org-db-hashtags’
- open a hashtag.
- `org-db-properties’
- search for entries with a property that matches a pattern
- `org-db-editmarks’
- Search editmarks in your org-files
You can add a lot of files with `org-db-index’.
When active, every time you save an org-file it will be added to a queue to be indexed during idle time.
If you need sophisticated structured searches, check out `org-ql-select’ and `org-ql-query’ from https://github.com/alphapapa/org-ql.
For example, this searches the current buffer for a heading matching “queries”, and it returns a data structure.
(org-ql-select (current-buffer) '(heading "queries"))
headline | (:raw-value Structured queries of org-files :begin 57974 :end 58008 :pre-blank 0 :contents-begin 58009 :contents-end 58009 :level 2 :priority nil :tags nil :todo-keyword nil :todo-type nil :post-blank 1 :footnote-section-p nil :archivedp nil :commentedp nil :post-affiliated 57974 :title (Structured queries of org-files)) |
Or from a file
(org-ql-select "scimax.org" '(heading "queries"))
headline | (:raw-value Structured queries of org-files :begin 57974 :end 58008 :pre-blank 0 :contents-begin 58009 :contents-end 58009 :level 2 :priority nil :tags nil :todo-keyword nil :todo-type nil :post-blank 1 :footnote-section-p nil :archivedp nil :commentedp nil :post-affiliated 57974 :title (Structured queries of org-files)) |
Or from a list of files.
(org-ql-select '("scimax.org" "README.org") '(or (heading "queries") (heading "users")))
headline | (:raw-value Structured queries of org-files :begin 57974 :end 58008 :pre-blank 0 :contents-begin 58009 :contents-end 58009 :level 2 :priority nil :tags nil :todo-keyword nil :todo-type nil :post-blank 1 :footnote-section-p nil :archivedp nil :commentedp nil :post-affiliated 57974 :title (Structured queries of org-files)) |
headline | (:raw-value Windows users :begin 1310 :end 1326 :pre-blank 0 :contents-begin 1327 :contents-end 1327 :level 2 :priority nil :tags nil :todo-keyword nil :todo-type nil :post-blank 1 :footnote-section-p nil :archivedp nil :commentedp nil :post-affiliated 1310 :title (Windows users)) |
headline | (:raw-value Mac users :begin 1682 :end 1694 :pre-blank 0 :contents-begin 1695 :contents-end 1695 :level 2 :priority nil :tags nil :todo-keyword nil :todo-type nil :post-blank 1 :footnote-section-p nil :archivedp nil :commentedp nil :post-affiliated 1682 :title (Mac users)) |
headline | (:raw-value Alternative manual installation of scimax for Mac users :begin 2268 :end 2327 :pre-blank 0 :contents-begin 2328 :contents-end 2328 :level 3 :priority nil :tags nil :todo-keyword nil :todo-type nil :post-blank 1 :footnote-section-p nil :archivedp nil :commentedp nil :post-affiliated 2268 :title (Alternative manual installation of scimax for Mac users)) |
headline | (:raw-value Linux users :begin 3249 :end 3263 :pre-blank 0 :contents-begin 3264 :contents-end 3264 :level 2 :priority nil :tags nil :todo-keyword nil :todo-type nil :post-blank 1 :footnote-section-p nil :archivedp nil :commentedp nil :post-affiliated 3249 :title (Linux users)) |
I don’t use this library enough.
Navigation is almost as complex as searching, and it means moving your cursor to the place you want it to be. Yes, you can use a mouse or arrow keys. There are often faster ways to get what you want though. In scimax see `scimax-navigation/body’ which provides ways to navigate by:
- character
- word
- sentence
- paragraph
- line
- buffer
See also `scimax-jump/body’ which provides ways to jump to all kinds of things like:
- chars
- words
- sentences
- paragraphs
- org headings
- links
- recent files
- windows
- buffers and buffer positions
- lines
- symbols
Many of those open hydra menus that further refine where those things are, e.g. below or above the current position.
`scimax-help’ will open this document.
Emacs is described as “self-documenting”, and it provides a lot of introspective ways to access documentation. A classic way to access help is via “info” pages. These are hyperlinked documents containing a lot of detail about Emacs and its libraries.
Emacs-manual: info:Emacs
n | goto next page |
u | up a node |
d | Main directory |
? | list of keys and commands |
q | quit |
Emacs libraries: info:dir Emacs-lisp manual: info:elisp
org-mode manual: info:org
To get help on functions use: `counsel-describe-function’ and on variables use `counsel-describe-variable’.
If you do not know exactly what you are looking for try: `counsel-apropos’. This covers commands, functions, variables, faces, classes, and some other things.
If you have man pages installed (Linux/Mac for sure, maybe on windows) you can access them easily via Emacs. I like to read man pages in Emacs with `woman’ although `man’ is also good.
Note while on a man page you can use these keys:
m Prompt to retrieve a new manpage. r Retrieve reference in SEE ALSO section. M-n Jump to next manpage in circular list. M-p Jump to previous manpage in circular list. n Jump to next manpage section. p Jump to previous manpage section. g Go to a manpage section. s Jumps to the SEE ALSO manpage section. q Deletes the manpage window, bury its buffer. k Deletes the manpage window, kill its buffer. ? Prints this help text.
scimax also defines a link for man pages.
Manpage for BSDTAR(1)
The `describe-key’ function will prompt you for a key sequence or you can click on a menu item to see what it does.
The `describe-mode’ function will provide a full list of all the keybindings in the current buffer.
In org-mode the `ore’ command will give you information about the org-element under your cursor, including some commands that you can use at the point. You can also customize this by adding your own notes (click on User documentation in the help buffer).
If you use the menus, they will often have the shortcut in the menu.
The help functions usually show you if a shortcut is defined for a command.
If you really want to define your own keys, see `define-key’ and `global-set-key’.
Make yourself some notes in org-mode using `emacs-keybinding-command-tooltip-mode’.
Suppose you have your own Emacs setup already and only want to use a few parts of scimax without loading the whole thing. No problem. Just add the scimax dir to your load-path, and require as you like.
For example, to just use the scimax ipython enhancements (jkitchin#191 (comment)), this might work:
(add-to-list 'load-path "path/to/scimax-dir")
(require 'ob-ipython)
(require 'scimax-org-babel-ipython-upstream)
Note that a lot of packages are installed in ./packages.el and you may have to inspect the source of the packages you are requiring to make sure all the dependencies get installed.
`navy’ opens a hydra for navigation. The following keys are bound to commands that do something in the following senses
j | left |
l | right |
i | up |
k | down |
The default mode is character mode, and you can change the mode with single characters, include a word mode (w), sentence (s), paragraph (p), page (g), line (n) and sexp (x) mode. These modes allow you navigate forward and backward by those elements. They also define binding
I have tried to make the following keys consistent:
; | avy-goto-char-2 |
‘ | avy-goto-line |
< | goto point-min |
> | goto point-max |
There are some useful bindings in `navy’ also.
r | counsel-git-grep |
a | swiper-all |
(require 'ox-texinfo)
(org-texinfo-export-to-info)