Emacs

Table of Contents

Usage

CTRL and CapsLock

Source: emacswiki.org

Some Emacs users prefer to use key-bindings with CapsLock instead of the CTRL key.

Temporary

Swap the action of the two keys:

setxkbmap -option ctrl:swapcaps

Set CapsLock as an additional CTRL key.

setxkbmap -option ctrl:nocaps

Permanent

(Did not work on Ubuntu 16.04).

Edit /etc/default/keyboard and replace this line:

XKBOPTIONS=""

with

XKBOPTIONS="ctrl:nocaps"

or:

"ctrl:swapcaps"

Key-bindings

"C" is CTRL, "M" is Meta (Alt), "S" is SHIFT.

Navigation

  • C-p - previous line (up)
  • C-n - next line (down)
  • C-b - back one character (left)
  • C-f - forward one character (right)
  • M-b - back one word (left)
  • M-f - forward one word (right)
  • M-g g - go to line number

Killing and yanking (cut and paste)

Emacs has a "kill-ring" that contains the (by default) last 60 text-strings that have been killed (cut or copied).

  • space - set the mark from where your editing.
  • C-w - kill (cut) text between mark and pointer.
  • M-w - copy text between mark and pointer.
  • C-y - yank (paste) last killed (cut) text back into the buffer.
  • M-y - jump back in the kill ring yanking the previously killed text instead of the last. Subsequent key-presses will jump further back in the kill-ring history. Note that this will require you to press M-y up to sixty times if you accidentally passed beyond the value you were looking for.

Windows

  • C-2 - Split current window into two windows - horizontally
  • C-3 - Split current window into two windows - vertically
  • C-o - Move between open windows (the split-screen windows with open buffers):
  • C-0 - Close window (but not the buffer)
  • C-1 - Close all other windows (but not the buffers)

Buffers

  • C-x b - Switch between buffers or type in the name of a new empty buffer.
  • C-x C-b - Open buffer by selecting from list
  • C-k - Close buffer

Bookmarks

Bookmarks are kept in your account-wide settings - so you can always jump to your bookmarked files from any running copy of Emacs. Great for often used files like your Getting-Things-Done file or the main segments of the software projects you're working on. Remove bookmarks using M-x bookmark-delete

  • C-x r m - set bookmark
  • C-x r b - jump to bookmark
  • C-x r l - list bookmarks
  • M-x bookmark-delete - prompts for bookmark to delete.

Rectangle editing

There are three things worth noting about rectangle editing.

  1. There is no rectangle kill-ring - only one rectangle can be in the "clip-board" at a time.
  2. The rectangle will not include the column that the curson is in - when your drawing the rectangle in the right direction.
  3. The rectangle will not include the starting position - when you're drawing the rectangle in the left direction.

Mark with C-space and move the pointer to the diagonally opposite corner1 of the rectangle.

  • C-x r k - Rectangle kill.
  • C-x r y - Rectangle yank.
  • C-x r M-w - Save the text of the region-rectangle as the “last killed rectangle” (clip-board).
  • C-x r y - Yank the last killed rectangle with its upper left corner at pointer position.
  • C-x r d - Delete the text of the region-rectangle (delete-rectangle). Text will not be added to the "clip-board".
  • C-x r t - Prepend marked lines with string.

Graphic client only

  • C-x + - increase font size.
  • C-x - - decrease font size.

Help

  • C-h k - Describe function called by key-binding.
  • C-a h - Search functions by name.

Useful Commands

Emacs commands can be executed using M-x. Again M is Meta (Alt)

  • delete-trailing-whitespace - removes all trailing whitespaces from current line or marked region.
  • flush-lines - prompts for a regex to match, use ^$ to remove blank lines.
  • ispell - run the ispell/aspell spell-checker.
  • toggle-truncate-lines - Enable or disable wrapping lines of text that spans more that the width of the window.
  • describe-function - Prompts for a function-name (e.g. 'delete-trailing-whitespace' or 'arp') and shows a short description.
  • helper-describe-bindings - List all key-bindings for current mode.

Macros

  • C-x ( - begin recording macro.
  • C-x ) - stop recording macro.
  • C-x e - execute current macro.
  • C-u 10 C-e - execute the current macro ten times.
  • M-x name-last-macro - give the current macro a name for this session. this makes it possible to execute the macro using 'M-x macro-name' within Emacs.
  • M-x insert-kbd-macro - insert the macro code. Useful to store macros in .emacs thus "saving" the macro for next time you use Emacs.

