Browse Source

Big change: Emacs and packages come from nixpkgs

  * Use `nix build` to build everything (and install my config)

  * Perfect for use with Home Manager!
master
Peter J. Jones 1 year ago
parent
commit
a2e289fd38
Signed by: Peter Jones <pjones@devalot.com> GPG Key ID: 9DAFAA8D01941E49
54 changed files with 161 additions and 3988 deletions
  1. 1
    0
      .gitignore
  2. 0
    13
      GNUmakefile
  3. 1
    1
      LICENSE
  4. 17
    24
      README.md
  5. 0
    16
      bin/GNUmakefile
  6. 0
    4
      bin/eterm
  7. 109
    0
      default.nix
  8. 7
    1
      dot.emacs.el
  9. 0
    59
      emacs.mk
  10. 0
    6
      lisp/GNUmakefile
  11. 0
    21
      lisp/autoload.el
  12. 0
    18
      lisp/gnus-init.el
  13. 1
    1
      lisp/keys.el
  14. 18
    20
      lisp/loadpath.el
  15. 0
    1
      lisp/modes.el
  16. 0
    1
      lisp/options.el
  17. 0
    77
      lisp/packages.el
  18. 6
    14
      lisp/projector.el
  19. 0
    1
      lisp/suspend.el
  20. 0
    2
      modes/GNUmakefile
  21. 0
    17
      modes/bbdb-conf.el
  22. 0
    1
      modes/bm-conf.el
  23. 0
    2
      modes/circe-conf.el
  24. 1
    5
      modes/company-conf.el
  25. 0
    1
      modes/company-ghc-conf.el
  26. 0
    1
      modes/conf-mode-conf.el
  27. 0
    1
      modes/css-mode-conf.el
  28. 0
    1
      modes/deft-conf.el
  29. 0
    18
      modes/eshell-conf.el
  30. 0
    1
      modes/flycheck-conf.el
  31. 0
    2
      modes/haskell-mode-conf.el
  32. 0
    4
      modes/highline-conf.el
  33. 0
    1
      modes/js-conf.el
  34. 0
    1
      modes/markdown-mode-conf.el
  35. 0
    1
      modes/message-conf.el
  36. 0
    1
      modes/oauth2-conf.el
  37. 0
    20
      modes/oddmuse-conf.el
  38. 0
    1
      modes/plstore-conf.el
  39. 0
    1
      modes/rcirc-conf.el
  40. 0
    1
      modes/sgml-mode-conf.el
  41. 0
    1
      modes/simple-conf.el
  42. 0
    1
      modes/speedbar-conf.el
  43. 0
    2
      modes/yaml-mode-conf.el
  44. 0
    7
      modes/yasnippet-conf.el
  45. 0
    11
      scripts/check-emacs-output.sh
  46. 0
    16
      snippets/GNUmakefile
  47. 0
    7
      snippets/js-mode/function
  48. 0
    3
      third-party/GNUmakefile
  49. 0
    559
      third-party/boxquote.el
  50. 0
    317
      third-party/goto-chg.el
  51. 0
    919
      third-party/graphviz-dot-mode.el
  52. 0
    1109
      third-party/highline.el
  53. 0
    551
      third-party/oddmuse.el
  54. 0
    124
      third-party/rcirc-color.el

+ 1
- 0
.gitignore View File

@@ -1 +1,2 @@
*.elc
/result

+ 0
- 13
GNUmakefile View File

@@ -1,13 +0,0 @@
DIRS = third-party lisp modes snippets themes bin
DOTFILE = $(HOME)/.emacs
MAKE_ARGS = --no-print-directory

.PHONEY: all

all: $(DOTFILE)

all uninstall:
@ for d in $(DIRS); do $(MAKE) $(MAKE_ARGS) -C $$d $@ || exit 1; done

$(DOTFILE): dot.emacs.el
cp $< $@

+ 1
- 1
LICENSE View File

@@ -1,4 +1,4 @@
Copyright (c) 2008-2014 Peter Jones <pjones@devalot.com>
Copyright (c) 2008-2018 Peter Jones <pjones@devalot.com>

All rights reserved.


+ 17
- 24
README.md View File

@@ -1,31 +1,18 @@
# Emacs Configuration

This repository contains my [Emacs] [] configuration. I thought I'd
This repository contains my [Emacs][] configuration. I thought I'd
share it with the rest of the world because I'm doing a few
interesting things:

* As you can see, configuration is split among several files instead
of having one giant configuration file. More on this below.

* All files are compiled into byte code and installed in
`~/.emacs.d` automatically using [GNU Make] [].

* I'm slowly switching to the modern Emacs package system. Some of
the libraries I rely on are not yet available as packages so for
those I have scripts and Makefiles for downloading and installing
them.

* Libraries that I use that are available as packages are
automatically installed by Make.
* All files are compiled into byte code for faster loading

## Configuration Organization

* `bin`: Custom tools I use with Emacs.

