Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
candera committed Mar 27, 2011
0 parents commit df01782
Show file tree
Hide file tree
Showing 12 changed files with 18,818 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*.elc
*~
74 changes: 74 additions & 0 deletions ac-slime.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
;;----------------------------------------------------------------------------
;; An auto-complete source using slime completions
;;
;; Author: Steve Purcell <steve at sanityinc dot com>
;;
;; Usage:
;; (require 'ac-slime)
;; (add-hook 'slime-mode-hook 'set-up-slime-ac)
;; (add-hook 'slime-repl-mode-hook 'set-up-slime-ac)
;;----------------------------------------------------------------------------

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

(defun ac-source-slime-fuzzy-candidates ()
"Return a possibly-empty list of fuzzy completions for the symbol at point."
(if (slime-connected-p)
(let ((slime-fuzzy-completion-limit 50))
(mapcar 'car (car (slime-fuzzy-completions ac-prefix))))))

(defun ac-source-slime-simple-candidates ()
"Return a possibly-empty list of completions for the symbol at point."
(if (slime-connected-p)
(car (slime-simple-completions ac-prefix))))

(defvar ac-slime-current-doc nil "Holds slime docstring for current symbol")
(defun ac-slime-documentation (symbol-name)
(let ((symbol-name (substring-no-properties symbol-name)))
(slime-eval `(swank:documentation-symbol ,symbol-name))))

(defun ac-slime-init ()
(setq ac-slime-current-doc nil))

(defface ac-slime-menu-face
'((t (:inherit 'ac-candidate-face)))
"Face for slime candidate menu."
:group 'auto-complete)

(defface ac-slime-selection-face
'((t (:inherit 'ac-selection-face)))
"Face for the slime selected candidate."
:group 'auto-complete)

(defvar ac-source-slime-fuzzy
'((init . ac-slime-init)
(candidates . ac-source-slime-fuzzy-candidates)
(candidate-face . ac-slime-menu-face)
(selection-face . ac-slime-selection-face)
(prefix . slime-symbol-start-pos)
(symbol . "l")
(document . ac-slime-documentation))
"Source for fuzzy slime completion")

(defvar ac-source-slime-simple
'((init . ac-slime-init)
(candidates . ac-source-slime-simple-candidates)
(candidate-face . ac-slime-menu-face)
(selection-face . ac-slime-selection-face)
(prefix . slime-symbol-start-pos)
(symbol . "l")
(document . ac-slime-documentation))
"Source for slime completion")


(defun set-up-slime-ac (&optional fuzzy)
"Add an optionally-fuzzy slime completion source to the
front of `ac-sources' for the current buffer."
(interactive)
(setq ac-sources (add-to-list 'ac-sources
(if fuzzy
'ac-source-slime-fuzzy
'ac-source-slime-simple))))


(provide 'ac-slime)
65 changes: 65 additions & 0 deletions candera/journal.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; This section sets up automatic journal file creation
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defvar *journal-roots* '()) ; new entries must end with slash

(defun find-yesterday-log-file (&optional days-ago)
"Open a file that has the default settings for yesterday's entry"
(interactive "p")
(let*
((n-days-ago (if (null days-ago) 1 days-ago))
(logfile-date (time-n-days-ago n-days-ago))
(logfile-directory (available-logfile-directory *journal-roots*))
(new-logfile-directory (format-time-string (concat logfile-directory "%Y/%m-%b") logfile-date))
(new-logfile-filename
(format-time-string
(concat new-logfile-directory "/%Y%m%d.txt") logfile-date)))
(progn
(make-directory new-logfile-directory 't)
(find-file new-logfile-filename)
(unless (file-exists-p new-logfile-filename)
(insert (concat (format-time-string "%A, %B " logfile-date)
(day-of-month-ordinal (string-to-number (format-time-string "%e" logfile-date)))
(format-time-string ", %Y." logfile-date)))
(newline)
(newline)
(newline)
(previous-line))
;; (flyspell-mode 1)
(message (concat "Opened " new-logfile-filename)))))

;; (defun days-ago (n)
;; "Returns a value similar to current-time, but for n days ago"
;; (interactive)
;; (let ((now (float-time)))
;; (

(defun time-n-days-ago (n)
"Returns a value similar to get-float-time, but for n days ago"
(interactive)
(seconds-to-time (- (float-time) (* 24 3600 n))))

(defun available-logfile-directory (journal-roots)
"Returns the first available directory from the list journal-roots"
(interactive)
(if journal-roots
(if (or (file-directory-p (car journal-roots))
(tramp-handle-file-directory-p (car journal-roots)))
(car journal-roots)
(available-logfile-directory (cdr journal-roots)))
nil))

(defun day-of-month-ordinal (n)
"Returns ordinal for range 1-31 (1st, 2nd, 3rd, etc.)"
()
(if (= n 1) "1st"
(if (= n 2) "2nd"
(if (= n 3) "3rd"
(if (= n 21) "21st"
(if (= n 22) "22nd"
(if (= n 23) "23rd"
(if (= n 31) "31st"
(if (and (> n 0) (< n 31)) (concat (number-to-string n) "th") nil)))))))))

Loading

0 comments on commit df01782

Please sign in to comment.