Sample macro code: When window contains output from 'sortsomething|uniq -c -d' and you want to remove first from-bottom-found occurrance and two lines below.

(fset 'macro-name
[?\C-a ?\M-f ?\C-f ?\C-  ?\C-e ?\M-w ?\C-x ?o ?\M-> ?\C-r ?\C-y ?\C-a ?\C-k ?\C-k ?\C-k ?\C-k ?\C-k ?\C-x ?o ?\C-n])

; Add the following to .emacs to add a key-binding to the macro

(global-set-key (kbd "C-c a") 'macro-name)

Regular Expressions

Emacs regex is not like PCRE.

  • Escape next character
    \
    
  • Beginning of string
    \`
    
  • End of string
    \'
    

Using newline in regexp (and other input) in Emacs.

C - q C - j - insert "newline", e.g. similar to "\n"

Shell and Files

Daemonize and re-attach

Using the –daemon option you can make Emacs behave in a GNU Screen-like manner. It will run in the background keeping all your buffers open and active. You can even open multiple Emacs sessions, GUI and Terminal, on the same running environment.

Start it in the backround.

emacs --daemon

Use emacsclient to connect to the running Emacs process.

emacsclient -t

Commands and Output

  • M-! - Prompts for a command, inserts output into separate buffer.
  • M-| - Uses the marked region as input for the (prompted-for) command. Inserts output in separate buffer.

Shell inside Emacs

Shell

Not all (graphical, TUI) libraries work well in this terminal environment - but you can scroll through the buffer and kill/yank it's contents like any other Emacs buffer.

  • M-x shell - Start the shell buffer.
  • C-u M-x shell - Prompts for shell buffer name so you can have multiple shell buffers open simultaneously.

Ansi-Term

Quite capable terminal environment, direct buffer interaction is not possible. Most terminal programs work well in ansi-term mode.

  • M-x ansi-term - then: /bin/bash

Dired

Start Dired mode with "M-x dired"

Dired Key bindings

Dired key-bindings work on the selected file (where the pointer/cursor is at) if no files are marked - otherwise they iterate over the marked files.

Move the pointer to the element you want to use and press

  • Enter - open the file or folder (opens in a new buffer).
  • q - close directory.
  • C - copy the file (note: capital C).
  • R - rename/move file (note: capital R).
  • D - delete file (note: capital D).
  • + - create a new folder.
  • Z - gzip/ungzip file.
  • S - create a symbolic link to the marked file, prompts for symlink name.
  • M - chmod
  • G - set file group on selected or marked files.
  • O - set file owner on selected or marked files.
  • = - compare/diff marked file with selection file.

Marking for deletion.

  • d - mark file for deletion.
  • u - remove mark on file and switch to next line.
  • ~ - mark all Emacs auto-backup files for deletion.
  • # - mark all Emacs auto-save files for deletion.
  • % d - mark files matching the supplied regular-expression.
  • BACKSPACE - remove mark on file, same as 'u' but switches to previous line ().
  • x - delete the files that have been marked for deletion. This will prompt for confirmation.

Marking for operation

  • * m - mark current file/directory.
  • * u - unmark current file/directory.
  • * / - mark sub-directories.
  • * s - mark all files in directory.
  • * ! - unmark everything in current buffer.

Access remote files

The "Transparent Remote (file) Access, Multiple Protocol" (TRAMP) package gives you seemingly transparent access to remote files via SSH/SCP.

The only trick necessary is actually to open files with '/ssh:username@hostname' pre-pended to the path.

From the command-line:

emacs /ssh:username@hostname:filename.txt

From within Emacs you can 'change directory' to the remote location.

  • M-x cd - run the 'cd' command to change the default directory.
/ssh:username@hostname:

Your session is now opening all files relative to the supplied remote path.

Documents And Messaging

Org-mode

General Key bindings

  • C-c C-n - jump to next headline.
  • C-c C-p - jump to previous headline.
  • M-left - Move header one sub-level or move table-column one column to the left.
  • M-right - Move header up on sub-level or table-column one column to the right.
  • M-up - Move section 'up' before previous section (on same (sub-)level) or move table-row one row up.
  • M-down - Move section 'down' after next section (on same (sub-)level) or move table-row one row down.
  • M-S up - delete current table row.
  • M-S down - insert row below pointer.

Links

  • C-c C-l - create link. Prompts for link (format: "file: filename.org::header-name" - without white-space after colon) and description. See note regarding export to HTML2.
  • C-c C-o - open (follow) link.
  • C-c & - jump back from link.

Foot-notes

Note: for some reason using the header named 'Footnotes' prevents it (the header and sub-sections) from being published. Perhaps the title is clashing withe the auto-generated "Footnotes" header at the bootom of the document.

  • C-c C-x f - creates a new footnote or (if pointer is on footnote) jumps between first footnote and definition.
  • C-c C-c - when pointer is on footnote: jump to definition or vice versa.

Tags

  • C-c C-q - Tag the current headline (C-c C-c can also be used when the cursor is placed on a headline).
  • C-c \ or C-c / m - Search for headlines with supplied tag. Collapses all other headlines.

ToDo

  • Shift-left - Cycle TODO labels.
  • Shift-right - Cycle TODO labels.

Dates, schedules, deadlines

  • C-c C-d - insert a DEADLINE for the task.
  • C-c C-s - insert a SCHEDULE date for the task.
  • C-c / d - check org-file for deadlines. Collapses all headlines except those that are over due.
  • C-c / b - check DEADLINEs/SCHEDULEs before supplied date. Collapses all headlines except those that are before the date.
  • C-c / a - check DEADLINEs/SCHEDULEs after supplied date. Collapses all headlines except those that are after the date.

In-buffer settings

Adding the following lines to your .org buffer will have the following effects.

Option Effect
#+TITLE: Set the documents title, by default the filename, empty disables.
#+AUTHOR: Set the document author name,
#+OPTIONS: toc:nil Prevent generating a Table-of-Contents.
#+OPTIONS: toc:3 Set the table-of-contents depth to 3 levels.
#+OPTIONS: num:nil Do not show the header numbering int the table-of-contents.
#+OPTIONS: ^:nil Disable the LaTeX sub- and superscript using _ and ^

Table editing

Pressing TAB will re-adjust the whole table. Columns whose rows/cells only contain numerics will have the title right-aligned.

  • C-c | - Create new table or convert region to table, guessing what character to split fields on.
  • C-u C-c | - splitting fields using CSV (comma?).
  • C-u C-u C-c | - splitting fields by/at TAB.
  • TAB - Jump to next cell - or add new line if pressed at last cell on row.
  • C-c C-c - Realign table.
  • M-left - Move column to the left.
  • M-right - Move column to the right.
  • M-up - Move row up.
  • M-down - Move row down.
  • M-S-left - insert column left of current column (S is SHIFT).
  • M-S-right - delete current column (S is SHIFT).
  • C-c - - insert horizontal line.

Export table with:

  • M-x org-table-export RET - exports the table to a prompted-for file-name.
  • Uses file-extension to match prompted-for export-filter.
  • Options
    • comma seperated list (CSV)
    • tab separated list (TSV)
    • multiple LaTeX options

Code Blocks

Code block is an org-mode feature that allows the inclusion of source-code segments in an org-document.

Type the language-mode-name for org-babel after BEGIN SRC to have the code block evaluated by said interpreter. I had to add ' :results output' to make the execution actually output the STDOUT from the script.

#+NAME: helloworld
#+BEGIN_SRC perl :results output 
print "Hello, world!";
#+END_SRC
#+RESULTS:
: Hello, world!
  • Key bindings
    • <s TAB - Typing '<s' and pressing tabulator will expand into a BEGIN SRC block.
    • C-c ' - to edit the current code block (with font-lock-mode). Use it again to switch close the code editing buffer.
    • C-c C-c - to evaluate the current code block and insert its results in the Org-mode buffer.
  • Tangle

    The tangle header enables a feature that will write the contents of a code block to file.

    Use the path and filename as the values for the :tangle header.

    :tangle /home/USER/important.c
    
    • C-c C-v t - write the contents of the code block where the cursor is located to be written to file.
  • Org-Babel

    Org-Babel supplies features to evaluate source-code in code blocks, importing the output and exporting the source and/or the results of code blocks. The BEGIN SRC and BEGIN EXAMPLE elements are matched using the 'name' on the BEGIN SRC block and the 'results' on the BEGIN EXAMPLE block. This is automatically added if the result block is missing.

    Export only results:

    #+name:  path/filename.txt
    #+BEGIN_SRC sh :results output replace :exports results
    cat path/filename.txt
    #+END_SRC
    
    Contents of filename.txt
    #+RESULTS: path/filename.txt
    #+begin_example
    line 1 some text.
    line 2 some text.
    #+end_example
    

    Export both SRC and RESULTS:

    #+name: path/filename.txt
    #+BEGIN_SRC sh :results output replace :exports both
    cat path/filename.txt
    #+END_SRC
    
    Contents of filename.txt
    #+RESULTS: path/filename.txt
    #+begin_example
    line 1 some text.
    line 2 some text.
    #+end_example
    
  • Org-Babel SQL

    Note: if started after TRAMP session it fails with: Invalid function: with-parsed-tramp-file-name. Resolve by closing the TRAMP sessions and the TRAMP buffers.

    Sample DB connection and SQL query.

    #+NAME: get-current-time-from-db-server
    #+BEGIN_SRC sql :engine postgresql :dbhost thebigdbserver :dbuser myuser :dbpassword "VerySecretUnsharedString" :database namesnumbers
    select current_timestamp;
    #+END_SRC
    

    Executing the CODE-BLOCK with C-c C-c will give the following result:

    #+RESULTS: get-current-time-from-db-server
    | current_timestamp   |
    |---------------------|
    | 2016-03-10 15:42:53 |
    
  • Code Evaluation

    The following lines need to added to your .emacs file if you want org-babel to recognize the various language-modes.

    ;; Org-babel
    ; Must have org-mode loaded before we can configure org-babel
    (require 'org-install)
    ; Some initial languages we want org-babel to support
    (org-babel-do-load-languages
     'org-babel-load-languages
     '(
       (sh . t)
       (python . t)
       (R . t)
       (ruby . t)
       (ditaa . t)
       (dot . t)
       (octave . t)
       (sqlite . t)
       (perl . t)
       ))
    

    Tired of being prompted for evaluating each and every source-block when exporting? Set Emacs variable org-export-babel-evaluate to nil to prevent source-block code evaluation at export. Mark the following line from ( to ) (including both) and press C-c C-e - the mini-buffer should output 'nil'.

    (set 'org-export-babel-evaluate nil)
    

    Disable confirmation when evaluating source-blocks.

    (set 'org-confirm-babel-evaluate nil)
    
  • Properties

    Properties can be used to define variables.

    :PROPERTIES:
    :var: servername="staging-database-01.tld"
    :END:
    

    Check uptime of server via property/variable.

    #+BEGIN_SRC 
      ssh $servername uptime
    #+END_SRC
    
  • Sessions

    Code blocks can share a session, making it possible to

    Create a session.

    #+BEGIN_SRC sh :results output :session dbserver
      ssh the_database_server
    #+END_SRC
    

    Get hostname using session.

    hostname
    

Exporting and publishing.

Org-Mode support exporting to a range of formats. LaTex, PDF, HTML, OpenDocument amongst others.

  • C-c C-e - brings up the Export menu.

I publish the website using FTP having the credentials in the .netrc file

machine SERVER-NAME login USERNAME port PORT-NUMBER password SECRET-PASSWORD

My current ~/.emacs.d/publish.el file - as referred to in the ~/.emacs file.

If you want to test these settings without adding them to your Emacs setting then paste the following to an Emacs buffer and press C-x C-e at the end of the first line, at then end of the second line and at the end of the last line.

(require 'ox-publish)
(setq private-publish-ftp-proj (concat "/ftp:" web-ftp-user "@" web-ftp-host ":web/"))
(setq org-publish-project-alist
      '(

        ("web-text"
         :base-directory "~/Documents/roi.torkilsheyggi.fo/org/"
         :base-extension "org"
         :publishing-directory "~/Documents/roi.torkilsheyggi.fo/web/"
         :recursive t
         :publishing-function org-html-publish-to-html
         :headline-levels 3
         :auto-preamble t
         :auto-sitemap t
         :sitemap-filename "index.html"
         :sitemap-title "roi.torkilsheyggi.fo"
         )

        ("web-static"
         :base-directory "~/Documents/roi.torkilsheyggi.fo/org/"
         :base-extension "css\\|js\\|png\\|jpg\\|gif\\|pdf\\|mp3\\|ogg\\|swf"
         :publishing-directory "~/public_html/"
         :recursive t
         :publishing-function org-publish-attachment
         )

        ("web-ftp"
         :base-directory "~/Documents/roi.torkilsheyggi.fo/org/"
         :base-extension "org"
         :publishing-directory private-publish-ftp-proj
         :publishing-function org-html-publish-to-html
         :completion-function (lambda () (let ((htmlfile private-publish-ftp-proj 
                                                                 ))))
         :section-numbers nil
         :with-toc t
         :html-preamble t
         :auto-sitemap t
         :sitemap-filename "index.html"
         :sitemap-title "roi.torkilsheyggi.fo"
         )

        ("web" :components ("web-text" "web-static" "web-ftp"))

        ))

Exporting to PDF

The PDF exporting feature requires texlive-latex-base - installable on Ubuntu (and perhaps Debian) with:

sudo aptitude install texlive-latex-base texlive-latex-extra

Missing the texlive-latex-extra package will give you this error:

LaTeX Error: File `wrapfig.sty' not found.

Sending Email

Sending email is a built-in feature. It supports encryption.

  • C-x m - compose-mail.
  • C-c C-c - send email, close buffer.

Attach document whilst in email buffer.

  • C-c C-a - prompts for file-name to attach along with description and message.

Gnus - Gnus Network User Services

Gnus is a news-reader and email client. Remember to stop it using 'q' so that it can save any changes.

  • M-x gnus - Start Gnus. This shows the Group buffer.

The credentials for Gnus are stored in the ~/.authinfo file:

machine SERVER-NAME login USERNAME port PORT-NUMBER password SECRET-PASSWORD

Group Buffer

  • g - Fetch messages.
  • q - Quit Gnus.
  • Enter - Open the selected Group Summery buffer.
  • c - Mark unread messages selected group as read.
  • # - Mark a group (you can mark multiple and perform actions on all selected).
  • l - show only groups with unread messages.
  • L - show all groups.
  • u - toggle subscription of selected folder.
  • m - Compose new message.
  • C-u RET - show all messages in group.
  • C-u SPC - Show all messages in group.

Summery Buffer

  • Space or Enter - show the selected message.
  • Tab - show the selected message and jump to the message window.
  • n - Show next unread message.
  • p - Show previous message.
  • d - Mark as read.
  • r - Reply without citing the message.
  • R - Reply citing the selected message.
  • f - Reply to all without quoting message.
  • F - Reply to all quoting the whole message.
  • C-c C-f - Forward message quoting current message.
  • M-g - Refresh the current group/mailbox-folder.
  • C-u M-g - Show all messages in group.
  • M-u - Remove all marking.
  • T T - Toggle threading.
  • C-u g - Show message source. Use 'g' to switch back to normal view.
  • t - Toggle headers.
  • W w - Enable word-wrap on selected message.

Other notes

  • C-c C-d - Save message as draft.
  • C-c C-k - Cancel messages.
  • C-c C-m f - Attache file to message.
  • D e - Edit draft messages (from Summary view).
  • D s - Send draft messages (from Summary view).

Actions in Summary View

Note: Gnus key-bindings! These are not META or CTRL key-bindings - B is literal 'B' and M is literal 'M'

  • M P R - Mark articles with Subject matching regex.
  • M P U - Unmark ALL articles
  • M P i - Invert markings - mark unmarked and unmark marked
  • & Execute a command on all messages with header matching given regex.
  • M-& Executa a command on all the messages that have the process mark
  • B m - move marked messages to group (will prompt for group name - may have to exist before issuing move command).
  • M-s Search all messages for string matching regex (forward).
  • M-r Search all messages for string matching regex (backwards).

Splitting Mail

"Splitting mail" is emacs jargon for mail-filters.

Splitting mail works with Emacs24 and IMAP using nnmail-split-methods and "nnimap-split-methods default" under gnus-select-method.

Example

;; DavMail localhost IMAP
(setq gnus-select-method
      '(nnimap "localhost"
               (nnimap-stream network)
               (nnimap-address "localhost")
               (nnimap-authenticator login)
               (nnimap-server-port 1143)
           (nnimap-split-methods default)
               ))
