;; alan's emacs config 

;; To fix

;; left hand margin missing when line numbers are not in use.

;; i.e. in org mode.


;; ============================================================

;; Comments - Quickstart guide

;; ============================================================

;;                                                               o

;;                                                             o%

;;                                                            //

;;                                                       -="~\

;;                                                         ~\\\

;;                                                            \\

;;                                                             );\

;;                                                            /|;;\

;;                                                       """;;;;;;;\

;;                                                 ///"""""""";;;;;;\

;;                                     ___////+++++""""""""""""";;;@@\

;;                       __________///////++++++++++++++""""""""@@@@%)

;;            ....__/0)///0)//0)//0)/++////////++++++++++"""@@@%%%%%/

;;      ..---0)/--------////////////////+++++++/////+++++@@%%%%%%%/

;;       ..///---0)---0)///0)//0)///0)/////////+++++====@%%%%%%/

;;    ...0)....//----///------////////////+++++///"     \/\\//

;;       //../0)--0)///0)///0)///0)//++++/////          /  \/

;;       --///--------///////////+++/////             _/   /

;; .-//..0).-/0)--0)--0)--0)--..                      /\  /

;;        .......--/////////.                            /\_

;;             .0)..0)..

;; ============================================================

;; Quickstart guide - USE-PACKAGE declarations

;; ============================================================

;; ;; USE-PACKAGE enables the package when invoked, checking against the package archive

;; ;; loads the package if its found else

;;         installs -> adds to archive -> loads package

;; ensure t tells use-package explicitly to attempt install

;; ensure nil for already shipped packages to load and not bother to install if not found.

;; default may be changed with use-package-always-ensure t


;; quelpa elpaca have their own declarations they like to have for

;; proper setup


;; :config - tells use package to evaluate code placed under, after

;; the use-package loads the package

;; :init - make sure the state of emacs is setup prior package loading

