Skip to content

I will keep my emacs configuration file up to date here - feel free to use!

Notifications You must be signed in to change notification settings

ylivuoto/emacs-conf

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 

Repository files navigation

Emacs configuration

All the sections below will contain declarations for my emacs setup. When using .org configuration file, please include a short line in your .emacs or init.el file

;; Include something like this your .emacs file:
  (org-babel-load-file (expand-file-name "~/.emacs.d/my-conf.org"))

or similar to include your fresh config file! Also, be careful when making changes. Sometimes, when making changes to settings graphically, emacs will create some new lines to .emacs file and there will be duplicates with the .org config file - watch out those!

Well, your .emacs file might look something like this:

;; Let's set up essential package archives
(require 'package)
(add-to-list 'package-archives
               '("melpa" . "http://melpa.org/packages/") t)
(unless package--initialized (package-initialize))

;; For ease of use, highly recommended to use this package
(unless (package-installed-p 'use-package)
    (package-refresh-contents)
    (package-install 'use-package))

;; The rest of the configuration is taken care in a separate file, at
;; the moment called README.org but may be named whatever sensible.
(add-to-list 'load-path "~/.emacs.d/extra-config-files/")
(org-babel-load-file (expand-file-name "~/.emacs.d/extra-config-files/my-conf.org"))

(setq custom-file "~/.emacs.d/custom.el")
(load custom-file)

Configuration file starts from here

Structured configuration file for Emacs with org mode. Since you already have something in your .emacs file, these will take effect when emacs starts.

General

Exec-path

Shell path for linux or osx systems

  ;;  describe-coding-system 'unix
;;(use-package exec-path-from-shell
;;  :ensure t
;;  :config
;;  (when (memq window-system '(mac ns x))
;;    (exec-path-from-shell-initialize)))
;;
  ;; Backup files to another location
  (setq backup-directory-alist `(("." . "~/.emacs-saves")))

  ;; Org agenda files in this dir
  (setq org-agenda-files nil)
  (setq org-agenda-files '("~/notes"))

  (prefer-coding-system 'utf-8)
  (set-default-coding-systems 'utf-8)
  (set-terminal-coding-system 'utf-8)
  (set-keyboard-coding-system 'utf-8)
  (set-selection-coding-system 'utf-8)
  (set-file-name-coding-system 'utf-8)
  (set-clipboard-coding-system 'utf-8)
  (set-buffer-file-coding-system 'utf-8)

Appearance

Here are collection of delcarations and packages that mainly affects to appearance of emacs.

Startup screen

(add-hook 'after-init-hook (lambda ()
                             (drag-stuff-global-mode 1)
                             (toggle-scroll-bar 0)))

(use-package dashboard
  :ensure t
  :config
  (dashboard-setup-startup-hook)
  :init
  ;; Icons 
  (setq dashboard-set-heading-icons t)
  (setq dashboard-set-file-icons t)
  (setq dashboard-display-icons-p t) ;; display icons on both GUI and terminal
  (setq dashboard-icon-type 'all-the-icons) ;; use `all-the-icons' package

  ;; Headings
  (setq dashboard-heading-icons '((recents . "file-directory")
                                  (bookmarks . "bookmark")))

  ;; Content is not centered by default. To center, set
  (setq dashboard-center-content t))

(setq initial-buffer-choice (lambda () (get-buffer-create "*dashboard*")))
(global-set-key (kbd "<f12>") 'dashboard-open)

;; Set the title
(setq dashboard-banner-logo-title "Happy hacking!")
(set-face-attribute 'dashboard-banner-logo-title nil
                    :family "Pixelify Sans" ; Change to Consolas if font does not exist
                    :foreground "#e67128"
                    :height 196)

;; (defvar my-face '(:family "Silkscreen"
;;                          :height 144))

;; This function is used to insert a clock to separate line
;;    (defun dashboard-insert-custom (list-size)
;;         (defvar timestmp)
;;         (setq timestmp  (current-time-string))
;;         (put-text-property 0 (length timestmp) 'face my-face
;;                            timestmp)
;;         (put-text-property 11 19 'face '(:foreground "#e67128" :family "Silkscreen" :height 164)
;;                            timestmp)
;;
;;         (insert timestmp)
;;         (center-line)
;;
;;         (run-with-timer 1 t (lambda()
;;                               (defvar temp)
;;                               (defvar p)
;;                               (setq temp (current-time-string))
;;                               (setq p (point))
;;                               (while (re-search-forward timestmp nil t)
;;                                 (replace-match temp))
;;                               (setq timestmp temp)
;;                               (when (string= (buffer-name) "*dashboard*")
;;                                 (revert-buffer)
;;                                 (goto-char p)))))
;;
;;
;;        (add-to-list 'dashboard-item-generators  '(custom . dashboard-insert-custom))
;;        (add-to-list 'dashboard-items '(custom) t)

;; Running the timestring with a timer, and
;; then calling the func with the help of custom and
;; finally altering an appearance a bit

;; NOTE: MODIFICATIONS TO DASHBOARD-WIDGETS.EL ALSO NECESSARY! (2023-03-09)
;; A new face needs to be defined there and assigned for dashboard-init-info
;; Look, below there is used 'dashboard-init-info-face'
(defun run-clock (list-size)
  "Running a clock with timer"
  (setq time (current-time-string))
  (setq dashboard-init-info time)
  (run-with-timer 1 t (lambda()
                        (setq time (current-time-string))
                        (defvar p)
                        (setq p (point))
                        (when (string= (buffer-name) "*dashboard*")
                          (revert-buffer)
                          (goto-char p)))))

;; currently the custom function is not inserting lines, other than
;; it is basically changing the original init-info line
(add-to-list 'dashboard-item-generators  '(custom . run-clock))
(add-to-list 'dashboard-items '(custom) t)

;; Tweaking the clock's look, this face has to
;; be created separately to dashboard-widgets.el

;;Uncomment these few rows, when you have created a new face
;;(set-face-attribute 'dashboard-init-info-face nil
;;		      :family "Consolas"
;;		      :height 178
;;		      :foreground "#74af68")

;;(setq dashboard-startup-banner "d:/youtubevideot/logo/logo_pixelated_small.png")
;; Value can be
;; - nil to display no banner
;; - 'official which displays the official emacs logo
;; - 'logo which displays an alternative emacs logo
;; - 1, 2 or 3 which displays one of the text banners
;; - "path/to/your/image.gif", "path/to/your/image.png" or "path/to/your/text.txt" which displays whatever gif/image/text you would prefer
;; - a cons of '("path/to/your/image.png" . "path/to/your/text.txt")



;; Footer
(setq dashboard-set-footer t)
(setq dashboard-footer-messages '("Ylivuoto Dashboard. \"No wild kangaroos in Austria!\""))
(setq dashboard-footer-icon (all-the-icons-octicon "dashboard"
                                                   :height 1.1
                                                   :v-adjust -0.05
                                                   :face 'font-lock-keyword-face))

;; Change the font for footer
;; (set-face-attribute 'dashboard-footer nil
;;                     :family "Consolas")

;; Items displayed
;; TODO: Proper trigger needed for clock.
;; Using custom here to trigger the clock. A bit
;; messy solution but works.
(setq dashboard-items '((custom . 0)
                        (recents  . 5)
                        (bookmarks . 7)))

Window

(add-to-list 'default-frame-alist '(fullscreen . maximized))
(add-hook 'server-after-make-frame-hook (lambda() (scroll-bar-mode -1)))

Powerline

;(use-package powerline
;  :ensure t
;  :config
;  (powerline-default-theme))

Also some appearance declaraitions for modeline

;  (set-face-attribute 'mode-line nil
;                      :background "#e67128"
;                      :foreground "white"
;                      :box '(:line-width 2 :color "#233B3B")
;                      :overline nil
;                      :underline nil)
;
;  (set-face-attribute 'mode-line-inactive nil
;                      :background "#182b2b"
;                      :foreground "DarkGrey"
;                      :box '(:line-width 1 :color "#182b2b")
;                      :overline nil
;                      :underline nil)
;
;  (set-face-attribute 'powerline-active1 nil
;                      :background "#23d7d7"
;                      :foreground "black"
;                      :overline nil
;                      :underline nil)
;
;
;  (set-face-attribute 'powerline-active2 nil
;                      :background "#008b8b"
;                      :foreground "black"
;                      :overline nil
;                      :underline nil)
;
;  (set-face-attribute 'powerline-inactive2 nil
;                      :background "#182b2b"
;                      :foreground "white"
;                      :overline nil
;                      :underline nil)

Doom-modeline

(use-package doom-modeline
  :ensure t
  :init (doom-modeline-mode 1))

;; Whether display the battery status. It respects `display-battery-mode'.
(setq doom-modeline-battery t)

;; Whether display the time. It respects `display-time-mode'.
(setq doom-modeline-time t)

Org bullets

Bullets may not work in terminal with default background unspecified. Changed e.g. #002b36 to unspecified-bg, and prefixed asterisks are ugly visible

(use-package org-bullets
  :ensure t
  :init (add-hook 'org-mode-hook (lambda ()(org-bullets-mode 1)
                                   (org-indent-mode))))

Let’s just set some cool bullets for orgbullets

(setq org-bullets-bullet-list '("󰯫"
                                "󰯮"
                                "󰯱"
                                "󰯷"
                                "󰯺"))

Colors

Some colors here, defined to help to use same colors as in the theme

#2e3748
#23d7d7
#00ede1
#dbdb95
#e67128
#ffad29
#008b8b
#74af68
#2b303b

All the Icons

NOTE: Be sure to use also ‘M-x all-the-icons-install-fonts’ and at the end just manually install them (Windows 11)

;; If you need icons and other fancy stuff, uncomment below
;; Additionally, download emacswiki.org/emacs/font-lock+.el and add it
;; to the load path

;;(use-package font-lock+
;;:ensure t)

(use-package all-the-icons
  :ensure t )
;; Use 'prepend for the NS and Mac ports or Emacs will crash.
(set-fontset-font t 'unicode (font-spec :family "all-the-icons") nil 'append)
(set-fontset-font t 'unicode (font-spec :family "file-icons") nil 'append)
(set-fontset-font t 'unicode (font-spec :family "Material Icons") nil 'append)
(set-fontset-font t 'unicode (font-spec :family "github-octicons") nil 'append)
(set-fontset-font t 'unicode (font-spec :family "FontAwesome") nil 'append)
(set-fontset-font t 'unicode (font-spec :family "Weather Icons") nil 'append)

Nerd fonts

(use-package nerd-icons
;; :custom
;; The Nerd Font you want to use in GUI
;; "Symbols Nerd Font Mono" is the default and is recommended
;; but you can use any other Nerd Font if you want
;; (nerd-icons-font-family "Symbols Nerd Font Mono")
)

Themes

;;  (use-package timu-spacegrey-theme
;;    :ensure t
;;    :config
;;    (load-theme 'timu-spacegrey t))
;;  
;;  (defun timu-toggle-dark-light()
;;    "Toogle timu-spacegray theme color"
;;    (interactive)
;;    (if (equal "dark" timu-spacegrey-flavour)
;;        (customize-set-variable 'timu-spacegrey-flavour "light")
;;      (customize-set-variable 'timu-spacegrey-flavour "dark"))
;;    (load-theme (car custom-enabled-themes) t))
;;  
;;    (global-set-key (kbd "C-<f12>") 'timu-toggle-dark-light)

Usability packages

These packages helps you to use directories and files without breaking your nerves!

Neotree

;;  (use-package neotree
;;    :ensure t
;;    :init (global-set-key [f8] 'neotree-toggle))
;;  neo-smart-open t
;;
;;  (add-hook 'neo-after-create-hook (lambda (_x) (display-line-numbers-mode -1)))
;;  (setq neo-theme (if (display-graphic-p) 'icons 'arrow))

Treemacs

(use-package treemacs
:ensure t)

(use-package treemacs-nerd-icons
  :config
  (treemacs-load-theme "nerd-icons"))

Drag-stuff

  (use-package drag-stuff
    :ensure t
    :bind (("C-S-<up>" . drag-stuff-up) ("C-S-<down>" . drag-stuff-down))
    :init (add-hook 'after-init-hook (lambda () (drag-stuff-global-mode 1))))

;  (with-eval-after-load 'org
 ;   (define-key org-mode-map [(control shift up)]  'drag-stuff-up)
  ;  (define-key org-mode-map [(control shift down)]  'drag-stuff-down))

Helm

Suggests and organizes stuff, when giving commands etc.

(use-package helm
  :ensure t
  :bind ("M-x" . helm-M-x)
  :init (helm-mode 1))

Yasnippet

(use-package yasnippet
  :ensure t
  :init (yas-global-mode t))

(use-package yasnippet-snippets
  :ensure t)

Let’s also define paths for snippets, they will be organized all into their own folders and files.

(setq yas-snippet-dirs
      '("~/.emacs.d/snippets"                 ;; personal snippets
        "~/.emacs.d/elpa/yasnippet-snippets-20230314.2056/snippets")) ;; installed snippets

(yas-global-mode 1) ;; or M-x yas-reload-all if you've started YASnippet already.

Company-mode

(use-package company
  :ensure t
  :config
  (setq company-idle-delay 0
        company-minimum-prefix-length 2
        company-show-numbers t
        company-tooltip-limit 10
        company-tooltip-align-annotations t
        ;; invert the navigation direction if the the completion popup-isearch-match
        ;; is displayed on top (happens near the bottom of windows)
        company-tooltip-flip-when-above t)
  (global-company-mode t)
  )

(use-package anaconda-mode
  :ensure t
  :config
  (add-hook 'python-mode-hook 'anaconda-mode)
  ;;(add-hook 'python-mode-hook 'anaconda-eldoc-mode)
  )

(use-package company-anaconda
  :ensure t
  :init (require 'rx)
  :after (company)
  :config
  (add-to-list 'company-backends '(company-anaconda :with company-capf))
  )

;;Different compaay backends below:
(use-package company-auctex
  :ensure t)

(defun my-org-hook ()
  (set (make-local-variable 'company-backends) '((:separate company-yasnippet company-capf) company-keywords)))
                                        ;      (setq-local company-backends '((:separate company-capf company-yasnippet company-keywords)))

(add-hook 'org-mode-hook #'my-org-hook)

 ;;(setq company-idle-delay
 ;;     (lambda () (if (company-in-string-or-comment) nil 0.1)))

Smartparens

(use-package smartparens
  :ensure t
  :init (require 'smartparens-config)
  :config (smartparens-global-mode t))
;(sp-pair "{" nil :actions :rem)

Flycheck

(use-package flycheck
  :ensure t
  :config (global-flycheck-mode))

(with-eval-after-load 'flycheck
  (add-hook 'flycheck-mode-hook #'flycheck-falco-rules-setup))

Org-pomodoro

(use-package org-pomodoro
  :ensure t)

(setq org-pomodoro-format "%s")
(setq org-pomodoro-length 45)
(setq org-pomodoro-short-break-length 5)
(setq org-pomodoro-long-break-length 15)
(set-face-attribute 'org-pomodoro-mode-line nil
                    :foreground "black")
(set-face-attribute 'org-pomodoro-mode-line-break nil
                    :foreground "#23d7d7")

(setq org-pomodoro-audio-player (or (executable-find "aplay")
                                       (executable-find "afplay")
                                       (executable-find "play-sound-file")))

Beamer

(setq org-latex-listings 'minted
    org-latex-packages-alist '(("" "minted"))
    org-latex-pdf-process
    '("pdflatex -shell-escape -interaction=nonstopmode -output-directory=%o %f"))

Sound-wav

;(use-package sound-wav
;  :ensure t)

Powershell

;(use-package powershell
;  :ensure t)

Coding and versioning

Copilot

;; (use-package copilot
;;   :quelpa (copilot :fetcher github
;;                    :repo "copilot-emacs/copilot.el"
;;                    :branch "main"
;;                    :files ("dist" "*.el")))
;; you can utilize :map :hook and :config to customize copilot
;;(define-key copilot-completion-map (kbd "C-c TAB") 'copilot-accept-completion)

Hugo

;; Update files with last modifed date, when #+lastmod: is available
(setq time-stamp-active t
      time-stamp-start "#\\+lastmod:[ \t]*"
      time-stamp-end "$"
      time-stamp-format "%04Y-%02m-%02d")
(add-hook 'before-save-hook 'time-stamp nil)1

Language server

(use-package lsp-mode
  :ensure t
  :commands (lsp lsp-deferred)
  :init (setq lsp-keymap-prefix "C-c l" lsp-typescript-npm "c:/Program Files/nodejs/npm"))

Magit

(use-package magit
  :ensure t
  :bind (("C-x g" . magit-status)))

Web mode, TS and JS2 mode

;;  (defun setup-tide-mode ()
;;    "Set up tide mode and turn on related modes with tide specific configurations."
;;    (tide-setup)
;;    (tide-hl-identifier-mode 1)
;;    (flycheck-mode 1)
;;    (setq flycheck-check-syntax-automatically
;;          '(save mode-enabled idle-change)
;;          (company-mode 1)
;;          (eldoc-mode 1)))
;; (use-package tree-sitter-langs
;;   :ensure t
;;   :after tree-sitter)
;; (use-package web-mode
;;   :ensure t)
;; (add-to-list 'auto-mode-alist '("\\.tsx\\'" . web-mode))
;; (add-to-list 'auto-mode-alist '("\\.html\\'" . web-mode))
;; (add-hook 'web-mode-hook
;;            (lambda ()
;;              (when (string-equal "tsx" (file-name-extension buffer-file-name))
;;                (setup-tide-mode))))
                                        ;enable typescript-tslint checker
;;    (flycheck-add-mode 'typescript-tslint 'web-mode)

;; (use-package js2-mode
;;   :ensure t )
;; (add-to-list 'auto-mode-alist '("\\.*js\\'" . js2-mode))

Yaml

(use-package yaml
  :ensure t)

Misc

Some variable declarations and/or packages which might be useful too.

About

I will keep my emacs configuration file up to date here - feel free to use!

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published