Skip to content

Instantly share code, notes, and snippets.

View milkypostman's full-sized avatar
🏠
zzz

Donald Curtis milkypostman

🏠
zzz
View GitHub Profile
(make-face 'font-lock-number-face)
(set-face-attribute 'font-lock-number-face nil :inherit font-lock-constant-face)
(setq font-lock-number-face 'font-lock-number-face)
(defvar font-lock-number "[0-9-.]+\\([eE][+-]?[0-9]*\\)?")
(defvar font-lock-hexnumber "0[xX][0-9a-fA-F]+")
(defun add-font-lock-numbers (mode)
(font-lock-add-keywords mode `(
(,(concat "\\<\\(" font-lock-number "\\)\\>" ) 0 font-lock-number-face)
(,(concat "\\<\\(" font-lock-hexnumber "\\)\\>" ) 0 font-lock-number-face)
)))
@milkypostman
milkypostman / package.el
Created September 12, 2011 16:11
Function to update all packages in package.el
(defun package-update-all ()
"Update all packages"
(interactive)
(dolist (elt package-alist)
(let* ((name (car elt))
(file-name (symbol-name name))
(available-pkg (assq name package-archive-contents))
(available-version (and available-pkg
(package-desc-vers (cdr available-pkg))))
(current-version (package-desc-vers (cdr elt)))
@milkypostman
milkypostman / package.el
Created September 12, 2011 16:40
package.el modified to allow git packages
;;; package.el --- Simple package system for Emacs
;; Copyright (C) 2007-2011 Free Software Foundation, Inc.
;; Author: Tom Tromey <tromey@redhat.com>
;; Created: 10 Mar 2007
;; Version: 0.9
;; Keywords: tools
;; This file is part of GNU Emacs.
@milkypostman
milkypostman / init.el
Created September 14, 2011 14:44
elisp to open Marked on the current file in Emacs
(defun marked ()
"Open the current file (if visiting one) in Marked."
(interactive)
(when (buffer-file-name)
(shell-command (concat "open -a Marked.app " (shell-quote-argument buffer-file-name)))))
@milkypostman
milkypostman / Open Current File in Marked.workflow
Created September 14, 2011 15:41
Addition to Open Current File in Marked (service) for Emacs
-- Open in Marked
-- Attempts to open the currently-edited document in Marked for previewing
-- Based on ideas by Lri <https://gist.github.com/1077745>
on run {}
tell application "System Events"
set frontApp to (name of first process whose frontmost is true)
end tell
tell application frontApp to activate
set f to false
@milkypostman
milkypostman / markdown-number.el
Created October 3, 2011 03:56
elisp functions for renumbering lists of a markdown document
(defun markdown-cleanup-list-numbers-level (&optional pfx)
"Update the numbering for pfx (as a string of spaces).
Assume that the previously found match was for a numbered item in a list."
(let ((m pfx)
(idx 0)
(success t))
(while (and success
(not (string-prefix-p "#" (match-string-no-properties 1)))
(not (string< (setq m (match-string-no-properties 2)) pfx)))
@milkypostman
milkypostman / Date Time.textexpander
Created October 12, 2011 20:25
Date Time Snippets
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>groupInfo</key>
<dict>
<key>expandAfterMode</key>
<integer>1</integer>
<key>groupName</key>
<string>Date Time</string>
@milkypostman
milkypostman / shell-command-region-to-string.el
Created October 13, 2011 03:51
Shell Command Function in Elisp
(defun shell-command-on-region-to-string (start end command)
(with-output-to-string
(shell-command-on-region start end command standard-output)))
@milkypostman
milkypostman / ghc-7.0.4-nowarnosx.patch
Created October 25, 2011 14:00
Patch for GHC 7.0.4 to avoid warnings when compiling.
--- ./ghc/ghc.wrapper.old 2011-10-25 08:57:34.000000000 -0500
+++ ./ghc/ghc.wrapper 2011-10-25 08:57:06.000000000 -0500
@@ -1 +1 @@
-exec "$executablename" -B"$topdir" -pgmc "$pgmgcc" -pgma "$pgmgcc" -pgml "$pgmgcc" -pgmP "$pgmgcc -E -undef -traditional" ${1+"$@"}
+exec "$executablename" -B"$topdir" -pgmc "$pgmgcc" -pgma "$pgmgcc" -optl "-Wl,-read_only_relocs,suppress" -pgml "$pgmgcc" -pgmP "$pgmgcc -E -undef -traditional" ${1+"$@"}
@milkypostman
milkypostman / cleanup-markdown-lists.el
Created October 27, 2011 20:08
Cleanup markdown lists using elisp.
(defun markdown-cleanup-list-numbers-level (&optional pfx)
"Update the numbering for pfx (as a string of spaces).
Assume that the previously found match was for a numbered item in a list."
(let ((m pfx)
(idx 0)
(success t))
(while (and success
(not (string-prefix-p "#" (match-string-no-properties 1)))
(not (string< (setq m (match-string-no-properties 2)) pfx)))