======================== The Emacs and Mg Editors ======================== If you ever get into trouble: Ctrl-g = cancel current operation Ctrl-x u = undo latest edit Ctrl-x s = save current buffer to file (save) Ctrl-x Ctrl-w = write current buffer to a new file (save as) Ctrl-x c = close emacs Ctrl-h b = list of key bindings Ctrl-h = help prompt (Emacs only) Ctrl-h Ctrl-h = help menu (In mg, a=apropos b=key-binding c=key description) --------- Bookmarks --------- Display bookmarks: Ctrl-x r l Bookmark currently displayed file or directory: Ctrl-x r m With your bookmarks displayed, you can rename or delete a bookmark by moving the cursor to the bookmark and typing: r = rename d = mark for deletion x = remove (delete) an entry that has been marked for deletion ------- Buffers ------- Kill Buffer = Ctrl-x k List All Buffers = Ctrl-x Ctrl-b Next Buffer = Ctrl-x [right arrow] Previous Buffer = Ctrl-x [left arrow] Select Buffer = Ctrl-x b -------- Calendar -------- If you have latitude and longitude defined in your init.el, you can run: M-x sun[rise-sunset] Define longitude and latitude with something like: (setq calendar-latitude 38.05) (setq calendar-longitude -84.5) (setq calendar-location-name "Lexington, Ky.") -------------- Copy and Paste -------------- Ctrl- = mark beginning of selection at cursor Move to end of text that you wish to select Esc-w = copy selected text to clipboard Ctrl-w = cut selected text to clipboard Ctrl-y = paste selected text at cursor location ---------------------- EWW / Web Browser Mode ---------------------- To open the emacs internal web browser, type: Meta-x eww You will then be prompted to enter a URL. Use "Meta-x eww" each time you wish to enter a new URL. Some useful commands: q = exit browser mode l = go to previously loaded page (lower case "L") r = go to subsequently loaded page d = download H = show history b = add bookmark B = show bookmarks C = show cookies EWW: Socks Proxy ---------------- You can route Emacs EWW traffic through a Socks 5 proxy by adding the following lines to your init.el file. ;; Socks Proxy (setq socks-override-functions 1) (setq socks-noproxy '("localhost")) (require 'socks) (setq socks-server '("My Proxy" "localhost" 5222 5)) In the "socks-server" line, "My Proxy" is simply a description. You can make it whatever you wish. The "localhost" on the "sock-server" line is where the proxy lives, and my own socks proxies are simply SSH tunnels running on localhost. The "5222" is the port number, and the "5" is the socks version. Unfortunately, Emacs's support for Socks proxies only supports HTTP connections, not HTTPS connections. ------------- Exiting Emacs ------------- Normally, if changes have been made to any buffers when you hit Ctrl-c Ctrl-x to close Emacs, Emacs will ask you if you wish to save those changed buffers. If you choose "n" (for "no"), Emacs will prompt you again with "Modified buffers exist; exit anyway?" You can disable that second confirmation check with the following code in your init.el file. ;; Don't add a second exit prompt if I've already chosen not ;; to save modified buffers: (defun my/force-exit-without-nag (orig-fun &rest args) "Allow exiting Emacs without the 'Modified buffers exist' prompt." (cl-letf* ((old-yes-or-no (symbol-function 'yes-or-no-p)) ((symbol-function 'yes-or-no-p) (lambda (prompt) (if (string-match-p "Modified buffers exist; exit anyway" prompt) t ; Automatically say "yes" to the nag prompt (funcall old-yes-or-no prompt))))) (apply orig-fun args))) (advice-add 'save-buffers-kill-emacs :around #'my/force-exit-without-nag) --------------- File Operations --------------- You can use Emacs much as you would the ncurses file browser, MC. In graphical Emacs, check "Operate" menu. With the cursor on a file name: d = Mark file for Deletion u = Remove Deletion mark (Unmark) x = Remove file that has been marked for deletion C = Copy R = Rename S = Symbolic Link H = Hard Link O = Change Owner G = Change Group -------------- Initialization -------------- Some minimal tweaks that you probably want to include in your ~/.emacs.d/init.el file: ;;; Don't create backup files or autosave (setq make-backup-files nil) (setq auto-save-default nil) ;;; Display column number (column-number-mode 1) Optional Basic -------------- These init.el additions are optional but can be very useful in a lot of scenarios, not just specialized scenarios, like your journal. (global-auto-revert-mode 1) ; update open buffer if file changed externally (setq-default major-mode 'text-mode) (add-hook 'text-mode-hook 'ruler-mode) (add-hook 'text-mode-hook 'turn-on-visual-line-mode) mg Initialization ----------------- A Simple ~/.mg file: #backup-to-home-directory make-backup-files no column-number-mode If you opt for backup-to-home-directory, then you should create the ~/.mg.d directory that mg expects. ------------------- Miscellaneous Tools ------------------- Ctrl-x * q = open a simple calculator in the status bar Meta $ = spell check word under cursor Meta x ispell = spell check buffer Meta x center-line = center line under cursor Meta l = make word lower case Meta u = make word upper case Meta c = capitalize word