Added custom config

This commit is contained in:
Niten 2020-12-01 15:09:35 -08:00
parent 390b95c46c
commit 0613fcec82
8 changed files with 855 additions and 2 deletions

View File

@ -6,8 +6,8 @@
;; Some functionality uses this to identify you, e.g. GPG configuration, email ;; Some functionality uses this to identify you, e.g. GPG configuration, email
;; clients, file templates and snippets. ;; clients, file templates and snippets.
(setq user-full-name "John Doe" (setq user-full-name "Niten"
user-mail-address "john@doe.com") user-mail-address "niten@fudo.org")
;; Doom exposes five (optional) variables for controlling fonts in Doom. Here ;; Doom exposes five (optional) variables for controlling fonts in Doom. Here
;; are the three important ones: ;; are the three important ones:
@ -52,3 +52,75 @@
;; ;;
;; You can also try 'gd' (or 'C-c c d') to jump to their definition and see how ;; You can also try 'gd' (or 'C-c c d') to jump to their definition and see how
;; they are implemented. ;; they are implemented.
(load! "site-functions.el")
(setq inferior-lisp-program "sbcl")
(setq emerge-diff-options "--ignore-all-space")
(setq alert-default-style 'libnotify)
(setq sentence-end-double-space nil)
(setq diff-switches "-u")
(setq tab-always-indent t)
(defadvice kill-buffer (around kill-buffer-around-advice activate)
"Bury the *scratch* buffer, but never kill it."
(let ((buffer-to-kill (ad-get-arg 0)))
(if (equal buffer-to-kill "*scratch*")
(bury-buffer)
ad-do-it)))
(defun save-persistent-scratch ()
"Write the contents of *scratch* to the file name
`persistent-scratch-file-name'."
(with-current-buffer (get-buffer-create "*scratch*")
(write-region (point-min) (point-max) "~/.emacs.d/persistent-scratch.el")))
(defun load-persistent-scratch ()
"Load the contents of `persistent-scratch-file-name' into the
scratch buffer, clearing its contents first."
(when (file-exists-p "~/.emacs.d/persistent-scratch.el")
(with-current-buffer (get-buffer "*scratch*")
(delete-region (point-min) (point-max))
(insert-file-contents "~/.emacs.d/persistent-scratch.el"))))
(add-hook 'after-init-hook 'load-persistent-scratch)
(add-hook 'kill-emacs-hook 'save-persistent-scratch)
(when (eq system-type 'darwin)
(setq mac-option-modifier 'meta)
(setq mac-command-modifier 'meta))
(when (or (eq window-system 'x)
(eq window-system 'darwin))
(when (boundp 'edit-start-server)
(edit-start-server)))
(global-prettify-symbols-mode 1)
(with-current-buffer (get-buffer "*scratch*")
(emacs-lisp-mode))
(defun filter (condp lst)
"Filter list lst to only those elements matching condp."
(delq nil (mapcar (lambda (x) (and (funcall condp x) x)) lst)))
(let ((site-dir (expand-file-name "~/.doom.d/site.d/")))
(let ((configs (filter (lambda (name)
(not (or (string-match "~$" name)
(string-match "^[.]" name))))
(directory-files site-dir))))
(dolist (file configs)
(let ((full-file (expand-file-name file site-dir)))
(if (or (file-regular-p full-file) (file-symlink-p full-file))
(progn (message "Loading file %s" full-file)
(load full-file))
(message "Skipping invalid file %s" full-file))))))
(provide 'config)
;;; config.el ends here

View File

@ -10,6 +10,7 @@
; (package! some-package) ; (package! some-package)
(package! elpher) (package! elpher)
(package! edit-server)
;; To install a package directly from a remote git repo, you must specify a ;; To install a package directly from a remote git repo, you must specify a
;; `:recipe'. You'll find documentation on what `:recipe' accepts here: ;; `:recipe'. You'll find documentation on what `:recipe' accepts here:

403
site-functions.el Normal file
View File

@ -0,0 +1,403 @@
;;; site-functions.el -*- lexical-binding: t; -*-
;;(require 'eshell)
;;(require 'em-dirs)
(provide 'site-functions)
;;; Code:
(defun kill-whitespace ()
"Kill the whitespace from here to the next non-whitespace character."
(interactive "*")
(save-excursion
(save-restriction
(save-match-data
(progn
(re-search-forward "[ \t\r\n]+" nil t)
(replace-match "" nil nil))))))
;; (defun split-line ()
;; "Split the current line into two at the current point."
;; (interactive "*")
;; (save-excursion
;; (save-restriction
;; (save-match-data
;; (progn (newline-and-indent))))))
(defun bind-hooks-to-modes (hooks modes)
"Takes a list of HOOKS and a list of MODES, add all hooks to all modes."
(dolist (hook hooks)
(dolist (mode modes)
(add-hook mode hook))))
(defun bind-hook-to-modes (hook modes)
"Bind a single HOOK to many MODES."
(bind-hooks-to-modes (list hook) modes))
(defun bind-hooks-to-mode (hooks mode)
"Bind many HOOKS to a single MODE."
(bind-hooks-to-modes hooks (list mode)))
;; (defun remote-shell (host)
;; "Open a remote shell on the given host"
;; (interactive "sRemote host name: \n")
;; (let ((default-directory (concat "/" host ":/home/" (user-login-name) "/")))
;; (shell (concat "*" host "*"))))
;; Emacs Lisp doesnt come with a filter function to keep elements that satisfy
;; a conditional and excise the elements that do not satisfy it. One can use mapcar
;; to iterate over a list with a conditional, and then use delq to remove the nil
;; values.
(defun filter (condp lst)
"Remove all elements not matching CONDP from LST."
(delq nil
(mapcar (lambda (x) (and (funcall condp x) x)) lst)))
;; Therefore
;;
;; (my-filter 'identity my-list)
;; is equivalent to
;; (delq nil my-list)
;;
;; For example:
;;(let ((num-list '(1 'a 2 "nil" 3 nil 4)))
;; (my-filter 'numberp num-list)) ==> (1 2 3 4)
;;
;; Actually the package cl-seq contains the functions remove-if and remove-if-not.
;; The latter can be used instead of my-filter.
;;
;; Never understood why Emacs doesn't have this function.
;;
(defun rename-file-and-buffer (new-name)
"Renames both current buffer and file it's visiting to NEW-NAME."
(interactive "sNew name: ")
(let ((name (buffer-name))
(filename (buffer-file-name)))
(if (not filename)
(message "Buffer '%s' is not visiting a file!" name)
(if (get-buffer new-name)
(message "A buffer named '%s' already exists!" new-name)
(progn
(rename-file name new-name 1)
(rename-buffer new-name)
(set-visited-file-name new-name)
(set-buffer-modified-p nil))))))
;;
;; Never understood why Emacs doesn't have this function, either.
;;
(defun move-buffer-file (dir)
"Move both current buffer and file it's visiting to DIR."
(interactive "DNew directory: ")
(let* ((name (buffer-name))
(filename (buffer-file-name))
(dir
(if (string-match dir "\\(?:/\\|\\\\)$")
(substring dir 0 -1) dir))
(newname (concat dir "/" name)))
(if (not filename)
(message "Buffer '%s' is not visiting a file!" name)
(progn
(copy-file filename newname 1)
(delete-file filename)
(set-visited-file-name newname)
(set-buffer-modified-p nil)
t))))
(defun join-dirs (&rest strings)
"Connect a list of STRINGS with a path separator, /."
(mapconcat 'identity strings "/"))
(defun my-copy-line (&optional arg)
"Copy ARG lines to kill ring."
(interactive "P")
(let ((n (if arg
arg
1)))
(kill-ring-save (line-beginning-position)
(line-beginning-position (+ n 1)))
(message "%d line%s copied" n (if (= 1 n) "" "s"))))
(defvar my-time-format "%k:%M:%S")
(defvar my-date-format "%Y-%m-%d")
(defun my-run-command-on-this-line (cmd)
"Run the CMD found on this line in an external shell."
(beginning-of-line-text)
(let ((start (point)))
(end-of-line)
(command start (end-of-line))))
(defun my-kill-this-buffer ()
"Kill the current buffer."
(interactive)
(kill-buffer (buffer-name))
(set-name))
(defun my-forward-word ()
"Move one word forward. Leave the pointer at start of word."
(interactive)
(forward-char 1)
(backward-word 1)
(forward-word 2)
(backward-word 1)
(backward-char 1)
(forward-char 1))
(defun my-backward-word ()
"Move one word backward. Leave the pointer at start of word."
(interactive)
(backward-word 1)
(backward-char 1)
(forward-char 1))
(defun smart-tab ()
(interactive)
(if (minibufferp)
(unless (minibuffer-complete)
(dabbrev-expand nil))
(if mark-active
(indent-region (region-beginning)
(region-end))
(indent-for-tab-command))))
;; (defun smart-tab ()
;; "This smart tab is minibuffer compliant: it acts as usual in
;; the minibuffer. Else, if mark is active, indents region. Else if
;; point is at the end of a symbol, expands it. Else indents the
;; current line."
;; (interactive)
;; (if (minibufferp)
;; (unless (minibuffer-complete)
;; (dabbrev-expand nil))
;; (if mark-active
;; (indent-region (region-beginning)
;; (region-end))
;; (if (looking-at "\\_>")
;; ;;(dabbrev-expand nil)
;; (hippie-expand nil)
;; (indent-for-tab-command)))))
;; (defun indent-or-expand (arg)
;; "Either indent according to mode, or expand the word preceding point."
;; (interactive "*P")
;; (if (and
;; (or (bobp) (= ?w (char-syntax (char-before))))
;; (or (eobp) (not (= ?w (char-syntax (char-after))))))
;; (hippie-expand arg)
;; (indent-according-to-mode)))
(defun copy-line (&optional arg)
(interactive)
(save-excursion
(beginning-of-line-text)
(let ((start (point)))
(end-of-line)
(kill-ring-save start (point)))))
(defun get-point (symbol &optional arg)
"get the point"
(funcall symbol arg)
(point))
(defun copy-thing (begin-of-thing end-of-thing &optional arg)
"copy thing between beg & end into kill ring"
(let ((beg (get-point begin-of-thing 1))
(end (get-point end-of-thing arg)))
(copy-region-as-kill beg end)))
(defun copy-word (&optional arg)
"Copy words at point into kill-ring"
(interactive "P")
(save-excursion
(copy-thing 'backward-word 'forward-word arg)))
(defun move-text-internal (arg)
(cond
((and mark-active transient-mark-mode)
(let ((column (current-column))
(text (delete-and-extract-region (point) (mark))))
(forward-line arg)
(move-to-column column t)
(set-mark (point))
(insert text)
(exchange-point-and-mark)
(setq deactivate-mark nil)))
(t
(beginning-of-line)
(when (or (> arg 0) (not (bobp)))
(forward-line)
(when (or (< arg 0) (not (eobp)))
(transpose-lines arg))
(forward-line -1)))))
(defun move-text-down (arg)
"Move region (transient-mark-mode active) or current line
arg lines down."
(interactive "*p")
(move-text-internal arg))
(defun move-text-up (arg)
"Move region (transient-mark-mode active) or current line
arg lines up."
(interactive "*p")
(move-text-internal (- arg)))
(defun ido-find-file-in-tag-files ()
(interactive)
(save-excursion
(let ((enable-recursive-minibuffers t))
(visit-tags-table-buffer))
(ido-completing-read "Project file "
(tags-table-files)
nil t)))
(defun untabify-this-file ()
(interactive)
(save-excursion
(end-of-buffer)
(let ((pos (point)))
(untabify 0 pos))))
(defun ensime-remote-connect (host port)
(interactive (list
(read-from-minibuffer "Host: " ensime-default-server-host)
(read-from-minibuffer "Port: " (format "%d" ensime-default-port)
nil t)))
(let ((c (ensime-connect host port))
(config (ensime-config-load "/Users/whunmr/lab/scala/.ensime")))
(ensime-set-config c config)
(setq ensime-buffer-connection c)))
(defun path-join (paths)
(mapconcat 'identity paths ":"))
(defun strip-dup-paths (path)
(path-join
(delete-dups
(split-string path ":"))))
(defun strip-invalid-paths (path)
(path-join
(filter (lambda (p)
(string-match "^/" p))
(split-string path ":"))))
(defun get-path ()
(split-string (getenv "PATH") ":"))
(defun string-join (lst chr)
(mapconcat 'identity lst chr))
(defun any-p (f lst)
(reduce
(lambda (a b) (or a b))
(mapcar f lst)
:initial-value '()))
(defun every-p (f lst)
(reduce
(lambda (a b) (and a b))
(mapcar f lst)
:initial-value t))
(defun odd-p (n)
(= (% n 2) 1))
(defun even-p (n)
(not (odd-p n)))
(defun subpath-p (parent child-p)
(string-match (concat "^" parent ".+") child-p))
(defvar read-only-paths '())
(defun should-be-readonly (filepath)
(any-p
(lambda (path)
(subpath-p path filepath))
read-only-paths))
(defun goto-match-paren (arg)
"Go to the matching parenthesis if on parenthesis,
vi style of % jumping to matching brace."
(interactive "p")
(cond ((looking-at "\\s\(") (forward-list 1) (backward-char 1))
((looking-at "\\s\)") (forward-char 1) (backward-list 1))
(t (self-insert-command (or arg 1)))))
(defun yank-buffer-path ()
"Yank the current buffer's path"
(interactive)
(let ((filename (if (equal major-mode 'dired-mode)
default-directory
(buffer-file-name))))
(when filename
(with-temp-buffer
(insert filename)
(clipboard-kill-region (point-min) (point-max)))
(message filename))))
(defun kill-matching-lines (regexp &optional rstart rend interactive)
"Kill lines containing matches for REGEXP.
See `flush-lines' or `keep-lines' for behavior of this command.
If the buffer is read-only, Emacs will beep and refrain from deleting
the line, but put the line in the kill ring anyway. This means that
you can use this command to copy text from a read-only buffer.
\(If the variable `kill-read-only-ok' is non-nil, then this won't
even beep.)"
(interactive
(keep-lines-read-args "Kill lines containing match for regexp"))
(let ((buffer-file-name nil)) ;; HACK for `clone-buffer'
(with-current-buffer (clone-buffer nil nil)
(let ((inhibit-read-only t))
(keep-lines regexp rstart rend interactive)
(kill-region (or rstart (line-beginning-position))
(or rend (point-max))))
(kill-buffer)))
(unless (and buffer-read-only kill-read-only-ok)
;; Delete lines or make the "Buffer is read-only" error.
(flush-lines regexp rstart rend interactive)))
(defun eshell/x ()
(insert "exit")
(eshell-send-input)
(delete-window))
;; (save-excursion
;; (save-restriction
;; (save-match-data
;; (progn
;; (re-search-forward "[ \t\r\n]+" nil t)
;; (replace-match "" nil nil)))))
(defun open-and-indent-line ()
(interactive)
(save-restriction
(save-match-data
(progn (end-of-line)
(newline-and-indent)))))
(defun open-and-indent-previous-line ()
(interactive)
(save-restriction
(save-match-data
(progn (beginning-of-line)
(newline)
(forward-line -1)
(indent-according-to-mode)))))
(defun foreach (f alist)
(while alist
(progn (funcall f (car alist))
(setq alist (cdr alist)))))
;; site-functions.el ends here

71
site.d/bindings.el Normal file
View File

@ -0,0 +1,71 @@
;; -*-emacs-lisp-*-
(global-set-key "\M-g" 'goto-line)
(global-set-key "\C-xb" 'ivy-switch-buffer)
(global-set-key "\C-cb" '+ivy/switch-workspace-buffer)
(global-set-key "\C-x\C-m" 'execute-extended-command)
(global-set-key "\C-c\C-m" 'execute-extended-command)
(global-set-key "\C-cj" 'org-journal-entry)
(global-set-key "\C-e" 'end-of-line)
(global-set-key [?\C-*] 'er/expand-region)
(global-set-key (kbd "C-.") 'ace-jump-mode)
(global-set-key (kbd "M-.") 'avy-goto-char)
(defalias 'qrr 'query-replace-regexp)
(global-set-key [M-right] 'forward-word)
(global-set-key [M-left] 'backward-word)
(global-set-key [\M-up] 'move-text-up)
(global-set-key [\M-down] 'move-text-down)
(global-set-key "\C-c\C-f" 'find-file-at-point)
(global-set-key "\C-a" 'beginning-of-line-text)
(global-set-key "\C-c\C-u" 'untabify-this-file)
(global-set-key "\C-e" 'end-of-line)
(global-set-key (kbd "C-;") 'kill-whitespace)
(global-set-key (kbd "C-c ;") 'kill-whitespace)
(global-set-key (kbd "C-,") 'split-line)
(global-set-key (kbd "C-c ,") 'split-line)
(global-set-key "\C-cr" 'read-only-mode)
(global-set-key (kbd "C-!") 'eshell-here)
(global-set-key (kbd "C->") 'mc/mark-next-like-this)
(global-set-key (kbd "C-<") 'mc/mark-previous-like-this)
(global-set-key (kbd "M-n") 'mc/mark-next-like-this)
;;(global-set-key (kbd "M-p") 'mc/mark-previous-like-this)
(global-set-key (kbd "C-S-n") 'mc/mark-next-word-like-this)
(global-set-key (kbd "C-S-p") 'mc/mark-previous-word-like-this)
(global-set-key (kbd "C-c C-<") 'mc/mark-all-like-this)
(global-set-key (kbd "C-S-c C-S-c") 'mc/edit-lines)
(global-set-key (kbd "C-c C-e") 'mc/mark-all-dwim)
(global-set-key "\C-ct" 'org-capture)
(global-set-key (kbd "C-c C-p") 'open-and-indent-previous-line)
(global-set-key (kbd "C-c C-n") 'open-and-indent-line)
(global-set-key (kbd "C-c c") 'comment-or-uncomment-region)
;; Create & destroy views in ivy (virtual buffers/bookmarks)
(global-set-key (kbd "C-c b") 'ivy-push-view)
(global-set-key (kbd "C-c B") 'ivy-pop-view)
(global-set-key (kbd "C-s") 'swiper)
(global-set-key (kbd "C-c s") 'isearch-forward-regexp)
(global-set-key (kbd "C-c S") 'isearch-backward-regexp)
(global-set-key (kbd "C-c C--") 'text-scale-decrease)
(global-set-key (kbd "C-c C-+") 'text-scale-increase)

247
site.d/eshell.el Normal file
View File

@ -0,0 +1,247 @@
;;; eshell.el -*- lexical-binding: t; -*-
(require 'dash)
(require 's)
(require 'cl-lib)
;; (eval-when-compile
;; ;; (require 'eshell)
;; (require 'cl-lib)
;; (require 'esh-mode))
(require 'esh-util)
;; _
;; | |
;; ___ _ __ ___ __| |___
;; / __| '_ ` _ \ / _` / __|
;; | (__| | | | | | (_| \__ \
;; \___|_| |_| |_|\__,_|___/
;;
;; Doesn't work over tramp...
;; (defun eshell/ws (&optional workspace)
;; (if workspace
;; (let ((workspace-path (concat "/google/src/cloud/"
;; (user-login-name)
;; "/"
;; workspace
;; "/google3")))
;; (if (file-directory-p workspace-path)
;; (eshell/cd workspace-path)
;; (format "Not a valid workspace: %s\n"
;; workspace)))
;; (p4-current-client)))
;; (defun eshell/ws? ()
;; (eshell/ls (concat "/google/src/cloud/"
;; (user-login-name))))
(defun eshell/ff (file)
(find-file file))
;;(defun eshell/ffow (file)
;; (find-file-other-window file))
(defun eshell/edit (file)
(find-file file))
(defun str-empty-p (str)
(string= str ""))
(defun get-last-line-from-output (output)
(let ((out (split-string output "\n")))
(last (remove-if #'str-empty-p out))))
(defun eshell/g4d (&rest args)
(let* ((command (mapconcat 'identity (cons "p4 g4d" args) " "))
(newpath (get-last-line-from-output
(shell-command-to-string command))))
(when newpath
(eshell/cd (first newpath)))))
(defun eshell-here ()
"Opens up a new shell in the directory associated with the
current buffer's file. The eshell is renamed to match that
directory to make multiple eshell windows easier."
(interactive)
(let* ((parent (if (buffer-file-name)
(file-name-directory (buffer-file-name))
default-directory))
(height (/ (window-total-height) 3))
(name (car (last (split-string parent "/" t)))))
(split-window-vertically (- height))
(other-window 1)
(eshell "new")
(rename-buffer (concat "*eshell: " name "*"))
(defun eshell-here ()
"Opens up a new shell in the directory associated with the
current buffer's file. The eshell is renamed to match that
directory to make multiple eshell windows easier."
(interactive)
(let* ((parent (if (buffer-file-name)
(file-name-directory (buffer-file-name))
default-directory))
(height (/ (window-total-height) 3))
(name (car (last (split-string parent "/" t)))))
(split-window-vertically (- height))
(other-window 1)
(eshell "new")
(rename-buffer (concat "*eshell: " name "*"))
(insert (concat "ls"))
(eshell-send-input)))
(insert (concat "ls"))
(eshell-send-input)))
;; _
;; | |
;; _ __ _ __ ___ _ __ ___ _ __ | |_
;; | '_ \| '__/ _ \| '_ ` _ \| '_ \| __|
;; | |_) | | | (_) | | | | | | |_) | |_
;; | .__/|_| \___/|_| |_| |_| .__/ \__|
;; | | | |
;; |_| |_|
;;
;; http://www.modernemacs.com/post/custom-eshell/
;; (defmacro with-face (STR &rest PROPS)
;; `(propertize ,STR 'face (list ,@PROPS)))
;; (defmacro esh-section (NAME ICON FORM &rest PROPS)
;; "Build eshell section NAME with ICON prepended to evaled FORM with PROPS."
;; `(setq ,NAME
;; (lambda () (when ,FORM
;; (-> ,ICON
;; (concat esh-section-delim ,FORM)
;; (with-face ,@PROPS))))))
;; (defun esh-acc (acc x)
;; "Accumulator for evaluating and concatenating esh-sections."
;; (--if-let (funcall x)
;; (if (s-blank? acc)
;; it
;; (concat acc esh-sep it))
;; acc))
;; (defun esh-prompt-func ()
;; "Build `eshell-prompt-function'"
;; (let ((exit-code (eshell-exit-code)))
;; (concat (eshell-dynamic-header-string exit-code)
;; (-reduce-from 'esh-acc "" eshell-funcs)
;; "\n"
;; (eshell-dynamic-prompt-string exit-code))))
;; (defun p4-extract-client-name (client-str)
;; "Pull just the workspace name from the citc string."
;; (when client-str (nth 1 (split-string client-str ":"))))
;; (defun string-blank-p (str)
;; (or (equal str "")
;; (equal str '())))
;; (defun fig-client-name ()
;; "Take the client name from fig--root."
;; (let ((root (fig--root)))
;; (when root
;; (first (reverse (filter (lambda (s) (not (string-blank-p s)))
;; (split-string root "/")))))))
;; (defun shorten-path-if-necessary (path max)
;; (if (<= (string-width path) max)
;; path
;; (let* ((elems (split-string path "/"))
;; (head (nth 1 elems))
;; (tail (last elems 3)))
;; (mapconcat 'identity
;; (cons "" (cons head (cons ".." tail)))
;; "/"))))
;; (setq esh-sep " ")
;; (setq esh-section-delim " ")
;; (defun eshell-exit-code ()
;; "Return non-nil if the last command was successful.
;; Based on eshell-exit-success-p, but return the code if available."
;; eshell-last-command-status)
;; (defun eshell-color-from-code (exit-code string-to-facify)
;; "Based on the exit code of the last command, color red or green.
;; EXIT-CODE: numeric value where 0 is success
;; STRING-TO-FACIFY: string to which we apply the new face"
;; (if (= 0 exit-code)
;; (-> string-to-facify
;; (with-face :foreground "green" :weight 'bold))
;; (-> string-to-facify
;; (with-face :foreground "red" :weight 'bold))))
;; (defun eshell-dynamic-prompt-string (exit-code)
;; "Color the prompt based on the exit code of the last command.
;; EXIT-CODE: exit code of the last-run command"
;; (let ((prompt (concat "└─[" (number-to-string exit-code) "]─»")))
;; (setq eshell-prompt-regexp (concat "^" (regexp-quote prompt) " +"))
;; (concat (eshell-color-from-code exit-code prompt) " ")))
;; (defun eshell-dynamic-header-string (exit-code)
;; "Color the header based on the exit code of the last command.
;; EXIT-CODE: exit code of the last-run command"
;; (let ((header-string "\n┌─"))
;; (eshell-color-from-code exit-code header-string)))
;; (esh-section esh-dir
;; "\xf07c" ; folder
;; (shorten-path-if-necessary (eshell/pwd) 50)
;; '(:foreground "gold" :weight ultra-bold))
;; (esh-section esh-p4
;; "\x26d6"
;; (p4-extract-client-name (p4-current-client))
;; '(:foreground "pink"))
;; (esh-section esh-fig
;; "\x26d6"
;; (fig-client-name)
;; '(:foreground "pink"))
;; (esh-section esh-clock
;; "\x25d0" ;"\xf550" ; clock
;; (format-time-string "%H:%M" (current-time))
;; '(:foreground "forest green"))
;; (setq eshell-funcs (list esh-dir esh-p4 esh-fig esh-clock))
;; (setq eshell-prompt-function 'esh-prompt-func)
;; ___ _ ____ __
;; / _ \ '_ \ \ / /
;; | __/ | | \ V /
;; \___|_| |_|\_/
(setenv "P4DIFF" "/usr/bin/ediff")
(setenv "P4MERGE" "/usr/bin/ediff_merge")
(defalias 'contracts_cli
"/google/data/ro/teams/resource-management/contracts_cli.par $*")
(setenv "PAGER" "cat")
(setenv "EDITOR" "emacsclient -t")
(local-set-key "\M-p" 'helm-eshell-history)
;; (add-to-list 'eshell-visual-commands
;; "ssh"
;; "tail")
(defun eshell-append-history ()
"Call `eshell-write-history' with the `append' parameter set to t."
(when eshell-history-ring
(let ((newest-cmd-ring (make-ring 1)))
(ring-insert newest-cmd-ring (car (ring-elements eshell-history-ring)))
(let ((eshell-history-ring newest-cmd-ring))
(eshell-write-history eshell-history-file-name t)))))
;; (add-hook eshell-pre-command-hook 'eshell-append-history)
(setq eshell-history-size 10000)
;;; eshell.el ends here

22
site.d/lisp.el Normal file
View File

@ -0,0 +1,22 @@
;;; lisp.el -*- lexical-binding: t; -*-
;;
;; Common settings for Lisp modes
(defvar *lisp-mode-hooks* '(scheme-mode-hook
lisp-mode-hook
emacs-lisp-mode-hook
clojure-mode-hook
racket-mode-hook
clojure-mode-hook
clojurescript-mode-hook))
(defun my-lisp-mode-hook ()
(paredit-mode 1)
(local-set-key (kbd "C-c }") 'paredit-forward-barf-sexp)
(local-set-key (kbd "C-c {") 'paredit-backward-barf-sexp)
(local-set-key (kbd "C-}") 'paredit-forward-barf-sexp)
(local-set-key (kbd "C-{") 'paredit-backward-barf-sexp))
(bind-hook-to-modes 'my-lisp-mode-hook *lisp-mode-hooks*)
;;

32
site.d/ruby.el Normal file
View File

@ -0,0 +1,32 @@
;;; ruby.el -*- lexical-binding: t; -*-
;; (rx) lessons learned:
;; - you can insert (rx) output in another (rx) with (eval rx-out)
(add-to-list 'hs-special-modes-alist
`(ruby-mode
,(rx (or "{"
(seq bol
(zero-or-more (syntax whitespace))
"do"
(opt (seq "|"
(one-or-more (or alphanumeric "," " " "_"))
"|")))
(seq bol
(zero-or-more (syntax whitespace))
(or "def" "while" "class" "module" "case" "if")
" "
(one-or-more not-newline))))
,(rx (or "}"
(seq bol
(zero-or-more (syntax whitespace))
"end")))
,(rx (or "#" "=begin")) ; Comment start
ruby-forward-sexp nil))
;; Configure Smart-Parens
; Only want this for non-lisp languages
;(smartparens-global-mode)
;(show-smartparens-global-mode)
(sp-with-modes '(rhtml-mode)
(sp-local-pair "<" ">")
(sp-local-pair "<%" "%>"))

5
site.d/web.el Normal file
View File

@ -0,0 +1,5 @@
;;; web.el -*- lexical-binding: t; -*-
(setq js-indent-level 2)
(setq css-indent-offset 2)
(add-to-list 'auto-mode-alist '("\\.less\\'" . css-mode))