;; SMTP gnus
(setq mail-host-address "localhost")
(setq user-full-name "Name Surname")
(setq user-mail-address "user@domain.tld")


;; Gnus Splitting mail
(setq nnmail-inbox "INBOX") ;; enable splitting on 'INBOX'
(setq nnmail-split-methods
  '(("TestEnv" "^From:.*\\(user@test-server.*\\)")   
    ("Reports" "^Subject: Daily report.*")
    ))

IRC

  • M-x erc - starts ERC prompts for IRC server, nick and password.
  • M-x freenode - starts erc and connects to the freenode IRC network. Will prompt for nick and password.

eww - Emacs Web Browser

  • M-x eww - start the browser, prompts for URL.
  • g - reload page.
  • l - go back to previously visited page.
  • r - go forward to next visited page.
  • d - dowload current link.
  • & - open with external (default) browser.
  • h - show browsing history.
  • b - add bookmark.
  • B - list bookmarks.
  • C - Show cookies.
  • q - quit browser.

Code and Programming

PDE (Perl Development Environment)

  • C-c s - compile-dwim-compile
  • C-c r - compile-dwim-run
  • C-M-= - auto indent the whole buffer.
  • C-; - Comment/Uncomment marked region of code or add comment behind code on current line.
  • C-c C-t C-t - Clean up region or buffer by passing through Perl Tidy.
  • C-c C-k - Review code using Perl::Critic. Prompts for the full command. Options (like –exclude= and –harsh) can be added manually.

