Skip to content

Latest commit

 

History

History
1554 lines (1438 loc) · 65.4 KB

emacs.org

File metadata and controls

1554 lines (1438 loc) · 65.4 KB

Bootstrap

Make sure that required dependencies are in place:

sudo aptitude install vcsh git gnutls-bin

Clone Emacs configuration files:

vcsh clone https://github.com/manandbytes/.emacs.d.git emacs

Enable running Emacs as a systemd user service:

systemctl enable --user emacs.service

Check the status of Emacs with:

systemctl status --user emacs.service

Why?

Github-hosted repositories

  • Org document (and a number of other formats as well) will be rendered as HTML (not without gotchas, though), using GitHub Markup library.
  • Commits and pull requests that include prose documents have the ability to represent those documents with source and rendered views, see Rendering differences in prose documents.

What to read

Customization

Emacs provides a convenient way to browse, change and save settings via M-x customize. By default, it saves these settings to an initialization file, ~/.emacs.d/init.el. To keep initialization file clean and simple, customizations must go to a separate file:

(setq custom-file (expand-file-name "custom.el" user-emacs-directory))

Refine workflow

Check these resources for more info:

  • emacswiki:CategoryCustomize
  • emacswiki:CustomizingAndSaving

Actual usecase for customization file is:

  • set some initial, non-Emacs-default, values;
  • configure with code and settings;
  • override some settings with a user-defined, per-host, values.

Loading should be deferred and take place as late as possible.

How to handle WIP items

Manually add header argument :tangle no to source block. See Extracting source code - The Org Manual for more details. Another way is to automagically not tangle source code blocks under TODO items.

How to sync manual modifications with M-x customize-*

Enable server mode

