Skip to content

jwiegley/use-package-examples

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 

Repository files navigation

use-packages-examples

This repository collects community contributed use-package configuration examples, covering from Emacs built-in packages to 3rt party packages.

Built-in packages

env

Set environment variables:

(use-package env
  :ensure nil
  :config
  (setenv "PYTHONIOENCODING" "utf-8"))

mule and mule-cmds

Set default input method and coding system:

(use-package mule
  :ensure nil
  :init
  (setq default-input-method 'MacOSX)
  :config
  (set-terminal-coding-system 'utf-8)
  (set-keyboard-coding-system 'utf-8))

(use-package mule-cmds
  :preface (provide 'mule-cmds)
  :config
  (set-language-environment 'UTF-8))

ns-win

Set Mac modifiers:

(use-package ns-win
  :ensure nil
  :init
  (setq mac-command-modifier 'meta
        mac-option-modifier 'super))

hippie-exp

Set keybinding to M-/ and customize the list of expansion functions:

(use-package hippie-exp
  :ensure nil
  :bind ("M-/" . hippie-expand)
  :init
  (setq hippie-expand-try-functions-list
        '(try-expand-dabbrev
          try-expand-dabbrev-visible
          try-expand-dabbrev-all-buffers
          try-expand-dabbrev-from-kill
          try-complete-file-name-partially
          try-complete-file-name
          try-expand-all-abbrevs
          try-expand-list
          try-expand-line
          try-complete-lisp-symbol-partially
          try-complete-lisp-symbol)))

avoid

Move up mouse when cursor comes:

(use-package avoid
  :ensure nil
  :config
  (mouse-avoidance-mode 'animate))

tool-bar, scroll-bar, menu-bar

Disable all of them:

(use-package tool-bar
  :ensure nil
  :config
  (tool-bar-mode -1))

(use-package scroll-bar
  :ensure nil
  :config
  (scroll-bar-mode -1))

(use-package menu-bar
  :unless (eq system-type 'darwin)
  :ensure nil
  :config
  (menu-bar-mode -1))

time

(use-package time
  :ensure nil
  :init
  (setq display-time-day-and-date t
        display-time-24hr-format t
        display-time-use-mail-icon t
        display-time-interval 10)
  :config
  (display-time))

shell

Kill shell buffer when shell exits:

(use-package shell
  :ensure nil
  :hook (shell-mode . my-shell-mode-hook-func)
  :config
  (defun my-shell-mode-hook-func ()
    (set-process-sentinel (get-buffer-process (current-buffer))
                          'my-shell-mode-kill-buffer-on-exit))
  (defun my-shell-mode-kill-buffer-on-exit (process state)
    (message "%s" state)
    (if (or
         (string-match "exited abnormally with code.*" state)
         (string-match "finished" state))
        (kill-buffer (current-buffer)))))

paren

(use-package paren
  :ensure nil
  :init
  (setq show-paren-style 'parentheses)
  :config
  (show-paren-mode t))

3rd party packages

Copy specified environment variables:

(use-package exec-path-from-shell
  :if (memq window-system '(mac ns x))
  :ensure t
  :init
  (setq exec-path-from-shell-variables '("PATH" "MANPATH" "GOPATH", "PYTHONPATH))
  :config
  (exec-path-from-shell-initialize))
(use-package doom-themes
  :ensure t
  :init
  ;; Global settings (defaults)
  (setq doom-themes-enable-bold t    ; if nil, bold is universally disabled
        doom-themes-enable-italic t) ; if nil, italics is universally disabled
  :config
  (load-theme 'doom-one t)

  ;; Enable flashing mode-line on errors
  (doom-themes-visual-bell-config)

  (use-package doom-themes-ext-treemacs
    :init
    (setq doom-themes-treemacs-theme "doom-colors")) ; use the colorful treemacs theme)
  (doom-themes-treemacs-config)

  ;; Corrects (and improves) org-mode's native fontification.
  (doom-themes-org-config))
(use-package doom-modeline
  :ensure t
  :init
  (setq doom-modeline-minor-modes t
        doom-modeline-vcs-max-length 20)
  :config
  (doom-modeline-mode 1))
(use-package highlight-indent-guides
  :ensure t
  :delight highlight-indent-guides-mode
  :init
  (setq highlight-indent-guides-method 'character
        ;; default is \x2502 but it is very slow on Mac
        highlight-indent-guides-character ?\xFFE8
        highlight-indent-guides-responsive 'top))

Hook to prog-mode:

(use-package rainbow-delimiters
  :ensure t)

(use-package prog-mode
  :ensure nil
  :hook ((prog-mode . rainbow-delimiters-mode)))
(use-package projectile
  :ensure t
  :bind-keymap ("s-p" . projectile-command-map)
  :init
  (setq projectile-mode-line-function '(lambda () (format " [%s]" (projectile-project-name))))
  :config
  (projectile-mode +1))
(use-package company
  :ensure t
  :delight company-mode
  :demand t
  :init
  (setq company-idle-delay 0.1
        company-minimum-prefix-length 1)
  :bind (:map company-active-map
         ("C-n" . company-select-next)
         ("C-p". company-select-previous))
  :config
  (global-company-mode))

About

Example declarations to demonstrate the features of use-package

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published