Ediff

Ediff is a very capable diff interface. When started it prompts you for file A (defaults to current buffer) and file B.

Start it with: M-x ediff (then chose default file or type in filename of first and second file to compare).

  • n - jump to next diff.
  • p - jump to previous diff.
  • a - move file A's diff to file B.
  • b - move file B's diff to file A.
  • ? - expand the help window.

If you want to diff two revisions of a verion-controlled file: M-x ediff-revision

Version Control/Revision Control System

The built in version control system works with a range of tools. Git, Subversion, Mercurial, CVS, etc.

  • C-x v v - do "the next sensible thing"

This will:

  • first time: add a file to a repository if opened in a "working directory" (folder with versioned files)
  • second time: prompt for a commit message and commit change. Use C-c C-c to finish the commit.

List of changes:

  • C-x v l - version control log

Then press 'p' or 'n' (or up and down arrows) to move up and down between the commits.

Press 'd' to show the changes applied by the selected commit.

Magit

Magit is an even better Git interface for Emacs. It can be installed with el-get.

Usage

M-x magit-status show the current state of your project. Move the pointer to a given line and use the following key-bindings to stage, commit, push etc.

  • TAB - show the diff of the selected change.
  • s - stage your changes to be committed.
  • u - unstage your staged changes.
  • c c - Pressing c shows the Commit menu, pressing c again commits the staged changes. After entering the commit message use C-c, C-c to commit the change.
  • b b - Pressing b shoes the Branch menu, pressing b again lets you switch to an other branch.
  • P P - Pressing p shows the Push menu, pressing p again lets you push your changes to the current remote.
  • F F - Pressing F (note capitalized) shows the Pull menu, pressing F again lets you pull changes from the current remote.

