Skip to content

ciglass/.emacs.d

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Cameron Glass’ Emacs Configuration

Setup

Clone this repository in the ~/.emacs.d directory. This repository uses the newer-style init.el instead of a .emacs file.

Package installation

On first run, several package will not be installed.

Install packages by doing M-x package-list-packages

For each package to install, go to appropriate line and mark by hitting i

hc-zenburn-theme

yasnippet

yaml-mode

json-mode

Install by hitting x

Restart emacs

Submodule Setup

The qgrep package is installed by source as a submodule.

cd ~/.emacs.d
git submodule init
git submodule update 

Packages

(setq package-archives '(("gnu" . "https://elpa.gnu.org/packages/")
                           ("melpa" . "https://melpa.org/packages/")))
(let ((default-directory "~/.emacs.d/elpa/"))
  (normal-top-level-add-to-load-path '("."))
  (normal-top-level-add-subdirs-to-load-path))
(package-initialize)

Visual Appearance

Emacs Startup

(add-to-list 'default-frame-alist '(fullscreen . maximized))
(setq inhibit-splash-screen t)
(put 'view-emacs-news 'disabled t)
(put 'view-emacs-problems 'disabled t)

Modeline

(menu-bar-mode -1)
(tool-bar-mode -1)
(scroll-bar-mode -1)

(display-time-mode 1)

(setq-default column-number-mode t)

Color Theme

(load-theme 'hc-zenburn t)

Window Sizing

Set sensible window split policies

(setq split-height-threshold nil)
(setq split-width-threshold 0)

;; Attempted better window management after upgrading to emacs 27
(customize-set-variable
 'display-buffer-base-action
 '((display-buffer-reuse-window display-buffer-same-window
                                display-buffer-in-previous-window
                                display-buffer-use-some-window)))

Movement

Window Cycling

(defun select-next-window ()
  "Switch to the next window"
  (interactive)
  (select-window (next-window)))

(defun select-previous-window ()
  "Switch to the previous window"
  (interactive)
  (select-window (previous-window)))

