Last active
June 1, 2020 15:22
-
-
Save benmarwick/ee0f400b14af87a57e4a to your computer and use it in GitHub Desktop.
Notes on using Emacs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;Record startup timestamp | |
(defvar Emacs/invokation-time | |
(current-time)) | |
(custom-set-variables | |
;; custom-set-variables was added by Custom. | |
;; If you edit it by hand, you could mess it up, so be careful. | |
;; Your init file should contain only one such instance. | |
;; If there is more than one, they won't work right. | |
'(custom-enabled-themes (quote (tango-plus))) | |
'(custom-safe-themes | |
(quote | |
("ecb9fe1d5b165a35499191a909b2b5710a52935614058b327a39bfbbb07c7dc8" default))) | |
'(package-selected-packages | |
(quote | |
(autopair auto-complete dired+ dired-launch ess flyspell-correct-popup flyspell-popup ido-at-point ido-hacks ido-select-window ido-ubiquitous ido-vertical-mode magit org-ref pandoc pandoc-mode paren-completer pdf-tools polymode s smex status tango-plus-theme wc-mode auctex company org)))) | |
(custom-set-faces | |
;; custom-set-faces was added by Custom. | |
;; If you edit it by hand, you could mess it up, so be careful. | |
;; Your init file should contain only one such instance. | |
;; If there is more than one, they won't work right. | |
) | |
;; Much of this is from https://github.com/myTerminal/super-emacs | |
(set-default-font "PragmataPro 12") | |
;; for MELPA | |
(require 'package) | |
(add-to-list 'package-archives | |
'("melpa" . "http://melpa.milkbox.net/packages/") t) | |
(when (< emacs-major-version 24) | |
;; For important compatibility libraries like cl-lib | |
(add-to-list 'package-archives '("gnu" . "http://elpa.gnu.org/packages/"))) | |
(package-initialize) | |
;; When running in Windows, we want to use an alternate shell so we | |
;; can be more unixy. To get a shell: M-x shell | |
(setq shell-file-name "C:/Program Files/Git/bin/sh.exe") | |
(setq explicit-shell-file-name shell-file-name) | |
;; Disable the splash screen (to enable it agin, replace the t with 0) | |
(setq inhibit-splash-screen t) | |
;; hide the tool bar | |
(tool-bar-mode -1) ; clickable icons bad | |
(menu-bar-mode 1) ; dropdown menus good | |
;; Recent file list | |
(require 'recentf) | |
(recentf-mode 1) | |
(setq recentf-max-menu-items 50) | |
(global-set-key "\C-x\ \C-r" 'recentf-open-files) | |
;; modern conveniences | |
(cua-mode 1) ; CUA mode for copy-cut-paste | |
;; (global-linum-mode t) ; enable line number display | |
(global-visual-line-mode 1); Proper line wrapping | |
(set-fringe-mode '(0 . 0)); Disable fringe because I use visual-line-mode | |
(show-paren-mode 1) ; turn on paren match highlighting | |
(setq show-paren-style 'expression) ; highlight entire bracket expression | |
;; enable Ido mode | |
(setq ido-enable-flex-matching t) | |
(setq ido-everywhere t) | |
(ido-mode 1) | |
(require 'ido-completing-read+) | |
(ido-ubiquitous-mode 1) | |
(setq magit-completing-read-function 'magit-ido-completing-read) | |
(setq gnus-completing-read-function 'gnus-ido-completing-read) | |
(setq ess-use-ido t) | |
;; for M-x completion | |
(require 'smex) ; Not needed if you use package.el | |
(smex-initialize) ; Can be omitted. This might cause a (minimal) delay | |
; when Smex is auto-initialized on its first run. | |
(global-set-key (kbd "M-x") 'smex) | |
(global-set-key (kbd "M-X") 'smex-major-mode-commands) | |
;; This is your old M-x. | |
(global-set-key (kbd "C-c C-c M-x") 'execute-extended-command) | |
;;; MARKDOWN | |
(setq load-path | |
(append '("C:\emacs\.emacs.d\elpa" "C:\emacs\.emacs.d\elpa") | |
load-path)) | |
(require 'poly-R) | |
(require 'poly-markdown) | |
(add-to-list 'auto-mode-alist '("\\.md" . poly-markdown-mode)) | |
;;; R modes | |
(add-to-list 'auto-mode-alist '("\\.Snw" . poly-noweb+r-mode)) | |
(add-to-list 'auto-mode-alist '("\\.Rnw" . poly-noweb+r-mode)) | |
(add-to-list 'auto-mode-alist '("\\.Rmd" . poly-markdown+r-mode)) | |
(add-to-list 'auto-mode-alist '("\\.rmd" . poly-markdown+r-mode)) | |
;; add on the fly spell check for markdown docs | |
(setq-default ispell-program-name "C:/Program Files (x86)/Aspell/bin/aspell.exe") | |
(setq text-mode-hook '(lambda() (flyspell-mode t) )) | |
(setq ispell-program-name "aspell" | |
ispell-extra-args '("--sug-mode=ultra")) | |
(autoload 'flyspell-mode "flyspell" "On-the-fly spelling checker." t) | |
(autoload 'flyspell-delay-command "flyspell" "Delay on command." t) | |
(autoload 'pandoc-mode-flyspell-verify "flyspell" "" t) | |
(add-hook 'pandoc-mode-hook 'turn-on-flyspell) | |
(add-hook 'flyspell-mode-hook #'flyspell-popup-auto-correct-mode) | |
;;; enable word-count on startup | |
(add-to-list 'load-path "{user-emacs-directory}/elpa") | |
(require 'wc-mode) | |
(autoload 'wc-mode "wc-mode" "Wordcount Mode" t) | |
(provide 'wcmode-config) | |
;; word count by C-c w | |
(global-set-key "\C-cw" 'wc-mode) | |
;; enable word count on startup | |
(define-globalized-minor-mode global-wc-mode wc-mode | |
(lambda () (wc-mode 1))) | |
(global-wc-mode 1) | |
;; use count-words instead of count-words-region as it works on buffer | |
;; if no region is selected | |
(global-set-key (kbd "M-=") 'count-words) | |
;; Use shift-enter to split window & launch R (if not running), execute highlighted region (if R running & area highlighted), or execute current line (and move to next line, skipping comments) | |
(require 'ess-site) | |
(setq ess-ask-for-ess-directory nil) | |
(setq ess-local-process-name "R") | |
(setq ansi-color-for-comint-mode 'filter) | |
(setq comint-scroll-to-bottom-on-input t) | |
(setq comint-scroll-to-bottom-on-output t) | |
(setq comint-move-point-for-output t) | |
(defun my-ess-start-R () | |
(interactive) | |
(if (not (member "*R*" (mapcar (function buffer-name) (buffer-list)))) | |
(progn | |
(delete-other-windows) | |
(setq w1 (selected-window)) | |
(setq w1name (buffer-name)) | |
(setq w2 (split-window-right w1 nil t)) | |
(R) | |
(set-window-buffer w2 "*R*") | |
(set-window-buffer w1 w1name)))) | |
(defun my-ess-eval () | |
(interactive) | |
(my-ess-start-R) | |
(if (and transient-mark-mode mark-active) | |
(call-interactively 'ess-eval-region) | |
(call-interactively 'ess-eval-line-and-step))) | |
(add-hook 'ess-mode-hook | |
'(lambda() | |
(local-set-key [(shift return)] 'my-ess-eval))) | |
(add-hook 'inferior-ess-mode-hook | |
'(lambda() | |
(local-set-key [C-up] 'comint-previous-input) | |
(local-set-key [C-down] 'comint-next-input))) | |
(add-hook 'Rnw-mode-hook | |
'(lambda() | |
(local-set-key [(shift return)] 'my-ess-eval))) | |
(require 'ess-site) | |
;; cause "Shift+Enter" to send the current line to *R* | |
(defun my-ess-eval () | |
(interactive) | |
(if (and transient-mark-mode mark-active) | |
(call-interactively 'ess-eval-region) | |
(call-interactively 'ess-eval-line-and-step))) | |
(add-hook 'ess-mode-hook | |
'(lambda() | |
(local-set-key [(shift return)] 'my-ess-eval))) | |
;; default ESS to use R | |
(defun ess-set-language () | |
(setq-default ess-language "R") | |
(setq ess-language "R") | |
) | |
(add-hook 'ess-post-run-hook 'ess-set-language t) | |
; compile rmarkdown to HTML or PDF with M-n s | |
; use YAML in Rmd doc to specify the usual options | |
; which can be seen at http://rmarkdown.rstudio.com/ | |
;; thanks http://roughtheory.com/posts/ess-rmarkdown.html | |
(defun ess-rmarkdown () | |
"Compile R markdown (.Rmd). Should work for any output type." | |
(interactive) | |
; Check if attached R-session | |
(condition-case nil | |
(ess-get-process) | |
(error | |
(ess-switch-process))) | |
(let* ((rmd-buf (current-buffer))) | |
(save-excursion | |
(let* ((sprocess (ess-get-process ess-current-process-name)) | |
(sbuffer (process-buffer sprocess)) | |
(buf-coding (symbol-name buffer-file-coding-system)) | |
(R-cmd | |
(format "library(rmarkdown); rmarkdown::render(\"%s\")" | |
buffer-file-name))) | |
(message "Running rmarkdown on %s" buffer-file-name) | |
(ess-execute R-cmd 'buffer nil nil) | |
(switch-to-buffer rmd-buf) | |
(ess-show-buffer (buffer-name sbuffer) nil))))) | |
(define-key polymode-mode-map "\M-ns" 'ess-rmarkdown) | |
;; autocomplete | |
(add-hook 'after-init-hook 'global-company-mode) | |
(add-to-list 'load-path "{user-emacs-directory}/elpa") ;; comment if autopair.el is in standard load path | |
(require 'autopair) | |
(autopair-global-mode) ;; enable autopair in all buffers | |
;; get the magrittr pipe with CTRL-shift-m | |
(defun then_R_operator () | |
"R - %>% operator or 'then' pipe operator" | |
(interactive) | |
(just-one-space 1) | |
(insert "%>%") | |
(reindent-then-newline-and-indent)) | |
(define-key ess-mode-map (kbd "C-S-m") 'then_R_operator) | |
(define-key inferior-ess-mode-map (kbd "C-S-m") 'then_R_operator) | |
;; imenu-anywhere | |
(unless (package-installed-p 'imenu-anywhere) | |
(package-refresh-contents) | |
(package-install 'imenu-anywhere)) | |
(global-set-key (kbd "C-.") #'imenu-anywhere) | |
;; super-emacs - packages.el | |
;Create repositories cache, if required | |
(when (not package-archive-contents) | |
(package-refresh-contents)) | |
;Declare a list of required packages | |
(defvar super-emacs--required-packages | |
'(helm | |
multiple-cursors | |
ace-jump-mode | |
ace-window | |
powerline | |
buffer-move | |
auto-complete | |
ztree | |
undo-tree | |
neotree | |
material-theme | |
dired-launch | |
which-key | |
meta-presenter | |
myterminal-controls | |
theme-looper)) | |
;Install required packages | |
(mapc (lambda (p) | |
(package-install p)) | |
super-emacs--required-packages) | |
;Load default auto-complete configs | |
(ac-config-default) | |
;Start undo-tree | |
(global-undo-tree-mode) | |
;Set hooks for dired-launch-mode | |
(add-hook 'dired-mode-hook | |
'dired-launch-mode) | |
;Start which-key-mode | |
(which-key-mode) | |
;Set up ace-jump-mode | |
(autoload 'ace-jump-mode | |
"ace-jump-mode" | |
"Emacs quick move minor mode" | |
t) | |
(autoload 'ace-jump-mode-pop-mark | |
"ace-jump-mode" | |
"Ace jump back:-" | |
t) | |
;Enable powerline | |
(powerline-center-theme) | |
(setq powerline-default-separator | |
'slant) | |
;Set up helm-mode | |
(helm-mode 1) | |
(helm-autoresize-mode 1) | |
(setq helm-split-window-in-side-p | |
t) | |
;Disable tool-bar | |
(tool-bar-mode -1) | |
;Disable scroll-bar | |
(scroll-bar-mode -1) | |
;Activate material theme | |
(load-theme 'material | |
t) | |
(defvar super-emacs--my-keyboard-bindings | |
'(;;("C-}" . mc/mark-next-like-this) | |
;;("C-{" . mc/mark-previous-like-this) | |
("C-|" . mc/mark-all-like-this) | |
("C->" . ace-jump-mode) | |
("C-<" . ace-jump-mode-pop-mark) | |
("M-/" . undo-tree-visualize) | |
("C-\," . neotree-toggle) | |
("C-\"" . theme-looper-enable-next-theme) | |
("C-M-'" . myterminal-controls-open-controls) | |
("C-c M-x" . execute-extended-command) | |
("M-x" . helm-M-x) | |
("C-x b" . helm-mini) | |
("C-x C-b" . helm-buffers-list) | |
("C-x C-f" . helm-find-files) | |
("C-x C-r" . helm-recentf) | |
("M-y" . helm-show-kill-ring) | |
("C-;" . ace-window) | |
("C-S-<up>" . buf-move-up) | |
("C-S-<down>" . buf-move-down) | |
("C-S-<left>" . buf-move-left) | |
("C-S-<right>" . buf-move-right) | |
("<f5>" . super-emacs-reload-current-file))) | |
(defun super-emacs-apply-keyboard-bindings (pair) | |
"Apply keyboard-bindings for supplied list of key-pair values" | |
(global-set-key (kbd (car pair)) | |
(cdr pair))) | |
(mapc 'super-emacs-apply-keyboard-bindings | |
super-emacs--my-keyboard-bindings) | |
;; Keep this at the end -------------------------------------------- | |
;;Print welcome message | |
(princ (cl-concatenate 'string | |
"Startup completed in " | |
(number-to-string (cadr (time-subtract (current-time) | |
Emacs/invokation-time))) | |
" seconds\n\n" | |
"Welcome to Emacs!\n\n" | |
"Today's date: " | |
(format-time-string "%B %d %Y")) | |
(get-buffer-create (current-buffer))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; refresh the config file by SPC f e R. Also, restart is SPC q R |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(custom-set-variables | |
;; custom-set-variables was added by Custom. | |
;; If you edit it by hand, you could mess it up, so be careful. | |
;; Your init file should contain only one such instance. | |
;; If there is more than one, they won't work right. | |
'(custom-enabled-themes (quote (tango-plus))) | |
'(custom-safe-themes | |
(quote | |
("ecb9fe1d5b165a35499191a909b2b5710a52935614058b327a39bfbbb07c7dc8" default))) | |
'(package-selected-packages | |
(quote | |
(autopair auto-complete dired+ dired-launch ess flyspell-correct-popup flyspell-popup ido-at-point ido-hacks ido-select-window ido-ubiquitous ido-vertical-mode magit org-ref pandoc pandoc-mode paren-completer pdf-tools polymode s smex status tango-plus-theme wc-mode auctex company org)))) | |
(custom-set-faces | |
;; custom-set-faces was added by Custom. | |
;; If you edit it by hand, you could mess it up, so be careful. | |
;; Your init file should contain only one such instance. | |
;; If there is more than one, they won't work right. | |
) | |
;; for MELPA | |
(require 'package) | |
(add-to-list 'package-archives | |
'("melpa" . "http://melpa.milkbox.net/packages/") t) | |
(when (< emacs-major-version 24) | |
;; For important compatibility libraries like cl-lib | |
(add-to-list 'package-archives '("gnu" . "http://elpa.gnu.org/packages/"))) | |
(package-initialize) | |
;; When running in Windows, we want to use an alternate shell so we | |
;; can be more unixy. To get a shell: M-x shell | |
(setq shell-file-name "C:/Program Files/Git/bin/sh.exe") | |
(setq explicit-shell-file-name shell-file-name) | |
;; Disable the splash screen (to enable it agin, replace the t with 0) | |
(setq inhibit-splash-screen t) | |
;; hide the tool bar | |
(tool-bar-mode -1) ; clickable icons bad | |
(menu-bar-mode 1) ; dropdown menus good | |
;; Recent file list | |
(require 'recentf) | |
(recentf-mode 1) | |
(setq recentf-max-menu-items 50) | |
(global-set-key "\C-x\ \C-r" 'recentf-open-files) | |
;; modern conveniences | |
(cua-mode 1) ; CUA mode for copy-cut-paste | |
;; (global-linum-mode t) ; enable line number display | |
(global-visual-line-mode 1); Proper line wrapping | |
(set-fringe-mode '(0 . 0)); Disable fringe because I use visual-line-mode | |
(show-paren-mode 1) ; turn on paren match highlighting | |
(setq show-paren-style 'expression) ; highlight entire bracket expression | |
;; enable Ido mode | |
(setq ido-enable-flex-matching t) | |
(setq ido-everywhere t) | |
(ido-mode 1) | |
;;; MARKDOWN | |
(setq load-path | |
(append '("C:\emacs\.emacs.d\elpa" "C:\emacs\.emacs.d\elpa") | |
load-path)) | |
(require 'poly-R) | |
(require 'poly-markdown) | |
(add-to-list 'auto-mode-alist '("\\.md" . poly-markdown-mode)) | |
;;; R modes | |
(add-to-list 'auto-mode-alist '("\\.Snw" . poly-noweb+r-mode)) | |
(add-to-list 'auto-mode-alist '("\\.Rnw" . poly-noweb+r-mode)) | |
(add-to-list 'auto-mode-alist '("\\.Rmd" . poly-markdown+r-mode)) | |
(add-to-list 'auto-mode-alist '("\\.rmd" . poly-markdown+r-mode)) | |
;; add on the fly spell check for markdown docs | |
(setq-default ispell-program-name "C:/Program Files (x86)/Aspell/bin/aspell.exe") | |
(setq text-mode-hook '(lambda() (flyspell-mode t) )) | |
(setq ispell-program-name "aspell" | |
ispell-extra-args '("--sug-mode=ultra")) | |
(autoload 'flyspell-mode "flyspell" "On-the-fly spelling checker." t) | |
(autoload 'flyspell-delay-command "flyspell" "Delay on command." t) | |
(autoload 'pandoc-mode-flyspell-verify "flyspell" "" t) | |
(add-hook 'pandoc-mode-hook 'turn-on-flyspell) | |
(add-hook 'flyspell-mode-hook #'flyspell-popup-auto-correct-mode) | |
;;; enable word-count on startup | |
(add-to-list 'load-path "{user-emacs-directory}/elpa") | |
(require 'wc-mode) | |
(autoload 'wc-mode "wc-mode" "Wordcount Mode" t) | |
(provide 'wcmode-config) | |
;; word count by C-c w | |
(global-set-key "\C-cw" 'wc-mode) | |
;; enable word count on startup | |
(define-globalized-minor-mode global-wc-mode wc-mode | |
(lambda () (wc-mode 1))) | |
(global-wc-mode 1) | |
;; use count-words instead of count-words-region as it works on buffer | |
;; if no region is selected | |
(global-set-key (kbd "M-=") 'count-words) | |
;; Use shift-enter to split window & launch R (if not running), execute highlighted region (if R running & area highlighted), or execute current line (and move to next line, skipping comments) | |
(require 'ess-site) | |
(setq ess-ask-for-ess-directory nil) | |
(setq ess-local-process-name "R") | |
(setq ansi-color-for-comint-mode 'filter) | |
(setq comint-scroll-to-bottom-on-input t) | |
(setq comint-scroll-to-bottom-on-output t) | |
(setq comint-move-point-for-output t) | |
(defun my-ess-start-R () | |
(interactive) | |
(if (not (member "*R*" (mapcar (function buffer-name) (buffer-list)))) | |
(progn | |
(delete-other-windows) | |
(setq w1 (selected-window)) | |
(setq w1name (buffer-name)) | |
(setq w2 (split-window-right w1 nil t)) | |
(R) | |
(set-window-buffer w2 "*R*") | |
(set-window-buffer w1 w1name)))) | |
(defun my-ess-eval () | |
(interactive) | |
(my-ess-start-R) | |
(if (and transient-mark-mode mark-active) | |
(call-interactively 'ess-eval-region) | |
(call-interactively 'ess-eval-line-and-step))) | |
(add-hook 'ess-mode-hook | |
'(lambda() | |
(local-set-key [(shift return)] 'my-ess-eval))) | |
(add-hook 'inferior-ess-mode-hook | |
'(lambda() | |
(local-set-key [C-up] 'comint-previous-input) | |
(local-set-key [C-down] 'comint-next-input))) | |
(add-hook 'Rnw-mode-hook | |
'(lambda() | |
(local-set-key [(shift return)] 'my-ess-eval))) | |
(require 'ess-site) | |
;; default ESS to use R | |
(defun ess-set-language () | |
(setq-default ess-language "R") | |
(setq ess-language "R") | |
) | |
(add-hook 'ess-post-run-hook 'ess-set-language t) | |
; compile rmarkdown to HTML or PDF with M-n s | |
; use YAML in Rmd doc to specify the usual options | |
; which can be seen at http://rmarkdown.rstudio.com/ | |
;; thanks http://roughtheory.com/posts/ess-rmarkdown.html | |
(defun ess-rmarkdown () | |
"Compile R markdown (.Rmd). Should work for any output type." | |
(interactive) | |
; Check if attached R-session | |
(condition-case nil | |
(ess-get-process) | |
(error | |
(ess-switch-process))) | |
(let* ((rmd-buf (current-buffer))) | |
(save-excursion | |
(let* ((sprocess (ess-get-process ess-current-process-name)) | |
(sbuffer (process-buffer sprocess)) | |
(buf-coding (symbol-name buffer-file-coding-system)) | |
(R-cmd | |
(format "library(rmarkdown); rmarkdown::render(\"%s\")" | |
buffer-file-name))) | |
(message "Running rmarkdown on %s" buffer-file-name) | |
(ess-execute R-cmd 'buffer nil nil) | |
(switch-to-buffer rmd-buf) | |
(ess-show-buffer (buffer-name sbuffer) nil))))) | |
(define-key polymode-mode-map "\M-ns" 'ess-rmarkdown) | |
;; autocomplete | |
(add-hook 'after-init-hook 'global-company-mode) | |
(add-to-list 'load-path "{user-emacs-directory}/elpa") ;; comment if autopair.el is in standard load path | |
(require 'autopair) | |
(autopair-global-mode) ;; enable autopair in all buffers | |
;; get the magrittr pipe with CTRL-shift-m | |
(defun then_R_operator () | |
"R - %>% operator or 'then' pipe operator" | |
(interactive) | |
(just-one-space 1) | |
(insert "%>%") | |
(reindent-then-newline-and-indent)) | |
(define-key ess-mode-map (kbd "C-S-m") 'then_R_operator) | |
(define-key inferior-ess-mode-map (kbd "C-S-m") 'then_R_operator) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1. Download and install emacs from one of these http://www.gnu.org/software/emacs/ http://ftp.gnu.org/pub/gnu/emacs/windows/ http://emacsformacosx.com/ Follow these instructions if on windows: http://www1.cmc.edu/pages/faculty/alee/emacs/emacs.html | |
Get aspell and the en dictionary: http://aspell.net/win32/ before running emacs. This enables on the fly spell checking. | |
3. Get some useful packages. First we need to install the package manager, Melpa (more details: http://melpa.milkbox.net/). Find the .emacs file and edit it to add this chunk near the top: | |
;; for MELPA | |
(require 'package) | |
(add-to-list 'package-archives | |
'("melpa" . "http://melpa.milkbox.net/packages/") t) | |
(when (< emacs-major-version 24) | |
;; For important compatibility libraries like cl-lib | |
(add-to-list 'package-archives '("gnu" . "http://elpa.gnu.org/packages/"))) | |
(package-initialize) | |
Now save and close that file and restart emacs, and then type this; | |
M-x package-list-packages <RET> | |
Which means: hold the Alt key, press the x key, release the Alt key, type 'package-list-packages' then press the enter key. In the list that appears, use and up and down arrows and the scroll bar to find these packages, when you find them, place the curser at their name and press i at each package: | |
magit # see http://www.emacswiki.org/emacs/Magit for how to use | |
pandoc-mode # see http://joostkremers.github.io/pandoc-mode/ for how to use | |
markdown-mode # http://jblevins.org/projects/markdown-mode/ for how to use | |
ESS # http://ess.r-project.org/ | |
babel # http://orgmode.org/worg/org-contrib/babel/ | |
auctex # http://www.gnu.org/software/auctex/ | |
wc-mode # https://github.com/bnbeckwith/wc-mode | |
visual-regex | |
evil | |
multiple-cursors | |
polymode | |
org | |
And any others that sound interesting. After you've made your selections, press x and then type 'yes' to confirm that you want to install those. | |
4. Now you'll need to make a few more updates to your .emacs file, see the .emacs below | |
And save those changes and restart emacs. | |
5. Now study examples of other people using markdown in emacs (eg. https://raw.githubusercontent.com/kjhealy/pandoc-templates/master/examples/article-markdown.md) and watch videos that gently introduce working with emacs such as the 'research tools' series (https://www.youtube.com/playlist?list=PL7E11B34616530F5E), and the 'hack emacs' series (https://www.youtube.com/watch?v=VpFK6abGCOg&list=PLABBCB510477C08DB). Here are some handy keyboard shortcuts for these kinds of documents: | |
# New/Open/Save/Close file | |
C-x C-f to open a new file or find an existing one | |
C-x C-r open a recent file | |
C-x s to save a file | |
C-x k to kill (close) active buffer | |
# Quit | |
C-x g to get out of an incomplete command (ie. when stuck!) | |
C-x C-c to quit (it will ask if you want to save) | |
# managing buffers (ie. windows) | |
C-x 0 to make the active buffer window disappear | |
C-x 1 to make active buffer full window, close all windows except the current one | |
C-x 2 to split screen horizontally | |
C-x 3 to split screen vertically (more useful) | |
C-x b to change active buffer to another buffer | |
C-x o to change to other buffer | |
C-x k to kill (close) active buffer | |
# changing pane size | |
C-x - (shrink-window-if-larger-than-buffer) will shrink a window to fit its content. | |
C-x + (balance-windows) will make windows the same heights and widths. | |
C-x ^ (enlarge-window) increases the height by 1 line, or the prefix arg value. A negative arg shrinks the window. e.g. C-- C-1 C-6 C-x ^ shrinks by 16 rows, as does C-u - 1 6 C-x ^. | |
# navigate through text | |
C-{ Move back to previous paragraph beginning (backward-paragraph). | |
C-} Move forward to next paragraph end (forward-paragraph). | |
M-a Move back to the beginning of the sentence (backward-sentence). | |
M-e Move forward to the end of the sentence (forward-sentence). | |
# Pandoc & markdown | |
C-c C-c p to view html output in browser | |
C-c / p to create PDF (yes, press the / button) | |
# R | |
shift-enter to run a line or region | |
M-x R to start R | |
C-c C-j to send a line of R code to console | |
C-M-x to send a paragraph of R code to console | |
M-n s to knit Rmd to HTML or PDF using rmarkdown (and YAML) | |
# Git | |
M-x magit-status to see git status, and in the status buffer: | |
s to stage files | |
c c to commit (type the message then C-c C-c to actually commit) | |
b b to switch to another branch | |
P P to do a git push | |
# working with text | |
C-s to search | |
C-space to mark a region of text | |
M-w to copy | |
C-w to cut | |
C-y to paste | |
C-k kill (cut) to end of line | |
M-% string <RET> newstring <RET> to Replace some occurrences of string with newstring. | |
# working with LaTeX | |
C-c C-c RET to compile to PDF, need this for XeLatex http://tug.org/pipermail/xetex/2012-September/023663.html | |
C-c ; to comment out LaTeX | |
# working with Rmd files | |
C-x C-f to open a new file or find an existing one | |
C-c C-a l inserts an inline link of form [text](url) | |
C-c C-i i inserts markup for inline image | |
C-c C-s b inserts blockquote for active region (nice!!) | |
C-c C-s p inserts code block for active region (nice!!) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for this! I snagged ess-rmarkdown for my own setup.