 
 ;; ensure buffer titles are unique
 (use-package uniquify
+  :defer 2
   :config
   (setq uniquify-buffer-name-style 'forward))
 


;; help emacs find executables
(add-to-list 'exec-path "/Library/TeX/texbin/")

;; highlight and auto-create matching parentheses
(show-paren-mode 1)

;; acceptable line length
(setq-default fill-column 80)

;; don't permanently delete files
(setq delete-by-moving-to-trash t)

;; set macOS modifier keys
(when (eq system-type 'darwin)
  ;; command is switched with control
  (setq mac-right-option-modifier 'meta
	mac-right-command-modifier 'control
	mac-command-modifier 'control
	mac-control-modifier 'super)
  ;; prevent accidental press
  (global-unset-key (kbd "s-g")))

;; point dired to correct ls binary on macOS
(when (eq system-type 'darwin)
  (setq dired-use-ls-dired t
        insert-directory-program "/usr/local/bin/gls"
        dired-listing-switches "-aBhl --group-directories-first"))

;; neuter annoying escape key
(define-key key-translation-map (kbd "ESC") (kbd "C-g"))

;; replaces unnecessary suspend command
(global-set-key (kbd "C-z") #'zap-up-to-char)

;; ibuffer for listing buffers
(global-set-key (kbd "C-x C-b") #'ibuffer)

;; Edit emacs directory
(defun t/edit-emacs-dir ()
  "Edit file from Emacs configuration directory."
  (interactive)
  (counsel-find-file user-emacs-directory))
(global-set-key (kbd "C-c f p") #'t/edit-emacs-dir)

;; Open scratch buffer
(defun t/open-scratch ()
  (interactive)
  (pop-to-buffer "*scratch*"))
(global-set-key (kbd "C-c x") #'t/open-scratch)

;; Toggles
(global-set-key (kbd "C-c t l") #'display-line-numbers-mode)
(global-set-key (kbd "C-c t f") #'toggle-frame-fullscreen)
