rpm -i http://download1.rpmfusion.org/free/el/updates/6/i386/rpmfusion-free-release-6-1.noarch.rpm
rpm -i http://download1.rpmfusion.org/nonfree/el/updates/6/i386/rpmfusion-nonfree-release-6-1.noarch.rpm
curl -sSL https://get.rvm.io | bash -s stable --ruby
# gconftool-2 -s -t string /desktop/gnome/interface/gtk_key_theme "Emacs"
;(add-hook 'after-init-hook (lambda () (setenv "SHELL" (setq shell-file-name "/bin/tcsh"))))
;(add-hook 'after-init-hook (lambda () (message "init file loaded")))
(let ((default-directory "~/.emacs.d/elpa/"))
(normal-top-level-add-subdirs-to-load-path))
(let ((default-directory "~/.emacs.d/manually-installed-packages/"))
(normal-top-level-add-subdirs-to-load-path))
(mapc (lambda (feature) (require feature nil t))
'(package
cc-mode
yasnippet
ido
org
dired
bf-mode
fill-column-indicator
doxymacs
org-agenda-property
god-mode
reftex))
(add-to-list 'load-path
"/home/sallred/.emacs.d/manually-installed-packages/doxygen/")
This code will manage a special file in your emacs directory called
.file-local-variables.alist
. It will be read in and eval
‘d at
startup. When find-file
visits a file that is in the association
list (alist), it will apply all of the variable-value associations as
appropriate. That way, the file can be kept clean.
defvar file-local-variables-alist
; ("/some/absolute.path" (var1 . val1) (var2 . val2))
defadvice find-file
see if assoc find an entry
if so, loop through cdr (the var-val pairs),
applying (setf (car kv) (cdr kv))
look for special 'mode key *first*
(defvar all-files-local-variables-alist nil)
(add-hook 'find-file-hook
(lambda ()
(print "hi")))
(defun set-all (variable-value-list)
"Takes VARIABLE-VALUE-LIST, an association list of dotted
pairs (variable . value), and sets each variable = value."
(if (assoc 'mode variable-value-list)
(switch-to-mode (cdr (assoc 'mode variable-value-list))))
(mapc (lambda (kv) (set (car kv) (cdr kv)))
variable-value-list))
http://www.emacswiki.org/emacs/FileLocalVariables#toc3
(defun my-file-locals-set-directory-class (file class &optional mtime)
"Enable 'directory local' classes for individual files,
by allowing non-directories in `dir-locals-directory-cache'.
Adapted from `dir-locals-set-directory-class'."
(setq file (expand-file-name file))
(unless (assq class dir-locals-class-alist)
(error "No such class `%s'" (symbol-name class)))
(push (list file class mtime) dir-locals-directory-cache))
Then use with
(dir-locals-set-class-variables 'my-javascript-class '((nil . ((js-indent-level . 2) (indent-tabs-mode . nil))))) (my-file-locals-set-directory-class "path/to/the/file.js" 'my-javascript-class)
(defun list-starts-with (starting-elements l)
(if (null starting-elements) t
(and (equal (car starting-elements) (car l))
(list-starts-with (cdr starting-elements) (cdr l)))))
(defun get-random-element (list)
"Returns a random element of LIST."
(if (not (and (list) (listp list)))
(nth (random (length list)) list)
(error "Argument to get-random-element not a list or the list is empty")))
(defun chomp (str)
"Chomp leading and tailing whitespace from STR."
(while (string-match "\\`\n+\\|^\\s-+\\|\\s-+$\\|\n+\\'" str)
(setq str (replace-match "" t t str))) str)
(defun shell-command-as-kill (command)
(interactive "sShell command: ")
(message (kill-new (chomp (shell-command-to-string command)))))
(defun file-string (file)
(with-temp-buffer
(insert-file-contents file)
(buffer-string)))
(defun file-lines (file)
(split-string (file-string file) "\n" t))
(defun write-string-to-file (string file)
(interactive "sEnter the string: \nFFile to save to: ")
(with-temp-buffer
(insert string)
(when (file-writable-p file)
(write-file file nil))))
(defun write-lines (lines file)
(write-string-to-file (mapconcat (function identity) lines "\n") file))
(defun toggle-fullscreen ()
(interactive)
(when (eq window-system 'x)
(set-frame-parameter
nil
'fullscreen
(when (not (frame-parameter nil 'fullscreen))
'fullboth))))
(defun toggle-show-trailing-whitespace ()
(interactive)
(message "Trailing whitespace display: %s"
(if
(setq show-trailing-whitespace
(not show-trailing-whitespace))
"on" "off")))
(defun yank-buffer-file-name (with-line)
(interactive "P")
(message (kill-new
(concat
(buffer-file-name)
(if with-line
(concat ":" (number-to-string (line-number-at-pos))
(if (> (car with-line) 4)
(concat "c" (number-to-string (current-column))))))))))
(defun get-9/80-workday ()
"See `timeclock-get-workday-function'."
(* 60 60
(if (string= (calendar-day-name
(calendar-current-date))
"Friday")
8 9)))
(c-add-style "gd-ais" '("linux" (c-basic-offset . 2)))
(global-set-key (kbd "s-!") #'shell-command-as-kill)
(global-set-key (kbd "M-n") #'menu-bar-open)
(global-set-key (kbd "C-c o") #'other-frame)
(global-set-key (kbd "C-M->") #'mc/mark-next-like-this)
(global-set-key (kbd "C->") #'mc/mark-next-lines)
(global-set-key (kbd "C-c l") #'org-store-link)
(global-set-key (kbd "C-c c") #'org-capture)
(global-set-key (kbd "M-<f12>") (lambda nil (interactive) (org-agenda nil "n")))
(global-set-key (kbd "s-SPC") #'just-one-space)
(global-set-key (kbd "C-x t") #'toggle-truncate-lines)
(global-set-key (kbd "M-?") #'magit-status)
(global-set-key (kbd "C-c q") #'auto-fill-mode)
(global-set-key (kbd "s-v") #'scroll-up-line)
(global-set-key (kbd "M-s-v") #'scroll-down-line)
(global-set-key (kbd "C-c a") #'align-regexp)
(global-set-key (kbd "C-<kp-6>") #'forward-sexp)
(global-set-key (kbd "C-<kp-4>") #'backward-sexp)
(global-set-key (kbd "C-<kp-2>") #'down-list)
(global-set-key (kbd "C-<kp-8>") #'backward-up-list)
(global-set-key (kbd "C-M-<kp-6>") #'forward-list)
(global-set-key (kbd "C-M-<kp-4>") #'backward-list)
(global-set-key (kbd "<f11>") #'toggle-fullscreen)
(global-set-key (kbd "<f12>") #'yank-buffer-file-name)
(global-set-key (kbd "C-c L") #'custom-revert)
(global-set-key (kbd "s-u") #'revert-buffer)
(global-set-key (kbd "C-c s") #'toggle-show-trailing-whitespace)
(define-key c-mode-base-map (kbd "C-c RET") #'ff-find-related-file)
(define-key dired-mode-map (kbd " F") #'dired-find-all)
(define-key c-mode-map (kbd "C-c C-'") #'source-and-compile)
(define-key c++-mode-map (kbd "C-c C-'") #'source-and-compile)
(define-key c++-mode-map (kbd "C-c C-d") #'doxymacs-insert-function-comment)
(define-key c++-mode-map (kbd "C-c C-n") #'insert-comment-guard)
Needs list-starts-with
General Utilities.
(defvar source-and-compile/shell
"/bin/tcsh"
"The shell to compile under.")
(defvar source-and-compile/source-directory-command
"ls ./source_me >& /dev/null && source ./source_me"
"The command to source a directory (whose relative name is
passed via `format'). This must not fail if the passed
directory exists.")
(defvar source-and-compile/home-directory
"~/src/current"
"The base directory for source code.")
(defvar source-and-compile/makefile-files
'("makefile.make"))
(defvar source-and-compile/make-candidates
'("mk"
"make -f makefile.make"
"make")
"The make calls in the order they should be tried.")
(defvar source-and-compile/make-in-parallel
t
"If t, `source-and-compile/*command' will append the \"--jobs\"
option to each make call.")
(defvar source-and-compile/post-compile-command
nil
"a command (or set of commands with ;) to execute after")
(defun source-and-compile/*prepare-candidate (candidate)
"Uses predefined variables MULTICORE and CLEAN to prepare a
call to make."
(let ((command (if multicore
(concat candidate " --jobs")
candidate)))
(if clean
(concat command " clean")
command)))
(defun source-and-compile/*command (absolute-file-path clean multicore)
"Generates a command for `source-and-compile' that, after
sourcing every 'source_me', traverses upwards in the directory
tree until it finds a makefile. This command is used as the
`compile-command' for `source-and-compile'."
(let* ((normalized-command (concat source-and-compile/source-directory-command "; "))
(path (cdr (butlast (split-string (file-name-directory absolute-file-path) "/"))))
(root-path (cdr (butlast (split-string (expand-file-name source-and-compile/home-directory) "/")))))
(if (not (list-starts-with root-path path))
(error "Not in source directory")
(let* ((relative-path (nthcdr (length root-path) path))
(all-source-commands (mapcar (lambda (dir) (concat "cd ./" dir "; " normalized-command)) (cdr relative-path)))
(single-source-command (apply #'concat all-source-commands))
(find-make (mapconcat #'identity
(make-list
4;(1- (length relative-path))
(mapconcat (lambda (file) (format "ls %s >&/dev/null" file))
source-and-compile/makefile-files " || ")) " || cd .. && "))
(make-command (mapconcat (lambda (candidate)
(concat candidate
(if multicore
" --jobs")
(if clean
" clean")))
source-and-compile/make-candidates " || ")))
(concat "cd " source-and-compile/home-directory "; "
(format normalized-command source-and-compile/home-directory)
single-source-command
find-make
" && exit 1 ; "
make-command
" || exit 1")))))
(defun source-and-compile (&optional do-prompt)
"This function sources every directory in the tree (starting
from 'current') and then uses `compile' to call the first
successful candidate in `source-make-candidates' on the deepest
makefile.make in the structure.
With a prefix argument, configure settings for cleaning and using
multiple cores."
(interactive "P")
(let ((file (buffer-file-name)))
(if (not file)
(error "Buffer is not visiting a file")
(let* ((shell-file-name source-and-compile/shell)
(clean (if do-prompt (y-or-n-p "Clean? ")))
(multicore (if do-prompt (y-or-n-p "Multicore? ") t))
(compile-command (concat (source-and-compile/*command file clean multicore)
" ; " source-and-compile/post-compile-command)))
(call-interactively #'compile)))))
(defun source-and-compile-maybe (arg)
"Call `source-and-compile' after confirmation. With a prefix
argument, configure settings for `source-and-compile'."
(interactive "P")
(if (y-or-n-p "Compile? ")
(call-interactively #'source-and-compile)
(message "Cancelled")))
(defun dired-find-all () (interactive)
(mapc #'find-file
(dired-get-marked-files)))
(setq custom-file "~/.emacs.d/.custom.el")
(defun custom-revert ()
"Loads `custom-file'"
(interactive)
(load custom-file))
(add-hook 'after-init-hook #'custom-revert)
; (add-hook 'after-change-major-mode-hook 'fci-mode)
(require 'ox)
(eval-after-load 'ox
'(progn (add-hook 'org-export-before-processing-hook
#'my-org-inline-css-hook)))
(defun delete-trailing-whitespace-if-showing ()
(interactive)
(if show-trailing-whitespace
(delete-trailing-whitespace)))
(defun doxymacs-font-lock-for-modes ()
(if (member major-mode '(c-mode c++-mode))
(doxymacs-font-lock)))
(add-hook 'before-save-hook
#'delete-trailing-whitespace-if-showing)
(add-hook 'font-lock-mode-hook
#'doxymacs-font-lock-for-modes)
(add-hook 'font-lock-mode-hook
(lambda () (if (member major-mode '(c-mode c++-mode))
(doxymacs-font-lock))))
(add-hook 'c-mode-hook #'doxymacs-mode)
(add-hook 'c++-mode-hook #'doxymacs-mode)
;(font-lock-add-keywords 'c++-mode
; '(("\\(?:/\\*\\*\\)\\s*\\(.*\\)" . 2)))
;
;(font-lock-add-keywords 'c++-mode
; '(("///\\(.*\\)" . 1)))
(font-lock-add-keywords 'c++-mode
'(("//-*" 0 'font-lock-warning-face-prepend)))
(defun insert-comment-guard ()
(interactive)
(insert "//" (make-string 78 ?-) "\n"))
(defun *my-doxy-func ()
(interactive)
(indent-for-tab-command)
(insert "//")
(while (< (current-column) 80) (insert "-"))
(beginning-of-line)
(let ((kill-whole-line t)) (kill-line))
(yank)
(newline-and-indent)
(doxymacs-insert-function-comment)
(save-excursion
(search-forward "*/")
(end-of-line)
(newline)
(yank)))
(defun my-org-inline-css-hook (exporter)
"Insert custom inline css. Include style.css if it exists in
the current directory. Otherwise, include
.emacs.d/org-style.css."
(when (eq exporter 'html)
(let* ((dir (ignore-errors (file-name-directory (buffer-file-name))))
(path (concat dir "style.css"))
(homestyle (or (null dir) (null (file-exists-p path))))
(final (if homestyle "~/.emacs.d/org-style.css" path)))
(when (file-exists-p final)
(setq org-html-head-include-default-style nil)
(setq org-html-head (concat
"<style type=\"text/css\">\n"
"<!--/*--><![CDATA[/*><!--*/\n"
(with-temp-buffer
(insert-file-contents final)
(buffer-string))
"/*]]>*/-->\n"
"</style>\n"))))))
(org-agenda-to-appt)
(appt-activate)
(yas-global-mode)
(org-agenda-to-appt)
(require 'magit)
(defun magit-relate-timeclock-project ()
(interactive)
(save-excursion
(goto-char (point-max))
(let* ((branch (or (magit-get-current-branch) "default"))
(header (format "Branch: %s" branch)))
(unless (string-match header (buffer-string))
(insert header)))))
(defun magit-branch-to-timeclock-project ()
(interactive)
(magit-create-branch (caddr timeclock-last-event) "master"))
(global-set-key (kbd "M-m") #'magit-status)
;(add-hook 'git-commit-mode-hook #'magit-relate-timeclock-project)
(require 'm4-mode)
(font-lock-add-keywords 'm4-mode '(("M_[a-zA-Z0-9_]+" . font-lock-keyword-face)))
(modify-syntax-entry ?# "@" m4-mode-syntax-table)
; (defface font-lock-warning-face
; '((t :inherit error))
; "Font Lock mode face used to highlight warnings."
; :group 'font-lock-faces)
(defface my-code-section-face
'((t :inherit error))
"Face used for comment guards")
(defun add-c-syntax-highlighting ()
(font-lock-add-keywords nil '(
("\\(//\\-+\\)" 1 (if t font-lock-warning-face
my-code-section-face) prepend))))
(eval-after-load 'god-mode
'(progn
(defun god-mode-update-cursor ()
(setq cursor-type (if (or god-local-mode buffer-read-only)
'hbar
'box)))
(add-hook 'god-mode-enabled-hook 'god-mode-update-cursor)
(add-hook 'god-mode-disabled-hook 'god-mode-update-cursor)
(global-set-key (kbd "<escape>") 'god-local-mode)
(define-key god-local-mode-map (kbd ".") 'repeat)
(define-key god-local-mode-map (kbd "i") 'god-local-mode)
(global-set-key (kbd "C-x C-1") 'delete-other-windows)
(global-set-key (kbd "C-x C-2") 'split-window-below)
(global-set-key (kbd "C-x C-3") 'split-window-right)
;(global-set-key (kbd "C-x C-0") 'delete-window)
(add-to-list 'god-exempt-major-modes 'dired-mode)))