Clyde Pinky

Dot Emacs

For reference, my current .emacs file.

Just an emacs user, so this is to avoid reinventing wheels.

(show-paren-mode 1)
(column-number-mode 1)
(setq inhibit-startup-screen t)
(setq make-backup-files nil)

(setq shift-select-mode t)
(delete-selection-mode 1)

(defun debug-pico (arg)
  (interactive "P")
  (let* ((default-elf (car (directory-files default-directory t "\\.elf$")))
         (elf (if arg
                  (read-file-name "ELF file: " default-directory default-elf)
                default-elf)))
    (if elf
        (gud-gdb (concat "arm-none-eabi-gdb --nh -x local.gdbinit " elf))
      (message "No ELF file found in current directory"))))

(global-set-key (kbd "C-c d") 'debug-pico)

(define-key key-translation-map (kbd "M-3") (kbd "#"))
(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.
 '(package-selected-packages
   '(cmake-mode corfu highlight-doxygen marginalia markdown-mode
		orderless vertico)))
(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.
 )

(require 'package)
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)
(package-initialize)

(require 'clang-format)
(global-set-key (kbd "C-c f") 'clang-format-buffer)


(add-to-list 'auto-mode-alist '("\\.h\\'" . c++-mode))
(add-hook 'c++-mode-hook
          (lambda () (add-hook 'before-save-hook #'clang-format-buffer nil t)))

(setq mac-command-modifier 'meta)
(setq mac-option-modifier 'super)


(load-theme 'modus-vivendi t)

(add-hook 'c++-mode-hook
          (lambda ()
            (setq c-basic-offset 4)
            (setq tab-width 4)
            (setq indent-tabs-mode nil)))

(add-hook 'c++-mode-hook #'eglot-ensure)
(setq mac-option-modifier 'none)

(add-hook 'c++-mode-hook 'highlight-doxygen-mode)

(global-set-key (kbd "C-c c") #'project-compile)

(use-package corfu
  :init
  (global-corfu-mode))

(global-auto-revert-mode 1)

(use-package vertico
  :init (vertico-mode))

(use-package orderless
  :custom
  (completion-styles '(orderless basic)))

(use-package marginalia
  :init (marginalia-mode))

(use-package perspective
  :bind
  ("C-x C-b" . persp-list-buffers)         ; or use a nicer switcher, see below
  :custom
  (persp-mode-prefix-key (kbd "C-x x"))  ; pick your own prefix key here
  :init
  (persp-mode))

(setq persp-state-default-file (expand-file-name "persp-state" user-emacs-directory))

(add-hook 'emacs-startup-hook
             (lambda ()
               (when (file-exists-p persp-state-default-file)
                 (persp-state-load persp-state-default-file))))
(add-hook 'kill-emacs-hook #'persp-state-save)