(require 'server)
(unless (server-mode)
  (server-mode))

Simplify ‘yes/no’ answers

(fset 'yes-or-no-p 'y-or-n-p)

Backups

By default, Emacs saves backup files (the files ending with ~) in the current directory. Stash them all under backups directory in user’s Emacs directory:

(defvar mn/backup-directory (expand-file-name "backups" user-emacs-directory))
(if (not (file-exists-p mn/backup-directory))
        (make-directory mn/backup-directory t))
(setq backup-directory-alist `((".*" . ,mn/backup-directory)))

Package management

Bootstrapping 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.github.com/dimitri/el-get/master/el-get-install.el")
    (goto-char (point-max))
    (eval-print-last-sexp)))

(el-get-bundle with-eval-after-load-feature)

Install platform-dependent packages

There are two flavors of platform-dependent packages:

  • Emacs package that should be installed in a platform-dependent way. In Debian, magit (and its dependencies) is available as deb:elpa-magit.
  • non-Emacs, platform-specific package, required by Emacs package. To open .class files automatically with javap, we need a platform-specific Java SDK implementation.

Platform-specific Emacs package

Some reasons to have platform-specific Emacs package are:

  • the package is functional on a specific platform only. There is a little sense in something working with Debian’s apt database when you’re on the system that doesn’t have apt;
  • you don’t want to use latest (but not always greatest) upstream version of the package;
  • Emacs package requires native, platform-specific tool. evernote-mode requires Ruby interpreter, and it’s much simplier to just install sudo apt-get install evernote-mode and let it drag in required Ruby implementation and all its transitive dependencies.

If the native Emacs package shares the same package name with el-get’s recipe:

(el-get-bundle js2-mode :type apt-get)

But if doesn’t, use :pkgname with the native package’s name:

(el-get-bundle seq :type apt-get :pkgname "elpa-seq")

Platform-specific dependency of Emacs package

For instance, pandoc-mode requires platform-specific binaries of the pandoc tool. While there is a native Debian package, deb:pandoc, neither this package provides Emacs’ mode nor there is a separate package for pandoc-mode Emacs.

Unfortunatelly, el-get doesn’t support installation of platform-specific packages. One of the (crazy) roads is to fool el-get and install such packages as :type apt-get:

(dolist (package '(make texinfo))
  (el-get-bundle apt-get:package :type apt-get))

apt-get package type’s status is poorly supported

el-get-dpkg-package-status relies on results from dpkg -l which knows nothing about virtual packages. As I’m mainly using deb:aptitude for package management anyway, let use it instead of dpkg:

(defun mn/el-get-aptitude-package-status (PACKAGE)
  "Use aptitude to check if PACKAGE is installed, taking into account also virtual packages"
  (let ((search-expr (format-spec "?or(?provides(%p), ?name(%p)) ?installed" (format-spec-make ?p PACKAGE))))
    (when (split-string (shell-command-to-string (format "aptitude search '%s' |cat" search-expr)) "[\n\r]" t)
      "ok")))

(advice-add #'el-get-dpkg-package-status :override #'mn/el-get-aptitude-package-status)
(el-get-dpkg-package-status "java-sdk")
(mn/el-get-aptitude-package-status "java-sdk")

Install packages over secure connection only

(setq el-get-allow-insecure nil)

Removing unnecessary packages

When trying out new packages, its easy to lose track of direct and indirect dependencies of (now) unused packages that could and should be removed, see issues Removing unnecessary packages and Feature request: el-get-autoremove.

(el-get-cleanup (mapcar 'el-get-source-name el-get-sources))

Hunt down errors in init files

(el-get-bundle seq :type github :pkgname "emacsmirror/seq")
(el-get-bundle bug-hunter :depends (seq))

Saving and restoring desktop state between sessions

(setq desktop-path (list user-emacs-directory))
(setq desktop-dirname user-emacs-directory)

By default, all the buffers in the desktop are restored at one go and may take quite some time. Do not restore immediately any buffers and let them be restored lazily, when Emacs is idle:

(setq desktop-restore-eager 0)

And finally enable desktop mode:

(desktop-save-mode 1)

Mode line

  • github:Malabarba/smart-mode-line
(el-get-bundle smart-mode-line
  (with-eval-after-load-feature smart-mode-line
    (add-to-list 'custom-safe-themes "a27c00821ccfd5a78b01e4f35dc056706dd9ede09a8b90c6955ae6a390eb1c1e")
    (if after-init-time (sml/setup)
      (add-hook 'after-init-hook 'sml/setup))
    (sml/apply-theme 'automatic)))

There are two forks of original emacswiki:powerline.el (references github:yuanotes/powerline, now unavailable):

  • github:milkypostman/powerline receiving updates from time to time, at least;
  • github:jonathanchu/emacs-powerline seems abandoned with latest commit on <2014-12-04 Thu> (or it is feature-complete, just works and needs no updates to fix bugs and add new features).
(el-get-bundle emacs-powerline
  (defadvice load-theme
      (after theme-reset-powerline (theme &optional no-confirm no-enable) activate)
    (el-get-reload 'emacs-powerline)))

Helm

(el-get-bundle helm
  (with-eval-after-load-feature (helm-command)
    (setq helm-M-x-fuzzy-match t))
  (helm-mode 1)
  (helm-adaptive-mode 1)
  (helm-autoresize-mode 1))
(el-get-bundle helm-swoop)

Changing the Location of Point

…to an absolute line number

Showing line numbers all the time is just noise but there is a case when they might be handy - when I have an error or log message and have to jump right to this line. To make this happen, show an absolute line number on the left fringe using linum-mode and on activating point-moving command only:

(el-get-bundle linum-mode :builtin "22")

(global-unset-key (kbd "M-g g"))
(global-unset-key (kbd "M-g M-g"))

(global-set-key (kbd "M-g l") 'goto-line)
(global-set-key [remap goto-line] 'mn/goto-line)

(defun mn/goto-line ()
  "Show line numbers temporarily, while prompting for the line number input"
  (interactive)
  (unwind-protect
      (progn
        (linum-mode 1)
        (hl-line-mode 1)
        (goto-line (read-number "Goto line: ")))
    (hl-line-mode -1)
    (linum-mode -1)))

…to a relative line number

And the only case when visible line numbers really matter is when you need to jump up to 11 lines or down to 5 lines from your current position.

  • show on activating point-moving command only;
  • show line number relative to the current line on the right fringe with linum-relative-mode
(el-get-bundle linum-relative
  :type http
  :url "https://raw.github.com/emacsmirror/emacswiki.org/master/linum-relative.el")

…to a (visible) word

(global-set-key (kbd "M-g w") 'avy-goto-word-or-subword-1)

Should I test key bindings?

(ert-deftest mn/goto-line ()
  (should (eq (global-key-binding (kbd "M-g l")) `goto-line))
  (should (eq (global-key-binding (kbd "M-g w")) `avy-goto-word-or-subword-1)))

Displaying Line and Column Numbers

Another valid use case for visible line numbers is when presenting your content to someone else (code reviews, presentation and alike) when it just easier to point to a specific text by line number.

Searching

(global-set-key [remap isearch-forward] 'helm-occur)

Buffer management

Use Helm to switch between buffers:

(el-get-bundle helm
  (global-set-key (kbd "C-x b") 'helm-buffers-list))

Close buffer with Ctrl-F4

(global-unset-key (kbd "C-x k"))
(global-set-key (kbd "<C-f4>") 'kill-buffer)

Networking

Check for network connectivity

To check the network connectivity state, get Connectivity property of org.freedesktop.NetworkManager D-Bus interface. It returns NM_CONNECTIVITY enumeration:

  • NM_CONNECTIVITY_UNKNOWN = 0
    Network connectivity is unknown.
        
  • NM_CONNECTIVITY_NONE = 1
    The host is not connected to any network.
        
  • NM_CONNECTIVITY_PORTAL = 2
    The host is behind a captive portal and cannot reach the full Internet.
        
  • NM_CONNECTIVITY_LIMITED = 3
    The host is connected to a network, but does not appear to be able to reach the full Internet.
        
  • NM_CONNECTIVITY_FULL = 4
    The host is connected to a network, and appears to be able to reach the full Internet
        
(require 'dbus)
(dbus-get-property
 :system "org.freedesktop.NetworkManager" "/org/freedesktop/NetworkManager"
 "org.freedesktop.NetworkManager" "Connectivity")

See emacswiki:GnusNetworkManager for experimental integration between Gnus agent and NetworkManager over D-Bus. Kill IMAP connections and unplug Gnus agent when network goes down, plug agent when network comes up.

As a fallback, if D-Bus is not available, nmcli utility from deb:network-manager may be used for the same purpose, see Emacs interface to Gnome’s Network Manager.

Use SOCKS 5 proxy

(require 'socks)
(setq socks-server '("Default server" "localhost" 9050 5)
      url-gateway-method 'socks)

Set proxies conditionally

Check Emacs GnuTLS

The GnuTLS library is an optional add-on for Emacs. Through it, any Emacs Lisp program can establish encrypted network connections that use “Secure Socket Layer” (SSL) and “Transport Layer Security” (TLS) protocols. The process of using SSL and TLS in establishing connections is as automated and transparent as possible.

Review tls-program variable

Default list of commands is dangerous as it uses --insecure flag when invoking gnutls-cli program:

("gnutls-cli --insecure -p %p %h"
 "gnutls-cli --insecure -p %p %h --protocols ssl3"
 "openssl s_client -connect %h:%p -no_ssl2 -ign_eof")

Communications

Encryption

Toggle automatic file encryption/decryption

(auto-encryption-mode 1)

Authentication sources

I’m not using .netrc, just .authinfo but encrypted instead of being it in clear-text:

(setq auth-sources '("~/.authinfo.gpg"))

Secret Service API

Secret Service API

Stack Exchange

SX provides a versatile experience for the Stack Exchange network within Emacs itself.

(el-get-bundle markdown-mode :type github :pkgname "jrblevin/markdown-mode")
(el-get-bundle let-alist :url "https://raw.githubusercontent.com/emacsmirror/let-alist/master/let-alist.el")
(el-get-bundle sx)

Allows insecure TLS communication

Check if Emacs’ gnutls-cli invocations called with –insecure flag? : emacs is still apply:

When using the stackexchange client for Emacs, I notice this every time in the Messages buffer:

Opening TLS connection to `api.stackexchange.com’… Opening TLS connection with `gnutls-cli –insecure -p 443 api.stackexchange.com’…done Opening TLS connection to `api.stackexchange.com’…done

Another option is to switch to the built-in GnuTLS integration.

Twitter

(el-get-bundle twittering-mode
  (setq twittering-oauth-use-ssl t
        twittering-use-master-password t
        twittering-timer-interval 300)
  (with-eval-after-load-feature twittering-mode
    (add-hook 'twittering-mode-init-hook
              (lambda ()
                (set-face-attribute twittering-uri-face nil :inherit `link)))))

Integrate different messaging systems under one umbrella?

  • Gnus already provides some backends for working with e-mails, news, RSS;
  • Stack Exchange;
  • Twitter.

Gnus

(el-get-bundle gnus :builtin "24")

Different identities

(el-get-bundle gnus-identities)

Remove duplicate messages

See Crosspost Handling and Duplicate Suppression for more details.

Reddit

There are two packages to read Reddit with Gnus:

(el-get-bundle nnreddit :type github :pkgname "paul-issartel/nnreddit"
  :features (nnheader nnoo gnus-group gnus-sum gnus-art gnus-util json mm-url))

and

(el-get-bundle gnus-reddit :type github :pkgname "fourier/gnus-reddit")

and one mode:

(el-get-bundle reddit-mode :type github :pkgname "death/reddit-mode"
  :features (thingatpt json url url-http tree-mode markdown-mode))

Browsing

(setq browse-url-browser-function 'browse-url-firefox)

Privacy

(setq url-user-agent "")
(setq url-privacy-level 'paranoid)
(url-setup-privacy-info)
(setq url-mime-accept-string "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 ")
(setq url-mime-charset-string nil)
(setq url-mime-language-string "en-US,en;q=0.5")
(setq url-mime-encoding-string "gzip, deflate")

Manually explore and test HTTP REST webservices

request.el

request.el is a HTTP request library with multiple backends (url.el and curl CLI) that helps to avoid imposing external dependencies such as curl to users while giving richer experience for users who have it.

(el-get-bundle request)

restclient.el

(el-get-bundle restclient)

Use restclient in Org’s source code blocks

#92: Implemented a minimal ob-restclient

(el-get-bundle ob-restclient
  :type github :pkgname "alf/ob-restclient.el" :depends (restclient org-mode))

Version control

Git

magit-revert-buffers is broken with outdated dash.el

Reverting buffers fails due to undefined function -non-nil:

@@ -678,8 +678,7 @@ When called interactively then the revert is forced."
             (let ((cnt (length buffers)))
               (when (> cnt 0)
                 (message "Reverting (up to) %s file-visiting buffer(s)..." cnt)
-                (setq cnt (length (-non-nil (mapcar #'magit-revert-buffer
-                                                    buffers))))
+                (setq cnt (length (mapcar #'magit-revert-buffer buffers)))
                 (if (> cnt 0)
                     (pcase magit-revert-buffers
                       (`t

While this change would work, it turned out that I just had an old version of dash.el, one of the Magit’s dependencies, without function -non-nil:

git log -S-non-nil --patch --summary -- *.el

With el-get it is not possible to extend existing package’s dependencies, so just amend receipe for dash:

(el-get-bundle dash :checkout "2.11.0")

Time machine

Step through historic versions of git controlled file:

(el-get-bundle git-timemachine)

Git configuration files

github:magit/git-modes, provides few extra modes Emacs major modes for various Git configuration files:

  • gitattributes-mode, will be available for .gitattributes, .git/info/attributes, and git/attributes files;
  • gitconfig-mode, enables the mode for .gitconfig, .git/config, git/config, and .gitmodules files;
  • gitignore-mode, enables the mode for .gitignore, .git/info/exclude, and git/ignore files.
(el-get-bundle git-modes)

Use conf-mode as a fall-back

(add-to-list 'auto-mode-alist '("/\\.gitconfig$" . conf-mode))

Magit

(el-get-bundle magit :type apt-get :pkgname "elpa-magit")
(global-set-key (kbd "C-x C-z") 'magit-status)

(el-get-bundle magit-view-file)

When committing, show a diff at the bottom of the commit buffer just to remind me of what is going to be committed:

(with-eval-after-load-feature (magit-commit)
  (add-to-list 'magit-commit-arguments "--verbose"))

Why upgrading to 2.2.0

Integrate Vcsh and Magit

(eval-after-load "tramp"
  '(progn
     (defconst tramp-vcsh-method "vcsh"
       "*When this method name is used, forward all calls to VCSH.")

     (setq tramp-methods (delq (assoc tramp-vcsh-method tramp-methods) tramp-methods))
     (add-to-list 'tramp-methods
                  (cons tramp-vcsh-method
                        '((tramp-login-program "vcsh")
                          (tramp-login-args (("enter") ("%h")))
                          (tramp-remote-shell "/bin/sh")
                          (tramp-remote-shell-args ("-c")))))

     (defun tramp-parse-vcsh (_ignore)
       "List all repositories"
       (mapcar (lambda (x) (list nil x)) (split-string (shell-command-to-string "vcsh list"))))
     (tramp-set-completion-function tramp-vcsh-method '((tramp-parse-vcsh "")))))

Improve filename completion

Vcsh provides a list of all files tracked by all repositories:

vcsh list-tracked

or a specific one:

vcsh list-tracked emacs

Use this feature to provide more fine-grained completion for repositories and files.

(defconst tramp-vcsh-file-name-handler-alist
  '((expand-file-name . tramp-vcsh-handle-expand-file-name)))

(add-to-list 'tramp-foreign-file-name-handler-alist
             (cons tramp-vcsh-method 'tramp-vcsh-file-name-handler-alist))

(defsubst tramp-vcsh-file-name-p (filename)
  "Check if it's a filename for VCSH."
  (let ((v (tramp-dissect-file-name filename)))
    (string= (tramp-file-name-method v) tramp-vcsh-method)))

Vcsh source for Helm

(defun vcsh-tracked-files (&optional repo)
  "List all files tracked by vcsh."
  (mapcar (lambda (file)
            (cons file file))
          (if repo
              (split-string (shell-command-to-string (format "vcsh list-tracked %s" repo)))
            (split-string (shell-command-to-string "vcsh list-tracked")))))

(helm :sources '((name . "vcsh")
                 (candidates-process . vcsh-tracked-files)
                 (volatile)))

Register Vcsh as VC backend

(add-to-list 'vc-handled-backends 'Vcsh)
(defvar vc-vcsh-master-templates nil "Templates for Vcsh")

(provide 'vc-vcsh)
(split-string (shell-command-to-string "vcsh list-tracked"))

Describe default key bindings

Enable for files with complete conflict markers

Integrate Magit and Gerrit Code Review

Google Gerrit provides web based code review and repository management for the Git version control system.

(el-get-bundle magit-gerrit)

Configuration

By default, will recognize Git repository as Gerrit one only when:

  • there is remote with name origin;
  • this remote’s URL uses SSH scheme and port 29418.

In other words, will work with ssh://user@git.eclipse.org:29418/equinox/rt.equinox.p2 out of the box. Working with non-anonymous HTTPS (like https://user@git.eclipse.org/r/a/equinox/rt.equinox.p2) will require setting magit-gerrit-ssh-creds.

Seems there is no support for anonymous access via https://git.eclipse.org/r/a/equinox/rt.equinox.p2.

git-gutter

(el-get-bundle git-gutter)

Integration with GitHub

Number of integrations has been built on top of github:sigma/gh.el, GitHub API library for Emacs:

gh.el-based integrations

  • github:sigma/magit-gh-pulls, Magit plugin for dealing with GitHub pull requests
(el-get-bundle magit-gh-pulls)
  • github:domtronn/magit-gh-issues.el, Magit plugin which allows users to see, open, comment and label GitHub issues
(el-get-bundle magit-gh-issues :type github :pkgname "domtronn/magit-gh-issues.el")
  • github:jtatarik/magit-gitflow, Magit plugin for github:petervanderdoes/gitflow-avh, AVH Edition of the git extensions to provide high-level repository operations for Vincent Driessen’s branching model:
(el-get-bundle magit-gitflow)

Other

  • github:jtamagnan/ghi.el, Emacs interface for ghi command-line tool. github:stephencelis/ghi is available as deb:ghi.
  • deb:github-cli, command-line interface to the GitHub Issues API

Misc

  • magit-svn

Mercurial

Enable proper mode for Mercurial’s configuration files:

(dolist (pattern '("/etc/mercurial/hgrc\\.d/.+\\.rc\\'" "/etc/mercurial/hgrc\\'" "/\\.hg/hgrc\\'" "/\\.hgrc\\'"))
  (add-to-list 'auto-mode-alist `(,pattern . conf-mode)))
(el-get-bundle monky :type github :pkgname "ananthakumaran/monky"
  (with-eval-after-load-feature monky
    (setq monky-process-type 'cmdserver)))

Enable conf-mode for other configuration files

Check man hgrc for supported filenames and locations, for multiple platforms.

Rebase mode for Hg a-la git-rebase-mode

Define mode

(define-derived-mode hg-histedit-mode git-rebase-mode "Hg Histedit"
  "Major mode for editing of a Hg histedit file.

Histedit files are generated when you run 'hg histedit <commit>'.
They describe how Hg should edit changeset history. See the
documentation for histedit (e.g., by running 'hg help histedit'
or 'hg help -e histedit' at the command line) for details.")

(add-to-list 'auto-mode-alist '("/hg-histedit-.*\\.txt\\'" . hg-histedit-mode))

Redefine keybindings

;; git-rebase-mode-map

Make only a part of the buffer read-only

(defun make-region-read-only (start end)
  (interactive "*r")
  (let ((inhibit-read-only t))
    (put-text-property start end 'read-only t)))

(defun make-region-read-write (start end)
  (interactive "*r")
  (let ((inhibit-read-only t))
    (put-text-property start end 'read-only nil)))

Manage a list of recently opened files

(require 'recentf)
(setq recentf-max-menu-items 100
      recentf-save-file (expand-file-name ".recentf" user-emacs-directory))
(recentf-mode 1)

Fonts

Use font Awesome in the mode line

Make parentheses less visible by dimming them

(el-get-bundle paren-face
  (with-eval-after-load-feature paren-face
    (global-paren-face-mode 1)))

Dim parentheses in other modes (i.e., Java, XML etc)

While this face is intended to be used with Lisp modes, it also works with other major modes, just add the mode to the value of paren-face-modes.

By default only parentheses are dimmed, customize option paren-face-regexp if you also want to dim brackets or braces. If you want to use a differnt regexp in different major-modes, then use a the mode hook to set the buffer local value.

Default font

Use window-system dependent default frame parameters:

(setq window-system-default-frame-alist
      '((x
         (font . "Liberation Mono"))
        (w32
         (font . "Lucida Sans Typewriter"))
        (nil)))

Differentiate Microsoft Windows and Cygwin

(when (member system-type '(windows-nt cygwin))
  (set-face-attribute 'default nil :family "Lucida Sans Typewriter"))
(when (eq system-type 'gnu/linux)
  (set-face-attribute 'default nil :family "Liberation Mono" :height 100))

Build face’s attributes only once depending on system-type

Vagrant

(el-get-bundle vagrant)
(el-get-bundle vagrant-tramp
  (vagrant-tramp-add-method))

Docker

(el-get-bundle spotify/dockerfile-mode
  (add-to-list 'auto-mode-alist '("Dockerfile" . dockerfile-mode)))

TRAMP integration for Docker containers

(el-get-bundle emacs-pe/docker-tramp.el)

Searching

Use ack, ack-grep but on steroids, silversearcher-ag:

(el-get-bundle ag :type apt-get :pkgname "silversearcher-ag-el")

UML Diagrams

PlantUML

PlantUML : Integration with Emacs mentions two ways to embed UML diagrams:

Generic source code block in plantuml-mode

#+BEGIN_SRC plantuml :file classes.png
  Alice -> Bob: Authentication Request
  Bob --> Alice: Authentication Response
#+END_SRC

are available with plantuml-mode:

(el-get-bundle plantuml-mode
  :post-init nil
  :prepare nil
  (with-eval-after-load 'org
    (add-to-list 'org-modules 'ob-plantuml)
    (add-to-list 'org-babel-load-languages '(plantuml . t))
    (let* ((jar-files (shell-command-to-string "dpkg -L plantuml |grep jar"))
           (mn/plantuml-jar (car (split-string jar-files))))
      (when (file-exists-p mn/plantuml-jar)
        (setq org-plantuml-jar-path mn/plantuml-jar
              plantuml-jar-path mn/plantuml-jar)))))

Special block of type _UML

#+BEGIN_UML
  Alice -> Bob: Authentication Request
  Bob --> Alice: Authentication Response
#+END_UML

should be available after installing

(el-get-bundle org-export-blocks-format-plantuml
  :type http
  :url "https://raw.github.com/emacsmirror/emacswiki.org/master/org-export-blocks-format-plantuml.el")

While org-exp-blocks.el — pre-process blocks when exporting org files still using org-exp-blocks, it should not be used anymore:

commit ee3b3eb421e74339119d730a5bf896a070b2ed60
Author: Bastien Guerry <bzg@altern.org>
Date:   Sat Mar 2 10:26:22 2013 +0100

    Remove contrib/oldexp/.

    If users want to use the old exporter, they now need
    to checkout an earlier version of Org.

 delete mode 100644 contrib/oldexp/README
 delete mode 100644 contrib/oldexp/org-ascii.el
 delete mode 100644 contrib/oldexp/org-beamer.el
 delete mode 100644 contrib/oldexp/org-docbook.el
 delete mode 100644 contrib/oldexp/org-exp-bibtex.el
 delete mode 100644 contrib/oldexp/org-exp-blocks.el
 delete mode 100644 contrib/oldexp/org-exp.el
 delete mode 100644 contrib/oldexp/org-export-generic.el
 delete mode 100644 contrib/oldexp/org-freemind.el
 delete mode 100644 contrib/oldexp/org-html.el
 delete mode 100644 contrib/oldexp/org-icalendar.el
 delete mode 100644 contrib/oldexp/org-jsinfo.el
 delete mode 100644 contrib/oldexp/org-latex.el
 delete mode 100644 contrib/oldexp/org-lparse.el
 delete mode 100644 contrib/oldexp/org-odt.el
 delete mode 100644 contrib/oldexp/org-publish.el
 delete mode 100644 contrib/oldexp/org-special-blocks.el
 delete mode 100644 contrib/oldexp/org-taskjuggler.el
 delete mode 100644 contrib/oldexp/org-xoxo.el
 delete mode 100644 contrib/oldexp/org2rem.el

Display generated images inline

Evaluating plantuml-mode source code block inserts RESULTS block with a link to the generated file. When clicked, the image will be opened in a new buffer. To make the image visible in the same buffer inline:

  • Toggle the display of inline images (disabled by default) by pressing C-c C-x C-v
  • After re-evaluating a plantuml-mode source code block, press C-c C-x C-M-v to refresh the display of inline image.

Under the hood, all this boils down to these functions:

  • org-redisplay-inline-images
  • org-display-inline-images
  • org-toggle-inline-images
  • org-remove-inline-images

Requires plantuml.jar to be available

Still have to find the automagic way to manage native dependencies required by Emacs packages, like in this case, deb:plantuml Debian package provides required functionality.

Puppet

(el-get-bundle puppet-mode)
(el-get-bundle flymake-puppet)

librarian-puppet, a manager for the Puppet modules, uses files Puppetfile, Modulefile or metadata.json as a source of modules’ dependencies:

(add-to-list 'auto-mode-alist '("Puppetfile$" . puppet-mode))

Use Puppet Forge API

The Puppet Forge API:

The Puppet Forge API (hereafter referred to as the Forge API) provides quick access to all the data on the Puppet Forge via a RESTful interface. Using the Forge API, you can write scripts and tools that interact with the Puppet Forge website. For example, you can use it to create custom aggregations against module metadata.

Tools like the puppet module tool and librarian-puppet use the Forge API to query and install modules; additional tools, such as Geppetto or Pulp, leverage the API to manage development workflow.

Missing flymake-puppet -> puppet-mode

grimradical/puppet-flymake vs benprew/flymake-puppet - what to chose?

There are two modes to check Puppet manifests against the Puppetlabs style guide:

  • github:grimradical/puppet-flymake
  • github:benprew/flymake-puppet

Both (provide 'flymake-puppet), use puppet-lint and are based on Steve Purcell’s flymake-coffe. For now, let use github:benprew/flymake-puppet.

Web x.0

(el-get-bundle web-mode)
(el-get-bundle js2-mode :type apt-get :pkgname "elpa-js2-mode")
(el-get-bundle skewer-mode)

Working with files

Open files as another user

(with-eval-after-load-feature 'tramp
  (defun mn/sudo-mode-line-function ()
    (when (string-match "^/su\\(do\\)?:" default-directory)
      (setq mode-line-format
            (format-mode-line mode-line-format
                              'font-lock-warning-face))))

  (defvar sudo-tramp-prefix
    "/sudo:"
    (concat "Prefix to be used by sudo commands when building tramp path "))

  (defun mn/sudo-file-name (filename)
    (set 'splitname (split-string filename ":"))
    (if (> (length splitname) 1)
        (progn (set 'final-split (cdr splitname))
               (set 'sudo-tramp-prefix "/sudo:"))
      (progn (set 'final-split splitname)
             (set 'sudo-tramp-prefix (concat sudo-tramp-prefix "root@localhost:"))))
    (set 'final-fn (concat sudo-tramp-prefix (mapconcat (lambda (e) e) final-split ":")))
    (message "splitname is %s" splitname)
    (message "sudo-tramp-prefix is %s" sudo-tramp-prefix)
    (message "final-split is %s" final-split)
    (message "final-fn is %s" final-fn)
    (message "%s" final-fn))

  (defun mn/sudo-reopen-file ()
    "Reopen file as root by prefixing its name with sudo-tramp-prefix and by clearing buffer-read-only"
    (interactive)
    (let*
        ((file-name (expand-file-name buffer-file-name))
         (sudo-name (mn/sudo-file-name file-name)))
      (progn
        (setq buffer-file-name sudo-name)
        (rename-buffer sudo-name)
        (setq buffer-read-only nil)
        (message (concat "File name set to " sudo-name)))))
  (add-hook 'find-file-hooks 'mn/sudo-mode-line-function)
  (add-hook 'dired-mode-hook 'mn/sudo-mode-line-function))

Org

(el-get-bundle org-mode
  :checkout "release_8.3.1" :checksum "003a0f10695f035e844d844eacb1a86a6d2df934"

  (global-set-key (kbd "C-c .") 'org-time-stamp) ;; insert timestamp everywhere with 'C-c .'
  (global-set-key (kbd "C-c b") 'org-switchb) ;; switch between org buffers with 'C-c b'

  (setq org-modules nil)

  (with-eval-after-load-feature (org-clock)
    ;; http://orgmode.org/manual/Clocking-work-time.html
    (setq org-clock-persist t)
    (org-clock-persistence-insinuate)))
(org-reload)

Don’t tolerate trailing whitespace in Org files

(add-hook 'org-mode-hook
          '(add-hook 'before-save-hook 'delete-trailing-whitespace))

Agenda

Define a keyboard shortcut to dispatch agenda commands to collect entries to the agenda buffer:

(global-set-key (kbd "C-c a") 'org-agenda)

Pressing C-c a a shows the agenda view with current tasks at hands, with minimal distractions:

  • starts on the current day;
  • shows current day only;
  • ignores scheduled but not finished items.
(setq org-agenda-start-on-weekday nil
      org-agenda-span 'day
      org-scheduled-past-days 0)

Strike-through DONE agenda items:

(set-face-attribute 'org-agenda-done nil :strike-through t)

Highlight the agenda line under cursor:

(add-hook 'org-agenda-mode-hook (lambda () (hl-line-mode 1)))

All files in a default location to look for Org files will be used for agenda display:

(setq org-agenda-files `(,org-directory))

Custom link types

Legacy types

(dolist (abbrev '(("google" . "http://www.google.com/search?q=%s")
                  ("hotline" . "http://hotline.ua/sr?x=29&y=14&q=%s")
                  ("debianbug" . "http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=%s")
                  ("jsr" . "http://jcp.org/en/jsr/detail?id=%s")
                  ("eclipsebug" . "https://bugs.eclipse.org/bugs/show_bug.cgi?id=%s")
                  ("googleplay" . "https://play.google.com/store/apps/details?id=%s&hl=en")
                  ("wikipedia" . "http://en.wikipedia.org/wiki/%s")))
  (add-to-list 'org-link-abbrev-alist abbrev))

Github

(dolist (abbrev '(("github" . "https://github.com/%s")
                  ("gist" . "https://gist.github.com/%s")))
  (add-to-list 'org-link-abbrev-alist abbrev))

Wikisites dedicated to Emacs

(dolist (list '(("emacswiki" . "http://www.emacswiki.org/emacs/%s")
                ("wikemacs" . "https://wikemacs.org/wiki/%s")))
  (add-to-list 'org-link-abbrev-alist list))

Debian package

To add link to Debian package, use deb: link type followed by package’s name, i.e. deb:python3-minimal. Opening such link will show package’s details with apt-utils-show-package (from apt-utils feature provided by deb:debian-el package).

(el-get-bundle apt-get:debian-el)
(with-eval-after-load-feature (org)
  (defun org-deb-open (package)
    (if (require 'apt-utils nil 'noerror)
        (apt-utils-show-package-1 package t nil)
      (message (format "Unable to open 'deb:%s' link: Debian package debian-el is required" package))))
  (org-add-link-type "deb"
                     'org-deb-open
                     (lambda (path desc backend)
                       (format "<a href=\"https://tracker.debian.org/pkg/%s\">%s</a>" path path))))

Autocomplete package name

Search for text using helm-apt and use selected search result:

(when (fboundp 'helm-apt)
  (defun org-deb-complete-link (&optional arg)
    "Complete debian packages"
    (let (package link)
      (setq package (helm-apt arg))
      (setq link (concat "deb:" package)))))

Store link when in apt-utils-mode

(with-eval-after-load-feature apt-utils
  (defun org-deb-store-link ()
    "Store a link to debian package"
    (when (memq major-mode '(apt-utils-mode))
      ;; this is apt-utils-mode buffer
      (let* ((package (caar apt-utils-package-history))
             (link (concat "deb:" package)))
        ;; store package's description too
        (org-store-link-props :type "deb" :link link :description nil))))
  (add-hook 'org-store-link-functions 'org-deb-store-link))

Export to HTML as a link to package on debian.org

Handle history

(("python-cffi" . normal-installed) ("python-cryptography" . normal-installed) ("python-openssl" . normal-installed) ("mitmproxy" . normal))

A cleaner presentation

  • all lines are prefixed for display with the necessary amount of space;
  • all headlines are prefixed with additional stars, so that the amount of indentation shifts by org-indent-indentation-per-level spaces per level;
  • all headline stars but the last one are made invisible;
  • enable Visual Line Mode.
(add-hook 'org-mode-hook (lambda ()
                           (setq org-indent-indentation-per-level 1)
                           (org-indent-mode 1)
                           (visual-line-mode 1)))

Other ways to achieve almost the same are:

  • for all files by customizing the variable org-startup-indented
  • for individual files using property #+STARTUP: indent

(Re)viewing differences

Fix little inconveniences when viewing differences between org-mode buffers.

Comparing using Ediff mode

For each diff selection, that portion of the tree for each buffer is expanded. When moving to a new diff, the previous portion of the tree is collapsed and the area surrounding the new diff location is expanded:

(with-eval-after-load-feature (ediff-init org)
  (add-hook 'ediff-select-hook 'mn/ediff-org-unfold-tree)
  (add-hook 'ediff-unselect-hook 'mn/ediff-org-fold-tree)

  (defun mn/ediff-org-showhide (buf command &rest cmdargs)
    "If buffer exists and is org-mode then execute command"
    (if (and buf
             (eq (buffer-local-value 'major-mode (get-buffer buf)) 'org-mode))
        (save-excursion (set-buffer buf) (apply command cmdargs))))

  (defun mn/ediff-org-unfold-tree ()
    "Unfold tree at diff location"
    (mn/ediff-org-showhide ediff-buffer-A 'org-reveal)
    (mn/ediff-org-showhide ediff-buffer-B 'org-reveal)
    (mn/ediff-org-showhide ediff-buffer-C 'org-reveal))

  (defun mn/ediff-org-fold-tree ()
    "Fold tree back to top level"
    (mn/ediff-org-showhide ediff-buffer-A 'hide-sublevels 1)
    (mn/ediff-org-showhide ediff-buffer-B 'hide-sublevels 1)
    (mn/ediff-org-showhide ediff-buffer-C 'hide-sublevels 1)))

Jumping from Magit-provided diff

Unfold point of interest after switching to org-mode buffer from the diff section, i.e. from magit-status-mode:

(with-eval-after-load-feature (org magit-diff)
  (defun mn/org-reveal-magit-diff-visit-file (FILE &optional OTHER-WINDOW FORCE-WORKTREE)
    "When switching to buffer in `org-mode', show more context with `org-reveal'. See `magit-diff-visit-file'"
    (if (derived-mode-p 'org-mode)
        (org-reveal)))

  (advice-add #'magit-diff-visit-file :after #'mn/org-reveal-magit-diff-visit-file))

Capture

Press Ctrl-C r to quickly create:

  • task
  • note
(with-eval-after-load 'org-capture
  (setq org-capture-templates
        '(("t" "Task" entry
           (file "NewTasks.org")
           "* TODO %?\n%U\n%a" :prepend t)
          ("n" "Note" entry
           (file+headline "NewNotes.org" "")
           "* %?\n%U\n%a" :prepend t))))
(global-set-key (kbd "C-c r") 'org-capture)

Capturing the web

(require 'org-protocol)
(add-to-list 'org-modules 'org-protocol)
(require 'org-capture)
(add-to-list 'org-capture-templates
             '("w" "Web citation" entry (file+headline "NewNotes.org" "")
               "* %c\n%U\n\n#+BEGIN_QUOTE\n%i\n#+END_QUOTE"))

Refine the flow

  • :prepend to insert newly captured information at the top of the file
  • :immediate-finish not offer to edit the information, just file it away immediately
  • :kill-buffer to kill the buffer again after capture is finalized
  • :jump-to-captured to jump to the captured entry when finished

Storing plain links

Another option is github:kuanyui/copy-as-org-mode which allows to copy the contents in page as Org-mode markup and has some features missing in Org-mode Capture:

  • Copy all tabs of current window as a Org list.
  • Right click on anywhere of a page and copy the page title with URL as Org.
  • Right click on a link and copy it as Org.
  • Right click on an image and copy it as Org.

Working with source code blocks

(setq org-src-fontify-natively t)

Shell

(require 'ob-shell)
(add-to-list 'org-babel-load-languages '(shell . t))

By default, src_emacs-lisp{(pp org-babel-shell-names)} {{{results(("sh" "bash" "csh" "ash" "dash" "ksh" "mksh" "posh"))}}} are supported. To change these, use org-babel-shell-names:

(add-to-list 'org-babel-shell-names "zsh")

adds the Z shell to the list of names of shell supported by Babel shell code blocks.

There are two (at least) modes to work with shell code snippets:

  • shell-mode, major mode for interacting with an inferior shell
  • sh-mode (shell-script-mode is an alias), major mode for editing shell scripts

The latter one should be used for source code blocks, i.e. #+BEGIN_SRC sh, and add it to the list of languages which can be evaluated:

Navigation between blocks

(el-get-bundle hydra)
(defhydra hydra-org-src-block ()
  "Navigate through source code blocks"
  ("j" org-babel-previous-src-block "Prev")
  ("k" org-babel-next-src-block "Next"))

HTTP

(el-get-bundle ob-http :type github :pkgname "zweifisch/ob-http" :depends (s))
#+BEGIN_SRC http :pretty
GET https://api.github.com/repos/zweifisch/ob-http/languages
Accept: application/vnd.github.moondragon+json
#+END_SRC

Mark the results of source block evaluation with specific mode

The :wrap header argument is used to mark the results of source block evaluation. The header argument can be passed a string that will be appended to #+BEGIN_ and #+END_, which will then be used to wrap the results.

#+BEGIN_SRC sh :wrap "_SRC diff"
#+END_SRC

Define initial key bindings

Splitting source code blocks

Split existing source code block

(setq custom-file (expand-file-name "custom.el" user-emacs-directory))
(load custom-file t)

in two

(setq custom-file (expand-file-name "custom.el" user-emacs-directory))
(load custom-file t)

Exporting

(setq org-html-head-include-default-style nil
      org-html-head-include-scripts nil
      org-html-html5-fancy t
      org-html-htmlize-output-type 'css)

Attribution for the quotation

With the HTML5’s blockquote element you could provide a link to the source of the quote like:

<blockquote>
  The people recognize themselves in their commodities; they find their soul in their automobile, hi-fi set, split-level home, kitchen equipment.
  — <cite><a href="http://en.wikipedia.org/wiki/Herbert_Marcuse">Herbert Marcuse</a></cite>
</blockquote>

It would be nice if Org’s quote has support for the same feature during export, at least, to HTML:

#+BEGIN_QUOTE :link [[http://en.wikipedia.org/wiki/Herbert_Marcuse][Herbert Marcuse]]
The people recognize themselves in their commodities; they find their soul in their automobile, hi-fi set, split-level home, kitchen equipment.
#+END_QUOTE

org-html-quote-block from ox-html converts Org’s quote block to HTML.

Pandoc

(el-get-bundle pandoc-mode)
(el-get-bundle org-pandoc
  :depends (pandoc-mode)
  :type github :pkgname "robtillotson/org-pandoc")

MediaWiki

(el-get-bundle orgmode-mediawiki)

Blogging

Octopress/Jekyll

Jekyll plugins

http://jekyllrb.com/docs/plugins/#converters:

If you have a new markup language you’d like to use with your site, you can include it by implementing your own converter. Both the Markdown and Textile markup languages are implemented using this method.

github:eggcaker/jekyll-org implements Jekyll plugin that allows to write posts and pages in Org directly, without an explicit export. The main drawback is GitHub Pages disables custom Jekyll plugins.

Org export

There are several options to export Org document to other formats:

  • native Org export and publish features
  • pandoc, which supports multiple input/output formats but it’s an external dependency
  • custom extensions of native Org’s export/publish

Another one, github:yoshinari-nomura/org-octopress, provides ox-jekyl, an Org exporter implementation:

(el-get-bundle orglue :type github :pkgname "yoshinari-nomura/orglue")
(el-get-bundle emacs-ctable :type github :pkgname "kiwanami/emacs-ctable")
(el-get-bundle org-octopress
  :type github :pkgname "yoshinari-nomura/org-octopress"
  :depends (org-mode orglue emacs-ctable))
(el-get-bundle jekyll-el)
(el-get-bundle org-jekyll :depends (org-mode))
(el-get-bundle org2jekyll :depends (org-mode))
(el-get-bundle happyblogger
  :type github :pkgname "bmaland/happyblogger"
  :depends (org-mode))
+ octopress
  + source
    + blog   <- (1) You compose YYYY-MM-DD-title.org
    + _posts <- (2) ox-jekyll.el exports to YYYY-MM-DD-title.html (w/ YAML)
  + public
    + blog   <- (3) Jekyll exports to YYYY-MM-DD-title.html (w/o YAML).

Let github:ardumont/org2jekyll export your Org-mode file to Jekyll:

What’s the difference with org-jekyll?

You don’t need to add some alien yaml in your org-mode file. You add specific org-mode headers and this will be used to format the jekyll post.
  

What’s the difference with github:bmaland/happyblogger?

Only emacs’ dependencies (org, etc…) no external ruby script.
  

Translate text

Emacs interface to Google Translate

(el-get-bundle google-translate)

Org

(el-get-bundle ob-translate :type github :pkgname "krisajenkins/ob-translate" :depends google-translate)

Command-line

Translate Shell (formerly Google Translate CLI) via deb:translate-shell.

Legacy configuration

;; yes-or-no -> y-or-n
(fset 'yes-or-no-p 'y-or-n-p)

;; disable menu bar and tool bar
(menu-bar-mode -1)
(tool-bar-mode -1)
(scroll-bar-mode -1)

;; change current buffer's font size with C-+ and C--
(global-set-key (kbd "C-+") 'text-scale-increase)
(global-set-key (kbd "C--") 'text-scale-decrease)

;; edit html files with nxml-mode
(add-to-list 'auto-mode-alist '("\\.html$" . nxml-mode))
(add-to-list 'auto-mode-alist '("\\.htm$" . nxml-mode))
(add-to-list 'auto-mode-alist '("\\.xhtml$" . nxml-mode))
(add-to-list 'auto-mode-alist '("\\.xhtm$" . nxml-mode))

;; Maven POM files
(add-to-list 'auto-mode-alist '("\\pom.xml$" . nxml-mode))
(add-to-list 'auto-mode-alist '("\\pom-*.xml$" . nxml-mode))

;; Eclipse's project files
(add-to-list 'auto-mode-alist '("\\.project$" . nxml-mode))
(add-to-list 'auto-mode-alist '("\\.classpath$" . nxml-mode))

;; use markdown mode for *.md files
(add-to-list 'auto-mode-alist '("\\.md$" . markdown-mode))
(add-to-list 'auto-mode-alist '("\\.markdown$" . markdown-mode))

;; Gemfile is a Ruby file
(add-to-list 'auto-mode-alist '("Gemfile$" . ruby-mode))

;; Killing lines, inspired by http://xahlee.org/emacs/emacs_delete_whole_line.html
;; - kill the rest of the current line, C-k by default
;; - kill the whole line including its terminating newline, C-S-k
(global-set-key (kbd "C-S-k") 'kill-whole-line)

Highlight Parenthesis

Highlight matching brackets (including () [] {} 「」 『』 【】 〖〗 〈〉 《》 ‹› «») when cursor is on one of the bracket:

(show-paren-mode 1)
(setq show-paren-style 'parenthesis)

Highlight entire bracket expression

Not sure if it makes sense to highlight an entire expression on a permanent basis:

(setq show-paren-style 'expression)

ANSI colors in buffers

(with-eval-after-load-feature compile
  (ignore-errors
    (require 'ansi-color)
    (defun mn/colorize-compilation-buffer ()
      "Apply ANSI colors to buffers in `compilation-mode'"
      (when (eq major-mode 'compilation-mode)
        (ansi-color-apply-on-region compilation-filter-start (point-max))))
    (add-hook 'compilation-filter-hook 'mn/colorize-compilation-buffer)))

Java

; Java deployable artifacts
(add-to-list 'auto-mode-alist '("\\.jar$" . archive-mode))
(add-to-list 'auto-mode-alist '("\\.war$" . archive-mode))
(add-to-list 'auto-mode-alist '("\\.ear$" . archive-mode))
(add-to-list 'auto-mode-alist '("\\.sar$" . archive-mode))

;; BeanShell files
(add-to-list 'auto-mode-alist '("\\.bsh$" . java-mode))

;; AspectJ files
(add-to-list 'auto-mode-alist '("\\.aj$" . java-mode))

Debian provides a number of different JDK implementations, for now I don’t care and will require a virtual package deb:java-sdk (which means ‘any installed Java SDK’):

(el-get-bundle apt-get:java-sdk)

Automatically open .class files with javap:

(add-to-list 'file-name-handler-alist '("\\.class$" . javap-handler))

(defun javap-handler (op &rest args)
  "Handle .class files by putting the output of javap in the buffer."
  (cond
   ((eq op 'get-file-buffer)
    (let ((file (car args)))
      (with-current-buffer (create-file-buffer file)
        (call-process "javap" nil (current-buffer) nil "-verbose"
                      "-classpath" (file-name-directory file)
                      (file-name-sans-extension (file-name-nondirectory file)))
        (setq buffer-file-name file)
        (setq buffer-read-only t)
        (set-buffer-modified-p nil)
        (goto-char (point-min))
        (java-mode)
        (current-buffer))))
   ((javap-handler-real op args))))

(defun javap-handler-real (operation args)
  "Run the real handler without the javap handler installed."
  (let ((inhibit-file-name-handlers
         (cons 'javap-handler
               (and (eq inhibit-file-name-operation operation)
                    inhibit-file-name-handlers)))
        (inhibit-file-name-operation operation))
    (apply operation args)))

Match .class files based on the content of the file

  • Chapter 4. The class File Format describes the Java Virtual Machine class file format.
  • Each class file contains the definition of a single class or interface.
  • The first item in the ClassFile structure is the magic item which supplies the magic number identifying the class file format - CAFEBABE.
  • According to GNU Emacs Manual: Choosing Modes, Emacs tries to determine the major mode by looking at the text at the start of the buffer, based on the variable magic-mode-alist.
(add-to-list 'magic-mode-alist '("^\xCA\xFE\xBA\xBE" . javap-mode))

Eclipse integration

(el-get-bundle eclim :depends (dash popup s json))

Android

(el-get-bundle android-mode)

Clojure

(el-get-bundle queue :type github :pkgname "emacsmirror/queue"
  :checkout "7bc5d823b226962ee01531c42df5f0d530ca6f83")
(el-get-bundle cider :depends (spinner queue pkg-info dash clojure-mode))

Lisp

Navigate and edit LISP code with Oleh Krehel’s lispy package:

(el-get-bundle swiper)
(el-get-bundle avy)
(el-get-bundle iedit :type http :url "https://raw.githubusercontent.com/emacsmirror/emacswiki.org/master/iedit.el")
(el-get-bundle lispy :checkout "0.26.0")
(add-hook 'emacs-lisp-mode-hook '(lambda () (lispy-mode 1)))

Missing dependency lispy -> swiper

Prolog

(el-get-bundle prolog-el :type apt-get :pkgname "prolog-el")

Org

(el-get-bundle ob-prolog :depends prolog-el :type github :pkgname "ljos/ob-prolog")

Commands, frequency of use

Originally Emacs’s Command Frequency Statistics by Xah Lee, had been replaced with github:dacap/keyfreq:

(el-get-bundle keyfreq
  (keyfreq-mode 1)
  (keyfreq-autosave-mode 1))

Wrap text with punctuation

(el-get-bundle wrap-region :type github :pkgname "rejeep/wrap-region.el"
  (with-eval-after-load 'wrap-region
    (wrap-region-global-mode)))

Making presentations

Plain HTML/CSS presentations with:

  • deb:pandoc
  • Org

Illustrate with diagram

reveal.js

(el-get-bundle org-reveal)

impress.js

impress.js is a presentation framework based on the power of CSS3 transforms and transitions in modern browsers and inspired by the idea behind prezi.com. github:kinjo/org-impress-js.el

(el-get-bundle org-impress-js
  :after (progn
           (when (featurep 'ox-html) (unload-feature 'ox-html nil))
           (require 'ox-html))
  :features ox-impress-js)

Backward-incompatible change in recent ox-html

org-impress-js-headline: Symbol’s function definition is void: org-export-get-headline-id

Download original impress.js library

For convenience, org-impress-js includes some version of impress.js. Make it possible to install original one either by downloading it directly or with with some JS package manager. May be just install deb:libjs-impress.

Travis CI

(el-get-bundle org-link-travis
  :pkgname "manandbytes/org-link-travis"
  :depends (org-mode)
  (org-add-link-type "travis-build" 'org-link-travis/open-build-link))

More advanced ways to interact with Travis CI

  • Travis CI API is the API used by the official Travis CI web interface, so everything the web UI is able to do can also be accomplished via the API. There are different API endpoints for Travis CI for open source, Travis Pro and Travis Enterprise.
  • Travis CI Client (CLI and Ruby library)

Install other packages

(el-get-bundle nhexl-mode :type github :pkgname "emacsmirror/nhexl-mode")

(el-get-bundle crontab-mode
  :checksum f68206c1d10de68ba0685ce4cb14741c7ca7c648
  (add-to-list 'auto-mode-alist '("\\.cron\\(tab\\)?\\'" . crontab-mode))
  (add-to-list 'auto-mode-alist '("cron\\(tab\\)?\\."    . crontab-mode)))

Install and configure packages

(el-get 'sync)

Atlassian Confluence

Interact with remote Confluence instance

(el-get-bundle confluence-el
  :url "https://confluence-el.googlecode.com/svn/trunk/")

Org mode exporter

(el-get-bundle org-confluence
  :type github :pkgname "hgschmie/org-confluence" :depends org-mode)

File formats

systemd configuration files

(add-to-list 'auto-mode-alist '("\\.service$" . conf-mode))

Use for other file extensions and locations

  • .target, .socket, .link and some others are valid systemd configuration files’ extensions;
  • files are in /usr/lib/systemd, /lib/systemd and some other places.

YAML

(el-get-bundle yaml-mode)
(add-to-list 'auto-mode-alist '("\\.yaml$" . yaml-mode))

Torrent

(el-get-bundle torrent
  :type http
  :url "https://github.com/kensanata/elisp/raw/master/torrent.el")

EPUB

.EPUB files are just plain ZIP archives, so treat them as such:

(eval-after-load 'files
  '(progn
     (add-to-list 'auto-mode-alist '("\\.epub$" . archive-mode))))
(eval-after-load 'mule
  '(progn
     (add-to-list 'auto-coding-alist '("\\.epub$" . no-conversion))))

Spell checking

(el-get-bundle flyspell :builtin "22")
(dolist (hook '(org-mode-hook text-mode-hook))
  (add-hook hook 'flyspell-mode))

Use org-reveal in org-mode buffers

Error is invisible as subtree remains collapsed, org-reveal should be used.

Load local customizations

(load custom-file t)

Tips and tricks

Show the log

The buffer Messages is an Emacs’ log with a lot of information about whats going on under the hood. The dumb way to swith to this buffer is to treat it as any other buffer and M-x switch-to-buffer and select it. Using a default keybinding C-h e will show this buffer but without switching to it.