Skip to content

Instantly share code, notes, and snippets.

@afeinberg
Last active August 29, 2015 13:57
Show Gist options
  • Select an option

  • Save afeinberg/9879927 to your computer and use it in GitHub Desktop.

Select an option

Save afeinberg/9879927 to your computer and use it in GitHub Desktop.

Revisions

  1. afeinberg revised this gist Apr 1, 2014. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions gistfile1.el
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,5 @@
    ;; based on something I found online, but no longer have original link to.

    (defvar *per-dir-hook-alist*
    '(("/home/alex/dev/project" project-c-mode-hook)))

  2. afeinberg revised this gist Apr 1, 2014. 1 changed file with 10 additions and 0 deletions.
    10 changes: 10 additions & 0 deletions gistfile1.el
    Original file line number Diff line number Diff line change
    @@ -2,6 +2,16 @@
    '(("/home/alex/dev/project" project-c-mode-hook)))

    (defun af-directory-based-c-hook ()
    (make-local-variable 'c-recognize-knr-p)
    (make-local-variable 'c-enable-xemacs-performance-kludge-p)
    (make-local-variable 'c-comment-only-line-offset)
    (make-local-variable 'c-hanging-braces-alist)
    (make-local-variable 'c-hanging-colons-alist)
    (make-local-variable 'c-hanging-semi&comma-criteria)
    (make-local-variable 'c-indent-comments-syntactically-p)
    (make-local-variable 'comment-column)
    (make-local-variable 'c-indent-comment-alist)
    (make-local-variable 'c-cleanup-list)
    (make-local-variable 'tab-width)
    (make-local-variable 'indent-tabs-mode)
    (make-local-variable 'fill-column)
  3. afeinberg renamed this gist Mar 30, 2014. 1 changed file with 0 additions and 1 deletion.
    1 change: 0 additions & 1 deletion gistfile1.txt → gistfile1.el
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,3 @@

    (defvar *per-dir-hook-alist*
    '(("/home/alex/dev/project" project-c-mode-hook)))

  4. afeinberg created this gist Mar 30, 2014.
    38 changes: 38 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,38 @@

    (defvar *per-dir-hook-alist*
    '(("/home/alex/dev/project" project-c-mode-hook)))

    (defun af-directory-based-c-hook ()
    (make-local-variable 'tab-width)
    (make-local-variable 'indent-tabs-mode)
    (make-local-variable 'fill-column)
    (make-local-variable 'tab-width)
    (make-local-variable 'c-tab-always-indent)
    (make-local-variable 'c-auto-hungry-initial-state)
    (make-local-variable 'c-default-style)
    (make-local-variable 'c-indent-level)
    (make-local-variable 'c-auto-hungry-initial-state)
    (make-local-variable 'c-block-comment-prefix)
    (make-local-variable 'c-basic-offset)
    (make-local-variable 'c-offsets-alist)
    (make-local-variable 'c-tab-always-indent)
    (make-local-variable 'fill-column)
    (dolist (dir-mode-pair *per-dir-hook-alist*)
    (let ((dir-name (concat (first dir-mode-pair) ".*"))
    (mode-is (car (last dir-mode-pair)))
    (match-dir-based (string-match
    (concat (first dir-mode-pair) ".*")
    (buffer-file-name))))
    (if (and (numberp match-dir-based)
    (>= match-dir-based 0))
    (funcall mode-is))))
    (message ">>> done af-directory-based-c-hook..."))

    (add-to-list 'auto-mode-alist '("/home/alex/dev/project/src/.*\\.h$" . c++-mode))

    (defun project-c-mode-hook ()
    (google-set-c-style)
    (google-make-newline-indent)
    (message ">>> done project-c-mode-hook"))

    (add-hook 'c++-mode-hook 'af-directory-based-c-hook)