* `download`: Libraries that are not yet available as packages (or I
haven't updated this directory yet) but are available as tarballs
or source code repositories. Automatically installed by Make.

* `lisp`: Basic configuration files organized by function.

* `modes`: One configuration file for each mode that I have
@@ -33,17 +20,23 @@ interesting things:
needed. See `lisp/modes.el` for more information. This makes a
big difference for Emacs start-up time.

* `scripts`: Scripts I use for compiling the configuration, etc.

* `themes`: Custom color themes.

* `third-party`: Libraries acquired via the [Emacs Wiki] [] that may
now be available as packages, but I haven't needed to update this
repo yet. I only plan on removing files from here as things break
after Emacs upgrades or I need a new feature.

* The `dot.emacs.el` file bootstraps all of this.

## Installation

What to try this configuration out without having to change your
existing configuartion in any way?

1. Install the [Nix Package Manager](https://nixos.org/nix/)

2. Run the following command:

nix build

3. Start Emacs:

./result/bin/emacs -q --load ./result/dot.emacs.el -f pjones:configure-new-frame

[emacs]: http://www.gnu.org/software/emacs/
[gnu make]: http://www.gnu.org/software/make/
[emacs wiki]: http://www.emacswiki.org/emacs/

+ 0
- 16
bin/GNUmakefile View File

@@ -1,16 +0,0 @@
FILES = $(shell ls | grep -v Makefile)

.PHONEY: all

all: $(HOME)/bin $(foreach f,$(FILES),$(HOME)/bin/$(f))
@:

$(HOME)/bin:
mkdir -p $@

define COPY_template
$(HOME)/bin/$(1): $(1)
install -m 0770 $(1) $(HOME)/bin/$(1)
endef

$(foreach f,$(FILES),$(eval $(call COPY_template,$(f))))

+ 0
- 4
bin/eterm View File

@@ -1,4 +0,0 @@
#!/bin/sh -eu

# Open an Emacs terminal.
e -ne '(pjones:terminal "'`pwd`'")'

+ 109
- 0
default.nix View File

@@ -0,0 +1,109 @@
{ pkgs ? (import <nixpkgs> {}).pkgs }:

let
emacs = pkgs.emacs.override {
withX = true;
withGTK2 = false;
withGTK3 = false;
};

emacsWithPackages = (pkgs.emacsPackagesNgGen emacs).emacsWithPackages;

pjones = pkgs.stdenv.mkDerivation rec {
name = "emacsrc";
src = ./.;

phases = [ "installPhase" ];
buildInputs = [ emacs'
pkgs.gitAndTools.gitFull # needed to compile magit config
];

installPhase = ''
mkdir -p "$out/bin" "$out/emacs.d"

export loadpathel="$out/emacs.d/lisp/loadpath.el"
substituteAll ${src}/dot.emacs.el "$out/dot.emacs.el"

cp -r ${src}/lisp ${src}/modes "$out/emacs.d/"
cp -r ${src}/bin/* "$out/bin/"
chmod u+w "$out"/emacs.d/*
chmod 0555 "$out"/bin/*

for f in ${emacs'}/bin/*; do
ln -nfs "$f" "$out/bin/"
done

for f in $(find "$out/emacs.d" -type f -name "*.el"); do
emacs -Q --quick --batch -f package-initialize \
--load "$loadpathel" -f batch-byte-compile "$f"
done
'';
};

emacs' =
emacsWithPackages (epkgs: (with epkgs.melpaPackages; [
beginend
bm
circe
circe-notifications
color-theme-sanityinc-tomorrow
company
company-ghc
company-quickhelp
company-statistics
dante
deft

# FIXME:
# dictionary broken :(

dired-filter
dired-narrow
dired-sidebar
dired-subtree
flx
flx-ido
flycheck
git-annex
god-mode
google-contacts
goto-chg
graphviz-dot-mode
indium
haskell-mode
highlight-indent-guides
htmlize
http
hydra
ido-completing-read-plus
idomenu
inf-ruby
js2-mode
magit
magit-annex
markdown-mode
nix-mode
noccur
no-littering
org-tree-slide
passmm
projectile
ruby-end
scad-mode
smex
smtpmail-multi
switch-window
yaml-mode

]) ++ (with epkgs.elpaPackages; [
rainbow-mode

]) ++ (with epkgs.orgPackages; [
org

]) ++ (with epkgs; [
pdf-tools

]));

in pjones

+ 7
- 1
dot.emacs.el View File

@@ -1,3 +1,9 @@
;; Important load settings:
(setq user-emacs-directory (expand-file-name "~/.cache/emacs"))

;; Prepare package management
(package-initialize)

;; Load other configuration files
(load (concat user-emacs-directory "pjones/lisp/loadpath"))
(load "@loadpathel@")
(pjones:load-configuration-files)

+ 0
- 59
emacs.mk View File

@@ -1,59 +0,0 @@
##############################################################################
SRC ?= $(wildcard *.el)
COMPILED = $(patsubst %.el,$(DEST)/%.elc,$(SRC))
PMADE_LOAD_PATH ?= $(CURDIR)/../lisp/loadpath.el
IGNORE_EMACS_WARNINGS ?= YES

##############################################################################
EMACS = emacs
EMACS_FLAGS = -Q --quick --batch
EMACS_FLAGS += --eval "(add-to-list 'load-path \".\")"
EMACS_FLAGS += --eval "(setq max-lisp-eval-depth 1200)"
EMACS_FLAGS += -l $(PMADE_LOAD_PATH)
EMACS_FLAGS += -f package-initialize
EMACS_FLAGS += -f batch-byte-compile

##############################################################################
CHECK_EMACS_OUTPUT ?= $(dir $(PMADE_LOAD_PATH))/../scripts/check-emacs-output.sh
EMACS_OUTPUT_FILE = emacs.out

##############################################################################
.PHONEY: all

##############################################################################
all: $(DEST) $(COMPILED) $(addprefix $(DEST)/,$(TO_REMOVE))
@:

##############################################################################
uninstall:
rm -f $(COMPILED)

##############################################################################
.SUFFIXES: .el .elc

##############################################################################
$(DEST)/%.elc: %.el
@ echo emacs compile $<
@ mkdir -p $(HOME)/.emacs.d/share/emacs/site-lisp
@ $(EMACS) $(EMACS_FLAGS) $< > $(EMACS_OUTPUT_FILE) 2>&1; exit
ifeq ($(IGNORE_EMACS_WARNINGS),)
@ if [ `$(CHECK_EMACS_OUTPUT) < $(EMACS_OUTPUT_FILE)` -ne 0 ]; then \
cat $(EMACS_OUTPUT_FILE); exit 1; \
fi
else
@ cat $(EMACS_OUTPUT_FILE)
endif
@ rm $(EMACS_OUTPUT_FILE)
@ mv $(<:.el=.elc) $@
@ if [ "$(EMACS_INSTALL_PACKAGES)" = "$<" ]; then \
echo emacs packages install; \
$(EMACS) -Q --batch -l $(PMADE_LOAD_PATH) -l $< -f "pjones:install-packages"; \
fi

##############################################################################
$(DEST):
mkdir -p $@

##############################################################################
$(addprefix $(DEST)/,$(TO_REMOVE))::
@ rm -f $@

+ 0
- 6
lisp/GNUmakefile View File

@@ -1,6 +0,0 @@
DEST = ~/.emacs.d/pjones/lisp
EMACS_INSTALL_PACKAGES = packages.el

${DEST}/themes.elc: ${DEST}/packages.elc

include ../emacs.mk

+ 0
- 21
lisp/autoload.el View File

@@ -1,21 +0,0 @@
;;; autoload.el -- Automatically load some libraries when their
;;; functions are called. Mostly for stuff in my third-party
;;; directory.

;; Go-to Last Change
(autoload 'goto-last-change "goto-chg" nil t)
(autoload 'goto-last-change-reverse "goto-chg" nil t)

;; Markdown mode
(autoload 'markdown-mode "markdown-mode" nil t)

;; Visual Bookmarks
(autoload 'bm-toggle "bm" "Toggle bookmark in current buffer." t)
(autoload 'bm-next "bm" "Goto bookmark." t)
(autoload 'bm-previous "bm" "Goto previous bookmark." t)

;; Highline (http://emacswiki.org/emacs/HighlineMode)
(autoload 'highline-mode "highline" "Highline Mode" t)

;; RHTML (.html.erb for Rails)
(autoload 'rhtml-mode "rhtml-mode" "RHTML" t)

+ 0
- 18
lisp/gnus-init.el View File

@@ -1,18 +0,0 @@
;;; gnus.el -- Settings that need to configured before Gnus can run.
(eval-when-compile
(require 'gnus)
(require 'gnus-start)
(require 'gnus-agent)
(require 'nnfolder)
(require 'nndraft))

;; Bring in an external Gnus, but first we need to set some location
;; variables otherwise Gnus will load and create the wrong
;; directories.
(setq mail-default-directory (expand-file-name "~/.gnus.d/")
gnus-startup-file (concat mail-default-directory "newsrc")
gnus-directory (concat mail-default-directory "news")
gnus-agent-directory (concat mail-default-directory "agent")
message-directory (concat mail-default-directory "mail")
nnfolder-directory (concat mail-default-directory "mail")
nndraft-directory (concat mail-default-directory "mail"))

+ 1
- 1
lisp/keys.el View File

@@ -64,7 +64,7 @@
(define-key pjones:z-map (kbd "e") 'hydra-launch/body)
(define-key pjones:z-map (kbd "f") 'pjones:kill-file-name)
(define-key pjones:z-map (kbd "g") 'rgrep)
(define-key pjones:z-map (kbd "H") 'highline-mode)
(define-key pjones:z-map (kbd "h") 'hl-line-mode)
(define-key pjones:z-map (kbd "i") 'idomenu)
(define-key pjones:z-map (kbd "I") 'pjones:uuid)
(define-key pjones:z-map (kbd "J") 'pjones:journal)

+ 18
- 20
lisp/loadpath.el View File

@@ -1,32 +1,30 @@
;;; loadpath.el -- Correctly set my load-path variable. <
;;; loadpath.el -- Correctly set my load-path variable.

;; Some basic variables used by my other configuration files.
(defvar pjones:lisp-dir (concat user-emacs-directory "pjones/lisp/")
(defvar pjones:lisp-dir
(file-name-directory load-file-name)
"The directory where I store my general Emacs configuration files.")

(defvar pjones:modes-dir (concat user-emacs-directory "pjones/modes/")
(defvar pjones:modes-dir
(concat (file-name-directory (directory-file-name pjones:lisp-dir)) "modes")
"The directory where I keep mode-specific configuration files.")

(defvar pjones:site-lisp (concat user-emacs-directory "share/emacs/site-lisp")
"The directory where I install extra software packages like org-mode.")

(defvar pjones:lisp-files
'("packages" "themes" "code" "modes" "options" "autoload" "automode"
"functions" "interactive" "completion" "keys" "gnus-init"
"projector" "projects" "suspend")
'( "themes"
"code"
"modes"
"options"
"automode"
"functions"
"interactive"
"completion"
"keys"
"projector"
"projects"
"suspend"
)
"A list of my config files to load in the correct order.")

;; Add my "site-lisp" directory to load-path.
(add-to-list 'load-path pjones:site-lisp)

;; Add all directories in "site-lisp" to the load-path.
(dolist (d (directory-files pjones:site-lisp t))
(cond
((file-directory-p (concat d "/lisp"))
(add-to-list 'load-path (concat d "/lisp")))
((file-directory-p d)
(add-to-list 'load-path d))))

(defun pjones:load-configuration-files ()
"Load all of my lisp configuration files."
(dolist (file pjones:lisp-files)

+ 0
- 1
lisp/modes.el View File

@@ -1,5 +1,4 @@
;;; modes.el -- Load files from ~/.emacs.d/pjones/modes on demand.
(eval-when-compile (load "loadpath.el"))

;; Global minor modes
(winner-mode)

+ 0
- 1
lisp/options.el View File

@@ -2,7 +2,6 @@
;;; Commentary:
;;; Code:
(eval-when-compile
(load "./packages")
(require 'server))

;; Personal information

+ 0
- 77
lisp/packages.el View File

@@ -1,77 +0,0 @@
;;; packages.el -- Emacs package management
(require 'package)

(defvar pjones:package-archives
'(("melpa" . "http://melpa.org/packages/")
("org" . "http://orgmode.org/elpa/"))
"List of package archives to use with Emacs.")

(defvar pjones:packages
'( beginend
bm
circe
circe-notifications
color-theme-sanityinc-tomorrow
company
company-flx
company-ghc
company-quickhelp
company-statistics
dante
deft
dictionary
dired-filter
dired-narrow
dired-sidebar
dired-subtree
flx
flx-ido
flycheck
gist
git-annex
god-mode
google-contacts
graphviz-dot-mode
indium
haskell-mode
highlight-indent-guides
htmlize
http
hydra
ido-completing-read+
idomenu
inf-ruby
js2-mode
magit
magit-annex
markdown-mode
nix-mode
nlinum
noccur
no-littering
org
org-tree-slide
passmm
projectile
rainbow-mode
ruby-end
scad-mode
smex
smtpmail-multi
switch-window
yaml-mode
)
"A list of packages to ensure are installed at launch.")

;; Prepare package management
(package-initialize)

(dolist (archive pjones:package-archives)
(add-to-list 'package-archives archive))

;; Make sure all the packages are installed
(defun pjones:install-packages ()
(package-refresh-contents)
(dolist (p pjones:packages)
(when (not (package-installed-p p))
(package-install p t))))

+ 6
- 14
lisp/projector.el View File

@@ -4,9 +4,6 @@
;;
;;
;;; Code:
(eval-when-compile
(require 'highline))

(defvar pjones:projector-font-big
"Dejavu Sans Mono-18"
"A large font to use for projectors.")
@@ -24,34 +21,29 @@
(set-frame-font (or font pjones:projector-font-big)))

(defun pjones:projector-highline ()
"Toggle highline mode from outside Emacs."
"Toggle hl-line-mode mode from outside Emacs."
(with-current-buffer (window-buffer (selected-window))
(call-interactively 'highline-mode)))
(call-interactively 'hi-line-mode)))

(defun pjones:projector-next-line ()
"Move to the next line from outside Emacs."
(with-current-buffer (window-buffer (selected-window))
(call-interactively 'next-line)
(if highline-mode (highline-highlight-current-line))))
(call-interactively 'next-line)))

(defun pjones:projector-prev-line ()
"Move to the previous line from outside Emacs."
(with-current-buffer (window-buffer (selected-window))
(call-interactively 'previous-line)
(if highline-mode (highline-highlight-current-line))))
(call-interactively 'previous-line)))

(defun pjones:projector-recenter ()
"Places the current line at the top of the window from outside
Emacs."
(with-current-buffer (window-buffer (selected-window))
(recenter 0)
(if highline-mode (highline-highlight-current-line))))
(recenter 0)))

(defun pjones:projector-other-window ()
"Move to the other window from outside Emacs."
(select-window (next-window nil 0 'visible))
(if highline-mode (highline-highlight-current-line)))

(select-window (next-window nil 0 'visible)))

(define-minor-mode projector-mode
"Global minor mode that makes things look nice on a projector."

+ 0
- 1
lisp/suspend.el View File

@@ -1,6 +1,5 @@
;;; suspend.el --- Secure Emacs on a system suspend, sleep, lock, etc.
(eval-when-compile
(load "./packages.el")
(require 'circe))

;; Require libraries at run time.

+ 0
- 2
modes/GNUmakefile View File

@@ -1,2 +0,0 @@
DEST = ~/.emacs.d/pjones/modes
include ../emacs.mk

+ 0
- 17
modes/bbdb-conf.el View File

@@ -1,17 +0,0 @@
;;; bbdb-conf.el -- Big Brother Database config.
(eval-when-compile
(load "../lisp/packages.el")
(require 'bbdb))

(setq
; Cycling while completing email addresses:
bbdb-complete-mail-allow-cycling t

; Currently a remote server is the master:
bbdb-read-only t
bbdb-auto-revert t

; No popup-buffers:
bbdb-pop-up-window-size 0
bbdb-pop-up-layout 'one-line
bbdb-mua-pop-up nil)

+ 0
- 1
modes/bm-conf.el View File

@@ -1,6 +1,5 @@
;;; bm-conf.el -- Visual bookmarks configuration.
(eval-when-compile
(load "../lisp/packages.el")
(require 'bm))

(setq bm-highlight-style 'bm-highlight-only-fringe

+ 0
- 2
modes/circe-conf.el View File

@@ -1,7 +1,5 @@
;;; circe-conf.el -- Settings for circe.el
(eval-when-compile
(load "../lisp/packages.el")
(load "../lisp/functions.el")
(require 'circe))

(require 'circe-notifications)

+ 1
- 5
modes/company-conf.el View File

@@ -1,10 +1,8 @@
;;; company-conf.el --- company-mode configuration.
(eval-when-compile
(load "../lisp/packages.el")
(require 'company)
(require 'company-quickhelp)
(require 'company-statistics)
(require 'company-flx))
(require 'company-statistics))

;; Settings for company-mode:
(custom-set-variables
@@ -39,8 +37,6 @@
(define-key map (kbd "M-h") #'company-quickhelp-manual-begin)
(define-key map (kbd "<tab>") #'company-complete-common-or-cycle))

;; Enable fuzzy (flx) matching in company-mode.
(company-flx-mode +1)
(company-quickhelp-mode +1)
(company-statistics-mode))


+ 0
- 1
modes/company-ghc-conf.el View File

@@ -1,6 +1,5 @@
;;; company-ghc-conf.el --- company-mode ghc-mod backend.
(eval-when-compile
(load "../lisp/packages.el")
(require 'company-ghc))

(setq company-ghc-show-info t

+ 0
- 1
modes/conf-mode-conf.el View File

@@ -1,6 +1,5 @@
;;; conf-mode-conf.el -- Settings for conf-mode.
(eval-when-compile
(load "../lisp/code.el")
(require 'conf-mode))

(declare-function pjones:add-programming-hook "code.el")

+ 0
- 1
modes/css-mode-conf.el View File

@@ -1,6 +1,5 @@
;;; css-mode-conf.el -- Settings for css-mode.
(eval-when-compile
(load "../lisp/code.el")
(require 'css-mode)
(require 'company))


+ 0
- 1
modes/deft-conf.el View File

@@ -2,7 +2,6 @@
(eval-when-compile
(require 'deft))


(custom-set-variables
`(deft-directory ,(expand-file-name "~/notes/"))
'(deft-recursive t)

+ 0
- 18
modes/eshell-conf.el View File

@@ -2,7 +2,6 @@
(eval-when-compile
(require 'eshell))

(require 'powerline)
(require 'esh-mode)

(custom-set-variables
@@ -11,26 +10,9 @@
'(eshell-where-to-jump (quote after))
'(eshell-smart-space-goes-to-end t))

(defun pjones:eshell-prompt-function ()
(let* ((separator-left (intern (format "powerline-%s-%s"
(powerline-current-separator)
(car powerline-default-separator-dir))))
(face0 'powerline-active0)
(face1 'powerline-active1)
(face2 'powerline-active2)
(dir (abbreviate-file-name (eshell/pwd)))
(host (concat (user-login-name) "@" system-name))
(bar (list (powerline-raw host face0 'l)
(funcall separator-left face0 face1)
(powerline-raw dir face1 'l)
(funcall separator-left face1 'default))))
(concat (powerline-render bar)
"\n❯ ")))

(defun pjones:eshell-mode-hook ()
"Customize Eshell."
(require 'em-smart)
(setq eshell-prompt-function 'pjones:eshell-prompt-function)
(eshell-smart-initialize))

(defvar eshell-mode-hook "Why isn't this defined?" nil)

+ 0
- 1
modes/flycheck-conf.el View File

@@ -1,6 +1,5 @@
;;; flycheck-conf.el -- Configuration for flycheck.
(eval-when-compile
(load "../lisp/packages.el")
(require 'flycheck))

(custom-set-variables

+ 0
- 2
modes/haskell-mode-conf.el View File

@@ -1,7 +1,5 @@
;;; haskell-mode-conf.el -- Settings for Haskell mode.
(eval-when-compile
(load "../lisp/code.el")
(load "../lisp/functions.el")
(require 'cl)
(require 'haskell-mode))


+ 0
- 4
modes/highline-conf.el View File

@@ -1,4 +0,0 @@
;;; highline-conf.el -- Settings for highline-mode.
(eval-when-compile (require 'highline))
(setq highline-priority 10
highline-face 'highlight)

+ 0
- 1
modes/js-conf.el View File

@@ -2,7 +2,6 @@
;;; Commentary:
;;; Code:
(eval-when-compile
(load "../lisp/packages.el")
(require 'js))

;; JavaScript mode settings

+ 0
- 1
modes/markdown-mode-conf.el View File

@@ -1,6 +1,5 @@
;;; markdown-conf.el -- Settings for markdown-mode.
(eval-when-compile
(load "../lisp/code.el")
(require 'markdown-mode)
(require 'whitespace)
(require 'company))

+ 0
- 1
modes/message-conf.el View File

@@ -2,7 +2,6 @@
;;; Commentary:
;;; Code:
(eval-when-compile
(load "../lisp/packages.el")
(require 'company)
(require 'message))


+ 0
- 1
modes/oauth2-conf.el View File

@@ -1,6 +1,5 @@
;;; oauth2-conf.el -- OAuth Configuration.
(eval-when-compile
(load "../lisp/packages.el")
(require 'oauth2))

(custom-set-variables

+ 0
- 20
modes/oddmuse-conf.el View File

@@ -1,20 +0,0 @@
;;; oddmuse-conf.el -- Settings for Oddmuse (EmacsWiki).
(eval-when-compile (require 'oddmuse))

(declare-function oddmuse-mode-initialize "oddmuse.el")

(defun pmade-oddmuse-hook ()
"Hook is run after oddmuse is started"
(unless (string-match "question" oddmuse-post)
(setq oddmuse-post (concat "uihnscuskc=1;" oddmuse-post))))

(setq oddmuse-username "PeterJones")
(setq oddmuse-directory "~/.oddmuse")

(defun pmade-oddmuse-edit ()
"Load oddmuse and run oddmuse-edit."
(interactive)
(require 'oddmuse)
(add-hook 'oddmuse-mode-hook 'pmade-oddmuse-hook)
(oddmuse-mode-initialize)
(call-interactively 'oddmuse-edit))

+ 0
- 1
modes/plstore-conf.el View File

@@ -1,6 +1,5 @@
;;; plstore-conf.el -- Settings for plstore.el.
(eval-when-compile
(load "../lisp/packages.el")
(require 'plstore))

(custom-set-variables

+ 0
- 1
modes/rcirc-conf.el View File

@@ -1,6 +1,5 @@
;;; rcirc-conf.el -- Settings for rcirc.
(eval-when-compile
(load "../lisp/functions.el")
(require 'cl)
(require 'rcirc))


+ 0
- 1
modes/sgml-mode-conf.el View File

@@ -2,7 +2,6 @@
;;; Commentary:
;;; Code:
(eval-when-compile
(load "../lisp/code.el")
(require 'company))

(defun pjones:sgml-mode-hook ()

+ 0
- 1
modes/simple-conf.el View File

@@ -1,5 +1,4 @@
;;; simple-conf.el -- Functions and settings for simple.el (mostly for
;;; prog-mode since it's defined in simple.el).
(eval-when-compile (load "../lisp/code.el"))
(declare-function pjones:add-programming-hook "code.el")
(pjones:add-programming-hook 'prog-mode-hook)

+ 0
- 1
modes/speedbar-conf.el View File

@@ -1,6 +1,5 @@
;;; speedbar.el -- quick access to files and tags in a frame.
(eval-when-compile
(load "../lisp/packages.el")
(require 'speedbar))

(setq speedbar-show-unknown-files t)

+ 0
- 2
modes/yaml-mode-conf.el View File

@@ -1,7 +1,5 @@
;;; yaml-mode-conf.el -- Settings for yaml-mode.
(eval-when-compile
(load "../lisp/packages.el")
(load "../lisp/code.el")
(require 'yaml-mode))

(declare-function pjones:add-programming-hook "code.el")

+ 0
- 7
modes/yasnippet-conf.el View File

@@ -1,7 +0,0 @@
;;; yasnippet-conf.el -- Settings for yasnippet.
(eval-when-compile
(load "../lisp/code.el")
(require 'yasnippet))

(custom-set-variables
`(yas-snippet-dirs ,(concat user-emacs-directory "pjones/snippets")))

+ 0
- 11
scripts/check-emacs-output.sh View File

@@ -1,11 +0,0 @@
#!/bin/sh

clean_output () {
egrep -v '^(Wrote|Loading)' | \
egrep -v '^[[:space:]]*$' | \
egrep -v '^In end of data:' | \
egrep -v 'org-bookmark-jump-unhide' | \
egrep -v '^[[:space:]]*be defined at runtime.'
}

clean_output | wc -l

+ 0
- 16
snippets/GNUmakefile View File

@@ -1,16 +0,0 @@
################################################################################
DEST = ~/.emacs.d/pjones/snippets
FILES = $(shell find . -type f | grep -v GNUmakefile | sed 's|\./||g')

##############################################################################
.PHONEY: all

################################################################################
define INSTALL
all: $(DEST)/$(1)
$(DEST)/$(1): $(1)
install -D -m0640 $$< $$@
endef

################################################################################
$(foreach f,$(FILES),$(eval $(call INSTALL,$(f))))

+ 0
- 7
snippets/js-mode/function View File

@@ -1,7 +0,0 @@
# -*- mode: snippet; require-final-newline: nil -*-
# name: function
# key: f
# --
function ${1:name}(${2:arg}) {
$0
}

+ 0
- 3
third-party/GNUmakefile View File

@@ -1,3 +0,0 @@
DEST = ${HOME}/.emacs.d/share/emacs/site-lisp
IGNORE_EMACS_WARNINGS = YES
include ../emacs.mk

+ 0
- 559
third-party/boxquote.el View File

@@ -1,559 +0,0 @@
;;; boxquote.el --- Quote text with a semi-box.
;; Copyright 1999-2008 by Dave Pearson <davep@davep.org>
;; $Revision: 1.19 $

;; boxquote.el is free software distributed under the terms of the GNU
;; General Public Licence, version 2 or (at your option) any later version.
;; For details see the file COPYING.

;;; Commentary:

;; boxquote provides a set of functions for using a text quoting style that
;; partially boxes in the left hand side of an area of text, such a marking
;; style might be used to show externally included text or example code.
;;
;; ,----
;; | The default style looks like this.
;; `----
;;
;; A number of functions are provided for quoting a region, a buffer, a
;; paragraph and a defun. There are also functions for quoting text while
;; pulling it in, either by inserting the contents of another file or by
;; yanking text into the current buffer.
;;
;; The latest version of boxquote.el can be found at:
;;
;; <URL:http://www.davep.org/emacs/#boxquote.el>

;;; Thanks:

;; Kai Grossjohann for inspiring the idea of boxquote. I wrote this code to
;; mimic the "inclusion quoting" style in his Usenet posts. I could have
;; hassled him for his code but it was far more fun to write it myself.
;;
;; Mark Milhollan for providing a patch that helped me get the help quoting
;; functions working with XEmacs.
;;
;; Oliver Much for suggesting the idea of having a `boxquote-kill-ring-save'
;; function.
;;
;; Reiner Steib for suggesting `boxquote-where-is' and the idea of letting
;; `boxquote-describe-key' describe key bindings from other buffers.

;;; Code:

;; Things we need:

(eval-when-compile
(require 'cl))
(require 'rect)

;; Attempt to handle older/other emacs.
(eval-and-compile
;; If customize isn't available just use defvar instead.
(unless (fboundp 'defgroup)
(defmacro defgroup (&rest rest) nil)
(defmacro defcustom (symbol init docstring &rest rest)
`(defvar ,symbol ,init ,docstring)))
;; If `line-beginning-position' isn't available provide one.
(unless (fboundp 'line-beginning-position)
(defun line-beginning-position (&optional n)
"Return the `point' of the beginning of the current line."
(save-excursion
(beginning-of-line n)
(point))))

;; If `line-end-position' isn't available provide one.
(unless (fboundp 'line-end-position)
(defun line-end-position (&optional n)
"Return the `point' of the end of the current line."
(save-excursion
(end-of-line n)
(point)))))

;; Customize options.

(defgroup boxquote nil
"Mark regions of text with a half-box."
:group 'editing
:prefix "boxquote-")

(defcustom boxquote-top-and-tail "----"
"*Text that will be used at the top and tail of the box."
:type 'string
:group 'boxquote)

(defcustom boxquote-top-corner ","
"*Text used for the top corner of the box."
:type 'string
:group 'boxquote)

(defcustom boxquote-bottom-corner "`"
"*Text used for the bottom corner of the box."
:type 'string
:group 'boxquote)

(defcustom boxquote-side "| "
"*Text used for the side of the box."
:type 'string
:group 'boxquote)

(defcustom boxquote-title-format "[ %s ]"
"*Format string to use when creating a box title."
:type 'string
:group 'boxquote)

(defcustom boxquote-title-files t
"*Should a `boxquote-insert-file' title the box with the file name?"
:type '(choice
(const :tag "Title the box with the file name" t)
(const :tag "Don't title the box with the file name" nil))
:group 'boxquote)

(defcustom boxquote-file-title-function #'file-name-nondirectory
"*Function to apply to a file's name when using it to title a box."
:type 'function
:group 'boxquote)

(defcustom boxquote-region-hook nil
"*Hooks to perform when on a region prior to boxquoting.

Note that all forms of boxquoting use `boxquote-region' to create the
boxquote. Because of this any hook you place here will be invoked by any of
the boxquoting functions."
:type 'hook
:group 'boxquote)

(defcustom boxquote-yank-hook nil
"*Hooks to perform on the yanked text prior to boxquoting."
:type 'hook
:group 'boxquote)

(defcustom boxquote-insert-file-hook nil
"*Hooks to perform on the text from an inserted file prior to boxquoting."
:type 'hook
:group 'boxquote)

(defcustom boxquote-kill-ring-save-title #'buffer-name
"*Function for working out the title for a `boxquote-kill-ring-save'.

The string returned from this function will be used as the title for a
boxquote when the saved text is yanked into a buffer with \\[boxquote-yank].

An example of a non-trivial value for this variable might be:

(lambda ()
(if (string= mode-name \"Article\")
(aref gnus-current-headers 4)
(buffer-name)))

In this case, if you are a `gnus' user, \\[boxquote-kill-ring-save] could be
used to copy text from an article buffer and, when it is yanked into another
buffer using \\[boxquote-yank], the title of the boxquote would be the ID of
the article you'd copied the text from."
:type 'function
:group 'boxquote)

(defcustom boxquote-describe-function-title-format "C-h f %s RET"
"*Format string to use when formatting a function description box title"
:type 'string
:group 'boxquote)

(defcustom boxquote-describe-variable-title-format "C-h v %s RET"
"*Format string to use when formatting a variable description box title"
:type 'string
:group 'boxquote)

(defcustom boxquote-describe-key-title-format "C-h k %s"
"*Format string to use when formatting a key description box title"
:type 'string
:group 'boxquote)

(defcustom boxquote-where-is-title-format "C-h w %s RET"
"*Format string to use when formatting a `where-is' description box title"
:type 'string
:group 'boxquote)

(defcustom boxquote-where-is-body-format "%s is on %s"
"*Format string to use when formatting a `where-is' description."
:type 'string
:group 'boxquote)
;; Main code:

(defun boxquote-xemacs-p ()
"Are we running in XEmacs?"
(and (boundp 'running-xemacs) (symbol-value 'running-xemacs)))

(defun boxquote-points ()
"Find the start and end points of a boxquote.

If `point' is inside a boxquote then a cons is returned, the `car' is the
start `point' and the `cdr' is the end `point'. NIL is returned if no
boxquote is found."
(save-excursion
(beginning-of-line)
(let* ((re-top (concat "^" (regexp-quote boxquote-top-corner)
(regexp-quote boxquote-top-and-tail)))
(re-left (concat "^" (regexp-quote boxquote-side)))
(re-bottom (concat "^" (regexp-quote boxquote-bottom-corner)
(regexp-quote boxquote-top-and-tail)))
(points
(flet ((find-box-end (re &optional back)
(save-excursion
(when (if back
(search-backward-regexp re nil t)
(search-forward-regexp re nil t))
(point)))))
(cond ((looking-at re-top)
(cons (point) (find-box-end re-bottom)))
((looking-at re-left)
(cons (find-box-end re-top t) (find-box-end re-bottom)))
((looking-at re-bottom)
(cons (find-box-end re-top t) (line-end-position)))))))
(when (and (car points) (cdr points))
points))))

(defun boxquote-quoted-p ()
"Is `point' inside a boxquote?"
(not (null (boxquote-points))))

(defun boxquote-points-with-check ()
"Get the `boxquote-points' and flag an error of no box was found."
(or (boxquote-points) (error "I can't see a box here")))

(defun boxquote-title-format-as-regexp ()
"Return a regular expression to match the title."
(with-temp-buffer
(insert (regexp-quote boxquote-title-format))
(setf (point) (point-min))
(when (search-forward "%s" nil t)
(replace-match ".*" nil t))
(buffer-string)))

(defun boxquote-get-title ()
"Get the title for the current boxquote."
(multiple-value-bind (prefix-len suffix-len)
(with-temp-buffer
(let ((look-for "%s"))
(insert boxquote-title-format)
(setf (point) (point-min))
(search-forward look-for)
(list (- (point) (length look-for) 1) (- (point-max) (point)))))
(save-excursion
(save-restriction
(boxquote-narrow-to-boxquote)
(setf (point) (+ (point-min)
(length (concat boxquote-top-corner
boxquote-top-and-tail))))
(if (looking-at (boxquote-title-format-as-regexp))
(buffer-substring-no-properties (+ (point) prefix-len)
(- (line-end-position) suffix-len))
"")))))

;;;###autoload
(defun boxquote-title (title)
"Set the title of the current boxquote to TITLE.

If TITLE is an empty string the title is removed. Note that the title will
be formatted using `boxquote-title-format'."
(interactive (list (read-from-minibuffer "Title: " (boxquote-get-title))))
(save-excursion
(save-restriction
(boxquote-narrow-to-boxquote)
(setf (point) (+ (point-min)
(length (concat boxquote-top-corner
boxquote-top-and-tail))))
(unless (eolp)
(kill-line))
(unless (zerop (length title))
(insert (format boxquote-title-format title))))))

;;;###autoload
(defun boxquote-region (start end)
"Draw a box around the left hand side of a region bounding START and END."
(interactive "r")
(save-excursion
(save-restriction
(flet ((bol-at-p (n)
(setf (point) n)
(bolp))
(insert-corner (corner pre-break)
(insert (concat (if pre-break "\n" "")
corner boxquote-top-and-tail "\n"))))
(let ((break-start (not (bol-at-p start)))
(break-end (not (bol-at-p end))))
(narrow-to-region start end)
(run-hooks 'boxquote-region-hook)
(setf (point) (point-min))
(insert-corner boxquote-top-corner break-start)
(let ((start-point (line-beginning-position)))
(setf (point) (point-max))
(insert-corner boxquote-bottom-corner break-end)
(string-rectangle start-point
(progn
(setf (point) (point-max))
(forward-line -2)
(line-beginning-position))
boxquote-side)))))))

;;;###autoload
(defun boxquote-buffer ()
"Apply `boxquote-region' to a whole buffer."
(interactive)
(boxquote-region (point-min) (point-max)))

;;;###autoload
(defun boxquote-insert-file (filename)
"Insert the contents of a file, boxed with `boxquote-region'.

If `boxquote-title-files' is non-nil the boxquote will be given a title that
is the result applying `boxquote-file-title-funciton' to FILENAME."
(interactive "fInsert file: ")
(insert (with-temp-buffer
(insert-file-contents filename nil)
(run-hooks 'boxquote-insert-file-hook)
(boxquote-buffer)
(when boxquote-title-files
(boxquote-title (funcall boxquote-file-title-function filename)))
(buffer-string))))

;;;###autoload
(defun boxquote-kill-ring-save ()
"Like `kill-ring-save' but remembers a title if possible.

The title is acquired by calling `boxquote-kill-ring-save-title'. The title
will be used by `boxquote-yank'."
(interactive)
(call-interactively #'kill-ring-save)
(setf (car kill-ring-yank-pointer)
(format "%S" (list
'boxquote-yank-marker
(funcall boxquote-kill-ring-save-title)
(car kill-ring-yank-pointer)))))

;;;###autoload
(defun boxquote-yank ()
"Do a `yank' and box it in with `boxquote-region'.

If the yanked entry was placed on the kill ring with
`boxquote-kill-ring-save' the resulting boxquote will be titled with
whatever `boxquote-kill-ring-save-title' returned at the time."
(interactive)
(save-excursion
(insert (with-temp-buffer
(yank)
(setf (point) (point-min))
(let ((title
(let ((yanked (condition-case nil
(read (current-buffer))
(error nil))))
(when (listp yanked)
(when (eq (car yanked) 'boxquote-yank-marker)
(setf (buffer-string) (nth 2 yanked))
(nth 1 yanked))))))
(run-hooks 'boxquote-yank-hook)
(boxquote-buffer)
(when title
(boxquote-title title))
(buffer-string))))))

;;;###autoload
(defun boxquote-defun ()
"Apply `boxquote-region' the current defun."
(interactive)
(mark-defun)
(boxquote-region (region-beginning) (region-end)))

;;;###autoload
(defun boxquote-paragraph ()
"Apply `boxquote-region' to the current paragraph."
(interactive)
(mark-paragraph)
(boxquote-region (region-beginning) (region-end)))

;;;###autoload
(defun boxquote-boxquote ()
"Apply `boxquote-region' to the current boxquote."
(interactive)
(let ((box (boxquote-points-with-check)))
(boxquote-region (car box) (1+ (cdr box)))))

(defun boxquote-help-buffer-name (item)
"Return the name of the help buffer associated with ITEM."
(if (boxquote-xemacs-p)
(loop for buffer in (symbol-value 'help-buffer-list)
when (string-match (concat "^*Help:.*`" item "'") buffer)
return buffer)
"*Help*"))

(defun boxquote-quote-help-buffer (help-call title-format item)
"Perform a help command and boxquote the output.

HELP-CALL is a function that calls the help command.

TITLE-FORMAT is the `format' string to use to product the boxquote title.

ITEM is a function for retrieving the item to get help on."
(let ((one-window-p (one-window-p)))
(boxquote-text
(save-window-excursion
(funcall help-call)
(with-current-buffer (boxquote-help-buffer-name (funcall item))
(buffer-string))))
(boxquote-title (format title-format (funcall item)))
(when one-window-p
(delete-other-windows))))
;;;###autoload
(defun boxquote-describe-function ()
"Call `describe-function' and boxquote the output into the current buffer."
(interactive)
(boxquote-quote-help-buffer
#'(lambda ()
(call-interactively #'describe-function))
boxquote-describe-function-title-format
#'(lambda ()
(car (if (boxquote-xemacs-p)
(symbol-value 'function-history)
minibuffer-history)))))

;;;###autoload
(defun boxquote-describe-variable ()
"Call `describe-variable' and boxquote the output into the current buffer."
(interactive)
(boxquote-quote-help-buffer
#'(lambda ()
(call-interactively #'describe-variable))
boxquote-describe-variable-title-format
#'(lambda ()
(car (if (boxquote-xemacs-p)
(symbol-value 'variable-history)
minibuffer-history)))))

;;;###autoload
(defun boxquote-describe-key (key)
"Call `describe-key' and boxquote the output into the current buffer.

If the call to this command is prefixed with \\[universal-argument] you will also be
prompted for a buffer. The key defintion used will be taken from that buffer."
(interactive "kDescribe key: ")
(let ((from-buffer (if current-prefix-arg
(read-buffer "Buffer: " (current-buffer) t)
(current-buffer))))
(let ((binding
(with-current-buffer from-buffer
(key-binding key))))
(if (or (null binding) (integerp binding))
(message "%s is undefined" (with-current-buffer from-buffer
(key-description key)))
(boxquote-quote-help-buffer
#'(lambda ()
(with-current-buffer from-buffer
(describe-key key)))
boxquote-describe-key-title-format
#'(lambda ()
(with-current-buffer from-buffer
(key-description key))))))))

;;;###autoload
(defun boxquote-shell-command (command)
"Call `shell-command' with COMMAND and boxquote the output."
(interactive (list (read-from-minibuffer "Shell command: " nil nil nil 'shell-command-history)))
(boxquote-text (with-temp-buffer
(shell-command command t)
(buffer-string)))
(boxquote-title command))

;;;###autoload
(defun boxquote-where-is (definition)
"Call `where-is' with DEFINITION and boxquote the result."
(interactive "CCommand: ")
(boxquote-text (with-temp-buffer
(where-is definition t)
(format boxquote-where-is-body-format definition (buffer-string))))
(boxquote-title (format boxquote-where-is-title-format definition)))

;;;###autoload
(defun boxquote-text (text)
"Insert TEXT, boxquoted."
(interactive "sText: ")
(save-excursion
(unless (bolp)
(insert "\n"))
(insert
(with-temp-buffer
(insert text)
(boxquote-buffer)
(buffer-string)))))
;;;###autoload
(defun boxquote-narrow-to-boxquote ()
"Narrow the buffer to the current boxquote."
(interactive)
(let ((box (boxquote-points-with-check)))
(narrow-to-region (car box) (cdr box))))

;;;###autoload
(defun boxquote-narrow-to-boxquote-content ()
"Narrow the buffer to the content of the current boxquote."
(interactive)
(let ((box (boxquote-points-with-check)))
(narrow-to-region (save-excursion
(setf (point) (car box))
(forward-line 1)
(point))
(save-excursion
(setf (point) (cdr box))
(line-beginning-position)))))

;;;###autoload
(defun boxquote-kill ()
"Kill the boxquote and its contents."
(interactive)
(let ((box (boxquote-points-with-check)))
(kill-region (car box) (1+ (cdr box)))))

;;;###autoload
(defun boxquote-fill-paragraph (arg)
"Perform a `fill-paragraph' inside a boxquote."
(interactive "P")
(if (boxquote-quoted-p)
(save-restriction
(boxquote-narrow-to-boxquote-content)
(let ((fill-prefix boxquote-side))
(fill-paragraph arg)))
(fill-paragraph arg)))
;;;###autoload
(defun boxquote-unbox-region (start end)
"Remove a box created with `boxquote-region'."
(interactive "r")
(save-excursion
(save-restriction
(narrow-to-region start end)
(setf (point) (point-min))
(if (looking-at (concat "^" (regexp-quote boxquote-top-corner)
(regexp-quote boxquote-top-and-tail)))
(let ((ends (concat "^[" (regexp-quote boxquote-top-corner)
(regexp-quote boxquote-bottom-corner)
"]" boxquote-top-and-tail))
(lines (concat "^" (regexp-quote boxquote-side))))
(loop while (< (point) (point-max))
if (looking-at ends) do (kill-line t)
if (looking-at lines) do (delete-char 2)
do (forward-line)))
(error "I can't see a box here")))))

;;;###autoload
(defun boxquote-unbox ()
"Remove the boxquote that contains `point'."
(interactive)
(let ((box (boxquote-points-with-check)))
(boxquote-unbox-region (car box) (1+ (cdr box)))))

(provide 'boxquote)

;;; boxquote.el ends here.

+ 0
- 317
third-party/goto-chg.el View File

@@ -1,317 +0,0 @@
;;; goto-chg.el --- goto last change
;;--------------------------------------------------------------------
;;
;; Copyright (C) 2002-2008, David Andersson
;;
;; This program is free software; you can redistribute it and/or
;; modify it under the terms of the GNU General Public License as
;; published by the Free Software Foundation; either version 2 of
;; the License, or (at your option) any later version.
;;
;; This program is distributed in the hope that it will be
;; useful, but WITHOUT ANY WARRANTY; without even the implied
;; warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
;; PURPOSE. See the GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public
;; License along with this program; if not, write to the Free
;; Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
;; MA 02111-1307 USA
;;
;;-------------------------------------------------------------------
;;
;; Author: David Andersson <l.david.andersson(at)sverige.nu>
;; Created: 16 May 2002
;; Version: 1.4
;;
;;; Commentary:
;;
;; Goto Last Change
;;
;; Goto the point of the most recent edit in the buffer.
;; When repeated, goto the second most recent edit, etc.
;; Negative argument, C-u -, for reverse direction.
;; Works by looking into buffer-undo-list to find points of edit.
;;
;; You would probably like to bind this command to a key.
;; For example in your ~/.emacs:
;;
;; (require 'goto-chg)
;;
;; (global-set-key [(control ?.)] 'goto-last-change)
;; (global-set-key [(control ?,)] 'goto-last-change-reverse)
;;
;; Works with emacs-19.29, 19.31, 20.3, 20.7, 21.1, 21.4 and 22.1.
;; Works with XEmacs-20.4 and 21.4 (but see todo about `last-command' below)
;;
;;--------------------------------------------------------------------
;; History
;;
;; Ver 1.4 2008-09-20 David Andersson
;; Improved property change description; Update comments.
;; Ver 1.3 2007-03-14 David Andersson
;; Added `goto-last-change-reverse'
;; Ver 1.2 2003-04-06 David Andersson
;; Don't let repeating error depthen glc-probe-depth.
;; Ver 1.1 2003-04-06 David Andersson
;; Zero arg describe changes. Negative arg go back.
;; Autoload. Remove message using nil in stead of an empty string.
;; Ver 1.0 2002-05-18 David Andersson
;; Initial version
;;
;;--------------------------------------------------------------------
;;
;;todo: Rename "goto-chg.el" -> "gotochange.el" or "goto-chgs" ?
;;todo: Rename function goto-last-change -> goto-last-edit ?
;;todo: Rename adjective "-last-" -> "-latest-" or "-most-recent-" ?
;;todo: There are some, maybe useful, funcs for region undo
;; in simple.el in emacs 20. Take a look.
;;todo: Add functionality to visit changed point in text order, not only in
;; chronological order. (Naa, highlight-changes-mode does that).
;;todo: Inverse indication that a change has been saved or not
;;todo: Highlight the range of text involved in the last change?
;;todo: Function that goes in reverse direction. Either a function
;; 'goto-next-change' only callable after 'goto-last-change'
;; or enter a minor mode similar to isearch.
;;todo: See session-jump-to-last-change in session.el?
;;todo: Unhide invisible text (e.g. outline mode) like isearch do.
;;todo: XEmacs sets last-command to `t' after an error, so you cannot reverse
;; after "No furter change info". Should we bother?
;;todo: Try distinguish "No further change info" (end of truncated undo list)
;; and "No further changes" (end of a complete undo list).
;;
;;--------------------------------------------------------------------

;;; Code:

(defvar glc-default-span 8 "*goto-last-change don't visit the same point twice. glc-default-span tells how far around a visited point not to visit again.")
(defvar glc-current-span 8 "Internal for goto-last-change.\nA copy of glc-default-span or the ARG passed to goto-last-change.")
(defvar glc-probe-depth 0 "Internal for goto-last-change.\nIt is non-zero between successive goto-last-change.")

;;todo: Find begin and end of line, then use it somewhere

(defun glc-center-ellipsis (str maxlen &optional ellipsis)
"Truncate STRING in the middle to length MAXLEN.
If STRING is max MAXLEN just return the string.
Optional third argument is the replacement, which defaults to \"...\"."
(if (<= (length str) maxlen)
str
;; else
(let* ((lipsis (or ellipsis "..."))
(i (/ (- maxlen (length lipsis)) 2)))
(concat (substring str 0 i)
lipsis
(substring str (- i))))))

(defun glc-adjust-pos2 (pos p1 p2 adj)
;; Helper function to glc-adjust-pos
(cond ((<= pos (- p1 glc-current-span))
pos)
((> pos (+ p2 glc-current-span))
(+ pos adj))
((zerop glc-current-span)
p1)
(t
nil)))

(defun glc-adjust-pos (pos e)
"Given POS, a buffer position before the edit E, compute and return
the \"same\" buffer position after E happened.
Exception: return nil if POS is closer than `glc-current-span' to the edit E.
\nInsertion edits before POS returns a larger value.
Deletion edits before POS returns a smaller value.
\nThe edit E is an entry from the `buffer-undo-list'. See for details."
(cond ((atom e) ; nil==cmd boundary, or, num==changed pos
pos)
((numberp (car e)) ; (beg . end)==insertion
(glc-adjust-pos2 pos (car e) (car e) (- (cdr e) (car e))))
;; (cond ((< pos (- (car e) glc-current-span)) pos)
;; ((> pos (+ (car e) glc-current-span)) (+ pos (- (cdr e) (car e))))
;; (t nil)))
((stringp (car e)) ; (string . pos)==deletion
(glc-adjust-pos2 pos (abs (cdr e)) (+ (abs (cdr e)) (length (car e))) (- (length (car e)))))
;; (cond ((< pos (- (abs (cdr e)) glc-current-span)) pos)
;; ((> pos (+ (abs (cdr e)) (length (car e)) glc-current-span)) (- pos (length (car e))))
;; (t nil)))
((null (car e)) ; (nil prop val beg . end)==prop change
(glc-adjust-pos2 pos (nth 3 e) (nthcdr 4 e) 0))
;; (cond ((< pos (- (nth 3 e) glc-current-span)) pos)
;; ((> pos (+ (nthcdr 4 e) glc-current-span)) pos)
;; (t nil)))
(t ; (marker . dist)==marker moved
pos)))

;; If recursive in stead of iterative (while), it tends to fill the call stack.
;; (Isn't it tail optimized?)
(defun glc-adjust-list (r)
"R is list of edit entries in chronological order.
Pick the point of the first edit entry and update that point with
the second, third, etc, edit entries. Return the final updated point,
or nil if the point was closer than `glc-current-span' to some edit in R.
\nR is basically a reversed slice from the buffer-undo-list."
(if r
;; Get pos
(let ((pos (glc-get-pos (car r))))
(setq r (cdr r))
;; Walk back in reverse list
(while (and r pos)
(setq pos (glc-adjust-pos pos (car r))
r (cdr r)))
pos)
;; else
nil))

(defun glc-get-pos (e)
"If E represents an edit, return a position value in E, the position
where the edit took place. Return nil if E represents no real change.
\nE is a entry in the buffer-undo-list."
(cond ((numberp e) e) ; num==changed position
((atom e) nil) ; nil==command boundary
((numberp (car e)) (cdr e)) ; (beg . end)==insertion
((stringp (car e)) (abs (cdr e))) ; (string . pos)==deletion
((null (car e)) (nthcdr 4 e)) ; (nil ...)==text property change
((atom (car e)) nil) ; (t ...)==file modification time
(t nil))) ; (marker ...)==marker moved

(defun glc-get-descript (e &optional n)
"If E represents an edit, return a short string describing E.
Return nil if E represents no real change.
\nE is a entry in the buffer-undo-list."
(let ((nn (or (format "T-%d: " n) "")))
(cond ((numberp e) "New position") ; num==changed position
((atom e) nil) ; nil==command boundary
((numberp (car e)) ; (beg . end)==insertion
(if (and n (< n 2))
(format "%sInserted %d chars \"%s\"" nn (- (cdr e) (car e))
(glc-center-ellipsis (buffer-substring (car e) (cdr e)) 60))
;; else
;; An older insert. The inserted text cannot easily be computed.
;; Just show the char count.
(format "%sInserted %d chars" nn (- (cdr e) (car e)))))
((stringp (car e)) ; (string . pos)==deletion
(format "%sDeleted \"%s\"" nn (glc-center-ellipsis (car e) 60)))
((null (car e)) ; (nil ...)==text property change
(format "%sProperty change" nn))
((atom (car e)) nil) ; (t ...)==file modification time
(t nil)))) ; (marker ...)==marker moved

(defun glc-is-positionable (e)
"Return non-nil if E is an insertion, deletion or text property change.
\nE is a entry in the buffer-undo-list."
(and (not (numberp e)) (glc-get-pos e)))

(defun glc-is-filetime (e)
"Return t if E indicates a buffer became \"modified\",
that is, it was previously saved or unchanged. Nil otherwise."
(and (listp e) (eq (car e) t)))

;;;###autoload
(defun goto-last-change (arg)
"Go to the point where the last edit was made in the current buffer.
Repeat the command to go to the second last edit, etc.
A preceding \\[universal-argument] - (minus) will reverse direction for the next command in
the sequence, to go back to a more recent edit.
\nIt does not go to the same point twice even if there has been many edits
there. I call the minimal distance between distinguishable edits \"span\".
Set variable `glc-default-span' to control how close is \"the same point\".
Default span is 8.
The span can be changed temporarily with \\[universal-argument] right before \\[goto-last-change]:
\\[universal-argument] <NUMBER> set current span to that number,
\\[universal-argument] (no number) multiplies span by 4, starting with default.
The so set span remains until it is changed again with \\[universal-argument], or the consecutive
repetition of this command is ended by any other command.
\nWhen span is zero (i.e. \\[universal-argument] 0) subsequent \\[goto-last-change] visits each and
every point of edit and a message shows what change was made there.
In this case it may go to the same point twice.
\nThis command uses undo information. If undo is disabled, so is this command.
At times, when undo information becomes too large, the oldest information is
discarded. See variable `undo-limit'."
(interactive "P")
(cond ((not (eq this-command last-command))
;; Start a glc sequence
;; Don't go to current point if last command was an obvious edit
;; (yank or self-insert, but not kill-region). Makes it easier to
;; jump back and forth when copying seleced lines.
(setq glc-probe-depth (if (memq last-command '(yank self-insert-command)) 1 0)
glc-direction 1
glc-current-span glc-default-span)
(if (< (prefix-numeric-value arg) 0)
(error "Negative arg: Cannot reverse as the first operation"))))
(cond ((null buffer-undo-list)
(error "Buffer has not been changed"))
((eq buffer-undo-list t)
(error "No change info (undo is disabled)")))
(cond ((numberp arg) ; Numeric arg sets span
(setq glc-current-span (abs arg)))
((consp arg) ; C-u's multiply previous span by 4
(setq glc-current-span (* (abs (car arg)) glc-default-span))
(message "Current span is %d chars" glc-current-span))) ;todo: keep message with "waiting" and "is saved"
(cond ((< (prefix-numeric-value arg) 0)
(setq glc-direction -1))
(t
(setq glc-direction 1)))
(let (rev ; Reversed (and filtered) undo list
pos ; The pos we look for, nil until found
(n 0) ; Steps in undo list (length of 'rev')
(l buffer-undo-list)
(passed-save-entry (not (buffer-modified-p)))
(new-probe-depth glc-probe-depth))
;; Walk back and forth in the buffer-undo-list, each time one step deeper,
;; until we can walk back the whole list with a 'pos' that is not coming
;; too close to another edit.
(while (null pos)
(setq new-probe-depth (+ new-probe-depth glc-direction))
(if (< glc-direction 0)
(setq rev ()
n 0
l buffer-undo-list
passed-save-entry (not (buffer-modified-p))))
(if (< new-probe-depth 1)
(error "No later change info"))
(if (> n 150)
(message "working..."))
;; Walk forward in buffer-undo-list, glc-probe-depth steps.
;; Build reverse list along the way
(while (< n new-probe-depth)
(cond ((null l)
;(setq this-command t) ; Disrupt repeat sequence
(error "No further change info"))
((glc-is-positionable (car l))
(setq n (1+ n)
rev (cons (car l) rev)))
((or passed-save-entry (glc-is-filetime (car l)))
(setq passed-save-entry t)))
(setq l (cdr l)))
;; Walk back in reverse list, from older to newer edits.
;; Adjusting pos along the way.
(setq pos (glc-adjust-list rev)))
;; Found a place not previously visited, in 'pos'.
;; (An error have been issued if nothing (more) found.)
(if (> n 150)
(message nil)) ; remove message "working..."
(if (and (= glc-current-span 0) (glc-get-descript (car rev) n))
(message "%s" (glc-get-descript (car rev) n))
;; else
(if passed-save-entry
(message "(This change is saved)")))
(setq glc-probe-depth new-probe-depth)
(goto-char pos)))

;; ;;;###autoload
(defun goto-last-change-reverse (arg)
(interactive "P")
;; Negate arg, all kinds
(cond ((eq arg nil) (setq arg '-))
((eq arg '-) (setq arg nil))
((listp arg) (setq arg (list (- (car arg)))))
(t (setq arg (- arg))))
;; Make 'goto-last-change-reverse' look like 'goto-last-change'
(cond ((eq last-command this-command)
(setq last-command 'goto-last-change)))
(setq this-command 'goto-last-change)
;; Call 'goto-last-change' to do the job
(goto-last-change arg))

(provide 'goto-chg)

;;; goto-chg.el ends here

+ 0
- 919
third-party/graphviz-dot-mode.el View File

@@ -1,919 +0,0 @@
;;; graphviz-dot-mode.el --- Mode for the dot-language used by graphviz (att).

;; Copyright (C) 2002 - 2005 Pieter Pareit <pieter.pareit@scarlet.be>

;; This program is free software; you can redistribute it and/or
;; modify it under the terms of the GNU General Public License as
;; published by the Free Software Foundation; either version 2 of
;; the License, or (at your option) any later version.

;; This program is distributed in the hope that it will be
;; useful, but WITHOUT ANY WARRANTY; without even the implied
;; warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
;; PURPOSE. See the GNU General Public License for more details.

;; You should have received a copy of the GNU General Public
;; License along with this program; if not, write to the Free
;; Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
;; MA 02111-1307 USA

;; Authors: Pieter Pareit <pieter.pareit@scarlet.be>
;; Rubens Ramos <rubensr AT users.sourceforge.net>
;; Maintainer: Pieter Pareit <pieter.pareit@planetinternet.be>
;; Homepage: http://users.skynet.be/ppareit/projects/graphviz-dot-mode/graphviz-dot-mode.html
;; Created: 28 Oct 2002
;; Last modified: 15 Feb 2005
;; Version: 0.3.3
;; Keywords: mode dot dot-language dotlanguage graphviz graphs att

;;; Commentary:
;; Use this mode for editing files in the dot-language (www.graphviz.org and
;; http://www.research.att.com/sw/tools/graphviz/).
;;
;; To use graphviz-dot-mode, add
;; (load-file "PATH_TO_FILE/graphviz-dot-mode.el")
;; to your ~/.emacs(.el) or ~/.xemacs/init.el
;;
;; The graphviz-dot-mode will do font locking, indentation, preview of graphs
;; and eases compilation/error location. There is support for both GNU Emacs
;; and XEmacs.
;;
;; Font locking is automatic, indentation uses the same commands as
;; other modes, tab, M-j and C-M-q. Insertion of comments uses the
;; same commands as other modes, M-; . You can compile a file using
;; M-x compile or C-c c, after that M-x next-error will also work.
;; There is support for viewing an generated image with C-c p.

;;; Todo:
;; * cleanup the mess of graphviz-dot-compilation-parse-errors
;; * electric indentation is fundamentally broken, because
;; {...} are also used for record nodes. You could argue, I suppose, that
;; many diagrams don't need those, but it would be worth having a note (and
;; it makes sense that the default is now for electric indentation to be
;; off).

;;; History:

;; Version 0.3.4 bug fixes
;; 24/02/2005: * fixed a bug in graphviz-dot-preview
;; Version 0.3.3 bug fixes
;; 13/02/2005: Reuben Thomas <rrt AT sc3d.org>
;; * add graphviz-dot-indent-width
;; Version 0.3.2 bug fixes
;; 25/03/2004: Rubens Ramos <rubensr AT users.sourceforge.net>
;; * semi-colons and brackets are added when electric
;; behaviour is disabled.
;; * electric characters do not behave electrically inside
;; comments or strings.
;; * default for electric-braces is disabled now (makes more
;; sense I guess).
;; * using read-from-minibuffer instead of read-shell-command
;; for emacs.
;; * Fixed test for easymenu, so that it works on older
;; versions of XEmacs.
;; * Fixed indentation error when trying to indent last brace
;; of an empty graph.
;; * region-active-p does not exist in emacs (21.2 at least),
;; so removed from code
;; * Added uncomment menu option
;; Version 0.3.1 bug fixes
;; 03/03/2004: * backward-word needs argument for older emacs
;; Version 0.3 added features and fixed bugs
;; 10/01/2004: fixed a bug in graphviz-dot-indent-graph
;; 08/01/2004: Rubens Ramos <rubensr AT users.sourceforge.net>
;; * added customization support
;; * Now it works on XEmacs and Emacs
;; * Added support to use an external Viewer
;; * Now things do not break when dot mode is entered
;; when there is no buffer name, but the side effect is
;; that in this case, the compilation command is not
;; correct.
;; * Preview works on XEmacs and emacs.
;; * Electric indentation on newline
;; * Minor changes to indentation
;; * Added keyword completion (but could be A LOT better)
;; * There are still a couple of ugly hacks. Look for 'RR'.
;; Version 0.2 added features
;; 11/11/2002: added preview support.
;; 10/11/2002: indent a graph or subgraph at once with C-M-q.
;; 08/11/2002: relaxed rules for indentation, the may now be extra chars
;; after beginning of graph (comment's for example).
;; Version 0.1.2 bug fixes and naming issues
;; 06/11/2002: renamed dot-font-lock-defaults to dot-font-lock-keywords.
;; added some documentation to dot-colors.
;; provided a much better way to handle my max-specpdl-size
;; problem.
;; added an extra autoload cookie (hope this helps, as I don't
;; yet use autoload myself)
;; Version 0.1.1 bug fixes
;; 06/11/2002: added an missing attribute, for font-locking to work.
;; fixed the regex generating, so that it only recognizes
;; whole words
;; 05/11/2002: there can now be extra white space chars after an '{'.
;; 04/11/2002: Why I use max-specpdl-size is now documented, and old value
;; gets restored.
;; Version 0.1 initial release
;; 02/11/2002: implemented parser for *compilation* of a .dot file.
;; 01/11/2002: implemented compilation of an .dot file.
;; 31/10/2002: added syntax-table to the mode.
;; 30/10/2002: implemented indentation code.
;; 29/10/2002: implemented all of font-lock.
;; 28/10/2002: derived graphviz-dot-mode from fundamental-mode, started
;; implementing font-lock.

;;; Code:

(defconst graphviz-dot-mode-version "0.3.3"
"Version of `graphviz-dot-mode.el'.")

(defgroup graphviz nil
"Major mode for editing Graphviz Dot files"
:group 'tools)

(defun graphviz-dot-customize ()
"Run \\[customize-group] for the `graphviz' group."
(interactive)
(customize-group 'graphviz))

(defvar graphviz-dot-mode-abbrev-table nil
"Abbrev table in use in Graphviz Dot mode buffers.")
(define-abbrev-table 'graphviz-dot-mode-abbrev-table ())

(defcustom graphviz-dot-dot-program "dot"
"*Location of the dot program. This is used by `compile'."
:type 'string
:group 'graphviz)

(defcustom graphviz-dot-view-command "doted %s"
"*External program to run on the buffer. You can use `%s' in this string,
and it will be substituted by the buffer name."
:type 'string
:group 'graphviz)

(defcustom graphviz-dot-view-edit-command nil
"*Whether to allow the user to edit the command to run an external
viewer."
:type 'boolean
:group 'graphviz)

(defcustom graphviz-dot-save-before-view t
"*If not nil, M-x graphviz-dot-view saves the current buffer before running
the command."
:type 'boolean
:group 'graphviz)

(defcustom graphviz-dot-auto-indent-on-newline t
"*If not nil, `electric-graphviz-dot-terminate-line' is executed in a line is terminated."
:type 'boolean
:group 'graphviz)

(defcustom graphviz-dot-indent-width default-tab-width
"*Indentation width in Graphviz Dot mode buffers."
:type 'integer
:group 'graphviz)

(defcustom graphviz-dot-auto-indent-on-braces nil
"*If not nil, `electric-graphviz-dot-open-brace' and `electric-graphviz-dot-close-brace' are executed when { or } are typed"
:type 'boolean
:group 'graphviz)

(defcustom graphviz-dot-auto-indent-on-semi t
"*If not nil, `electric-graphviz-dot-semi' is executed when semicolon is typed"
:type 'boolean
:group 'graphviz)

(defcustom graphviz-dot-preview-extension "png"
"*The extension to use for the compilation and preview commands. The format
for the compilation command is
`dot -T<extension> file.dot > file.<extension>'."
:type 'string
:group 'graphviz)

(defcustom graphviz-dot-toggle-completions nil
"*Non-nil means that repeated use of \
\\<graphviz-dot-mode-map>\\[graphviz-dot-complete-word] will toggle the possible
completions in the minibuffer. Normally, when there is more than one possible
completion, a buffer will display all completions."
:type 'boolean
:group 'graphviz)

(defcustom graphviz-dot-delete-completions nil
"*Non-nil means that the completion buffer is automatically deleted when a
key is pressed."
:type 'boolean
:group 'graphviz)

(defcustom graphviz-dot-attr-keywords
'("graph" "digraph" "subgraph" "node" "edge" "strict" "rankdir"
"size" "page" "Damping" "Epsilon" "URL" "arrowhead" "arrowsize"
"arrowtail" "bb" "bgcolor" "bottomlabel" "center" "clusterrank"
"color" "comment" "compound" "concentrate" "constraint" "decorate"
"dim" "dir" "distortion" "fillcolor" "fixedsize" "fontcolor"
"fontname" "fontpath" "fontsize" "group" "headURL" "headlabel"
"headport" "height" "label" "labelangle" "labeldistance" "labelfloat"
"labelfontcolor" "labelfontname" "labelfontsize" "labeljust"
"labelloc" "layer" "layers" "len" "lhead" "lp" "ltail" "margin"
"maxiter" "mclimit" "minlen" "model" "nodesep" "normalize" "nslimit"
"nslimit1" "ordering" "orientation" "overlap" "pack" "pagedir"
"pencolor" "peripheries" "pin" "pos" "quantum" "rank" "ranksep"
"ratio" "rects" "regular" "remincross" "rotate" "samehead" "sametail"
"samplepoint" "searchsize" "sep" "shape" "shapefile" "showboxes"
"sides" "skew" "splines" "start" "style" "stylesheet" "tailURL"
"taillabel" "tailport" "toplabel" "vertices" "voro_margin" "weight"
"z")
"*Keywords for attribute names in a graph. This is used by the auto
completion code. The actual completion tables are built when the mode
is loaded, so changes to this are not immediately visible."
:type '(repeat (string :tag "Keyword"))
:group 'graphviz)

(defcustom graphviz-dot-value-keywords
'("true" "false" "normal" "inv" "dot" "invdot" "odot" "invodot"
"none" "tee" "empty" "invempty" "diamond" "odiamond" "box" "obox"
"open" "crow" "halfopen" "local" "global" "none" "forward" "back"
"both" "none" "BL" "BR" "TL" "TR" "RB" "RT" "LB" "LT" ":n" ":ne" ":e"
":se" ":s" ":sw" ":w" ":nw" "same" "min" "source" "max" "sink" "LR"
"box" "polygon" "ellipse" "circle" "point" "egg" "triangle"
"plaintext" "diamond" "trapezium" "parallelogram" "house" "hexagon"
"octagon" "doublecircle" "doubleoctagon" "tripleoctagon" "invtriangle"
"invtrapezium" "invhouse" "Mdiamond" "Msquare" "Mcircle" "record"
"Mrecord" "dashed" "dotted" "solid" "invis" "bold" "filled"
"diagonals" "rounded" )
"*Keywords for attribute values. This is used by the auto completion
code. The actual completion tables are built when the mode is loaded,
so changes to this are not immediately visible."
:type '(repeat (string :tag "Keyword"))
:group 'graphviz)

;;; Font-locking:
(defvar graphviz-dot-colors-list
'(aliceblue antiquewhite antiquewhite1 antiquewhite2
antiquewhite3 antiquewhite4 aquamarine aquamarine1
aquamarine2 aquamarine3 aquamarine4 azure azure1
azure2 azure3 azure4 beige bisque bisque1 bisque2
bisque3 bisque4 black blanchedalmond blue blue1
blue2 blue3 blue4 blueviolet brown brown1 brown2
brown3 brown4 burlywood burlywood1 burlywood2
burlywood3 burlywood4 cadetblue cadetblue1
cadetblue2 cadetblue3 cadetblue4 chartreuse
chartreuse1 chartreuse2 chartreuse3 chartreuse4
chocolate chocolate1 chocolate2 chocolate3 chocolate4
coral coral1 coral2 coral3 coral4 cornflowerblue
cornsilk cornsilk1 cornsilk2 cornsilk3 cornsilk4
crimson cyan cyan1 cyan2 cyan3 cyan4 darkgoldenrod
darkgoldenrod1 darkgoldenrod2 darkgoldenrod3
darkgoldenrod4 darkgreen darkkhaki darkolivegreen
darkolivegreen1 darkolivegreen2 darkolivegreen3
darkolivegreen4 darkorange darkorange1 darkorange2
darkorange3 darkorange4 darkorchid darkorchid1
darkorchid2 darkorchid3 darkorchid4 darksalmon
darkseagreen darkseagreen1 darkseagreen2
darkseagreen3 darkseagreen4 darkslateblue