Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

emacs > mg > elvis > vim = nano

Name: 2012-03-06 2:41

Name: Anonymous 2012-03-08 13:45

(dolist (i (append
             ;; Change these to wherever you keep your extensions.
             ;; Do the same for the directories mentioned below.
             (list "~/.local/slime/site" "~/.emacs.d")
             (directory-files "~/.emacs.d/site-lisp" t "[0-9]$")))
  (add-to-list 'load-path i))

(defun mapcar* (function &rest args)
  (if (not (memq nil args))
      (cons (apply function (mapcar 'car args))
        (apply 'mapcar* function
           (mapcar 'cdr args)))))

(defun my-symbol-name-variant (sym text)
  (intern (concat (symbol-name sym) text)))

(defun my-paren-bindings (use-lisp)
  (let ((keys (list (kbd "[") (kbd "]") (kbd "(") (kbd ")")))
    (commands
     (if use-lisp
         '(paredit-open-round paredit-close-round
           paredit-open-square paredit-close-square)
       '(paredit-open-square paredit-close-square
         paredit-open-round paredit-close-round))))
    (mapcar* (lambda (key cmd) (define-key paredit-mode-map key cmd))
         keys commands)))

(defun my-backward-kill-line ()
  (interactive)
  ;; It would be nice to use an appropriate paredit command, but there
  ;; isn't one. 'paredit-kill just invokes regular kill-line if
  ;; there's a numeric argument.
  (kill-line 0))

(defun my-get-repl-or-paredit-bol ()
  (save-excursion
    (if (eq major-mode 'slime-repl-mode)
    (slime-repl-bol)
      (beginning-of-line))
    (point)))

(defun my-slime-repl-backward-kill-line ()
  (interactive)
  ;; Surely there is a better way to do this.
  (let ((bol (my-get-repl-or-paredit-bol)))
    (while (< bol (point))
      (paredit-backward-delete))))

(progn
  "Set up paredit-mode."
  (require 'paredit)
  (mapc (lambda (mode)
      (let ((hook (my-symbol-name-variant mode "-mode-hook"))
        (kmap (my-symbol-name-variant mode "-mode-map")))
        (add-hook hook (lambda ()
                 (paredit-mode +1)
                 t))))
    '(emacs-lisp lisp inferipr-lisp clojure scheme slime-repl))

  "Swap keys for square brackets and parentheses."
  (my-paren-bindings 't)

  "Bind ^W"
  (global-set-key (kbd "C-w") 'paredit-backward-kill-word)

  "Bind ^U"
  (global-set-key (kbd "C-u") 'my-backward-kill-line)
  ; Maybe I should always use my-slime-repl-backward-kill-line here

  "Bind ^Z"
  (global-set-key (kbd "C-z") 'slime-selector)

  "Bind M-space"
  (global-set-key (kbd "M-SPC") 'scroll-up)

  "Enable paredit in the minibuffer when editing an eval expression."
  (add-hook 'minibuffer-setup-hook
   (lambda ()
     (if (eq this-command 'eval-expression)
     (paredit-mode +1))))

  (autoload 'markdown-mode "markdown-mode.el"
    "Major mode for editing Markdown files" t)
  (setq auto-mode-alist
    (cons '("\\.md" . markdown-mode) auto-mode-alist))

  "Enable xterm mouse events (for iTerm2)"
  (unless window-system
    (require 'mwheel))

  "Initialize SLIME with Quicklisp helper"
  (load (expand-file-name "~/.local/lisp/quicklisp/slime-helper.el"))
  (setq inferior-lisp-program "/usr/local/bin/sbcl")
  (add-to-list 'load-path "~/.local/lisp/slime/")
  (require 'slime)
  (slime-setup '(slime-fancy slime-banner slime-asdf))

  "Rebind SLIME's backspace and C-u bindings"
  (defun override-slime-repl-bindings ()
    (define-key slime-repl-mode-map
      (read-kbd-macro paredit-backward-delete-key) nil)
    (define-key slime-repl-mode-map "\C-u"
      'my-slime-repl-backward-kill-line))
  (add-hook 'slime-repl-mode-hook 'override-slime-repl-bindings)

  "Start SLIME automatically when opening a Lisp file."
  (defun cliki:start-slime ()
    (unless (slime-connected-p)
      (save-excursion (slime))))
  (add-hook 'slime-mode-hook 'cliki:start-slime)

  'done)

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List