;; (use-package corfu

;;   :init 

;;   (setq tab-always-indent 'complete) - set tab behavior before package is loaded 

;;   :config

;; ...)



;; ============================================================

;; Conditional loading ( :if )

;; (use-package spacious-padding

;;   :ensure t

;;   :if (display-graphic-p) - -p indicates predicate; loads spacious

;;   padding only if graphical emacs, not terminal emacs

;;   :config

;;   ...)


;; (use-package slasdkjf-mode

;;   :ensure t 

;;   :if (eq system-type 'gnu/linux)

;; ...)


;; dont evaluate anything in the package unless it meets the condition.

;; This is better than above because above still installs the useless package

;; (when (eq system-type 'gnu/linux)

;;   (use-package adskfjs-mode

;;     :ensure t

;;     ...))



;; ============================================================

;; Defer loading by using keyword assignment ( :bind )

;; (use-package denote

;;   :ensure t

;;   :bind

;;   ("C-c n n" . denote)

;;   :init - will override the deferred loading of the package so



;; ============================================================






;; this needs to be evaluated at least once. I don't know the proper method.

;; (nerd-icons-install-fonts)

;; (all-the-icons-install-fonts)


;; ============================================================

;; Quickstart guide - End

;; ============================================================




;; Initialize package sources

(require 'package)        ;; brings in package management functions into environment

(require 'use-package)         ;; load use-package with require

(require 'use-package-ensure)


;; deleted quelpa



(unless package-archive-contents

  (package-refresh-contents))



;; (use-package vterm)



(use-package company

  :config

  (add-hook 'after-init-hook 'global-company-mode))




(use-package doom-themes

  :ensure t

  :config

  (load-theme 'doom-henna t))


(use-package spacious-padding

  :config

  (setq spacious-padding-mode 1))


(use-package ivy

  :diminish      ;; Prevents from expanding into minibuffer

  :bind (("C-s" . swiper)

:map ivy-minibuffer-map

("TAB" . ivy-alt-done)

("C-l" . ivy-alt-done)

("C-j" . ivy-next-line)

("C-k" . ivy-previous-line)

("C-w" . evil-window-up)

:map ivy-switch-buffer-map

("C-k" . ivy-previous-line)

("C-l" . ivy-done)

("C-d" . ivy-switch-buffer-kill)

:map ivy-reverse-i-search-map

("C-k" . ivy-previous-line)

("C-d" . ivy-reverse-i-search-kill))

  :config

  (ivy-mode 1))


;; this is the current file. 


(use-package spaceline)

;; (require 'spaceline-config)

  



;; makes the full path show in modeline 

;; (setq-default mode-line-buffer-identification

;;               (list 'buffer-file-name

;;                     (propertized-buffer-identification "%12f")

;;                     (propertized-buffer-identification "%12b")))


(spaceline-spacemacs-theme)

;; ;; (setq-default powerline-default-seperator 'zigzag)

;; ;; (setq spaceline-always-show-segments nil)

;; (use-package spaceline-all-the-icons 

;;   :after spaceline

;;   :config (spaceline-all-the-icons-theme))

;; (spaceline-all-the-icons--setup-anzu)            ;; Enable anzu searching

;; (spaceline-all-the-icons--setup-package-updates) ;; Enable package update indicator

;; (spaceline-all-the-icons--setup-git-ahead)       ;; Enable # of commits ahead of upstream in git

;; (spaceline-all-the-icons--setup-paradox)         ;; Enable Paradox mode line

;; (spaceline-all-the-icons--setup-neotree)         ;; Enable Neotree mode line



(use-package yascroll

  :config

  (scroll-bar-mode -1)

  (yascroll-bar-mode -1))


(use-package rainbow-delimiters

  :hook (prog-mode . rainbow-delimiters-mode))



(use-package desktop

  :init

  :config

  (desktop-save-mode 1)

  (setq desktop-load-locked-desktop t))



;; (use-package all-the-icons-ivy)

;; (use-package all-the-icons-completion)



;; (use-package all-the-icons-ibuffer

;;   :ensure t

;;   :hook 

;;         (ibuffer-mode . all-the-icons-ibuffer-mode)

;;         (ibuffer-mode . ibuffer-auto-mode))



(use-package which-key

  :init (which-key-mode)

  :diminish which-key-mode

  :config

  (setq which-key-idle-delay 0.8)

  (setq which-key-idle-secondary-delay 0))



(use-package org-modern

  :hook (org-mode . org-modern-mode)

  :config

 (setq org-modern-fold-stars

   '((">" . ">") (">>" . ">>") (">>>" . ">>>") (">>>>" . ">>>>") ("->" . "-->")))

 ;; (setq org-modern-fold-stars

 ;;   '(("" . "") ("󰄾" . "󰄼") ("󰶻" . "󰶹") ("" . "") ("" . "")))

)



(use-package ivy-rich

  :init

  (ivy-rich-mode 1))



;; menu matching in mini-buffer

(use-package counsel

  :bind (("M-x" . counsel-M-x)

("C-x b" . counsel-ibuffer)

  :map minibuffer-local-map

  ("C-r" . 'counsel-minibuffer-history))

  :config

  (setq ivy-initial-inputs-alist nil))



;; a different help function

(use-package helpful

  :custom

  (counsel-describe-function-function #'helpful-callable)

  (counsel-describe-variable-function #'helpful-variable)

  :bind

  ([remap describe-function] . counsel-describe-function)

  ([remap describe-command] . helpful-command)

  ([remap describe-variable] . counsel-describe-variable)

  ([remap describe-key] . helpful-key))


(bind-keys* ("<escape>" . keyboard-escape-quit)

    ("C-g" . evil-force-normal-state)

    ("C-a" . move-beginning-of-line)

    ("C-e" . move-end-of-line)

    ("M-l" . harpoon-quick-menu-hydra)

    )


(add-hook 'emms-browser-mode (lambda()

    (keymap-global-set (kbd "j") 'next-line)))



;; vim like keybindings

(use-package evil

  :demand t

  :bind ("<escape>" . keyboard-escape-quit)

("C-g" . evil-force-normal-state)

("C-a" . 'move-beginning-of-line)

("C-e" . 'move-end-of-line)

("M-l" . 'windmove-display-new-tab)

  :init

  ;; allows for using cgn

  ;; (setq evil-search-module 'evil-search)

  (setq evil-want-keybinding nil)

  ;; no vim insert bindings

  :config

  (evil-mode 1)

  (evil-set-undo-system 'undo-redo))



;; Vim Bindings Everywhere else

(use-package evil-collection

  :ensure t

  :after evil

  :config

  (setq evil-want-integration t)

  (evil-collection-init))



;; text wrapping on screen edge

(use-package visual-fill-column

  :ensure t

  :config

  (setq-default visual-fill-column-mode t)

  (setq-default set-fill-column 80)

  :bind

  ("C-c t l l" . visual-line-fill-column-mode)

  ("C-c t l r" . center-text-for-reading-toggle))



;; terminal keybinding support / fix for emacs

(use-package kkp

  :config

  (global-kkp-mode 1))



;; enable terminal emacs yank/paste to use system clipboard 


;; (use-package xclip

;;   :config

;;   (xclip-mode 1))


;; This isn't really working in hyprland (terminal). maybe a wlroots wayland version is needed.


;; Failed to connect to a Wayland server: No such file or directory

;; Note: WAYLAND_DISPLAY is unset (falling back to wayland-0)

;; Note: XDG_RUNTIME_DIR is set to /run/user/1000

;; Please check whether /run/user/1000/wayland-0 socket exists and is accessible.




(use-package vertico)



;; if using vertico+consult, use the minibuffer for completion in region

;; (terminal emacs doesn't support child frames)

(setq completion-in-region-function

      (lambda (&rest args)

        (apply (if vertico-mode

                   #'consult-completion-in-region

                 #'completion--in-region)

               args)))



;; A wrapper that simplifies theme customization

;; +=Path: ~/dotfolder/.emacs.d/mygreen-theme.el

;; Press C-c f l green 

(use-package autothemer

  :ensure t)



(use-package popper

  :ensure t ; or :straight t

  :bind (("C-;"   . popper-toggle)

         ("M-;"   . popper-cycle)

         ("C-M-;" . popper-toggle-type))

  :init

  (setq popper-reference-buffers

        '("\\*Messages\\*"

  "\\*scratch\\*"

  "\\*warnings\\*"

          "Output\\*$"

          "\\*Async Shell Command\\*"

          compilation-mode))

  (popper-mode +1)

  (popper-echo-mode +1))                ; For echo area hints




(use-package colorful-mode

  ;; :diminish

  :ensure t ; Optional

  :custom

  (colorful-use-prefix t)

  (colorful-only-strings 'only-prog)

  (css-fontify-colors t)

  :config

  (global-colorful-mode t)

  (add-to-list 'global-colorful-modes 'helpful-mode))



(use-package simple-bookmarks

  :init

  (simple-bookmarks-init))



;; must download, add mplayer to path for this to work on windows...

(use-package emms

             :ensure t

             :config

             (require 'emms-setup)

             (require 'emms-source-file)

             (require 'emms-source-playlist)

             (require 'emms-player-mplayer)

             (require 'emms-browser)

             (emms-all)

             (setq emms-player-list '(emms-player-mplayer))

             ;; (setq emms-source-file-default-directory "a:/SSD-Database/MasterMusicFolder/"))

             ;; (setq emms-player-list '(emms-player-mpv))

             (setq emms-source-file-default-directory "/mnt/c/Users/quite/AppData/Local/Programs/Syncthing/Music-Syncthing/"))



;; (require 'emms-dbus)

;;   (emms-dbus-enable)

;;   ;; covers

;;   (setq emms-browser-covers #'emms-browser-cache-thumbnail-async)

;;   (setq emms-browser-thumbnail-small-size 64)

;;   (setq emms-browser-thumbnail-medium-size 128)

;;   ;; filters

;;   (emms-browser-make-filter "all" #'ignore)

;;   (emms-browser-make-filter "recent"

;;      (lambda (track) (< 30

;;         (time-to-number-of-days

;;   (time-subtract (current-time)

;;         (emms-info-track-file-mtime track))))))

;;   (emms-browser-set-filter (assoc "all" emms-browser-filters))

;;   ;; history

;;   (emms-history-load)

;;   ;; libre-fm

;;   (emms-librefm-scrobbler-enable)



;; (use-package neotree

;;   :config

;;   (setq neo-theme 'ascii)

;;   (setq neo-autorefresh t)

;;   (setq neo-smart-open t)

;;   (setq neo-window-width 40)

;;   (setq neo-show-hidden-files t))

;; ;; Set the neo-window-width to the current width of the

;; ;; neotree window, to trick neotree into resetting the

;; ;; width back to the actual window width.

;; ;; Fixes: https://github.com/jaypei/emacs-neotree/issues/262

;; (eval-after-load "neotree"

;;   '(add-to-list 'window-size-change-functions

;;                 (lambda (frame)

;;                   (let ((neo-window (neo-global--get-window)))

;;                     (unless (null neo-window)

;;                       (setq neo-window-width (window-width neo-window)))))))



;; (add-to-list 'load-path "~/.emacs.d/site-lisp/qutebrowser.el")

;; (require 'qutebrowser)


;; ;; (use-package qutebrowser

;;   :quelpa (qutebrowser :fetcher github

;;                        :repo "lrustand/qutebrowser.el"

;;                        :files (:defaults "*.py")))




(use-package dired-open)

(use-package dired-preview)

;; (use-package diredc)



(use-package dired-toggle-sudo)

(define-key dired-mode-map (kbd "C-c C-s") 'dired-toggle-sudo)

(eval-after-load 'tramp

 '(progn

    ;; Allow to use: /sudo:user@host:/path/to/file

    (add-to-list 'tramp-default-proxies-alist

  '(".*" "\\`.+\\'" "/ssh:%h:"))))



(use-package ranger

  :bind ("C-c C-d" . ranger)

       ("C-c d" . ranger)

       ([remap dired] . ranger))


;; (use-package cheatsheet

;;   :config

;;   (load "~/.emacs.d/mycheatsheet.el"))


(use-package dired-preview

   :config

     ;; Default values for demo purposes

     (setq dired-preview-delay 0.0)

     (setq dired-preview-max-size (expt 2 20))

     (setq dired-preview-ignored-extensions-regexp

             (concat "\\."

                     "\\(gz\\|"

                     "zst\\|"

                     "tar\\|"

                     "xz\\|"

                     "rar\\|"

                     "zip\\|"

                     "iso\\|"

                     "epub"

                     "\\)"))


     ;; Enable `dired-preview-mode' in a given Dired buffer or do it

     ;; globally:

     (dired-preview-global-mode -1))


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;                     _wr""        "-q__                             

;;                  _dP                 9m_     

;;                _#P                     9#_                         

;;               d#@                       9#m                        

;;              d##                         ###                       

;;             J###                         ###L                      

;;             {###K                       J###K                      

;;             ]####K      ___aaa___      J####F                      

;;         __gmM######_  w#P""   ""9#m  _d#####Mmw__                  

;;      _g##############mZ_         __g##############m_               

;;    _d####M@PPPP@@M#######Mmp gm#########@@PPP9@M####m_             

;;   a###""          ,Z"#####@" '######"\g          ""M##m            

;;  J#@"             0L  "*##     ##@"  J#              *#K           

;;  #"               `#    "_gmwgm_~    dF               `#_          

;; 7F                 "#_   ]#####F   _dK                 JE          

;; ]                    *m__ ##### __g@"                   F          

;;                        "PJ#####LP"                                 

;;  `                       0######_                      '           

;;                        _0########_                                  

;;      .               _d#####^#####m__              ,              

;;       "*w_________am#####P"   ~9#####mw_________w*"                 

;;           ""9@#####@M""           ""P@#####@M""                    

;; my functions





;; this is the format for bookmarks in the bookmark file

;; ("recipes"

;;  (filename . "~/Documents-Syncthing/recipes.org")

;;  (front-context-string . "\n* Breads\n\n\n* Sh")

;;  (rear-context-string . "nis@hotmail.com\n")

;;  (position . 50)

;;  (last-modified 26512 29185 242160 0))


;; so the order of arguments is this:

;; ("key" (filename . "path")

;;        (front context string??)  these both have escapes with backslashes for new lines

;;        (rear context string??)  

;;        (position . line-number the mark is on)

;;        (last-modified 26412 29185 242160 0))


;; (report-emacs-bug--os-description)

;; (if (string-equal-ignore-case (report-emacs-bug--os-description) "Arch Linux")

;;      (set-face-font (:family "SauceCodePro NFM" :foundry "outline" :slant normal :weight regular :height 190 :width normal)))



(defun kill-all-other-buffers ()

  "kill all buffers on the buffer-list other than the current. For when you are overwhelmed."

  (interactive)

  (setq my-buffers (buffer-list))

  (setq num (length my-buffers))

  (pop my-buffers)

  (while (> num 1)

    (setq selection-for-kill (pop my-buffers))

    (setq num (1- num))

    (kill-buffer selection-for-kill))

  (message "Killed all other buffers! :)"))



;; (setenv "XDG_SESSION_TYPE" "wayland")


 ;; Set up wl-copy and wl-paste in terminal Emacs

(when (and (string= (getenv "XDG_SESSION_TYPE") "wayland")

           (executable-find "wl-copy")

           (executable-find "wl-paste"))

  (defun my-wl-copy (text)

    "Copy with wl-copy if in terminal, otherwise use the original value of `interprogram-cut-function'."

    (if (display-graphic-p)

        (gui-select-text text)

      (let ((wl-copy-process

             (make-process :name "wl-copy"

                           :buffer nil

                           :command '("wl-copy")

                           :connection-type 'pipe)))

        (process-send-string wl-copy-process text)

        (process-send-eof wl-copy-process))))

  (defun my-wl-paste ()

    "Paste with wl-paste if in terminal, otherwise use the original value of `interprogram-paste-function'."

    (if (display-graphic-p)

        (gui-selection-value)

      (shell-command-to-string "wl-paste --no-newline")))

  (setq interprogram-cut-function #'my-wl-copy)

  (setq interprogram-paste-function #'my-wl-paste))


(defun my-simple-markup-macro ()

  """Simple beginning and end of text insertion"""

  (interactive)

  (save-excursion)

   (evil-first-non-blank)

   (insert ?*)

   (end-of-line)

   (insert ?*))



(defun terminal-toggle ()

  (interactive)

  (split-and-follow-vertically)

  (vterm))



(defvar terminal-is-open nil)

(defun termninal-is-open ()

  (interactive)

  (if (setq terminal-is-open (not terminal-is-open))

      (terminal-toggle)

      (message "terminal opening!")

    (message "terminal closing.")

    (evil-window-delete)

    (setq terminal-is-open nil)))

;; select ibuffer window if its already open.

;; do the same for neotree

;; change mouse click behavior for ibuffer so that it opens with

;;  mouse-1 instead of selecting.


(defun center-text-for-reading-toggle ()

  (interactive)

  (setq visual-fill-column-center-text 'toggle)

  (word-wrap-whitespace-mode 'toggle))


(defun ibuffer-with-swiper-search ()

  (interactive)

  (ido-dired))


(defun split-and-follow-horizontally ()

  (interactive)

  (split-window-below)

  (balance-windows)

  (other-window 1))

(global-set-key (kbd "C-x 2") 'split-and-follow-horizontally)


(defun split-and-follow-vertically ()

  (interactive)

  (split-window-right)

  (balance-windows)

  (other-window 1))

(global-set-key (kbd "C-x 3") 'split-and-follow-vertically)



(use-package keycast

  ;; uncomment this if you're using straight.el

  ;; :straight t

  :ensure t

  :bind ("C-c t l k" . +toggle-keycast)

  :config

  (defun +toggle-keycast()

    (interactive)

    (if (member '("" keycast-mode-line " ") global-mode-string)

        (progn (setq global-mode-string (delete '("" keycast-mode-line " ") global-mode-string))

               (remove-hook 'pre-command-hook 'keycast--update)

               (message "Keycast OFF"))

      (add-to-list 'global-mode-string '("" keycast-mode-line " "))

      (add-hook 'pre-command-hook 'keycast--update t)

      (message "Keycast ON")))

  (keycast-tab-bar-mode 1)

  (+toggle-keycast))



(unless (package-installed-p 'quelpa)

  (with-temp-buffer

    (url-insert-file-contents "https://raw.githubusercontent.com/quelpa/quelpa/master/quelpa.el")

    (eval-buffer)

    (quelpa-self-upgrade)))


;; (setenv "LANG" "en_US.UTF-8")

;; (setenv "DICPATH" "C:\\Users\\aland\\.emacs.d\\dictionary\\en_US.aff")

;; (setq-default ispell-program-name "C:\\msys64\\mingw64\\bin\\hunspell.exe")

;; (setq-default ispell-complete-word-dict "C:\\Users\\aland\\.emacs.d\\dictionary\\english-words.txt")


;; (if (eq system-type 'gnu/linux)           ;; Asks if gnu/linux, if not assume windows, set ispell.

;;     ((setq-default ispell-program-name "/usr/bin/hunspell")

;;     (setenv "DICPATH" "/home/alan/.emacs.d/dictionary/en_US.aff")

;;     (setq-default ispell-complete-word-dict "/home/alan/dotfolder/.emacs.d/dictionary/english-words.txt")

;;     (setq server-operating-system "linux detected."))

;;   (setq server-operating-system "(Not) linux detected.")

;;  (message server-operating-system))


;; (setq ispell-local-dictionary "en_US")


;; (flyspell-mode 1)


;; ispell-word for showing correcting options of the current misspelled word

;; (global-set-key (kbd "M-\\") 'ispell-word)


(define-key global-map (kbd "M-/") 'ispell-word)

(define-key global-map (kbd "C-/") 'completion-at-point)

(define-key dired-mode-map (kbd "C-/") 'completion-at-point)

(define-key locate-mode-map (kbd "C-/") 'completion-at-point)


;; (use-package activities

;;  :init

;;  (activities-mode)

;;  (activities-tabs-mode)

;;  ;; Prevent `edebug' default bindings from interfering.

;;  (setq edebug-inhibit-emacs-lisp-mode-bindings t)


  ;; :bind

  ;; (("C-x C-a C-n" . activities-new)

  ;;  ("C-x C-a C-d" . activities-define)

  ;;  ("C-x C-a C-a" . activities-resume)

  ;;  ("C-x C-a C-k" . activities-kill)

  ;;  ("C-x C-a C-s" . activities-suspend)

  ;;  ("C-x C-a RET" . activities-switch)

  ;;  ("C-x C-a b" . activities-switch-buffer)

  ;;  ("C-x C-a g" . activities-revert)

  ;;  ("C-x C-a l" . activities-list)))



;; #############################################################

;; Customization frame and window preset options and settings

;; #############################################################

;;       _.-.

;;  __.-' ,  \

;; '--'-'._   \

;;         '.  \

;;          )-- \ __.--._

;;         /   .'        '--.

;;        .               _/-._

;;        :       ____._/   _-'

;;         '._          _.'-'

;;            '-._    _.'

;;                \_|/

;;               __|||

;;               >__/'





(use-package emacs

  :init

  (+toggle-keycast)

  (auto-fill-mode)

  (smooth-scrolling-mode t)

  (setq help-window-select t)

  (global-display-line-numbers-mode nil)

  (menu-bar-mode 1)

  (auto-save-visited-mode 1)

  (auto-save-mode 1)

  (global-font-lock-mode t)

  (blink-cursor-mode 1)

  (fringe-mode '(24 . 8))

  (tooltip-mode 1)

  (winner-mode t)

  (save-place-mode t)

  (tab-bar-mode t)

  (global-display-fill-column-indicator-mode t)

  (minibuffer-depth-indicate-mode t)

  (setq inhibit-compacting-font-caches t)

  ;; (setq truncate-partial-width-windows t)

  (setq-default truncate-lines t)

  ;; allow org links to work in org documents

  (setq org-return-follows-link t)

  (setq scroll-conservatively 0)

  (setq bookmark-save-flag 1)

  (setq scroll-margin 5)

  (setq auto-save-visited-interval 10)

  ;; (pixel-scroll-precision-mode 1)

  (setq-default line-spacing 2)

  (setq lsp-enable-indentation -1)

  ;; (all-the-icons-ivy-setup)

  (setq inhibit-startup-message t)

  (setq ring-bell-function 'ignore)

  (setq maximum-scroll-margin 0)

  (setq mouse-autoselect-window t)

  (setq-default display-line-numbers-type 'relative)

  )




;; Disable line numbers for some modes


(dolist (no-line-number-mode '(term-mode-hook

shell-mode-hook

eshell-mode-hook))

  (add-hook 'no-line-number-mode (lambda ()

  (display-line-numbers-mode 0)

  (center-text-for-reading-toggle))))



;; (set-face-bold-p 'bold nil)

;;  (mapc

;;   (lambda (face)

;;     (set-face-attribute face nil :weight 'medium :underline nil))

;;   (face-list))


(setq enable-recursive-minibuffers t)


(use-package nerd-icons)


;; UTF-8 support

(prefer-coding-system       'utf-8)

(set-default-coding-systems 'utf-8)

(set-terminal-coding-system 'utf-8)

(set-keyboard-coding-system 'utf-8)    

(setq x-select-request-type '(UTF8_STRING COMPOUND_TEXT TEXT STRING))




;; (use-package persp-mode)

;; (with-eval-after-load "persp-mode-autoloads"

;;   (setq wg-morph-on nil)

;;   ;; switch off the animation of restoring window configuration

;;   (setq persp-autokill-buffer-on-remove 'kill-weak)

;;   (add-hook 'after-init-hook (lambda () (persp-mode 1))))


;; ;; When installed without generating an autoloads file:

;; (with-eval-after-load "persp-mode"

;;   ;; .. all settings you want here

;;   (add-hook 'after-init-hook (lambda () (persp-mode 1))))

;; (require 'persp-mode)




;; (use-package per-buffer-theme

;;   :init

;;   (setq per-buffer-theme-mode t)

;;   :config

;;   (setq per-buffer-theme/use-timer t)

;;   (setq per-buffer-theme/timer-idle-delay 0.1)

;;   (setq per-buffer-theme/default-theme 'wombat)

;;   (setq per-buffer-theme/ignored-buffernames-regex

;;      (append '("*Completions*" "*Help*" "*info*" "*Warnings*" "*helpful*" "*Messages*")))

;;   (setq per-buffer-theme/themes-alist

;;      '((:theme . wombat)

;;        (:buffernames Notepad.org)

;;        (:modes org-mode

;;       org-interactice-mode

;;                haskell-interactive-mode))))



;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;          .   ,

;;        '. '.  \  \

;;       ._ '-.'. `\  \

;;         '-._; .'; `-.'. 

;;        `~-.; '.       '.

;;         '--,`           '.

;;            -='.          ;

;;  .--=~~=-,    -.;        ;

;;  .-=`;    `~,_.;        /

;; `  ,-`'    .-;         |

;;    .-~`.    .;         ;

;;     .;.-   .-;         ,\

;;       `.'   ,=;     .-'  `~.-._

;;        .';   .';  .'      .'   '-.

;;          .\  ;  ;        ,.' _  a',

;;         .'~";-`   ;      ;"~` `'-=.)

;;       .' .'   . _;  ;',  ;

;;       '-.._`~`.'  \  ; ; :

;;            `~'    _'\\_ \\_ 

;;                  /=`^^=`""/`)-.

;;                  \ =  _ =     =\

;;                   `""` `~-. =   ;


(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.

 '(column-number-mode t)

 '(custom-safe-themes

   '("b994e70c4385cefd9949a7090bcc974caf799889984b46027775720832215bc7"

     "b3a9bbed488534ed7ec7bf07d5eb92383f60bf992cfc9cbbcae954df22c80371"

     "5f128efd37c6a87cd4ad8e8b7f2afaba425425524a68133ac0efd87291d05874"

     "9013233028d9798f901e5e8efb31841c24c12444d3b6e92580080505d56fd392"

     "48042425e84cd92184837e01d0b4fe9f912d875c43021c3bcb7eeb51f1be5710"

     "7e377879cbd60c66b88e51fad480b3ab18d60847f31c435f15f5df18bdb18184"

     "7aa5eb0412ee93dfacdeb1fff906932c2fb1747b8c96063ac4d7c1dc461bc0e6"

     "7c340289e943a8e1fdd76152014b75a976912caaa93285d9ff9581641166221b"

     "7ec8fd456c0c117c99e3a3b16aaf09ed3fb91879f6601b1ea0eeaee9c6def5d9"

     "8d3ef5ff6273f2a552152c7febc40eabca26bae05bd12bc85062e2dc224cde9a"

     "456697e914823ee45365b843c89fbc79191fdbaff471b29aad9dcbe0ee1d5641"

     "6f1f6a1a3cff62cc860ad6e787151b9b8599f4471d40ed746ea2819fcd184e1a"

     "d6b934330450d9de1112cbb7617eaf929244d192c4ffb1b9e6b63ad574784aad"

     "4e2e42e9306813763e2e62f115da71b485458a36e8b4c24e17a2168c45c9cf9d"

     "c8b83e7692e77f3e2e46c08177b673da6e41b307805cd1982da9e2ea2e90e6d7"

     "3784baeeadd1fefff034f2eeae697982a8de36702b74533917bac30400bc93f6"

     "88f7ee5594021c60a4a6a1c275614103de8c1435d6d08cc58882f920e0cec65e"

     "38c0c668d8ac3841cb9608522ca116067177c92feeabc6f002a27249976d7434"

     "691d671429fa6c6d73098fc6ff05d4a14a323ea0a18787daeb93fde0e48ab18b"

     "13096a9a6e75c7330c1bc500f30a8f4407bd618431c94aeab55c9855731a95e1"

     "dccf4a8f1aaf5f24d2ab63af1aa75fd9d535c83377f8e26380162e888be0c6a9"

     "b5fd9c7429d52190235f2383e47d340d7ff769f141cd8f9e7a4629a81abc6b19"

     "dfab4d4e2904967f208647d14b15015a613c4ab904db491116a7c0968e44a115"

     "ff24d14f5f7d355f47d53fd016565ed128bf3af30eb7ce8cae307ee4fe7f3fd0"

     "16198c5c7319d07ded977d2414a96fff95f468af313cff6f684fd02f9dfff9b2"

     "2721b06afaf1769ef63f942bf3e977f208f517b187f2526f0e57c1bd4a000350"

     "f64189544da6f16bab285747d04a92bd57c7e7813d8c24c30f382f087d460a33"

     "56044c5a9cc45b6ec45c0eb28df100d3f0a576f18eef33ff8ff5d32bac2d9700"

     "4b6cc3b60871e2f4f9a026a5c86df27905fb1b0e96277ff18a76a39ca53b82e1"

     "4594d6b9753691142f02e67b8eb0fda7d12f6cc9f1299a49b819312d6addad1d"

     "81f53ee9ddd3f8559f94c127c9327d578e264c574cda7c6d9daddaec226f87bb"

     "e4a702e262c3e3501dfe25091621fe12cd63c7845221687e36a79e17cf3a67e0"

     "77fff78cc13a2ff41ad0a8ba2f09e8efd3c7e16be20725606c095f9a19c24d3d"

     "10e5d4cc0f67ed5cafac0f4252093d2119ee8b8cb449e7053273453c1a1eb7cc"

     "30d174000ea9cbddecd6cc695943afb7dba66b302a14f9db5dd65074e70cc744"

     "8c7e832be864674c220f9a9361c851917a93f921fedb7717b1b5ece47690c098"

     "02d422e5b99f54bd4516d4157060b874d14552fe613ea7047c4a5cfa1288cf4f"

     "f5f80dd6588e59cfc3ce2f11568ff8296717a938edd448a947f9823a4e282b66"

     "dd4582661a1c6b865a33b89312c97a13a3885dc95992e2e5fc57456b4c545176"

     "4ade6b630ba8cbab10703b27fd05bb43aaf8a3e5ba8c2dc1ea4a2de5f8d45882"

     "b3689a10ccc3d02f6f7e16f2cfab9e394c1e1801dcb315454e0bfb722e52b5af"

     "da75eceab6bea9298e04ce5b4b07349f8c02da305734f7c0c8c6af7b5eaa9738"

     "014cb63097fc7dbda3edf53eb09802237961cbb4c9e9abd705f23b86511b0a69"

     "6e33d3dd48bc8ed38fd501e84067d3c74dfabbfc6d345a92e24f39473096da3f"

     default))

 '(package-selected-packages

   '(activities all-the-icons-ibuffer autothemer cheatsheet colorful-mode

company counsel dired-open dired-preview

dired-toggle-sudo doom-themes emms evil-collection

harpoon helpful ivy-rich keycast kkp neotree

nerd-icons org-modern popper quelpa-use-package

rainbow-delimiters ranger simple-bookmarks spaceline

vertico visual-fill-column))

 '(warning-suppress-log-types '((frameset))))

(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.

 '(default ((t (:family "NotoSansM Nerd Font" :foundry "GOOG" :slant normal :weight regular :height 120 :width normal))))

 '(org-link ((t (:foreground "#87ceeb" :weight normal))))

 '(org-modern-date-inactive ((t (:inherit org-modern-label :background "gray20" :foreground "gray70")))))


;; ➡️⬇️▶️⏩⏬

     ;; ("󰛂" . "󰛀") ("󰧚" . "󰧖")))



;; transparency effects here

(set-frame-parameter (selected-frame) 'alpha '(80 . 80))

(add-to-list 'default-frame-alist '(alpha . (80 . 80)))


(set-frame-parameter nil 'alpha-background 100) ; For current frame

(add-to-list 'default-frame-alist '(alpha-background . 100)) ; For all new frames henceforth




;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;            .''

;;   ._.-.___.' (`\

;;  //(        ( `'

;; '/ )\ ).__. ) 

;; ' <' `\ ._/'\

;;    `   \     \

;; bindings binds 

;; Some principles

;; 1. C-g allows escape from everything back     to the plain buffer ( panic button )

;; 2. 


(global-set-key (kbd "C-1") #'harpoon-quick-menu-hydra)

(global-set-key (kbd "C-2") #'completion-at-point)

(global-set-key (kbd "C-7") #'kill-all-other-buffers)

(global-set-key (kbd "C-8") #'kill-current-buffer)

(global-set-key (kbd "C-9") #'previous-buffer)

(global-set-key (kbd "C-0") #'next-buffer)






(global-set-key (kbd "C-c SPC") 'indent-to)

(global-set-key (kbd "C-c s k") #'org-store-link)

(global-set-key (kbd "C-c s j") #'org-insert-last-stored-link)

(global-set-key (kbd "C-c s h") #'org-previous-link)

(global-set-key (kbd "C-c s l") #'org-next-link)



(global-set-key (kbd "C-c f l") #'bookmark-jump)

(global-set-key (kbd "C-c f k") #'bookmark-set)

(global-set-key (kbd "C-c f h") #'bookmark-delete)

(global-set-key (kbd "C-c f j") #'bookmark-insert)



(global-set-key (kbd "C-c g") #'switch-to-minibuffer)

(global-set-key (kbd "C-c q") #'exit-minibuffer)

(global-set-key (kbd "C-c j") #'ibuffer-with-swiper-search)

(global-set-key (kbd "C-c k") #'ido-switch-buffer-other-frame)



(global-set-key (kbd "M-k") #'(lambda () (interactive)(evil-scroll-line-up 20)))

(global-set-key (kbd "M-j") #'(lambda () (interactive)(evil-scroll-line-down 20)))

(global-set-key (kbd "M-K") #'scroll-other-window-down)

(global-set-key (kbd "M-J") #'scroll-other-window)


(use-package harpoon)

;; (global-set-key (kbd "M-l") #'(lambda () (interactive)(harpoon-quick-menu-hydra)))


(global-set-key (kbd "C-c C-t C-l ;") #'toggle-truncate-lines)

(global-set-key (kbd "C-c C-t C-l e") #'evil-mode)

(global-set-key (kbd "C-c C-t C-l f") #'toggle-frame-fullscreen)

(global-set-key (kbd "C-c C-t C-l m") #'menu-bar-mode)

(global-set-key (kbd "C-c C-t C-l n") #'display-line-numbers-mode)

(global-set-key (kbd "C-c C-t C-l o") #'org-mode)




(global-set-key (kbd "C-c 0") #'org-toggle-link-display)

[[file:~/Documents/arch-sync/myscripts/hyprland-arch-links.org::+Title: hyprland-settings-link.org][<no description>]]



;; Unbind q from evil-normal-state-map

(global-set-key (kbd "q") #'kill-buffer-and-window)

(define-key evil-insert-state-map (kbd "q") 'self-insert-command)

(define-key evil-motion-state-map (kbd "q") 'kill-buffer-and-window)

(define-key evil-normal-state-map (kbd "q") 'kill-buffer-and-window)

(define-key evil-replace-state-map (kbd "q") 'kill-buffer-and-window)

(define-key evil-visual-state-map (kbd "q") 'kill-buffer-and-window)

(define-key evil-operator-state-map (kbd "q") 'kill-buffer-and-window)



(define-key evil-motion-state-map (kbd "C-t") nil)

(define-key evil-motion-state-map (kbd "<TAB>") nil)

(define-key global-map (kbd "<TAB>") nil)


(define-key org-mode-map (kbd "C-j") nil)

(define-key org-mode-map (kbd "C-j") nil)


(define-key org-mode-map (kbd "M-j") nil)

(define-key org-mode-map (kbd "M-k") nil)


;; Quit out of minibuffer in all circumstances

(define-key minibuffer-local-map [escape] 'minibuffer-keyboard-quit)

(define-key minibuffer-local-ns-map [escape] 'minibuffer-keyboard-quit)

(define-key minibuffer-local-completion-map [escape] 'minibuffer-keyboard-quit)

(define-key minibuffer-local-must-match-map [escape] 'minibuffer-keyboard-quit)

(define-key minibuffer-local-isearch-map [escape] 'minibuffer-keyboard-quit)



(defvar-keymap my-harpoon-prefix-map

  "1" 'harpoon-go-to-1

  "2" 'harpoon-go-to-2

  "3" 'harpoon-go-to-3

  "4" 'harpoon-go-to-4

  "5" 'harpoon-go-to-5

  "6" 'harpoon-go-to-6

  "7" 'harpoon-go-to-7

  "8" 'harpoon-go-to-8

  "9" 'harpoon-go-to-9

  "0" 'harpoon-toggle-quick-menu

  "C-a" #'harpoon-add-file

  "C-d" #'harpoon-delete-items)


;; From prot emacs keymap guide. 

(defvar-keymap my-test-prefix-buffer-map

  :doc "A testing prefix map"

  "s" #'switch-to-buffer

  "m" #'buffer-menu)



;; 

(defvar-keymap my-test-prefix-visuals-map

  :doc "visual mode map"

  "l" #'display-line-numbers-mode

  "C-t" #'toggle-frame-tab-bar

  "t" 'counsel-load-theme

  "f" #'toggle-frame-fullscreen

  "m" #'toggle-menu-bar-mode-from-frame)


(defun line-number--toggle ()

  (interactive)

  (display-line-number-mode 'toggle))


(defvar-keymap my-test-prefix-map

  :doc "My prefix map."

  "C-t" my-test-prefix-visuals-map

  "h" my-harpoon-prefix-map

  "C-;" #'comment-line

  "o" #'center-paragraph

  "y" 'counsel-yank-pop

  "C-," 'harpoon-go-to-prev

  "C-." 'harpoon-go-to-next)


(keymap-set evil-normal-state-map "C-t" 'nil)

(keymap-set global-map "C-t" my-test-prefix-map)



;; (defvar-keymap eww-textarea-map

;;   :parent text-mode-map

;;   :doc "Keymap for the eww text area."

;;   "RET" #'forward-line

;;   "TAB" #'shr-next-link)


;; ;; Define key maps that will then be added to the prefix map

;; (defvar-keymap test-prefix-buffer-map

;;   :doc "My prefix key map for buffers."

;;   "s" #'save-buffer

;;   "w" #'write-file

;;   "p" #'previous-buffer

;;   "n" #'next-buffer)


;; (defvar-keymap test-prefix-mode-map

;;   :doc "My prefix key map for minor modes."

;;   "l" #'display-line-numbers-mode

;;   "h" #'hl-line-mode)


;; ;; Define a key map with commands and nested key maps

;; (defvar-keymap test-prefix-map

;;   :doc "My prefix key map."

;;   "b" test-prefix-buffer-map

;;   "m" test-prefix-mode-map

;;   "f" #'find-file

;;   "d" #'dired)


;; ;; Define how the nested keymaps are labelled in `which-key-mode'.

;; (which-key-add-keymap-based-replacements test-prefix-map

;;   "b" `("Buffer" . ,test-prefix-buffer-map)

;;   "m" `("Testing" . ,test-prefix-mode-map))