(global-set-key (kbd "\C-x o") 'select-next-window)
(global-set-key (kbd "\C-x i")  'select-previous-window)

Buffer Menu

I prefer to change the default behavior for how buffer menus pop up.

(global-set-key (kbd "C-x C-b") 'buffer-menu)
(global-set-key (kbd "C-x C-S-b") 'buffer-menu-other-window)

Search and Grep

Swap incremental serach keys with regex isearch keys

(global-set-key (kbd "\C-s") 'isearch-forward-regexp)
(global-set-key (kbd "\C-r") 'isearch-backward-regexp)
(global-set-key [(control meta s)] 'isearch-forward)
(global-set-key [(control meta r)] 'isearch-backward)

qgrep

Custom package for quickly grepping at point.

(let ((default-directory "~/.emacs.d/qgrep/"))
  (normal-top-level-add-to-load-path '("."))
  (normal-top-level-add-subdirs-to-load-path))

(autoload 'qgrep "qgrep" "Quick grep" t)
(autoload 'qgrep-no-confirm "qgrep" "Quick grep" t)
(autoload 'qgrep-confirm "qgrep" "Quick grep" t)
(global-set-key (kbd "\C-c g") 'qgrep-no-confirm)
(global-set-key (kbd "\C-c G") 'qgrep-confirm)
;; Stricter filters
(setq qgrep-default-find "find . \\( -wholename '*/.svn' -o -wholename '*/obj' -o -wholename '*/.git' -o -wholename '*/VCOMP' \\) -prune -o -type f \\( '!' -name '*atdesignerSave.ses' -a \\( '!' -name '*~' \\) -a \\( '!' -name '#*#' \\) -a \\( -name '*' \\) \\) -type f -print0")
(setq qgrep-default-grep "grep -iI -nH -e \"%s\"")

ediff

Use a single frame with a/b/merge/control windows.

(setq ediff-split-window-function 'split-window-horizontally)
(setq ediff-diff-options "-w")
(setq ediff-control-frame-upward-shift 40)
(setq ediff-narrow-control-frame-leftward-shift -30)
(setq ediff-window-setup-function 'ediff-setup-windows-plain)

Hotkeys

(global-set-key [f1] (lambda () (interactive) (shell "*shell*")))
(global-set-key [f2] (lambda () (interactive) (shell "*shell*<2>")))
(global-set-key [f3] (lambda () (interactive) (shell "*shell*<3>")))
(global-set-key [f4] (lambda () (interactive) (shell "*shell*<4>")))

(global-set-key (kbd "\C-c w") 'find-file-at-point)

(defun copy-line ()
  "Copy from the current point to end of the line to the kill ring without deleting it."
  (interactive)
  (copy-region-as-kill (point) (line-end-position)))
(global-set-key (kbd "C-S-k") 'copy-line)

yasnippet

(yas-global-mode)

Verilog Mode

Misc Settings

(setq verilog-typedef-regexp "\\(\\(_t\\)\\|\\(_e\\)\\|\\(_T\\)\\)$")

;; Comment indentation
(setq verilog-indent-level              2
      verilog-indent-level-module       2
      verilog-indent-level-declaration  2
      verilog-indent-level-behavioral   2
      verilog-indent-level-directive    2
      verilog-indent-begin-after-if     nil
      verilog-indent-lists              t
      verilog-indent-declaration-macros nil
      verilog-case-indent               2
      verilog-auto-newline              nil
      verilog-minimum-comment-distance  12
      verilog-align-ifelse              t
      verilog-auto-endcomments          nil
      verilog-auto-unused-ignore-regexp "^\\(\\(unused__\\)\\|\\(\\vss\\)\\|\\(vdd\\)\\|\\(gnd\\)\\|\\(subs\\)\\|\\(psub\\)\\)"
      verilog-auto-input-ignore-regexp "^unused__"
      verilog-auto-output-ignore-regexp "^unused__"
      )

AUTOINST

Make AUTOINST easier

(setq verilog-auto-inst-param-value t)
(setq verilog-auto-inst-param-type t)

Look for the following file extensions for AUTOINST

(setq verilog-library-extensions '(".v" ".vh" ".sv" ".svh" ".vams"))
(add-to-list 'auto-mode-alist '("\\.vams\\'" . verilog-mode))

System Verilog Helpers

;; This method of loading wasn't working and I haven't yet spent the time to debug it
;; (let ((default-directory "~/.emacs.d/sv_misc/"))
;;   (normal-top-level-add-to-load-path '("."))
;;   (normal-top-level-add-subdirs-to-load-path))
(load-file "~/.emacs.d/sv_misc/ports.el")
(global-set-key (kbd "\C-c P") 'sv-port-toggle-line)
(global-set-key (kbd "\C-c p") 'sv-port-toggle-region)

Misc Buffer Behavior

Buffer Uniquification

(require 'uniquify)
(setq uniquify-buffer-name-style 'post-forward-angle-brackets)
(setq uniquify-after-kill-buffer-p t)    ; rename after killing uniquified
(setq uniquify-ignore-buffers-re "^\\*") ; don't muck with special buffers

yes-or-no Conversion

Map the yes-or-no-p function to y-or-n-p for consistency.

(fset 'yes-or-no-p 'y-or-n-p)

Odds and Ends

(show-paren-mode 1)
(setq-default truncate-lines t)
(setq-default indent-tabs-mode nil)

; Name a macro with M-x kmacro-name-last-macro, then insert it with M-x insert-kb-macro, swap "lambda" for "defun <function name>", the put it into a comment in the file
; When want to recall it, eval the region that defines the function

; Disable C-z because it's used in tmux
(global-unset-key "\C-z")
(put 'narrow-to-region 'disabled nil)

Bazel

(add-to-list 'auto-mode-alist '("\\.bzl\\'" . python-mode))
(add-to-list 'auto-mode-alist '("\\BUILD\\'" . python-mode))
(add-to-list 'auto-mode-alist '("\\WORKSPACE\\'" . python-mode))

Wavedrom

; Make json tabs smaller to match the wavedrom editor defaults
(add-hook 'json-mode-hook
          (lambda ()
            (make-local-variable 'js-indent-level)
            (setq js-indent-level 2)))

; Make all wavedrom files come up in json-mode without a mode string at the top of the file
(add-to-list 'auto-mode-alist '("\\.wavedrom\\'" . json-mode))

Shell functions

These functions and key bindings speed up repetitive shell tasks I run frequently.

(defun waves ()
  "Search backwards in the shell for the last waves command and execute."
  (interactive)
  (point-max)
  (let ((wave-command))
    (save-excursion
      (re-search-backward "%I:sim: waves available:")
      (re-search-forward "%I:sim: waves available: ")
      (setq wave-command (buffer-substring-no-properties (point) (line-end-position))))
    (insert wave-command)
    (comint-send-input)))

(defun logfile ()
  "Search backwards in the shell for the last logfile and open it in a new buffer."
  (interactive)
  (point-max)
  (let ((logfile-command))
    (save-excursion
      (re-search-backward "[[:space:]]+[^[:space:]]+\.log")
      (forward-char)
      (setq logfile-command (buffer-substring-no-properties (point) (line-end-position))))
    (find-file logfile-command)))

(global-set-key (kbd "\C-c C-S-R") 'waves)
(global-set-key (kbd "\C-c C-S-L") 'logfile)

(defun rerun-last ()
  "Switch back to the shell buffer and rerun the last command."
  (interactive)
  (shell "*shell*")
  (end-of-buffer)
  (comint-previous-input 1)
  (comint-send-input))

(global-set-key (kbd "\C-c r") 'rerun-last)

Emacs Customize

(custom-set-variables
 ;; custom-set-variables was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 '(custom-safe-themes
   '("a37d20710ab581792b7c9f8a075fcbb775d4ffa6c8bce9137c84951b1b453016" default))
 '(package-selected-packages
   '(magit zenburn-theme yasnippet yaml-mode undo-tree json-mode jinja2-mode hc-zenburn-theme evil csv-mode)))
(custom-set-faces
 ;; custom-set-faces was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 )

About

My personal emacs configuration

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published