Installation

I tried installing it with el-get:

M-x el-get-install RET magit RET

But that gave this error:

make: makeinfo: Command not found

Solved with:

sudo apt-get install texinfo

Lisp

Indent Whole Buffer

source: http://emacsblog.org/2007/01/17/indent-whole-buffer/

(defun iwb ()
  "indent whole buffer"
  (interactive)
  (delete-trailing-whitespace)
  (indent-region (point-min) (point-max) nil)
  (untabify (point-min) (point-max)))

SQL

SQL modes, clients for each database type. Prompts for credentials and opens a new (SQL) buffer

  • M-x sql-postgres - PostgreSQL client
  • M-x sql-sqlite - SQLite client
  • M-x sql-mysql - MySQL client

Via SSH

It is possible to use TRAMP to access databases remotely over SSH. Run the change-directory command and give it the following TRAMP format input "/ssh:hostname:" (replace "hostname" with the hostname you want to access). Then run the respective SQL client.

  • M-x cd - this will prompt for a new default directory.

Then input:

'/ssh:hostname:'
  • M-x sql-postgres

dot-emacs

My currently running ~/.emacs file.

;; Key-bindings
; Use SHIFT-TAB for variable auto-completion. The default key-binding is unavailable due to not using US keyboard layout.
(global-set-key [backtab] 'dabbrev-expand)

;; PDE - Perl Development Environment
(add-to-list 'load-path "~/.emacs.d/pde/lisp")
(load "pde-load")

;; credentials for auto-login etc. Will need to migrate this over to .netrc/.authrc/.authrc.gpg
(load "~/.emacs.d/.creds")
(setq erc-nickserv-passwords
      `((freenode     (("roi1979" . ,freenode-roi1979)))
        (DALnet       (("roi1979" . ,dalnet-roi1979)))))

;; emacs.d/publish.el
(load "~/.emacs.d/publish.el")

;; Org-babel
; Must have org-mode loaded before we can configure org-babel
(require 'org-install)
; Some initial languages we want org-babel to support
(org-babel-do-load-languages
 'org-babel-load-languages
 '(
   (sh . t)
   (python . t)
   (R . t)
   (ruby . t)
   (ditaa . t)
   (dot . t)
   (octave . t)
   (sqlite . t)
   (perl . t)
   ))

;; el-get
(add-to-list 'load-path "~/.emacs.d/el-get/el-get")

(unless (require 'el-get nil 'noerror)
  (with-current-buffer
      (url-retrieve-synchronously
       "https://raw.githubusercontent.com/dimitri/el-get/master/el-get-install.el")
    (goto-char (point-max))
    (eval-print-last-sexp)))

(add-to-list 'el-get-recipe-path "~/.emacs.d/el-get-user/recipes")
(el-get 'sync)


;; Emacs Custom Variables
(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.

 ;; ERC - Emacs Relay Chat
 '(erc-autojoin-channels-alist
   (quote
    (("freenode.net" "#perl" "#rex")
     ("dal.net" "#faroese_chat"))))
 '(erc-away-nickname "roi1979_away")
 '(erc-email-userid "roi1979")
 '(erc-modules
   (quote
    (autoaway autojoin button completion fill irccontrols list match menu move-to-prompt netsplit networks noncommands readonly ring stamp track)))
 '(erc-nick "roi1979")
 '(erc-prompt-for-nickserv-password nil)
 '(erc-prompt-for-password nil)
 '(erc-system-name "roi1979")
 '(erc-user-full-name "roi1979")
 ;; SMTP
 '(send-mail-function (quote smtpmail-send-it))
 '(smtpmail-smtp-server "mail.nemt.fo")
 '(smtpmail-smtp-service 25))
(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.
 )

;; enable services mode for auto login, etc.
(require 'erc-services)
(erc-services-mode 1)

;; ERC auto connect - disabled :/
;; (erc :server "mozilla.se.eu.dal.net" :port 6667 :nick "roi1979")

;; default irc servers to connect to
(defun dalnet ()
  "Connect to the dalnet"
  (interactive)
  (erc :server "mozilla.se.eu.dal.net"))

(defun freenode ()
  "Connect to the freenode"
  (interactive)
  (erc :server "irc.freenode.net"))

Emacs variables

Load the credentials list in your ~/.emacs file.

(load "~/.emacs.d/the-list.txt")

The contents of the-list.txt would be:

(setq the-ftp-user "ftpuser")
(setq the-ftp-host "ftp.domain.tld")
(setq the-ftp-pass "something")

Notes

If you would like to use org-mode to organize your Emacs settings use the following in your init.el to export emacs-list code-blocks from config.org to config.el.

(org-babel-load-file (concat user-emacs-directory "config.org"))

Corrections

Footnotes:

1

Depends on whether you start from the top or bottom OR left or right of the rectangle.

2

Headers need a CUSTOM ID property to be exported correctly to HTML. See Corrections : Org-mode Links section.

Author: Rói á Torkilsheyggi

Created: 2016-09-25 Sun 00:59

Emacs 24.5.1 (Org mode 8.2.10)

Validate